setup.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. # copyright (c) 2024 PaddlePaddle Authors. All Rights Reserve.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. import os
  15. import glob
  16. import itertools
  17. from pathlib import Path
  18. from setuptools import find_packages
  19. from setuptools import setup
  20. def readme():
  21. """get readme"""
  22. with open("README.md", "r", encoding="utf-8") as file:
  23. return file.read()
  24. def dependencies():
  25. """get dependencies"""
  26. with open("requirements.txt", "r") as file:
  27. return file.read()
  28. def serving_dependencies():
  29. with open(os.path.join("paddlex", "serving_requirements.txt"), "r") as file:
  30. return file.read()
  31. def paddle2onnx_dependencies():
  32. with open(os.path.join("paddlex", "paddle2onnx_requirements.txt"), "r") as file:
  33. return file.read()
  34. def version():
  35. """get version"""
  36. with open(os.path.join("paddlex", ".version"), "r") as file:
  37. return file.read().rstrip()
  38. def packages_and_package_data():
  39. """get packages and package_data"""
  40. def _recursively_find(pattern, exts=None):
  41. for dir_ in glob.iglob(pattern):
  42. for root, _, files in os.walk(dir_):
  43. for f in files:
  44. if exts is not None:
  45. ext = os.path.splitext(f)[1]
  46. if ext not in exts:
  47. continue
  48. yield os.path.join(root, f)
  49. pkgs = find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"])
  50. pkg_data = []
  51. for p in itertools.chain(
  52. _recursively_find("paddlex/configs/*", exts=[".yml", ".yaml"]),
  53. ):
  54. if Path(p).suffix in (".pyc", ".pyo"):
  55. continue
  56. pkg_data.append(Path(p).relative_to("paddlex").as_posix())
  57. pipeline_config = [
  58. Path(p).relative_to("paddlex").as_posix()
  59. for p in glob.glob("paddlex/pipelines/*.yaml")
  60. ]
  61. pkg_data.append("inference/pipelines/ppchatocrv3/ch_prompt.yaml")
  62. pkg_data.extend(pipeline_config)
  63. pkg_data.append(".version")
  64. pkg_data.append("utils/fonts/PingFang-SC-Regular.ttf")
  65. pkg_data.append("repo_manager/requirements.txt")
  66. pkg_data.append("serving_requirements.txt")
  67. return pkgs, {"paddlex": pkg_data}
  68. if __name__ == "__main__":
  69. pkgs, pkg_data = packages_and_package_data()
  70. s = setup(
  71. name="paddlex",
  72. version=version(),
  73. description=("Low-code development tool based on PaddlePaddle."),
  74. long_description=readme(),
  75. author="PaddlePaddle Authors",
  76. author_email="",
  77. install_requires=dependencies(),
  78. extras_require={
  79. "serving": serving_dependencies(),
  80. "paddle2onnx": paddle2onnx_dependencies(),
  81. },
  82. packages=pkgs,
  83. package_data=pkg_data,
  84. entry_points={
  85. "console_scripts": [
  86. "paddlex = paddlex.__main__:console_entry",
  87. ],
  88. },
  89. # PyPI package information
  90. classifiers=[
  91. "Development Status :: 4 - Beta",
  92. "Intended Audience :: Developers",
  93. "Intended Audience :: Education",
  94. "Intended Audience :: Science/Research",
  95. "License :: OSI Approved :: Apache Software License",
  96. "Programming Language :: Python :: 3.8",
  97. "Programming Language :: Python :: 3.9",
  98. "Programming Language :: Python :: 3.10",
  99. "Topic :: Scientific/Engineering",
  100. "Topic :: Scientific/Engineering :: Mathematics",
  101. "Topic :: Scientific/Engineering :: Artificial Intelligence",
  102. "Topic :: Software Development",
  103. "Topic :: Software Development :: Libraries",
  104. "Topic :: Software Development :: Libraries :: Python Modules",
  105. ],
  106. license="Apache 2.0",
  107. keywords=["paddlepaddle"],
  108. )