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