setup.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 importlib.util import find_spec
  16. from pathlib import Path
  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. test_requirements = ["pytest>=3.8"]
  34. extras_require = {
  35. "ngrok": ["pyngrok>=5.1,<6.0"],
  36. "image": [
  37. "python-magic>=0.4.24,<0.5;platform_system!='Windows'",
  38. "python-magic-bin>=0.4.14,<0.5;platform_system=='Windows'",
  39. ],
  40. "rdp": ["rdp>=0.8"],
  41. "arrow": ["pyarrow>=10.0.1,<11.0"],
  42. "mssql": ["pyodbc>=4"],
  43. }
  44. def _build_webapp():
  45. already_exists = Path("./src/taipy/gui_core/lib/taipy-gui-core.js").exists()
  46. if not already_exists:
  47. # default site-packages path is from the current python interpreter
  48. site_packages_path = sysconfig.get_path("purelib")
  49. # taipy-gui should be available through setup_requires option
  50. # taipy-gui at this step is installed in a backend site-packages separated from the one being used by pip
  51. if find_spec("taipy") and find_spec("taipy.gui"):
  52. import taipy
  53. site_packages_path = Path(taipy.__file__).absolute().parent.parent
  54. # Specify the correct path to taipy-gui in gui/.env file
  55. env_file_path = Path(__file__).absolute().parent / "gui" / ".env"
  56. if not os.path.exists(env_file_path):
  57. with open(env_file_path, "w") as env_file:
  58. env_file.write(f"TAIPY_GUI_DIR={site_packages_path}\n")
  59. os.system("cd gui && npm ci && npm run build")
  60. class NPMInstall(build_py):
  61. def run(self):
  62. _build_webapp()
  63. build_py.run(self)
  64. setup(
  65. author="Avaiga",
  66. author_email="dev@taipy.io",
  67. python_requires=">=3.8",
  68. classifiers=[
  69. "Intended Audience :: Developers",
  70. "License :: OSI Approved :: Apache Software License",
  71. "Natural Language :: English",
  72. "Programming Language :: Python :: 3",
  73. "Programming Language :: Python :: 3.8",
  74. "Programming Language :: Python :: 3.9",
  75. "Programming Language :: Python :: 3.10",
  76. "Programming Language :: Python :: 3.11",
  77. ],
  78. description="A 360° open-source platform from Python pilots to production-ready web apps.",
  79. install_requires=requirements,
  80. entry_points={
  81. "console_scripts": [
  82. "taipy = taipy._entrypoint:_entrypoint",
  83. ]
  84. },
  85. license="Apache License 2.0",
  86. long_description=readme,
  87. long_description_content_type="text/markdown",
  88. keywords="taipy",
  89. name="taipy",
  90. package_dir={"": "src"},
  91. packages=find_namespace_packages(where="src") + find_packages(include=["taipy"]),
  92. include_package_data=True,
  93. test_suite="tests",
  94. url="https://github.com/avaiga/taipy",
  95. version=version_string,
  96. zip_safe=False,
  97. extras_require=extras_require,
  98. cmdclass={"build_py": NPMInstall},
  99. )