diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8b22dcd..f383277 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -40,7 +40,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -e ".[lint]" + pip install -e ".[dev]" - name: Lint with pysen run: | pysen run lint diff --git a/pyopenjtalk/htsengine.pyx b/pyopenjtalk/htsengine.pyx index a69400c..9936a6e 100644 --- a/pyopenjtalk/htsengine.pyx +++ b/pyopenjtalk/htsengine.pyx @@ -10,8 +10,8 @@ np.import_array() cimport cython from libc.stdlib cimport malloc, free -from htsengine cimport HTS_Engine -from htsengine cimport ( +from .htsengine cimport HTS_Engine +from .htsengine cimport ( HTS_Engine_initialize, HTS_Engine_load, HTS_Engine_clear, HTS_Engine_refresh, HTS_Engine_get_sampling_frequency, HTS_Engine_get_fperiod, HTS_Engine_set_speed, HTS_Engine_add_half_tone, diff --git a/pyopenjtalk/openjtalk.pyx b/pyopenjtalk/openjtalk.pyx index 650660c..9e0978a 100644 --- a/pyopenjtalk/openjtalk.pyx +++ b/pyopenjtalk/openjtalk.pyx @@ -11,18 +11,18 @@ np.import_array() cimport cython from libc.stdlib cimport calloc -from openjtalk.mecab cimport Mecab, Mecab_initialize, Mecab_load, Mecab_analysis -from openjtalk.mecab cimport Mecab_get_feature, Mecab_get_size, Mecab_refresh, Mecab_clear -from openjtalk.mecab cimport mecab_dict_index, createModel, Model, Tagger, Lattice -from openjtalk.njd cimport NJD, NJD_initialize, NJD_refresh, NJD_print, NJD_clear -from openjtalk cimport njd as _njd -from openjtalk.jpcommon cimport JPCommon, JPCommon_initialize,JPCommon_make_label -from openjtalk.jpcommon cimport JPCommon_get_label_size, JPCommon_get_label_feature -from openjtalk.jpcommon cimport JPCommon_refresh, JPCommon_clear -from openjtalk cimport njd2jpcommon -from openjtalk.text2mecab cimport text2mecab -from openjtalk.mecab2njd cimport mecab2njd -from openjtalk.njd2jpcommon cimport njd2jpcommon +from .openjtalk.mecab cimport Mecab, Mecab_initialize, Mecab_load, Mecab_analysis +from .openjtalk.mecab cimport Mecab_get_feature, Mecab_get_size, Mecab_refresh, Mecab_clear +from .openjtalk.mecab cimport mecab_dict_index, createModel, Model, Tagger, Lattice +from .openjtalk.njd cimport NJD, NJD_initialize, NJD_refresh, NJD_print, NJD_clear +from .openjtalk cimport njd as _njd +from .openjtalk.jpcommon cimport JPCommon, JPCommon_initialize,JPCommon_make_label +from .openjtalk.jpcommon cimport JPCommon_get_label_size, JPCommon_get_label_feature +from .openjtalk.jpcommon cimport JPCommon_refresh, JPCommon_clear +from .openjtalk cimport njd2jpcommon +from .openjtalk.text2mecab cimport text2mecab +from .openjtalk.mecab2njd cimport mecab2njd +from .openjtalk.njd2jpcommon cimport njd2jpcommon from libc.string cimport strlen cdef inline int Mecab_load_ex(Mecab *m, char* dicdir, char* userdic): diff --git a/pyproject.toml b/pyproject.toml index 39c1428..d5b34cc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,12 @@ [build-system] requires = [ - "wheel", "setuptools=0.28.0, <3.0", # NOTE: https://github.com/r9y9/pyopenjtalk/issues/55 - "numpy>=1.20.0", + "cython>=0.28.0,<3.0.0", + "cmake", + "numpy>=1.25.0; python_version>='3.9'", + "oldest-supported-numpy; python_version<'3.9'", ] +build-backend = "setuptools.build_meta" [tool.pysen] version = "0.10.2" diff --git a/setup.py b/setup.py index 62ec246..9563649 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ platform_is_windows = sys.platform == "win32" -version = "0.3.0" +version = "0.3.2" min_cython_ver = "0.21.0" try: @@ -71,6 +71,43 @@ def build_extensions(self): raise RuntimeError("Cython is required to generate C++ code") +def check_cmake_in_path(): + try: + result = subprocess.run( + ["cmake", "--version"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True, + ) + if result.returncode == 0: + # CMake is in the system path + return True, result.stdout.strip() + else: + # CMake is not in the system path + return False, None + except FileNotFoundError: + # CMake command not found + return False, None + + +if os.name == "nt": # Check if the OS is Windows + # Check if CMake is in the system path + cmake_found, cmake_version = check_cmake_in_path() + + if cmake_found: + print( + f"CMake is in the system path. Version: \ + {cmake_version}" + ) + else: + raise SystemError( + "CMake is not found in the \ + system path. Make sure CMake \ + is installed and in the system \ + path." + ) + + # Workaround for `distutils.spawn` problem on Windows python < 3.9 # See details: [bpo-39763: distutils.spawn now uses subprocess (GH-18743)] # (https://github.com/python/cpython/commit/1ec63b62035e73111e204a0e03b83503e1c58f2e) @@ -277,7 +314,6 @@ def run(self): cmdclass=cmdclass, install_requires=[ "numpy >= 1.20.0", - "cython >= " + min_cython_ver, "six", "tqdm", ], @@ -291,7 +327,8 @@ def run(self): "ipython", "jupyter", ], - "lint": [ + "dev": [ + "cython >= " + min_cython_ver + ",<3.0.0", "pysen", "types-setuptools", "mypy<=0.910", @@ -301,6 +338,7 @@ def run(self): "flake8-bugbear", "isort>=4.3,<5.2.0", "types-decorator", + "importlib-metadata<5.0", ], "test": ["pytest", "scipy"], "marine": ["marine>=0.0.5"],