1
0
Эх сурвалжийг харах

Merge pull request #83 from Avaiga/feature/enterprise#126

chore: add version information to init file
Jean-Robin 2 жил өмнө
parent
commit
c1bc2b32da

+ 11 - 1
.github/workflows/publish.yml

@@ -24,7 +24,17 @@ jobs:
 
 
       - name: Ensure package version is properly set
       - name: Ensure package version is properly set
         run: |
         run: |
-          echo 'version="${{ github.event.inputs.version }}"' | grep -f - setup.py
+          echo """
+          import json, sys, os
+          with open(f\"src{os.sep}taipy{os.sep}config{os.sep}version.json\") as version_file:
+              version_o = json.load(version_file)
+          version = f'{version_o.get(\"major\")}.{version_o.get(\"minor\")}.{version_o.get(\"patch\")}'
+          if vext := version_o.get(\"ext\"):
+              version = f'{version}.{vext}'
+          if version != sys.argv[1]:
+              raise ValueError(f\"Invalid version {version} / {sys.argv[1]}\")
+          """ > /tmp/check1.py
+          python /tmp/check1.py "${{ github.event.inputs.version }}"
 
 
       - name: Validate branch name
       - name: Validate branch name
         run: |
         run: |

+ 11 - 1
.github/workflows/release.yml

@@ -24,7 +24,17 @@ jobs:
 
 
       - name: Ensure package version is properly set
       - name: Ensure package version is properly set
         run: |
         run: |
-          echo 'version="${{ github.event.inputs.version }}"' | grep -f - setup.py
+          echo """
+          import json, sys, os
+          with open(f\"src{os.sep}taipy{os.sep}config{os.sep}version.json\") as version_file:
+              version_o = json.load(version_file)
+          version = f'{version_o.get(\"major\")}.{version_o.get(\"minor\")}.{version_o.get(\"patch\")}'
+          if vext := version_o.get(\"ext\"):
+              version = f'{version}.{vext}'
+          if version != sys.argv[1]:
+              raise ValueError(f\"Invalid version {version} / {sys.argv[1]}\")
+          """ > /tmp/check1.py
+          python /tmp/check1.py "${{ github.event.inputs.version }}"
 
 
       - name: Validate branch name
       - name: Validate branch name
         run: |
         run: |

+ 9 - 1
setup.py

@@ -13,11 +13,19 @@
 
 
 """The setup script."""
 """The setup script."""
 
 
+import json
+import os
 from setuptools import find_packages, find_namespace_packages, setup
 from setuptools import find_packages, find_namespace_packages, setup
 
 
 with open("README.md") as readme_file:
 with open("README.md") as readme_file:
     readme = readme_file.read()
     readme = readme_file.read()
 
 
+with open(f"src{os.sep}taipy{os.sep}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}"
+
 requirements = [
 requirements = [
     "taipy-gui@git+https://git@github.com/Avaiga/taipy-gui.git@develop",
     "taipy-gui@git+https://git@github.com/Avaiga/taipy-gui.git@develop",
     "taipy-rest@git+https://git@github.com/Avaiga/taipy-rest.git@develop",
     "taipy-rest@git+https://git@github.com/Avaiga/taipy-rest.git@develop",
@@ -58,7 +66,7 @@ setup(
     packages=find_namespace_packages(where="src") + find_packages(include=["taipy"]),
     packages=find_namespace_packages(where="src") + find_packages(include=["taipy"]),
     test_suite="tests",
     test_suite="tests",
     url="https://github.com/avaiga/taipy",
     url="https://github.com/avaiga/taipy",
-    version="2.1.0.dev",
+    version=version_string,
     zip_safe=False,
     zip_safe=False,
     extras_require=extras_require,
     extras_require=extras_require,
 )
 )

+ 3 - 0
src/taipy/__init__.py

@@ -10,6 +10,9 @@
 # specific language governing permissions and limitations under the License.
 # specific language governing permissions and limitations under the License.
 
 
 from importlib.util import find_spec
 from importlib.util import find_spec
+from .version import _get_version
+
+__version__ = _get_version()
 
 
 if find_spec('taipy'):
 if find_spec('taipy'):
     if find_spec("taipy.config"):
     if find_spec("taipy.config"):

+ 1 - 0
src/taipy/version.json

@@ -0,0 +1 @@
+{"major": 2, "minor": 1, "patch": 0, "ext": "dev0"}

+ 22 - 0
src/taipy/version.py

@@ -0,0 +1,22 @@
+# Copyright 2023 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
+
+
+def _get_version():
+    with open(f"src{os.sep}taipy{os.sep}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}"
+    return version_string