setup.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. # Copyright (c) 2020 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 os
  15. import os.path as osp
  16. import glob
  17. import shutil
  18. import subprocess
  19. from setuptools import find_packages, setup
  20. # ============== version definition ==============
  21. PPDET_VERSION = "2.4.0"
  22. def parse_version():
  23. return PPDET_VERSION.replace('-', '')
  24. def git_commit():
  25. try:
  26. cmd = ['git', 'rev-parse', 'HEAD']
  27. git_commit = subprocess.Popen(
  28. cmd,
  29. stdout=subprocess.PIPE, ).communicate()[0].strip()
  30. git_commit = git_commit.decode()
  31. except:
  32. git_commit = 'Unknown'
  33. return str(git_commit)
  34. def write_version_py(filename='ppdet/version.py'):
  35. ver_str = """# THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PY
  36. #
  37. full_version = '%(version)s'
  38. commit = '%(commit)s'
  39. """
  40. _git_commit = git_commit()
  41. with open(filename, 'w') as f:
  42. f.write(ver_str % {'version': PPDET_VERSION, 'commit': _git_commit})
  43. write_version_py()
  44. # ============== version definition ==============
  45. def readme():
  46. with open('README.md', encoding='utf-8') as f:
  47. content = f.read()
  48. return content
  49. def parse_requirements(fname):
  50. with open(fname, encoding="utf-8-sig") as f:
  51. requirements = f.readlines()
  52. return requirements
  53. def package_model_zoo():
  54. cur_dir = osp.dirname(osp.realpath(__file__))
  55. cfg_dir = osp.join(cur_dir, "configs")
  56. cfgs = glob.glob(osp.join(cfg_dir, '*/*.yml'))
  57. valid_cfgs = []
  58. for cfg in cfgs:
  59. # exclude dataset base config
  60. if osp.split(osp.split(cfg)[0])[1] not in ['datasets']:
  61. valid_cfgs.append(cfg)
  62. model_names = [
  63. osp.relpath(cfg, cfg_dir).replace(".yml", "") for cfg in valid_cfgs
  64. ]
  65. model_zoo_file = osp.join(cur_dir, 'ppdet', 'model_zoo', 'MODEL_ZOO')
  66. with open(model_zoo_file, 'w') as wf:
  67. for model_name in model_names:
  68. wf.write("{}\n".format(model_name))
  69. return [model_zoo_file]
  70. packages = [
  71. 'ppdet',
  72. 'ppdet.core',
  73. 'ppdet.data',
  74. 'ppdet.engine',
  75. 'ppdet.metrics',
  76. 'ppdet.modeling',
  77. 'ppdet.model_zoo',
  78. 'ppdet.slim',
  79. 'ppdet.utils',
  80. ]
  81. if __name__ == "__main__":
  82. setup(
  83. name='paddledet',
  84. packages=find_packages(exclude=("configs", "tools", "deploy")),
  85. package_data={'ppdet.model_zoo': package_model_zoo()},
  86. author='PaddlePaddle',
  87. version=parse_version(),
  88. install_requires=parse_requirements('./requirements.txt'),
  89. description='Object detection and instance segmentation toolkit based on PaddlePaddle',
  90. long_description=readme(),
  91. long_description_content_type='text/markdown',
  92. url='https://github.com/PaddlePaddle/PaddleDetection',
  93. download_url='https://github.com/PaddlePaddle/PaddleDetection.git',
  94. keywords=['ppdet paddle ppyolo'],
  95. classifiers=[
  96. 'Intended Audience :: Developers',
  97. 'License :: OSI Approved :: Apache Software License',
  98. 'Operating System :: OS Independent',
  99. 'Natural Language :: Chinese (Simplified)',
  100. 'Programming Language :: Python :: 3',
  101. 'Programming Language :: Python :: 3.5',
  102. 'Programming Language :: Python :: 3.6',
  103. 'Programming Language :: Python :: 3.7',
  104. 'Programming Language :: Python :: 3.8', 'Topic :: Utilities'
  105. ],
  106. license='Apache License 2.0',
  107. ext_modules=[])