setup.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 json
  13. import platform
  14. from pathlib import Path
  15. import subprocess
  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. with open(root_folder / "taipy" / "version.json") as version_file:
  21. version = json.load(version_file)
  22. version_string = f'{version.get("major", 0)}.{version.get("minor", 0)}.{version.get("patch", 0)}'
  23. if vext := version.get("ext"):
  24. version_string = f"{version_string}.{vext}"
  25. requirements = [r for r in (root_folder / "setup.requirements.txt").read_text("UTF-8").splitlines() if r]
  26. test_requirements = ["pytest>=3.8"]
  27. extras_require = {
  28. "ngrok": ["pyngrok>=5.1,<6.0"],
  29. "image": [
  30. "python-magic>=0.4.24,<0.5;platform_system!='Windows'",
  31. "python-magic-bin>=0.4.14,<0.5;platform_system=='Windows'",
  32. ],
  33. "rdp": ["rdp>=0.8"],
  34. "arrow": ["pyarrow>=14.0.2,<15.0"],
  35. "mssql": ["pyodbc>=4"],
  36. }
  37. class NPMInstall(build_py):
  38. def run(self):
  39. with_shell = platform.system() == "Windows"
  40. print(f"Building taipy frontend bundle in {root_folder}.")
  41. already_exists = (root_folder / "taipy" / "gui_core" / "lib" / "taipy-gui-core.js").exists()
  42. if already_exists:
  43. print(f'Found taipy frontend bundle in {root_folder / "taipy" / "gui_core" / "lib"}.')
  44. else:
  45. # Specify the correct path to taipy-gui in gui/.env file
  46. env_file_path = root_folder / "frontend" / "taipy" / ".env"
  47. if not env_file_path.exists():
  48. with open(env_file_path, "w") as env_file:
  49. env_file.write(f"TAIPY_DIR={root_folder}\n")
  50. subprocess.run(["npm", "ci"], cwd=root_folder / "frontend" / "taipy", check=True, shell=with_shell)
  51. subprocess.run(
  52. ["npm", "run", "build"], cwd=root_folder / "frontend" / "taipy", check=True, shell=with_shell
  53. )
  54. build_py.run(self)
  55. setup(
  56. author="Avaiga",
  57. author_email="dev@taipy.io",
  58. python_requires=">=3.8",
  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.8",
  65. "Programming Language :: Python :: 3.9",
  66. "Programming Language :: Python :: 3.10",
  67. "Programming Language :: Python :: 3.11",
  68. ],
  69. description="A 360° open-source platform from Python pilots to production-ready web apps.",
  70. install_requires=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._cli", "taipy.gui_core"]),
  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. )