setup.py 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. """
  22. with open('README.md', 'r', encoding='utf-8') as file:
  23. return file.read()
  24. def dependencies():
  25. """get dependencies
  26. """
  27. with open('requirements.txt', 'r') as file:
  28. return file.read()
  29. def version():
  30. """get version
  31. """
  32. with open(os.path.join('paddlex', '.version'), 'r') as file:
  33. return file.read().rstrip()
  34. def packages_and_package_data():
  35. """get packages and package_data
  36. """
  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(include=[
  47. 'paddlex',
  48. 'paddlex.modules',
  49. 'paddlex.modules.*',
  50. 'paddlex.pipelines',
  51. 'paddlex.pipelines.*',
  52. 'paddlex.repo_manager',
  53. 'paddlex.repo_apis',
  54. 'paddlex.repo_apis.*',
  55. 'paddlex.utils',
  56. 'paddlex.utils.*',
  57. ])
  58. pkg_data = []
  59. for p in itertools.chain(
  60. # Configuration files
  61. _recursively_find(
  62. "paddlex/configs/*", exts=['.yml', '.yaml']), ):
  63. parts = os.path.normpath(p).split(os.sep)
  64. ext = os.path.splitext(p)[1]
  65. # Globally exclude Python bytecode files
  66. if ext in ('.pyc', '.pyo'):
  67. continue
  68. # According to https://setuptools.pypa.io/en/latest/userguide/datafiles.html
  69. rp = '/'.join(parts[1:])
  70. pkg_data.append(rp)
  71. pkg_data.append('.version')
  72. pkg_data.append('utils/fonts/PingFang-SC-Regular.ttf')
  73. pkg_data.append('repo_manager/requirements.txt')
  74. return pkgs, {'paddlex': pkg_data}
  75. def check_paddle_version():
  76. """check paddle version
  77. """
  78. import paddle
  79. supported_versions = ['3.0', '0.0']
  80. version = paddle.__version__
  81. # Recognizable version number: major.minor.patch
  82. major, minor, patch = version.split('.')
  83. # Ignore patch
  84. version = f"{major}.{minor}"
  85. if version not in supported_versions:
  86. raise RuntimeError(
  87. f"The {version} version of PaddlePaddle is not supported. "
  88. f"Please install one of the following versions of PaddlePaddle: {supported_versions}."
  89. )
  90. if __name__ == '__main__':
  91. check_paddle_version()
  92. pkgs, pkg_data = packages_and_package_data()
  93. s = setup(
  94. name='paddlex',
  95. version=version(),
  96. description=('Low-code development tool based on PaddlePaddle.'),
  97. long_description=readme(),
  98. author='PaddlePaddle Authors',
  99. author_email='',
  100. install_requires=dependencies(),
  101. packages=pkgs,
  102. package_data=pkg_data,
  103. entry_points={
  104. 'console_scripts': ['paddlex = paddlex.paddlex_cli:main', ],
  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'])