Browse Source

chore: update pyproject.toml in packing action

Joao Andre 9 months ago
parent
commit
cf322cc0e5

+ 6 - 1
.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: |

+ 12 - 7
.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: |

+ 18 - 1
.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 .
 

+ 18 - 12
tools/release/setup_project.py

@@ -20,7 +20,7 @@ from pathlib import Path
 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)