setup.py 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 get_data_files(directory: str, filetypes: list = None):
  39. all_files = []
  40. filetypes = filetypes or []
  41. for root, _, files in os.walk(directory):
  42. rel_root = os.path.relpath(root, directory)
  43. for file in files:
  44. filepath = os.path.join(rel_root, file)
  45. filetype = os.path.splitext(file)[1][1:]
  46. if filetype in filetypes:
  47. all_files.append(filepath)
  48. return all_files
  49. def packages_and_package_data():
  50. """get packages and package_data"""
  51. def _recursively_find(pattern, exts=None):
  52. for dir_ in glob.iglob(pattern):
  53. for root, _, files in os.walk(dir_):
  54. for f in files:
  55. if exts is not None:
  56. ext = os.path.splitext(f)[1]
  57. if ext not in exts:
  58. continue
  59. yield os.path.join(root, f)
  60. pkgs = find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"])
  61. pkg_data = []
  62. for p in itertools.chain(
  63. _recursively_find("paddlex/configs/*", exts=[".yml", ".yaml"]),
  64. ):
  65. if Path(p).suffix in (".pyc", ".pyo"):
  66. continue
  67. pkg_data.append(Path(p).relative_to("paddlex").as_posix())
  68. pipeline_config = [
  69. Path(p).relative_to("paddlex").as_posix()
  70. for p in glob.glob("paddlex/pipelines/*.yaml")
  71. ]
  72. pkg_data.append("inference/pipelines/ppchatocrv3/ch_prompt.yaml")
  73. pkg_data.extend(pipeline_config)
  74. pkg_data.append(".version")
  75. pkg_data.append("utils/fonts/PingFang-SC-Regular.ttf")
  76. pkg_data.append("repo_manager/requirements.txt")
  77. pkg_data.append("serving_requirements.txt")
  78. pkg_data.append("paddle2onnx_requirements.txt")
  79. pkg_data.append("hpip_links.html")
  80. ops_file_dir = 'paddlex/ops'
  81. ops_file_types = ['h', 'hpp', 'cpp', 'cc', 'cu']
  82. return pkgs, {
  83. "paddlex.ops": get_data_files(ops_file_dir, ops_file_types),
  84. "paddlex": pkg_data}
  85. if __name__ == "__main__":
  86. pkgs, pkg_data = packages_and_package_data()
  87. s = setup(
  88. name="paddlex",
  89. version=version(),
  90. description=("Low-code development tool based on PaddlePaddle."),
  91. long_description=readme(),
  92. author="PaddlePaddle Authors",
  93. author_email="",
  94. install_requires=dependencies(),
  95. extras_require={
  96. "serving": serving_dependencies(),
  97. "paddle2onnx": paddle2onnx_dependencies(),
  98. },
  99. packages=pkgs,
  100. package_data=pkg_data,
  101. entry_points={
  102. "console_scripts": [
  103. "paddlex = paddlex.__main__:console_entry",
  104. ],
  105. },
  106. # PyPI package information
  107. classifiers=[
  108. "Development Status :: 4 - Beta",
  109. "Intended Audience :: Developers",
  110. "Intended Audience :: Education",
  111. "Intended Audience :: Science/Research",
  112. "License :: OSI Approved :: Apache Software License",
  113. "Programming Language :: Python :: 3.8",
  114. "Programming Language :: Python :: 3.9",
  115. "Programming Language :: Python :: 3.10",
  116. "Topic :: Scientific/Engineering",
  117. "Topic :: Scientific/Engineering :: Mathematics",
  118. "Topic :: Scientific/Engineering :: Artificial Intelligence",
  119. "Topic :: Software Development",
  120. "Topic :: Software Development :: Libraries",
  121. "Topic :: Software Development :: Libraries :: Python Modules",
  122. ],
  123. license="Apache 2.0",
  124. keywords=["paddlepaddle"],
  125. )