setup.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 os
  14. import sysconfig
  15. from pathlib import Path
  16. from importlib.util import find_spec
  17. from setuptools import find_namespace_packages, find_packages, setup
  18. from setuptools.command.build_py import build_py
  19. with open("README.md", "rb") as readme_file:
  20. readme = readme_file.read().decode("UTF-8")
  21. with open(f"src{os.sep}taipy{os.sep}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. requirements = [
  27. "backports.zoneinfo>=0.2.1,<0.3;python_version<'3.9'",
  28. "cookiecutter>=2.1.1,<2.2",
  29. "taipy-gui@git+https://git@github.com/Avaiga/taipy-gui.git@develop",
  30. "taipy-rest@git+https://git@github.com/Avaiga/taipy-rest.git@develop",
  31. "taipy-templates@git+https://git@github.com/Avaiga/taipy-templates.git@develop",
  32. ]
  33. setup_requirements = [(requirement for requirement in requirements if requirement.startswith("taipy-gui"))]
  34. test_requirements = ["pytest>=3.8"]
  35. extras_require = {
  36. "ngrok": ["pyngrok>=5.1,<6.0"],
  37. "image": [
  38. "python-magic>=0.4.24,<0.5;platform_system!='Windows'",
  39. "python-magic-bin>=0.4.14,<0.5;platform_system=='Windows'",
  40. ],
  41. "rdp": ["rdp>=0.8"],
  42. "arrow": ["pyarrow>=10.0.1,<11.0"],
  43. "mssql": ["pyodbc>=4"],
  44. }
  45. def _build_webapp():
  46. already_exists = Path("./src/taipy/gui_core/lib/taipy-gui-core.js").exists()
  47. if not already_exists:
  48. site_packages_path = sysconfig.get_path("purelib")
  49. if find_spec("taipy") and find_spec("taipy.gui"):
  50. import taipy
  51. site_packages_path = Path(taipy.__file__).parent.parent
  52. env_file_path = Path(__file__).absolute().parent / "gui" / ".env"
  53. if not os.path.exists(env_file_path):
  54. with open(env_file_path, "w") as env_file:
  55. env_file.write(f"TAIPY_GUI_DIR={site_packages_path}\n")
  56. os.system("cd gui && npm ci && npm run build")
  57. class NPMInstall(build_py):
  58. def run(self):
  59. _build_webapp()
  60. build_py.run(self)
  61. setup(
  62. author="Avaiga",
  63. author_email="dev@taipy.io",
  64. python_requires=">=3.8",
  65. classifiers=[
  66. "Intended Audience :: Developers",
  67. "License :: OSI Approved :: Apache Software License",
  68. "Natural Language :: English",
  69. "Programming Language :: Python :: 3",
  70. "Programming Language :: Python :: 3.8",
  71. "Programming Language :: Python :: 3.9",
  72. "Programming Language :: Python :: 3.10",
  73. "Programming Language :: Python :: 3.11",
  74. ],
  75. description="A 360° open-source platform from Python pilots to production-ready web apps.",
  76. setup_requires=setup_requirements,
  77. install_requires=requirements,
  78. entry_points={
  79. "console_scripts": [
  80. "taipy = taipy._entrypoint:_entrypoint",
  81. ]
  82. },
  83. license="Apache License 2.0",
  84. long_description=readme,
  85. long_description_content_type="text/markdown",
  86. keywords="taipy",
  87. name="taipy",
  88. package_dir={"": "src"},
  89. packages=find_namespace_packages(where="src") + find_packages(include=["taipy"]),
  90. include_package_data=True,
  91. test_suite="tests",
  92. url="https://github.com/avaiga/taipy",
  93. version=version_string,
  94. zip_safe=False,
  95. extras_require=extras_require,
  96. cmdclass={"build_py": NPMInstall},
  97. )