setup.py (2064B)
1 #!/usr/bin/env python3 2 # 3 # Copyright (c) 2021 Xiaomi Corporation (author: Fangjun Kuang) 4 5 import re 6 7 import setuptools 8 9 from cmake.cmake_extension import BuildExtension, bdist_wheel, cmake_extension 10 11 12 def read_long_description(): 13 with open("README.md", encoding="utf8") as f: 14 readme = f.read() 15 return readme 16 17 18 def get_package_version(): 19 with open("CMakeLists.txt") as f: 20 content = f.read() 21 22 match = re.search(r"set\(KALDI_NATIVE_FBANK_VERSION (.*)\)", content) 23 latest_version = match.group(1).strip('"') 24 return latest_version 25 26 27 package_name = "kaldi-native-fbank" 28 29 with open("kaldi-native-fbank/python/kaldi_native_fbank/__init__.py", "a") as f: 30 f.write(f"__version__ = '{get_package_version()}'\n") 31 32 setuptools.setup( 33 name=package_name, 34 version=get_package_version(), 35 author="Fangjun Kuang", 36 author_email="csukuangfj@gmail.com", 37 package_dir={"kaldi_native_fbank": "kaldi-native-fbank/python/kaldi_native_fbank"}, 38 packages=["kaldi_native_fbank"], 39 url="https://github.com/csukuangfj/kaldi-native-fbank", 40 long_description=read_long_description(), 41 long_description_content_type="text/markdown", 42 ext_modules=[cmake_extension("_kaldi_native_fbank")], 43 cmdclass={"build_ext": BuildExtension, "bdist_wheel": bdist_wheel}, 44 zip_safe=False, 45 classifiers=[ 46 "Programming Language :: C++", 47 "Programming Language :: Python", 48 "Programming Language :: Python :: 3", 49 "Topic :: Scientific/Engineering :: Artificial Intelligence", 50 ], 51 python_requires=">=3.6.0", 52 license="Apache licensed, as found in the LICENSE file", 53 ) 54 55 # remove the line __version__ from kaldi-native-fbank/python/kaldi_native_fbank/__init__.py 56 with open("kaldi-native-fbank/python/kaldi_native_fbank/__init__.py", "r") as f: 57 lines = f.readlines() 58 59 with open("kaldi-native-fbank/python/kaldi_native_fbank/__init__.py", "w") as f: 60 for line in lines: 61 if "__version__" in line: 62 # skip __version__ = "x.x.x" 63 continue 64 f.write(line)