setup.py 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. # Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
  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 glob
  15. import itertools
  16. import os
  17. from pathlib import Path
  18. from setuptools import find_packages, setup
  19. def readme():
  20. """get readme"""
  21. with open("README.md", "r", encoding="utf-8") as file:
  22. return file.read()
  23. def dependencies():
  24. """get dependencies"""
  25. with open("requirements.txt", "r") as file:
  26. return file.read()
  27. def serving_dependencies():
  28. with open(os.path.join("paddlex", "serving_requirements.txt"), "r") as file:
  29. return file.read()
  30. def paddle2onnx_dependencies():
  31. with open(os.path.join("paddlex", "paddle2onnx_requirements.txt"), "r") as file:
  32. return file.read()
  33. def version():
  34. """get version"""
  35. with open(os.path.join("paddlex", ".version"), "r") as file:
  36. return file.read().rstrip()
  37. def get_data_files(directory: str, filetypes: list = None):
  38. all_files = []
  39. filetypes = filetypes or []
  40. for root, _, files in os.walk(directory):
  41. rel_root = os.path.relpath(root, directory)
  42. for file in files:
  43. filepath = os.path.join(rel_root, file)
  44. filetype = os.path.splitext(file)[1][1:]
  45. if filetype in filetypes:
  46. all_files.append(filepath)
  47. return all_files
  48. def packages_and_package_data():
  49. """get packages and package_data"""
  50. def _recursively_find(pattern, exts=None):
  51. for dir_ in glob.iglob(pattern):
  52. for root, _, files in os.walk(dir_):
  53. for f in files:
  54. if exts is not None:
  55. ext = os.path.splitext(f)[1]
  56. if ext not in exts:
  57. continue
  58. yield os.path.join(root, f)
  59. pkgs = find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"])
  60. pkg_data = []
  61. for p in itertools.chain(
  62. _recursively_find("paddlex/configs/*", exts=[".yml", ".yaml"]),
  63. ):
  64. if Path(p).suffix in (".pyc", ".pyo"):
  65. continue
  66. pkg_data.append(Path(p).relative_to("paddlex").as_posix())
  67. pipeline_config = [
  68. Path(p).relative_to("paddlex").as_posix()
  69. for p in glob.glob("paddlex/pipelines/*.yaml")
  70. ]
  71. pkg_data.append("inference/pipelines/ppchatocrv3/ch_prompt.yaml")
  72. pkg_data.extend(pipeline_config)
  73. pkg_data.append(".version")
  74. pkg_data.append("serving_requirements.txt")
  75. pkg_data.append("paddle2onnx_requirements.txt")
  76. pkg_data.append("hpip_links.html")
  77. pkg_data.append("inference/utils/hpi_model_info_collection.json")
  78. ops_file_dir = "paddlex/ops"
  79. ops_file_types = ["h", "hpp", "cpp", "cc", "cu"]
  80. return pkgs, {
  81. "paddlex.ops": get_data_files(ops_file_dir, ops_file_types),
  82. "paddlex": pkg_data,
  83. }
  84. if __name__ == "__main__":
  85. pkgs, pkg_data = packages_and_package_data()
  86. s = setup(
  87. name="paddlex",
  88. version=version(),
  89. description=("Low-code development tool based on PaddlePaddle."),
  90. long_description=readme(),
  91. long_description_content_type="text/markdown",
  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. "Programming Language :: Python :: 3.11",
  117. "Programming Language :: Python :: 3.12",
  118. "Topic :: Scientific/Engineering",
  119. "Topic :: Scientific/Engineering :: Mathematics",
  120. "Topic :: Scientific/Engineering :: Artificial Intelligence",
  121. "Topic :: Software Development",
  122. "Topic :: Software Development :: Libraries",
  123. "Topic :: Software Development :: Libraries :: Python Modules",
  124. ],
  125. license="Apache 2.0",
  126. keywords=["paddlepaddle"],
  127. )