From 0628b4dfe8300164460d0a4dc759ed278d6affb0 Mon Sep 17 00:00:00 2001 From: Joao Andre Date: Sun, 4 Aug 2024 21:26:22 -0300 Subject: [PATCH 1/2] feat: replace setup.py with pyproject.toml --- pyproject.toml | 64 +++++++++++++++++ setup.py | 121 --------------------------------- taipy/config/pyproject.toml | 58 ++++++++++++++++ taipy/config/setup.py | 80 ---------------------- taipy/core/pyproject.toml | 62 +++++++++++++++++ taipy/core/setup.py | 102 --------------------------- taipy/gui/pyproject.toml | 58 ++++++++++++++++ taipy/gui/setup.py | 118 -------------------------------- taipy/rest/pyproject.toml | 50 ++++++++++++++ taipy/rest/setup.py | 87 ------------------------ taipy/templates/pyproject.toml | 53 +++++++++++++++ taipy/templates/setup.py | 74 -------------------- tools/release/setup_project.py | 91 +++++++++++++++++++++++++ 13 files changed, 436 insertions(+), 582 deletions(-) delete mode 100644 setup.py create mode 100644 taipy/config/pyproject.toml delete mode 100644 taipy/config/setup.py create mode 100644 taipy/core/pyproject.toml delete mode 100644 taipy/core/setup.py create mode 100644 taipy/gui/pyproject.toml delete mode 100644 taipy/gui/setup.py create mode 100644 taipy/rest/pyproject.toml delete mode 100644 taipy/rest/setup.py create mode 100644 taipy/templates/pyproject.toml delete mode 100644 taipy/templates/setup.py create mode 100644 tools/release/setup_project.py diff --git a/pyproject.toml b/pyproject.toml index ae7392ad68..e45eb1081f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,67 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "taipy" +version = "0.0.0" # will be dynamically set +description = "A 360° open-source platform from Python pilots to production-ready web apps." +readme = "package_desc.md" +requires-python = ">=3.8" +license = {text = "Apache License 2.0"} +keywords = ["taipy"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development", + "Topic :: Scientific/Engineering", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Operating System :: Unix", + "Operating System :: MacOS", +] +dependencies = [] # will be dynamically set + +[project.optional-dependencies] +test = ["pytest>=3.8"] +ngrok = ["pyngrok>=5.1,<6.0"] +image = [ + "python-magic>=0.4.24,<0.5; platform_system!='Windows'", + "python-magic-bin>=0.4.14,<0.5; platform_system=='Windows'" +] +rdp = ["rdp>=0.8"] +arrow = ["pyarrow>=14.0.2,<15.0"] +mssql = ["pyodbc>=4"] + +[project.urls] +Homepage = "https://www.taipy.io" +Documentation = "https://docs.taipy.io" +Source = "https://github.com/Avaiga/taipy" +Download = "https://pypi.org/project/taipy/#files" +Tracker = "https://github.com/Avaiga/taipy/issues" +Security = "https://github.com/Avaiga/taipy?tab=security-ov-file#readme" +"Release notes" = "https://docs.taipy.io/en/release-0.0.0/relnotes/" # version will be dynamically set + +[tool.setuptools.packages.find] +include = ["taipy", "taipy.*"] + +[tool.setuptools.package-data] +"taipy" = ["version.json"] + +[tool.setuptools] +zip-safe = false + +[project.scripts] +taipy = "taipy._entrypoint:_entrypoint" + [tool.ruff] exclude = [ ".git", diff --git a/setup.py b/setup.py deleted file mode 100644 index da7c813193..0000000000 --- a/setup.py +++ /dev/null @@ -1,121 +0,0 @@ -# Copyright 2021-2024 Avaiga Private Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on -# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the -# specific language governing permissions and limitations under the License. - -"""The setup script for taipy package""" - -import os -import json -import platform -import subprocess -from pathlib import Path - -from setuptools import find_packages, setup -from setuptools.command.build_py import build_py - -root_folder = Path(__file__).parent - -package_desc = Path("package_desc.md").read_text("UTF-8") - -# get current version -with open(os.path.join("taipy", "version.json")) as version_file: - version = json.load(version_file) - version_string = f'{version.get("major", 0)}.{version.get("minor", 0)}.{version.get("patch", 0)}' - if vext := version.get("ext"): - version_string = f"{version_string}.{vext}" - - -def get_requirements(): - # get requirements from the different setups in tools/packages (removing taipy packages) - reqs = set() - for pkg in (root_folder / "tools" / "packages").iterdir(): - requirements_file = pkg / "setup.requirements.txt" - if requirements_file.exists(): - reqs.update(requirements_file.read_text("UTF-8").splitlines()) - - return [r for r in reqs if r and not r.startswith("taipy")] - - -test_requirements = ["pytest>=3.8"] - -extras_require = { - "ngrok": ["pyngrok>=5.1,<6.0"], - "image": [ - "python-magic>=0.4.24,<0.5;platform_system!='Windows'", - "python-magic-bin>=0.4.14,<0.5;platform_system=='Windows'", - ], - "rdp": ["rdp>=0.8"], - "arrow": ["pyarrow>=14.0.2,<15.0"], - "mssql": ["pyodbc>=4"], -} - - -class NPMInstall(build_py): - def run(self): - subprocess.run( - ["python", "bundle_build.py"], - cwd=root_folder / "tools" / "frontend", - check=True, - shell=platform.system() == "Windows", - ) - build_py.run(self) - - -setup( - author="Avaiga", - author_email="dev@taipy.io", - python_requires=">=3.8", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Natural Language :: English", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Topic :: Software Development", - "Topic :: Scientific/Engineering", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX", - "Operating System :: Unix", - "Operating System :: MacOS", - ], - description="A 360° open-source platform from Python pilots to production-ready web apps.", - install_requires=get_requirements(), - entry_points={ - "console_scripts": [ - "taipy = taipy._entrypoint:_entrypoint", - ] - }, - license="Apache License 2.0", - long_description=package_desc, - long_description_content_type="text/markdown", - keywords="taipy", - name="taipy", - packages=find_packages(include=["taipy", "taipy.*"]), - include_package_data=True, - test_suite="tests", - version=version_string, - zip_safe=False, - extras_require=extras_require, - cmdclass={"build_py": NPMInstall}, - project_urls={ - "Homepage": "https://www.taipy.io", - "Documentation": "https://docs.taipy.io", - "Source": "https://github.com/Avaiga/taipy", - "Download": "https://pypi.org/project/taipy/#files", - "Tracker": "https://github.com/Avaiga/taipy/issues", - "Security": "https://github.com/Avaiga/taipy?tab=security-ov-file#readme", - f"Release notes": "https://docs.taipy.io/en/release-{version_string}/relnotes/", - }, -) diff --git a/taipy/config/pyproject.toml b/taipy/config/pyproject.toml new file mode 100644 index 0000000000..a2ef5d8ee8 --- /dev/null +++ b/taipy/config/pyproject.toml @@ -0,0 +1,58 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "taipy-config" +version = "0.0.0" # will be dynamically set +description = "A Taipy package dedicated to easily configure a Taipy application." +readme = "package_desc.md" +requires-python = ">=3.8" +license = {text = "Apache License 2.0"} +keywords = ["taipy-config"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development", + "Topic :: Scientific/Engineering", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Operating System :: Unix", + "Operating System :: MacOS", +] + +dependencies = [ + "toml>=0.10,<0.11", + "deepdiff>=6.7,<6.8" +] + +[project.optional-dependencies] +test = [ + "pytest>=3.8" +] + +[project.urls] +Homepage = "https://www.taipy.io" +Documentation = "https://docs.taipy.io" +Source = "https://github.com/Avaiga/taipy" +Download = "https://pypi.org/project/taipy/#files" +Tracker = "https://github.com/Avaiga/taipy/issues" +Security = "https://github.com/Avaiga/taipy?tab=security-ov-file#readme" +"Release notes" = "https://docs.taipy.io/en/release-0.0.0/relnotes/" # version will be dynamically set + +[tool.setuptools.packages] +find = {where = ["."], include = ["taipy", "taipy.config", "taipy.config.*", "taipy.logger", "taipy.logger.*"]} + +[tool.setuptools.package-data] +"version" = ["version.json"] + +[tool.setuptools] +zip-safe = false diff --git a/taipy/config/setup.py b/taipy/config/setup.py deleted file mode 100644 index 82ce4c540f..0000000000 --- a/taipy/config/setup.py +++ /dev/null @@ -1,80 +0,0 @@ -# Copyright 2021-2024 Avaiga Private Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on -# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the -# specific language governing permissions and limitations under the License. - -"""The setup script for taipy-config package""" - -import json -import os -from pathlib import Path - -from setuptools import find_namespace_packages, find_packages, setup - -package_desc = Path("package_desc.md").read_text("UTF-8") - -version_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "version.json") - -with open(version_path) as version_file: - version = json.load(version_file) - version_string = f'{version.get("major", 0)}.{version.get("minor", 0)}.{version.get("patch", 0)}' - if vext := version.get("ext"): - version_string = f"{version_string}.{vext}" - -requirements = ["toml>=0.10,<0.11", "deepdiff>=6.7,<6.8"] - -test_requirements = ["pytest>=3.8"] - -setup( - author="Avaiga", - author_email="dev@taipy.io", - python_requires=">=3.8", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Natural Language :: English", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Topic :: Software Development", - "Topic :: Scientific/Engineering", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX", - "Operating System :: Unix", - "Operating System :: MacOS", - ], - description="A Taipy package dedicated to easily configure a Taipy application.", - install_requires=requirements, - long_description=package_desc, - long_description_content_type="text/markdown", - license="Apache License 2.0", - keywords="taipy-config", - name="taipy-config", - packages=find_namespace_packages(where=".") - + find_packages(include=["taipy", "taipy.config", "taipy.config.*", "taipy.logger", "taipy.logger.*"]), - include_package_data=True, - data_files=[('version', ['version.json'])], - test_suite="tests", - tests_require=test_requirements, - version=version_string, - zip_safe=False, - project_urls={ - "Homepage": "https://www.taipy.io", - "Documentation": "https://docs.taipy.io", - "Source": "https://github.com/Avaiga/taipy", - "Download": "https://pypi.org/project/taipy/#files", - "Tracker": "https://github.com/Avaiga/taipy/issues", - "Security": "https://github.com/Avaiga/taipy?tab=security-ov-file#readme", - f"Release notes": "https://docs.taipy.io/en/release-{version_string}/relnotes/", - }, -) diff --git a/taipy/core/pyproject.toml b/taipy/core/pyproject.toml new file mode 100644 index 0000000000..c4beab78d8 --- /dev/null +++ b/taipy/core/pyproject.toml @@ -0,0 +1,62 @@ +[build-system] +requires = ["setuptools>=42", "wheel", ] +build-backend = "setuptools.build_meta" + +[project] +name = "taipy-core" +version = "0.0.0" # will be dynamically set +description = "A Python library to build powerful and customized data-driven back-end applications." +readme = "package_desc.md" +requires-python = ">=3.8" +keywords = ["taipy-core", ] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development", + "Topic :: Scientific/Engineering", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Operating System :: Unix", + "Operating System :: MacOS", +] + +dependencies = [] # will be dynamically set + +[project.license] +text = "Apache License 2.0" + +[project.optional-dependencies] +test = ["pytest>=3.8", ] +mssql = ["pyodbc>=4,<4.1", ] +mysql = ["pymysql>1,<1.1", ] +postgresql = ["psycopg2>2.9,<2.10", ] +parquet = ["fastparquet==2022.11.0", "pyarrow>=14.0.2,<15.0", ] +s3 = ["boto3==1.29.1", ] +mongo = ["pymongo[srv]>=4.2.0,<5.0", ] + +[project.urls] +Homepage = "https://www.taipy.io" +Documentation = "https://docs.taipy.io" +Source = "https://github.com/Avaiga/taipy" +Download = "https://pypi.org/project/taipy/#files" +Tracker = "https://github.com/Avaiga/taipy/issues" +Security = "https://github.com/Avaiga/taipy?tab=security-ov-file#readme" +"Release notes" = "https://docs.taipy.io/en/release-4.0.0.dev0/relnotes/" + +[tool.setuptools] +zip-safe = false + +[tool.setuptools.package-data] +taipy = ["version.json", ] + +[tool.setuptools.packages.find] +where = [".", ] +include = ["taipy", "taipy.core", "taipy.core.*", ] diff --git a/taipy/core/setup.py b/taipy/core/setup.py deleted file mode 100644 index 52fd69db09..0000000000 --- a/taipy/core/setup.py +++ /dev/null @@ -1,102 +0,0 @@ -# Copyright 2021-2024 Avaiga Private Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on -# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the -# specific language governing permissions and limitations under the License. - -"""The setup script for taipy-core package""" - -import json -import os -from pathlib import Path - -from setuptools import find_namespace_packages, find_packages, setup - -root_folder = Path(__file__).parent - -package_desc = Path("package_desc.md").read_text("UTF-8") - -version_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "version.json") -with open(version_path) as version_file: - version = json.load(version_file) - version_string = f'{version.get("major", 0)}.{version.get("minor", 0)}.{version.get("patch", 0)}' - if vext := version.get("ext"): - version_string = f"{version_string}.{vext}" - - -def get_requirements(): - # get requirements from the different setups in tools/packages (removing taipy packages) - reqs = set() - for pkg in (root_folder / "tools" / "packages").iterdir(): - if "taipy-core" not in str(pkg): - continue - requirements_file = pkg / "setup.requirements.txt" - if requirements_file.exists(): - reqs.update(requirements_file.read_text("UTF-8").splitlines()) - - return [r for r in reqs if r and not r.startswith("taipy")] - - -test_requirements = ["pytest>=3.8"] - -extras_require = { - "mssql": ["pyodbc>=4,<4.1"], - "mysql": ["pymysql>1,<1.1"], - "postgresql": ["psycopg2>2.9,<2.10"], - "parquet": ["fastparquet==2022.11.0", "pyarrow>=14.0.2,<15.0"], - "s3": ["boto3==1.29.1"], - "mongo": ["pymongo[srv]>=4.2.0,<5.0"], -} - -setup( - author="Avaiga", - author_email="dev@taipy.io", - python_requires=">=3.8", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Natural Language :: English", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Topic :: Software Development", - "Topic :: Scientific/Engineering", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX", - "Operating System :: Unix", - "Operating System :: MacOS", - ], - description="A Python library to build powerful and customized data-driven back-end applications.", - install_requires=get_requirements(), - long_description=package_desc, - long_description_content_type="text/markdown", - license="Apache License 2.0", - keywords="taipy-core", - name="taipy-core", - packages=find_namespace_packages(where=".") + find_packages(include=["taipy", "taipy.core", "taipy.core.*"]), - include_package_data=True, - data_files=[('version', ['version.json'])], - test_suite="tests", - tests_require=test_requirements, - version=version_string, - zip_safe=False, - extras_require=extras_require, - project_urls={ - "Homepage": "https://www.taipy.io", - "Documentation": "https://docs.taipy.io", - "Source": "https://github.com/Avaiga/taipy", - "Download": "https://pypi.org/project/taipy/#files", - "Tracker": "https://github.com/Avaiga/taipy/issues", - "Security": "https://github.com/Avaiga/taipy?tab=security-ov-file#readme", - f"Release notes": "https://docs.taipy.io/en/release-{version_string}/relnotes/", - }, -) diff --git a/taipy/gui/pyproject.toml b/taipy/gui/pyproject.toml new file mode 100644 index 0000000000..48557267ab --- /dev/null +++ b/taipy/gui/pyproject.toml @@ -0,0 +1,58 @@ +[build-system] +requires = [ "setuptools>=42", "wheel", "setuptools_scm",] +build-backend = "setuptools.build_meta" + +[project] +name = "taipy-gui" +version = "0.0.0" # will be set dynamically +description = "Low-code library to create graphical user interfaces on the Web for your Python applications." +readme = "package_desc.md" +requires-python = ">=3.8" +keywords = [ "taipy-gui",] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development", + "Topic :: Scientific/Engineering", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Operating System :: Unix", + "Operating System :: MacOS", +] +dependencies = [] # will be set dynamically + +[project.license] +text = "Apache License 2.0" + +[project.optional-dependencies] +test = [ "pytest>=3.8",] +ngrok = [ "pyngrok>=5.1,<6.0",] +image = [ "python-magic>=0.4.24,<0.5; platform_system!='Windows'", "python-magic-bin>=0.4.14,<0.5; platform_system=='Windows'",] +arrow = [ "pyarrow>=14.0.2,<15.0",] + +[project.urls] +Homepage = "https://www.taipy.io" +Documentation = "https://docs.taipy.io" +Source = "https://github.com/Avaiga/taipy" +Download = "https://pypi.org/project/taipy/#files" +Tracker = "https://github.com/Avaiga/taipy/issues" +Security = "https://github.com/Avaiga/taipy?tab=security-ov-file#readme" +"Release notes" = "https://docs.taipy.io/en/release-0.0.0/relnotes/" # will be set dynamically + +[tool.setuptools] +zip-safe = false + +[tool.setuptools.package-data] +taipy = [ "version.json",] + +[tool.setuptools.packages.find] +where = [ ".",] +include = [ "taipy", "taipy.gui", "taipy.gui.*",] diff --git a/taipy/gui/setup.py b/taipy/gui/setup.py deleted file mode 100644 index 0d0f8a6de6..0000000000 --- a/taipy/gui/setup.py +++ /dev/null @@ -1,118 +0,0 @@ -# Copyright 2021-2024 Avaiga Private Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on -# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the -# specific language governing permissions and limitations under the License. - -"""The setup script for taipy-gui package""" - -import json -import os -from pathlib import Path - -from setuptools import find_namespace_packages, find_packages, setup -from setuptools.command.build_py import build_py - -root_folder = Path(__file__).parent - -package_desc = Path("package_desc.md").read_text("UTF-8") - -version_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "version.json") -with open(version_path) as version_file: - version = json.load(version_file) - version_string = f'{version.get("major", 0)}.{version.get("minor", 0)}.{version.get("patch", 0)}' - if vext := version.get("ext"): - version_string = f"{version_string}.{vext}" - - -def get_requirements(): - # get requirements from the different setups in tools/packages (removing taipy packages) - reqs = set() - for pkg in (root_folder / "tools" / "packages").iterdir(): - if "taipy-gui" not in str(pkg): - continue - requirements_file = pkg / "setup.requirements.txt" - if requirements_file.exists(): - reqs.update(requirements_file.read_text("UTF-8").splitlines()) - - return [r for r in reqs if r and not r.startswith("taipy")] - - -test_requirements = ["pytest>=3.8"] - -extras_require = { - "ngrok": ["pyngrok>=5.1,<6.0"], - "image": [ - "python-magic>=0.4.24,<0.5;platform_system!='Windows'", - "python-magic-bin>=0.4.14,<0.5;platform_system=='Windows'", - ], - "arrow": ["pyarrow>=14.0.2,<15.0"], -} - - -def _build_webapp(): - already_exists = Path("./taipy/gui/webapp/index.html").exists() - if not already_exists: - os.system("cd ../../frontend/taipy-gui/dom && npm ci") - os.system("cd ../../frontend/taipy-gui && npm ci --omit=optional && npm run build") - - -class NPMInstall(build_py): - def run(self): - _build_webapp() - build_py.run(self) - - -setup( - author="Avaiga", - author_email="dev@taipy.io", - python_requires=">=3.8", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Natural Language :: English", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Topic :: Software Development", - "Topic :: Scientific/Engineering", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX", - "Operating System :: Unix", - "Operating System :: MacOS", - ], - description="Low-code library to create graphical user interfaces on the Web for your Python applications.", - long_description=package_desc, - long_description_content_type="text/markdown", - install_requires=get_requirements(), - license="Apache License 2.0", - include_package_data=True, - data_files=[("version", ["version.json"])], - keywords="taipy-gui", - name="taipy-gui", - packages=find_namespace_packages(where=".") + find_packages(include=["taipy", "taipy.gui", "taipy.gui.*"]), - test_suite="tests", - tests_require=test_requirements, - version=version_string, - zip_safe=False, - extras_require=extras_require, - cmdclass={"build_py": NPMInstall}, - project_urls={ - "Homepage": "https://www.taipy.io", - "Documentation": "https://docs.taipy.io", - "Source": "https://github.com/Avaiga/taipy", - "Download": "https://pypi.org/project/taipy/#files", - "Tracker": "https://github.com/Avaiga/taipy/issues", - "Security": "https://github.com/Avaiga/taipy?tab=security-ov-file#readme", - f"Release notes": "https://docs.taipy.io/en/release-{version_string}/relnotes/", - }, -) diff --git a/taipy/rest/pyproject.toml b/taipy/rest/pyproject.toml new file mode 100644 index 0000000000..50ca160b0f --- /dev/null +++ b/taipy/rest/pyproject.toml @@ -0,0 +1,50 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "taipy-rest" +version = "0.0.0" # will be dynamically set +description = "Library to expose taipy-core REST APIs." +readme = "package_desc.md" +requires-python = ">=3.8" +license = {text = "Apache License 2.0"} +keywords = ["taipy-rest"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development", + "Topic :: Scientific/Engineering", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Operating System :: Unix", + "Operating System :: MacOS", +] +dependencies = [] # will be dynamically set + +[project.urls] +Homepage = "https://www.taipy.io" +Documentation = "https://docs.taipy.io" +Source = "https://github.com/Avaiga/taipy" +Download = "https://pypi.org/project/taipy/#files" +Tracker = "https://github.com/Avaiga/taipy/issues" +Security = "https://github.com/Avaiga/taipy?tab=security-ov-file#readme" +"Release notes" = "https://docs.taipy.io/en/release-0.0.0/relnotes/" # version will be dynamically set + +[tool.setuptools.packages.find] +where = ["."] +include = ["taipy", "taipy.rest"] + +[tool.setuptools.package-data] +"taipy" = ["version.json"] + +[tool.setuptools] +zip-safe = false diff --git a/taipy/rest/setup.py b/taipy/rest/setup.py deleted file mode 100644 index 096802c796..0000000000 --- a/taipy/rest/setup.py +++ /dev/null @@ -1,87 +0,0 @@ -# Copyright 2021-2024 Avaiga Private Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on -# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the -# specific language governing permissions and limitations under the License. - -"""The setup script for taipy-rest package""" - -import json -import os -from pathlib import Path - -from setuptools import find_namespace_packages, find_packages, setup - -root_folder = Path(__file__).parent - -package_desc = Path("package_desc.md").read_text("UTF-8") - -version_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "version.json") -with open(version_path) as version_file: - version = json.load(version_file) - version_string = f'{version.get("major", 0)}.{version.get("minor", 0)}.{version.get("patch", 0)}' - if vext := version.get("ext"): - version_string = f"{version_string}.{vext}" - - -def get_requirements(): - # get requirements from the different setups in tools/packages (removing taipy packages) - reqs = set() - for pkg in (root_folder / "tools" / "packages").iterdir(): - if "taipy-rest" not in str(pkg): - continue - requirements_file = pkg / "setup.requirements.txt" - if requirements_file.exists(): - reqs.update(requirements_file.read_text("UTF-8").splitlines()) - - return [r for r in reqs if r and not r.startswith("taipy")] - - -setup( - author="Avaiga", - name="taipy-rest", - keywords="taipy-rest", - python_requires=">=3.8", - version=version_string, - author_email="dev@taipy.io", - packages=find_namespace_packages(where=".") + find_packages(include=["taipy", "taipy.rest"]), - include_package_data=True, - data_files=[('version', ['version.json'])], - long_description=package_desc, - long_description_content_type="text/markdown", - description="Library to expose taipy-core REST APIs.", - license="Apache License 2.0", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Natural Language :: English", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Topic :: Software Development", - "Topic :: Scientific/Engineering", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX", - "Operating System :: Unix", - "Operating System :: MacOS", - ], - install_requires=get_requirements(), - project_urls={ - "Homepage": "https://www.taipy.io", - "Documentation": "https://docs.taipy.io", - "Source": "https://github.com/Avaiga/taipy", - "Download": "https://pypi.org/project/taipy/#files", - "Tracker": "https://github.com/Avaiga/taipy/issues", - "Security": "https://github.com/Avaiga/taipy?tab=security-ov-file#readme", - f"Release notes": "https://docs.taipy.io/en/release-{version_string}/relnotes/", - }, -) diff --git a/taipy/templates/pyproject.toml b/taipy/templates/pyproject.toml new file mode 100644 index 0000000000..b1bf428bd0 --- /dev/null +++ b/taipy/templates/pyproject.toml @@ -0,0 +1,53 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "taipy-templates" +version = "0.0.0" # will be dynamically set +description = "An open-source package holding Taipy application templates." +readme = "package_desc.md" +requires-python = ">=3.8" +license = {text = "Apache License 2.0"} +keywords = ["taipy-templates"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development", + "Topic :: Scientific/Engineering", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Operating System :: Unix", + "Operating System :: MacOS", +] +dependencies = [] # version will be dynamically set + +[project.optional-dependencies] +test = ["pytest>=3.8"] + +[project.urls] +Homepage = "https://www.taipy.io" +Documentation = "https://docs.taipy.io" +Source = "https://github.com/Avaiga/taipy" +Download = "https://pypi.org/project/taipy/#files" +Tracker = "https://github.com/Avaiga/taipy/issues" +Security = "https://github.com/Avaiga/taipy?tab=security-ov-file#readme" +"Release notes" = "https://docs.taipy.io/en/release-0.0.0/relnotes/" # version will be dynamically set + +[tool.setuptools.packages.find] +where = ["."] +include = ["taipy"] + +[tool.setuptools.package-data] +"taipy" = ["version.json"] + +[tool.setuptools] +zip-safe = false diff --git a/taipy/templates/setup.py b/taipy/templates/setup.py deleted file mode 100644 index 58c794718a..0000000000 --- a/taipy/templates/setup.py +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright 2021-2024 Avaiga Private Limited -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on -# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the -# specific language governing permissions and limitations under the License. - -"""The setup script for taipy-templates package""" - -import json -import os -from pathlib import Path - -from setuptools import find_namespace_packages, find_packages, setup - -package_desc = Path("package_desc.md").read_text("UTF-8") - -version_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "version.json") -with open(version_path) as version_file: - version = json.load(version_file) - version_string = f'{version.get("major", 0)}.{version.get("minor", 0)}.{version.get("patch", 0)}' - if vext := version.get("ext"): - version_string = f"{version_string}.{vext}" - -test_requirements = ["pytest>=3.8"] - -setup( - author="Avaiga", - author_email="dev@taipy.io", - python_requires=">=3.8", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Natural Language :: English", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Topic :: Software Development", - "Topic :: Scientific/Engineering", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX", - "Operating System :: Unix", - "Operating System :: MacOS", - ], - description="An open-source package holding Taipy application templates.", - license="Apache License 2.0", - long_description=package_desc, - long_description_content_type="text/markdown", - keywords="taipy-templates", - name="taipy-templates", - packages=find_namespace_packages(where=".") + find_packages(include=["taipy"]), - include_package_data=True, - data_files=[('version', ['version.json'])], - test_suite="tests", - version=version_string, - zip_safe=False, - project_urls={ - "Homepage": "https://www.taipy.io", - "Documentation": "https://docs.taipy.io", - "Source": "https://github.com/Avaiga/taipy", - "Download": "https://pypi.org/project/taipy/#files", - "Tracker": "https://github.com/Avaiga/taipy/issues", - "Security": "https://github.com/Avaiga/taipy?tab=security-ov-file#readme", - f"Release notes": "https://docs.taipy.io/en/release-{version_string}/relnotes/", - }, -) diff --git a/tools/release/setup_project.py b/tools/release/setup_project.py new file mode 100644 index 0000000000..3522d4db26 --- /dev/null +++ b/tools/release/setup_project.py @@ -0,0 +1,91 @@ +# Copyright 2021-2024 Avaiga Private Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. + +import json +import os +import platform +import re +import subprocess +import sys +from pathlib import Path + +import toml # type: ignore + + +def get_requirements(pkg: str): + # get requirements from the different setups in tools/packages (removing taipy packages) + reqs = set() + pkg_name = pkg if pkg == "taipy" else f"taipy-{pkg}" + root_folder = Path(__file__).parent + package_path = os.path.join(root_folder.parent, "packages", pkg_name) + requirements_file = os.path.join(package_path, "setup.requirements.txt") + if os.path.exists(requirements_file): + reqs.update(Path(requirements_file).read_text("UTF-8").splitlines()) + return [r for r in reqs if r and not r.startswith("taipy")] + + +def update_pyproject(version_path: str, pyproject_path: str): + with open(version_path) as version_file: + version = json.load(version_file) + version_string = f'{version.get("major", 0)}.{version.get("minor", 0)}.{version.get("patch", 0)}' + if vext := version.get("ext"): + version_string = f"{version_string}.{vext}" + + pyproject_data = toml.load(pyproject_path) + pyproject_data["project"]["version"] = version_string + pyproject_data["project"]["urls"]["Release notes"] = f"https://docs.taipy.io/en/release-{version_string}/relnotes/" + pyproject_data["project"]["dependencies"] = get_requirements(get_pkg_name(pyproject_path)) + + with open(pyproject_path, "w") as pyproject_file: + toml.dump(pyproject_data, pyproject_file) + + +def _build_webapp(webapp_path: str): + already_exists = Path(webapp_path).exists() + if not already_exists: + os.system("cd ../../frontend/taipy-gui/dom && npm ci") + os.system("cd ../../frontend/taipy-gui && npm ci --omit=optional && npm run build") + + +def get_pkg_name(path: str) -> str: + # The regex pattern + pattern = r"([^/]+)/pyproject\.toml$" + + # Search for the pattern + match = re.search(pattern, os.path.abspath(path)) + if not match: + raise ValueError(f"Could not find package name in path: {path}") + return match.group(1) + + +if __name__ == "__main__": + _pyproject_path = f"{sys.argv[1]}/pyproject.toml" + + pkg = get_pkg_name(_pyproject_path) + if pkg == "taipy": + _version_path = f"{sys.argv[1]}/taipy/version.json" + _webapp_path = f"{sys.argv[1]}/taipy/gui/webapp/index.html" + else: + _version_path = f"{sys.argv[1]}/version.json" + _webapp_path = f"{sys.argv[1]}/webapp/index.html" + + update_pyproject(_version_path, _pyproject_path) + + if pkg == "gui": + _build_webapp(_webapp_path) + + if pkg == "taipy": + subprocess.run( + ["python", "bundle_build.py"], + cwd=os.path.join("tools", "frontend"), + check=True, + shell=platform.system() == "Windows", + ) From cf322cc0e5fcc2946f047c7d00f59f86cd209968 Mon Sep 17 00:00:00 2001 From: Joao Andre Date: Mon, 5 Aug 2024 20:14:43 -0300 Subject: [PATCH 2/2] chore: update pyproject.toml in packing action --- .../build-and-release-single-package.yml | 7 ++++- .github/workflows/build-and-release.yml | 19 +++++++----- .github/workflows/packaging.yml | 19 +++++++++++- tools/release/setup_project.py | 30 +++++++++++-------- 4 files changed, 54 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-and-release-single-package.yml b/.github/workflows/build-and-release-single-package.yml index 2a4a7cac57..ba836816c5 100644 --- a/.github/workflows/build-and-release-single-package.yml +++ b/.github/workflows/build-and-release-single-package.yml @@ -153,10 +153,15 @@ jobs: run: | cp -r taipy/_cli/. ${{ steps.set-variables.outputs.package_dir }}/taipy/_cli + - name: Update pyproject.toml + working-directory: ${{ steps.set-variables.outputs.package_dir }} + run: | + python tools/release/setup_project.py . prod + - name: Build package working-directory: ${{ steps.set-variables.outputs.package_dir }} run: | - python setup.py build_py && python -m build + python -m build - name: Rename files run: | diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 978cd924cf..5a340f69bd 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -151,10 +151,15 @@ jobs: run: | cp -r taipy/_cli/. ${{ steps.set-variables.outputs.package_dir }}/taipy/_cli + - name: Update pyproject.toml + working-directory: ${{ steps.set-variables.outputs.package_dir }} + run: | + python tools/release/setup_project.py . prod + - name: Build package working-directory: ${{ steps.set-variables.outputs.package_dir }} run: | - python setup.py build_py && python -m build + python -m build for file in ./dist/*; do mv "$file" "${file//_/-}"; done - name: Create tag and release @@ -204,18 +209,18 @@ jobs: python -m pip install --upgrade pip pip install build wheel - - - name: Backup setup.py - run: | - mv setup.py setup.old.py - - name: Copy files from tools run: | cp -r tools/packages/taipy/. . + - name: Update pyproject.toml + working-directory: ${{ steps.set-variables.outputs.package_dir }} + run: | + python tools/release/setup_project.py . prod + - name: Build Taipy package run: | - python setup.py build_py && python -m build + python -m build - name: Create tag and release Taipy run: | diff --git a/.github/workflows/packaging.yml b/.github/workflows/packaging.yml index 7042afd080..2556c61ed6 100644 --- a/.github/workflows/packaging.yml +++ b/.github/workflows/packaging.yml @@ -31,11 +31,28 @@ jobs: with: python-version: ${{ matrix.python-versions }} + - name: Install Dependencies + run: | + pip install toml + - name: Build frontends run: | python tools/frontend/bundle_build.py - - name: Install Taipy without dependencies + - name: Update pyproject.toml + run: | + python tools/release/setup_project.py taipy/config + python tools/release/setup_project.py taipy/core + python tools/release/setup_project.py taipy/gui + python tools/release/setup_project.py taipy/rest + python tools/release/setup_project.py taipy/templates + python tools/release/setup_project.py . + + - name: Install Taipy Subpackages + run: | + pip install taipy/config taipy/core taipy/gui taipy/rest taipy/templates + + - name: Install Taipy run: | pip install . diff --git a/tools/release/setup_project.py b/tools/release/setup_project.py index 3522d4db26..6b887b76ce 100644 --- a/tools/release/setup_project.py +++ b/tools/release/setup_project.py @@ -20,7 +20,7 @@ import toml # type: ignore -def get_requirements(pkg: str): +def get_requirements(pkg: str, env: str = "dev") -> list: # get requirements from the different setups in tools/packages (removing taipy packages) reqs = set() pkg_name = pkg if pkg == "taipy" else f"taipy-{pkg}" @@ -29,10 +29,12 @@ def get_requirements(pkg: str): requirements_file = os.path.join(package_path, "setup.requirements.txt") if os.path.exists(requirements_file): reqs.update(Path(requirements_file).read_text("UTF-8").splitlines()) - return [r for r in reqs if r and not r.startswith("taipy")] + if env == "dev": + return [r for r in reqs if r and not r.startswith("taipy")] + return list(reqs) -def update_pyproject(version_path: str, pyproject_path: str): +def update_pyproject(version_path: str, pyproject_path: str, env: str = "dev"): with open(version_path) as version_file: version = json.load(version_file) version_string = f'{version.get("major", 0)}.{version.get("minor", 0)}.{version.get("patch", 0)}' @@ -42,9 +44,9 @@ def update_pyproject(version_path: str, pyproject_path: str): pyproject_data = toml.load(pyproject_path) pyproject_data["project"]["version"] = version_string pyproject_data["project"]["urls"]["Release notes"] = f"https://docs.taipy.io/en/release-{version_string}/relnotes/" - pyproject_data["project"]["dependencies"] = get_requirements(get_pkg_name(pyproject_path)) + pyproject_data["project"]["dependencies"] = get_requirements(get_pkg_name(pyproject_path), env) - with open(pyproject_path, "w") as pyproject_file: + with open(pyproject_path, "w", encoding="utf-8") as pyproject_file: toml.dump(pyproject_data, pyproject_file) @@ -57,7 +59,7 @@ def _build_webapp(webapp_path: str): def get_pkg_name(path: str) -> str: # The regex pattern - pattern = r"([^/]+)/pyproject\.toml$" + pattern = r"([^/\\]+)[/\\]pyproject\.toml$" # Search for the pattern match = re.search(pattern, os.path.abspath(path)) @@ -67,17 +69,21 @@ def get_pkg_name(path: str) -> str: if __name__ == "__main__": - _pyproject_path = f"{sys.argv[1]}/pyproject.toml" + _pyproject_path = os.path.join(sys.argv[1], "pyproject.toml") + try: + env = sys.argv[2] + except IndexError: + env = "dev" pkg = get_pkg_name(_pyproject_path) if pkg == "taipy": - _version_path = f"{sys.argv[1]}/taipy/version.json" - _webapp_path = f"{sys.argv[1]}/taipy/gui/webapp/index.html" + _version_path = os.path.join(sys.argv[1], "taipy", "version.json") + _webapp_path = os.path.join(sys.argv[1], "taipy", "gui", "webapp", "index.html") else: - _version_path = f"{sys.argv[1]}/version.json" - _webapp_path = f"{sys.argv[1]}/webapp/index.html" + _version_path = os.path.join(sys.argv[1], "version.json") + _webapp_path = os.path.join(sys.argv[1], "webapp", "index.html") - update_pyproject(_version_path, _pyproject_path) + update_pyproject(_version_path, _pyproject_path, env) if pkg == "gui": _build_webapp(_webapp_path)