setup.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. # Copyright 2023 Avaiga Private Limited
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  4. # the License. You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  9. # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  10. # specific language governing permissions and limitations under the License.
  11. """The setup script."""
  12. import json
  13. import platform
  14. import subprocess
  15. from pathlib import Path
  16. from setuptools import find_packages, setup
  17. from setuptools.command.build_py import build_py
  18. root_folder = Path(__file__).parent
  19. readme = (root_folder / "README.md").read_text("UTF-8")
  20. # get current version
  21. with open(root_folder / "taipy" / "version.json") as version_file:
  22. version = json.load(version_file)
  23. version_string = f'{version.get("major", 0)}.{version.get("minor", 0)}.{version.get("patch", 0)}'
  24. if vext := version.get("ext"):
  25. version_string = f"{version_string}.{vext}"
  26. # build MANIFEST.in from tools/packages/taipy*/MANIFEST.in
  27. with open(root_folder / "MANIFEST.in", "w") as man:
  28. for pman in [
  29. dir / "MANIFEST.in"
  30. for dir in (root_folder / "tools" / "packages").iterdir()
  31. if dir.is_dir() and dir.stem.startswith("taipy")
  32. ]:
  33. man.write(pman.read_text("UTF-8"))
  34. def get_requirements():
  35. # get requirements from the different setups in tools/packages (removing taipy packages)
  36. reqs = set()
  37. for pkg in (root_folder / "tools" / "packages").iterdir():
  38. reqs.update((pkg / "setup.requirements.txt").read_text("UTF-8").splitlines())
  39. return [r for r in reqs if r and not r.startswith("taipy")]
  40. test_requirements = ["pytest>=3.8"]
  41. extras_require = {
  42. "ngrok": ["pyngrok>=5.1,<6.0"],
  43. "image": [
  44. "python-magic>=0.4.24,<0.5;platform_system!='Windows'",
  45. "python-magic-bin>=0.4.14,<0.5;platform_system=='Windows'",
  46. ],
  47. "rdp": ["rdp>=0.8"],
  48. "arrow": ["pyarrow>=10.0.1,<11.0"],
  49. "mssql": ["pyodbc>=4"],
  50. }
  51. class NPMInstall(build_py):
  52. def run(self):
  53. subprocess.run(
  54. ["python", "bundle_build.py"],
  55. cwd=root_folder / "tools" / "frontend",
  56. check=True,
  57. shell=platform.system() == "Windows",
  58. )
  59. build_py.run(self)
  60. setup(
  61. author="Avaiga",
  62. author_email="dev@taipy.io",
  63. python_requires=">=3.8",
  64. classifiers=[
  65. "Intended Audience :: Developers",
  66. "License :: OSI Approved :: Apache Software License",
  67. "Natural Language :: English",
  68. "Programming Language :: Python :: 3",
  69. "Programming Language :: Python :: 3.8",
  70. "Programming Language :: Python :: 3.9",
  71. "Programming Language :: Python :: 3.10",
  72. "Programming Language :: Python :: 3.11",
  73. ],
  74. description="A 360° open-source platform from Python pilots to production-ready web apps.",
  75. install_requires=get_requirements(),
  76. entry_points={
  77. "console_scripts": [
  78. "taipy = taipy._entrypoint:_entrypoint",
  79. ]
  80. },
  81. license="Apache License 2.0",
  82. long_description=readme,
  83. long_description_content_type="text/markdown",
  84. keywords="taipy",
  85. name="taipy",
  86. packages=find_packages(include=["taipy", "taipy.*"]),
  87. include_package_data=True,
  88. test_suite="tests",
  89. url="https://github.com/avaiga/taipy",
  90. version=version_string,
  91. zip_safe=False,
  92. extras_require=extras_require,
  93. cmdclass={"build_py": NPMInstall},
  94. )