Skip to content

Commit 708a5c1

Browse files
authored
Merge pull request #271 from cmusphinx/cython_module
Switch back to Cython and use scikit-build for Python module
2 parents 5ca46a5 + 34eea3a commit 708a5c1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2294
-2908
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ jobs:
2020
pytest:
2121
runs-on: ubuntu-latest
2222
steps:
23-
- name: Install Build Dependencies
24-
run: sudo apt-get -y install doxygen swig
2523
- name: Checkout
2624
uses: actions/checkout@v3
2725
- name: Install
2826
run: |
27+
python -m pip install --upgrade pip
2928
pip install -r requirements.dev.txt
3029
pip install .
3130
- name: Run tests

CMakeLists.txt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.14) # I like pie
22

3-
project(PocketSphinx VERSION 4.9.999.0
3+
project(PocketSphinx VERSION 5.0.0
44
DESCRIPTION "A small speech recognizer"
55
HOMEPAGE_URL "https://github.com/cmusphinx/pocketsphinx")
66
include(CMakePrintHelpers)
@@ -60,10 +60,6 @@ else()
6060
add_compile_options(-Wall -Wextra)
6161
endif()
6262

63-
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
64-
if(BUILD_SHARED_LIBS)
65-
add_definitions(-DSPHINX_DLL)
66-
endif()
6763
option(FIXED_POINT "Build using fixed-point math" OFF)
6864
if(NOT DEFAULT_RADIX)
6965
set(DEFAULT_RADIX 12)
@@ -79,18 +75,24 @@ configure_file(config.h.in config.h)
7975
configure_file(sphinx_config.h.in include/sphinxbase/sphinx_config.h)
8076
add_definitions(-DHAVE_CONFIG_H)
8177

82-
add_subdirectory(src)
83-
# Only build SWIG and Python if we are building the package
84-
if(CALL_FROM_SETUP_PY)
85-
add_subdirectory(swig)
78+
# Python build
79+
if(SKBUILD)
80+
add_subdirectory(src)
81+
add_subdirectory(cython)
8682
else()
87-
# Don't build or install these in Python
83+
# C shared library build
84+
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
85+
if(BUILD_SHARED_LIBS)
86+
add_definitions(-DSPHINX_DLL)
87+
endif()
88+
add_subdirectory(src)
8889
add_subdirectory(model)
8990
add_subdirectory(doc)
9091
add_subdirectory(include)
9192
add_subdirectory(programs)
9293
add_subdirectory(test)
9394
configure_file(pocketsphinx.pc.in pocketsphinx.pc @ONLY)
95+
install(TARGETS pocketsphinx LIBRARY)
9496
install(FILES ${CMAKE_BINARY_DIR}/pocketsphinx.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
9597
endif()
9698

NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
PocketSphinx 5.0.0
2+
^^^^^^^^^^^^^^^^^^
3+
4+
Not released yet!
5+
16
Pocketsphinx 0.8
27
^^^^^^^^^^^^^^^^
38

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
PocketSphinx 5.0.0 prerelease
2-
=============================
1+
PocketSphinx 5.0.0 release candidate 1
2+
======================================
33

44
This is PocketSphinx, one of Carnegie Mellon University's open source large
55
vocabulary, speaker-independent continuous speech recognition engines.

cython/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.so
2+
model

cython/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
find_package(PythonExtensions REQUIRED)
2+
find_package(Python COMPONENTS Interpreter Development)
3+
find_package(Cython)
4+
5+
set_property(TARGET pocketsphinx PROPERTY POSITION_INDEPENDENT_CODE on)
6+
7+
add_cython_target(_pocketsphinx _pocketsphinx.pyx)
8+
add_library(_pocketsphinx MODULE ${_pocketsphinx})
9+
target_link_libraries(_pocketsphinx pocketsphinx)
10+
target_include_directories(
11+
_pocketsphinx PRIVATE ${PYTHON_INCLUDE_DIR}
12+
_pocketsphinx PRIVATE ${PROJECT_SOURCE_DIR}/src
13+
_pocketsphinx PRIVATE ${PROJECT_SOURCE_DIR}/include
14+
_pocketsphinx PRIVATE ${CMAKE_BINARY_DIR} # for config.h
15+
)
16+
python_extension_module(_pocketsphinx)
17+
install(TARGETS _pocketsphinx LIBRARY DESTINATION cython/pocketsphinx5)

0 commit comments

Comments
 (0)