You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

setup.py 5.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. # Copyright 2021 The KubeEdge Authors.
  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. """Setuptools of sedna"""
  15. from setuptools import setup, find_packages
  16. import sys
  17. import os
  18. assert sys.version_info >= (3, 6), "Sorry, Python < 3.6 is not supported."
  19. class InstallPrepare:
  20. """
  21. Parsing dependencies
  22. """
  23. def __init__(self):
  24. self.project = os.path.join(os.path.dirname(__file__), "sedna")
  25. self._long_desc = os.path.join(self.project, "README.md")
  26. self._version = os.path.join(self.project, "VERSION")
  27. self._owner = os.path.join(self.project, "..", "OWNERS")
  28. self._requirements = os.path.join(self.project, "..",
  29. "requirements.txt")
  30. self._dev_requirements = os.path.join(self.project, "..",
  31. "requirements.dev.txt")
  32. @property
  33. def long_desc(self):
  34. if not os.path.isfile(self._long_desc):
  35. return ""
  36. with open(self._long_desc, "r", encoding="utf-8") as fh:
  37. long_desc = fh.read()
  38. return long_desc
  39. @property
  40. def version(self):
  41. default_version = "999.dev"
  42. if not os.path.isfile(self._version):
  43. return default_version
  44. with open(self._version, "r", encoding="utf-8") as fh:
  45. __version__ = fh.read().strip()
  46. return __version__ or default_version
  47. @property
  48. def owners(self):
  49. default_owner = "sedna"
  50. if not os.path.isfile(self._owner):
  51. return default_owner
  52. with open(self._owner, "r", encoding="utf-8") as fh:
  53. check, approvers = False, set()
  54. for line in fh:
  55. if not line.strip():
  56. continue
  57. if check:
  58. approvers.add(line.strip().split()[-1])
  59. check = (line.startswith("approvers:") or
  60. (line.startswith(" -") and check))
  61. return ",".join(approvers) or default_owner
  62. @property
  63. def basic_dependencies(self):
  64. return self._read_requirements(self._requirements)
  65. def feature_dependencies(self, feature):
  66. _c = os.path.join(self.project, 'core', feature, "requirements.txt")
  67. if os.path.isfile(_c):
  68. return self._read_requirements(_c)
  69. return self._read_requirements(self._dev_requirements, feature)
  70. @staticmethod
  71. def _read_requirements(file_path, section="all"):
  72. print(f"Start to install requirements of {section} "
  73. f"in sedna from {file_path}")
  74. if not os.path.isfile(file_path):
  75. return []
  76. with open(file_path, "r", encoding="utf-8") as f:
  77. install_requires = [p.strip() for p in f.readlines() if p.strip()]
  78. if section == "all":
  79. return list(filter(lambda x: not x.startswith("#"),
  80. install_requires))
  81. section_start = False
  82. section_requires = []
  83. for p in install_requires:
  84. if section_start:
  85. if p.startswith("#"):
  86. return section_requires
  87. section_requires.append(p)
  88. elif p.startswith(f"# {section}"):
  89. section_start = True
  90. return section_requires
  91. _infos = InstallPrepare()
  92. setup(
  93. name='sedna',
  94. version=_infos.version,
  95. description="The sedna package is designed to help developers \
  96. better use open source frameworks such as tensorflow \
  97. on Sedna project",
  98. packages=find_packages(exclude=["tests", "*.tests",
  99. "*.tests.*", "tests.*"]),
  100. author=_infos.owners,
  101. author_email="pujie2@huawei.com",
  102. maintainer=_infos.owners,
  103. maintainer_email="",
  104. include_package_data=True,
  105. python_requires=">=3.6",
  106. long_description=_infos.long_desc,
  107. long_description_content_type="text/markdown",
  108. license="Apache License 2.0",
  109. url="https://github.com/kubeedge/sedna",
  110. classifiers=[
  111. "Programming Language :: Python :: 3",
  112. "License :: OSI Approved :: Apache Software License",
  113. "Operating System :: POSIX :: Linux",
  114. ],
  115. install_requires=_infos.basic_dependencies,
  116. extras_require={
  117. "fl": _infos.feature_dependencies("federated_learning"),
  118. "il": _infos.feature_dependencies("incremental_learning"),
  119. "ji": _infos.feature_dependencies("joint_inference"),
  120. "ll": _infos.feature_dependencies("lifelong_learning")
  121. },
  122. )