setup.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # Copyright 2021-2024 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 os
  13. import json
  14. import platform
  15. import subprocess
  16. from pathlib import Path
  17. from setuptools import find_packages, setup
  18. from setuptools.command.build_py import build_py
  19. root_folder = Path(__file__).parent
  20. readme = (root_folder / "README.md").read_text("UTF-8")
  21. # get current version
  22. with open(os.path.join("taipy", "version.json")) as version_file:
  23. version = json.load(version_file)
  24. version_string = f'{version.get("major", 0)}.{version.get("minor", 0)}.{version.get("patch", 0)}'
  25. if vext := version.get("ext"):
  26. version_string = f"{version_string}.{vext}"
  27. def get_requirements():
  28. # get requirements from the different setups in tools/packages (removing taipy packages)
  29. reqs = set()
  30. for pkg in (root_folder / "tools" / "packages").iterdir():
  31. requirements_file = pkg / "setup.requirements.txt"
  32. if requirements_file.exists():
  33. reqs.update(requirements_file.read_text("UTF-8").splitlines())
  34. return [r for r in reqs if r and not r.startswith("taipy")]
  35. test_requirements = ["pytest>=3.8"]
  36. extras_require = {
  37. "ngrok": ["pyngrok>=5.1,<6.0"],
  38. "image": [
  39. "python-magic>=0.4.24,<0.5;platform_system!='Windows'",
  40. "python-magic-bin>=0.4.14,<0.5;platform_system=='Windows'",
  41. ],
  42. "rdp": ["rdp>=0.8"],
  43. "arrow": ["pyarrow>=14.0.2,<15.0"],
  44. "mssql": ["pyodbc>=4"],
  45. }
  46. class NPMInstall(build_py):
  47. def run(self):
  48. subprocess.run(
  49. ["python", "bundle_build.py"],
  50. cwd=root_folder / "tools" / "frontend",
  51. check=True,
  52. shell=platform.system() == "Windows",
  53. )
  54. build_py.run(self)
  55. setup(
  56. author="Avaiga",
  57. author_email="dev@taipy.io",
  58. python_requires=">=3.9",
  59. classifiers=[
  60. "Intended Audience :: Developers",
  61. "License :: OSI Approved :: Apache Software License",
  62. "Natural Language :: English",
  63. "Programming Language :: Python :: 3",
  64. "Programming Language :: Python :: 3.9",
  65. "Programming Language :: Python :: 3.10",
  66. "Programming Language :: Python :: 3.11",
  67. "Programming Language :: Python :: 3.12",
  68. ],
  69. description="A 360° open-source platform from Python pilots to production-ready web apps.",
  70. install_requires=get_requirements(),
  71. entry_points={
  72. "console_scripts": [
  73. "taipy = taipy._entrypoint:_entrypoint",
  74. ]
  75. },
  76. license="Apache License 2.0",
  77. long_description=readme,
  78. long_description_content_type="text/markdown",
  79. keywords="taipy",
  80. name="taipy",
  81. packages=find_packages(include=["taipy", "taipy.*"]),
  82. include_package_data=True,
  83. test_suite="tests",
  84. url="https://github.com/avaiga/taipy",
  85. version=version_string,
  86. zip_safe=False,
  87. extras_require=extras_require,
  88. cmdclass={"build_py": NPMInstall},
  89. )