setup.py 4.0 KB

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