setup.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 for taipy-gui package"""
  12. import json
  13. import os
  14. import platform
  15. from pathlib import Path
  16. import subprocess
  17. from setuptools import find_packages, setup
  18. from setuptools.command.build_py import build_py
  19. root_folder = Path(__file__).parent
  20. package_desc = Path(root_folder / "package_desc.md").read_text("UTF-8")
  21. version_path = os.path.join(root_folder, "taipy/gui/version.json")
  22. setup_requirements = Path("taipy/gui/setup.requirements.txt")
  23. with open(version_path) as version_file:
  24. version = json.load(version_file)
  25. version_string = f'{version.get("major", 0)}.{version.get("minor", 0)}.{version.get("patch", 0)}'
  26. if vext := version.get("ext"):
  27. version_string = f"{version_string}.{vext}"
  28. requirements = [r for r in (setup_requirements).read_text("UTF-8").splitlines() if r]
  29. test_requirements = ["pytest>=3.8"]
  30. extras_require = {
  31. "ngrok": ["pyngrok>=5.1,<6.0"],
  32. "image": [
  33. "python-magic>=0.4.24,<0.5;platform_system!='Windows'",
  34. "python-magic-bin>=0.4.14,<0.5;platform_system=='Windows'",
  35. ],
  36. "arrow": ["pyarrow>=14.0.2,<15.0"],
  37. }
  38. class NPMInstall(build_py):
  39. def run(self):
  40. with_shell = platform.system() == "Windows"
  41. print(f"Building taipy-gui frontend bundle in {root_folder}.")
  42. already_exists = (root_folder / "taipy" / "gui" / "webapp" / "index.html").exists()
  43. if already_exists:
  44. print(f'Found taipy-gui frontend bundle in {root_folder / "taipy" / "gui" / "webapp"}.')
  45. else:
  46. subprocess.run(
  47. ["npm", "ci"], cwd=root_folder / "frontend" / "taipy-gui" / "dom", check=True, shell=with_shell
  48. )
  49. subprocess.run(
  50. ["npm", "ci", "--omit=optional"],
  51. cwd=root_folder / "frontend" / "taipy-gui",
  52. check=True,
  53. shell=with_shell,
  54. )
  55. subprocess.run(
  56. ["npm", "run", "build"], cwd=root_folder / "frontend" / "taipy-gui", check=True, shell=with_shell
  57. )
  58. build_py.run(self)
  59. setup(
  60. author="Avaiga",
  61. author_email="dev@taipy.io",
  62. python_requires=">=3.8",
  63. classifiers=[
  64. "Development Status :: 5 - Production/Stable",
  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. "Programming Language :: Python :: 3.12",
  74. "Topic :: Software Development",
  75. "Topic :: Scientific/Engineering",
  76. "Operating System :: Microsoft :: Windows",
  77. "Operating System :: POSIX",
  78. "Operating System :: Unix",
  79. "Operating System :: MacOS",
  80. ],
  81. description="Low-code library to create graphical user interfaces on the Web for your Python applications.",
  82. long_description=package_desc,
  83. long_description_content_type="text/markdown",
  84. install_requires=requirements,
  85. license="Apache License 2.0",
  86. include_package_data=True,
  87. keywords="taipy-gui",
  88. name="taipy-gui",
  89. packages=find_packages(where=root_folder, include=["taipy", "taipy.gui", "taipy.gui.*"]),
  90. test_suite="tests",
  91. tests_require=test_requirements,
  92. version=version_string,
  93. zip_safe=False,
  94. extras_require=extras_require,
  95. cmdclass={"build_py": NPMInstall},
  96. project_urls={
  97. "Homepage": "https://www.taipy.io",
  98. "Documentation": "https://docs.taipy.io",
  99. "Source": "https://github.com/Avaiga/taipy",
  100. "Download": "https://pypi.org/project/taipy/#files",
  101. "Tracker": "https://github.com/Avaiga/taipy/issues",
  102. "Release notes": "https://docs.taipy.io/en/latest/relnotes/",
  103. },
  104. )