pyopenjtalk因cmake版本太高导致pip无法安装
错误:
pyopenjtalk
Resolved 191 packages in 528ms
× Failed to build `pyopenjtalk==0.4.0`
├─▶ The build backend returned an error
╰─▶ Call to `setuptools.build_meta.build_wheel` failed (exit code: 1)
[stdout]
-- Configuring incomplete, errors occurred!
CMake is in the system path. Version: cmake version 4.0.0
CMake suite maintained and supported by Kitware (kitware.com/cmake).
[stderr]
CMake Error at CMakeLists.txt:5 (cmake_minimum_required):
Compatibility with CMake < 3.5 has been removed from CMake.
Update the VERSION argument <min> value. Or, use the <min>...<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> or earlier.
Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "C:\Users\Mi\AppData\Local\uv\cache\builds-v0\.tmp2sTMMi\lib\site-packages\setuptools\build_meta.py", line 334, in
get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[])
File "C:\Users\Mi\AppData\Local\uv\cache\builds-v0\.tmp2sTMMi\lib\site-packages\setuptools\build_meta.py", line 304, in
_get_build_requires
self.run_setup()
File "C:\Users\Mi\AppData\Local\uv\cache\builds-v0\.tmp2sTMMi\lib\site-packages\setuptools\build_meta.py", line 320, in run
exec(code, locals())
File "<string>", line 109, in <module>
File "C:\Users\Mi\AppData\Roaming\uv\python\cpython-3.10.16-windows-x86_64-none\lib\subprocess.py", line 457, in check_retu
raise CalledProcessError(self.returncode, self.args, self.stdout,
subprocess.CalledProcessError: Command '['cmake', '..', '-DHTS_ENGINE_INCLUDE_DIR=.', '-DHTS_ENGINE_LIB=dummy']' returned non
Resolved 1 package in 151ms
Prepared 1 package in 25ms
░░░░░░░░░░░░░░░░░░░░ [0/1] Installing wheels...
warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance.
If the cache and target directories are on different filesystems, hardlinking may not be supported.
If this is intentional, set `export UV_LINK_MODE=copy` or use `--link-mode=copy` to suppress this warning.
Installed 1 package in 424ms
+ setuptools==78.1.0
错误的原因很简单,pyopenjtalk 在执行编译wheel文件时,用的cmake 版本是4.0,但是这个版本太高,不兼容该包定义的值。
注意,这个时候,即使你配置了其他低版本的cmake到环境变量中,setuptools也也不会去找它来编译。
解决方案:
step 1、将pyopenjtalk源码或者到pypi将产物下载下来,找到其中的cmakelist.txt文件,将他的最低版本直接改到3.5,如图:
cmake_minimum_required(VERSION 3.5)
# The name "HTSEngine" is used in the original makefile
# Due to historical reasons, let me use "hts_engine_API" instead first.
# we may want to use "HTSEngine" in the future.
# NOTE: we should use semanitc versioning. 1.09 -> 1.0.9!
step 2、通过修改后的源码安装
pip install pyopenjtalk-0.4.0
打完收功