mirror of
https://github.com/csukuangfj/kaldifeat.git
synced 2025-12-11 06:55:26 +00:00
Fix building on Windows.
This commit is contained in:
parent
47ff9a2c35
commit
959da88b6e
@ -20,6 +20,10 @@ def is_macos():
|
||||
return platform.system() == "Darwin"
|
||||
|
||||
|
||||
def is_windows():
|
||||
return platform.system() == "Windows"
|
||||
|
||||
|
||||
try:
|
||||
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
|
||||
|
||||
@ -63,34 +67,64 @@ class BuildExtension(build_ext):
|
||||
if cmake_args == "":
|
||||
cmake_args = "-DCMAKE_BUILD_TYPE=Release"
|
||||
|
||||
if make_args == "" and system_make_args == "":
|
||||
print("For fast compilation, run:")
|
||||
print('export KALDIFEAT_MAKE_ARGS="-j"; python setup.py install')
|
||||
|
||||
if "PYTHON_EXECUTABLE" not in cmake_args:
|
||||
print(f"Setting PYTHON_EXECUTABLE to {sys.executable}")
|
||||
cmake_args += f" -DPYTHON_EXECUTABLE={sys.executable}"
|
||||
|
||||
build_cmd = f"""
|
||||
cd {self.build_temp}
|
||||
|
||||
cmake {cmake_args} {kaldifeat_dir}
|
||||
|
||||
|
||||
make {make_args} _kaldifeat
|
||||
"""
|
||||
print(f"build command is:\n{build_cmd}")
|
||||
|
||||
ret = os.system(build_cmd)
|
||||
if ret != 0:
|
||||
raise Exception(
|
||||
"\nBuild kaldifeat failed. Please check the error message.\n"
|
||||
"You can ask for help by creating an issue on GitHub.\n"
|
||||
"\nClick:\n\thttps://github.com/csukuangfj/kaldifeat/issues/new\n" # noqa
|
||||
if is_windows():
|
||||
build_cmd = f"""
|
||||
cmake {cmake_args} -B {self.build_temp} -S {kaldifeat_dir}
|
||||
cmake --build {self.build_temp} --target _kaldifeat --config Release -- -m
|
||||
"""
|
||||
print(f"build command is:\n{build_cmd}")
|
||||
ret = os.system(
|
||||
f"cmake {cmake_args} -B {self.build_temp} -S {kaldifeat_dir}"
|
||||
)
|
||||
if ret != 0:
|
||||
raise Exception("Failed to build kaldifeat")
|
||||
|
||||
ret = os.system(
|
||||
f"cmake --build {self.build_temp} --target _kaldifeat --config Release -- -m"
|
||||
)
|
||||
if ret != 0:
|
||||
raise Exception("Failed to build kaldifeat")
|
||||
else:
|
||||
if make_args == "" and system_make_args == "":
|
||||
print("For fast compilation, run:")
|
||||
print(
|
||||
'export KALDIFEAT_MAKE_ARGS="-j"; python setup.py install'
|
||||
)
|
||||
|
||||
build_cmd = f"""
|
||||
cd {self.build_temp}
|
||||
|
||||
cmake {cmake_args} {kaldifeat_dir}
|
||||
|
||||
|
||||
make {make_args} _kaldifeat
|
||||
"""
|
||||
print(f"build command is:\n{build_cmd}")
|
||||
|
||||
ret = os.system(build_cmd)
|
||||
if ret != 0:
|
||||
raise Exception(
|
||||
"\nBuild kaldifeat failed. Please check the error message.\n"
|
||||
"You can ask for help by creating an issue on GitHub.\n"
|
||||
"\nClick:\n\thttps://github.com/csukuangfj/kaldifeat/issues/new\n" # noqa
|
||||
)
|
||||
|
||||
lib_so = glob.glob(f"{self.build_temp}/lib/*kaldifeat*.so")
|
||||
lib_so += glob.glob(f"{self.build_temp}/lib/*kaldifeat*.dylib") # macOS
|
||||
|
||||
# bin/Release/_k2.cp38-win_amd64.pyd
|
||||
lib_so = glob.glob(
|
||||
f"{self.build_temp}/**/*kaldifeat*.pyd", recursive=True
|
||||
) # windows
|
||||
|
||||
# lib/Release/*.lib
|
||||
lib_so = glob.glob(
|
||||
f"{self.build_temp}/**/*kaldifeat*.lib", recursive=True
|
||||
) # windows
|
||||
for so in lib_so:
|
||||
print(f"Copying {so} to {self.build_lib}/")
|
||||
shutil.copy(f"{so}", f"{self.build_lib}/")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user