diff --git a/conda-recipes/main-library/meta.yaml b/conda-recipes/main-library/meta.yaml index e210e6710..364a89a36 100755 --- a/conda-recipes/main-library/meta.yaml +++ b/conda-recipes/main-library/meta.yaml @@ -1,7 +1,7 @@ source: path: ../.. -{% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\d+\.\d+\.\d+(?:[\.\-][\.\w\-]+)?)').group(1) %} +{% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\d+(?:\.\d+)*+(?:[\+\w\.]+))').group(1) %} package: name: sls_detector_software version: {{ version }} #2025.3.19 @@ -50,8 +50,6 @@ outputs: - libgcc-ng - - - name: slsdetgui script: copy_gui.sh requirements: diff --git a/conda-recipes/python-client/meta.yaml b/conda-recipes/python-client/meta.yaml index 03c4b4436..dd9ea031c 100644 --- a/conda-recipes/python-client/meta.yaml +++ b/conda-recipes/python-client/meta.yaml @@ -1,7 +1,7 @@ source: path: ../.. -{% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\d+\.\d+\.\d+(?:[\.\w\-]+)?)').group(1) %} +{% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\d+(?:\.\d+)*+(?:[\+\w\.]+))').group(1) %} package: name: slsdet version: {{ version }} # diff --git a/update_version.py b/update_version.py index c72099b3c..914797a1d 100644 --- a/update_version.py +++ b/update_version.py @@ -7,6 +7,7 @@ Script to update VERSION file with semantic versioning if provided as an argumen import sys import re import toml +from packaging.version import Version, InvalidVersion def get_version(): @@ -16,21 +17,22 @@ def get_version(): version = sys.argv[1] - # Validate that the version argument matches semantic versioning format (X.Y.Z) - if not re.match(r'^\d+\.\d+\.\d+(?:[\-\.][\.\w\-]+)?+$', version): - print("Error: Version argument must be in semantic versioning format (X.Y.Z[./-][postfix])") + try: + v = Version(version) # normalize according to PEP 440 specification + return v + except InvalidVersion as e: + print(f"Invalid version {version}. Version format must follow semantic versioning format of python PEP 440 version identification specification.") sys.exit(1) - return version def write_version_to_file(version): with open("VERSION", "w") as version_file: - version_file.write(version) + version_file.write(str(version)) print(f"Version {version} written to VERSION file.") def update_pyproject_toml_file(version): pyproject = toml.load("pyproject.toml") - pyproject["project"]["version"] = version + pyproject["project"]["version"] = str(version) toml.dump(pyproject, open("pyproject.toml", "w")) #write back print(f"Version in pyproject.toml set to {version}")