setup.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 version():
  32. """get version"""
  33. with open(os.path.join("paddlex", ".version"), "r") as file:
  34. return file.read().rstrip()
  35. def packages_and_package_data():
  36. """get packages and package_data"""
  37. def _recursively_find(pattern, exts=None):
  38. for dir_ in glob.iglob(pattern):
  39. for root, _, files in os.walk(dir_):
  40. for f in files:
  41. if exts is not None:
  42. ext = os.path.splitext(f)[1]
  43. if ext not in exts:
  44. continue
  45. yield os.path.join(root, f)
  46. pkgs = find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"])
  47. pkg_data = []
  48. for p in itertools.chain(
  49. _recursively_find("paddlex/configs/*", exts=[".yml", ".yaml"]),
  50. ):
  51. if Path(p).suffix in (".pyc", ".pyo"):
  52. continue
  53. pkg_data.append(Path(p).relative_to("paddlex").as_posix())
  54. pipeline_config = [
  55. Path(p).relative_to("paddlex").as_posix()
  56. for p in glob.glob("paddlex/pipelines/*.yaml")
  57. ]
  58. pkg_data.append("inference/pipelines/ppchatocrv3/ch_prompt.yaml")
  59. pkg_data.extend(pipeline_config)
  60. pkg_data.append(".version")
  61. pkg_data.append("utils/fonts/PingFang-SC-Regular.ttf")
  62. pkg_data.append("repo_manager/requirements.txt")
  63. pkg_data.append("serving_requirements.txt")
  64. return pkgs, {"paddlex": pkg_data}
  65. if __name__ == "__main__":
  66. pkgs, pkg_data = packages_and_package_data()
  67. s = setup(
  68. name="paddlex",
  69. version=version(),
  70. description=("Low-code development tool based on PaddlePaddle."),
  71. long_description=readme(),
  72. author="PaddlePaddle Authors",
  73. author_email="",
  74. install_requires=dependencies(),
  75. extras_require={
  76. "serving": serving_dependencies(),
  77. },
  78. packages=pkgs,
  79. package_data=pkg_data,
  80. entry_points={
  81. "console_scripts": [
  82. "paddlex = paddlex.__main__:console_entry",
  83. ],
  84. },
  85. # PyPI package information
  86. classifiers=[
  87. "Development Status :: 4 - Beta",
  88. "Intended Audience :: Developers",
  89. "Intended Audience :: Education",
  90. "Intended Audience :: Science/Research",
  91. "License :: OSI Approved :: Apache Software License",
  92. "Programming Language :: Python :: 3.8",
  93. "Programming Language :: Python :: 3.9",
  94. "Programming Language :: Python :: 3.10",
  95. "Topic :: Scientific/Engineering",
  96. "Topic :: Scientific/Engineering :: Mathematics",
  97. "Topic :: Scientific/Engineering :: Artificial Intelligence",
  98. "Topic :: Software Development",
  99. "Topic :: Software Development :: Libraries",
  100. "Topic :: Software Development :: Libraries :: Python Modules",
  101. ],
  102. license="Apache 2.0",
  103. keywords=["paddlepaddle"],
  104. )