setup.py 1.9 KB

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