setup.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 setuptools import find_namespace_packages, find_packages, setup
  17. from setuptools.command.build_py import build_py
  18. with open("README.md", "rb") as readme_file:
  19. readme = readme_file.read().decode("UTF-8")
  20. with open(f"src{os.sep}taipy{os.sep}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 = [
  26. "backports.zoneinfo>=0.2.1,<0.3;python_version<'3.9'",
  27. "cookiecutter>=2.1.1,<2.2",
  28. "taipy-gui@git+https://git@github.com/Avaiga/taipy-gui.git@develop",
  29. "taipy-rest@git+https://git@github.com/Avaiga/taipy-rest.git@develop",
  30. "taipy-templates@git+https://git@github.com/Avaiga/taipy-templates.git@develop",
  31. ]
  32. setup_requirements = [(requirement for requirement in requirements if requirement.startswith("taipy-gui"))]
  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. site_packages_path = sysconfig.get_path('purelib')
  48. env_file_path = Path(__file__).absolute().parent / "gui" /".env"
  49. if not os.path.exists(env_file_path):
  50. with open(env_file_path, "w") as env_file:
  51. env_file.write(f"TAIPY_GUI_DIR={site_packages_path}\n")
  52. os.system("cd gui && npm ci && npm run build")
  53. class NPMInstall(build_py):
  54. def run(self):
  55. _build_webapp()
  56. build_py.run(self)
  57. setup(
  58. author="Avaiga",
  59. author_email="dev@taipy.io",
  60. python_requires=">=3.8",
  61. classifiers=[
  62. "Intended Audience :: Developers",
  63. "License :: OSI Approved :: Apache Software License",
  64. "Natural Language :: English",
  65. "Programming Language :: Python :: 3",
  66. "Programming Language :: Python :: 3.8",
  67. "Programming Language :: Python :: 3.9",
  68. "Programming Language :: Python :: 3.10",
  69. "Programming Language :: Python :: 3.11",
  70. ],
  71. description="A 360° open-source platform from Python pilots to production-ready web apps.",
  72. setup_requires=setup_requirements,
  73. install_requires=requirements,
  74. entry_points={
  75. "console_scripts": [
  76. "taipy = taipy._entrypoint:_entrypoint",
  77. ]
  78. },
  79. license="Apache License 2.0",
  80. long_description=readme,
  81. long_description_content_type="text/markdown",
  82. keywords="taipy",
  83. name="taipy",
  84. package_dir={"": "src"},
  85. packages=find_namespace_packages(where="src") + find_packages(include=["taipy"]),
  86. include_package_data=True,
  87. test_suite="tests",
  88. url="https://github.com/avaiga/taipy",
  89. version=version_string,
  90. zip_safe=False,
  91. extras_require=extras_require,
  92. cmdclass={"build_py": NPMInstall},
  93. )