setup.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Copyright 2021-2025 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. import os
  12. import json
  13. import platform
  14. import subprocess
  15. from pathlib import Path
  16. from setuptools import setup, find_packages
  17. from setuptools.command.build_py import build_py
  18. root_folder = Path(__file__).parent
  19. # get current version
  20. with open(os.path.join("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. def get_requirements():
  26. reqs = set()
  27. for pkg in (root_folder / "tools" / "packages").iterdir():
  28. requirements_file = pkg / "setup.requirements.txt"
  29. if requirements_file.exists():
  30. reqs.update(requirements_file.read_text("UTF-8").splitlines())
  31. return [r for r in reqs if r and not r.startswith("taipy")]
  32. class NPMInstall(build_py):
  33. def run(self):
  34. subprocess.run(
  35. ["python", "bundle_build.py"],
  36. cwd=root_folder / "tools" / "frontend",
  37. check=True,
  38. shell=platform.system() == "Windows",
  39. )
  40. build_py.run(self)
  41. setup(
  42. version=version_string,
  43. install_requires=get_requirements(),
  44. packages=find_packages(include=["taipy", "taipy.*"]),
  45. extras_require={
  46. "ngrok": ["pyngrok>=5.1,<6.0"],
  47. "image": [
  48. "python-magic>=0.4.24,<0.5;platform_system!='Windows'",
  49. "python-magic-bin>=0.4.14,<0.5;platform_system=='Windows'",
  50. ],
  51. "rdp": ["rdp>=0.8"],
  52. "arrow": ["pyarrow>=16.0.0,<19.0"],
  53. "mssql": ["pyodbc>=4"],
  54. },
  55. cmdclass={"build_py": NPMInstall},
  56. )