From da760b2b934af55e5e0f691591245af66c59e773 Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Tue, 22 Apr 2025 14:00:45 +0200 Subject: [PATCH 01/11] version number automated for python build --- conda-recipes/build_conda.sh | 8 ++++++++ conda-recipes/main-library/meta.yaml | 6 +++--- conda-recipes/python-client/meta.yaml | 4 ++-- pyproject.toml | 18 +++++++++--------- update_version.py | 22 +++++++++++++++++++++- 5 files changed, 43 insertions(+), 15 deletions(-) create mode 100755 conda-recipes/build_conda.sh diff --git a/conda-recipes/build_conda.sh b/conda-recipes/build_conda.sh new file mode 100755 index 000000000..6915f89a9 --- /dev/null +++ b/conda-recipes/build_conda.sh @@ -0,0 +1,8 @@ + +SCRIPTDIR=$(cd "$(dirname "$0")" && pwd) +VERSION=$(cat $SCRIPTDIR/../VERSION) +export VERSION + +echo "building conda package version: $VERSION" + +conda build . diff --git a/conda-recipes/main-library/meta.yaml b/conda-recipes/main-library/meta.yaml index 2ddc76a6f..232f89b20 100755 --- a/conda-recipes/main-library/meta.yaml +++ b/conda-recipes/main-library/meta.yaml @@ -1,8 +1,8 @@ +#{% set version = load_file('VERSION').strip %} package: name: sls_detector_software - version: 2025.3.19 - - + version: {{ environ.get('VERSION') }} #2025.3.19 + source: path: ../.. diff --git a/conda-recipes/python-client/meta.yaml b/conda-recipes/python-client/meta.yaml index 3b710151c..c5e2cbb38 100644 --- a/conda-recipes/python-client/meta.yaml +++ b/conda-recipes/python-client/meta.yaml @@ -1,7 +1,7 @@ + package: name: slsdet - version: 2025.3.19 #TODO! how to not duplicate this? - + version: 0.0.0 source: path: ../.. diff --git a/pyproject.toml b/pyproject.toml index 3d128f18e..5e11fdc45 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,27 +1,27 @@ [build-system] -requires = ["scikit-build-core>=0.10", "pybind11", "numpy"] +requires = [ "scikit-build-core>=0.10", "pybind11", "numpy",] build-backend = "scikit_build_core.build" [project] name = "slsdet" version = "2025.3.19" - [tool.cibuildwheel] before-all = "uname -a" -[tool.scikit-build] -build.verbose = true -cmake.build-type = "Release" -install.components = ["python"] +[tool.scikit-build.build] +verbose = true +[tool.scikit-build.cmake] +build-type = "Release" + +[tool.scikit-build.install] +components = [ "python",] [tool.scikit-build.cmake.define] -#Only build the control software and python ext SLS_USE_RECEIVER = "OFF" SLS_USE_RECEIVER_BINARIES = "OFF" SLS_USE_TEXTCLIENT = "OFF" SLS_BUILD_SHARED_LIBRARIES = "OFF" - SLS_USE_PYTHON = "ON" -SLS_INSTALL_PYTHONEXT = "ON" \ No newline at end of file +SLS_INSTALL_PYTHONEXT = "ON" diff --git a/update_version.py b/update_version.py index c074ae542..f5c28c5af 100644 --- a/update_version.py +++ b/update_version.py @@ -6,6 +6,10 @@ Script to update VERSION file with semantic versioning if provided as an argumen import sys import re +import os +import toml +import yaml +from jinja2 import Template, Undefined def get_version(): @@ -28,9 +32,25 @@ def write_version_to_file(version): version_file.write(version) print(f"Version {version} written to VERSION file.") +def define_environment_variable(version): + os.environ["VERSION"] = version + +def update_pyproject_toml_file(version): + pyproject = toml.load("pyproject.toml") + pyproject["project"]["version"] = version + toml.dump(pyproject, open("pyproject.toml", "w")) #write back + print(f"Version in pyproject.toml set to {version}") + +class NullUndefined(Undefined): + def __getattr__(self, key): + return '' + + # Main script if __name__ == "__main__": version = get_version() - write_version_to_file(version) \ No newline at end of file + write_version_to_file(version) + define_environment_variable(version) + update_pyproject_toml_file(version) From 8fe4a78febcf13e10653270d9fdfa4ad40db9b5f Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Tue, 22 Apr 2025 15:43:01 +0200 Subject: [PATCH 02/11] mistakenly set version back to 0.0.0 --- conda-recipes/python-client/meta.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conda-recipes/python-client/meta.yaml b/conda-recipes/python-client/meta.yaml index c5e2cbb38..7daa969a6 100644 --- a/conda-recipes/python-client/meta.yaml +++ b/conda-recipes/python-client/meta.yaml @@ -1,7 +1,8 @@ package: name: slsdet - version: 0.0.0 + version: {{ environ.get('VERSION') }} #2025.3.19 + source: path: ../.. From fca31cc4322fa80f33c458bf5f711c0c017babce Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Tue, 22 Apr 2025 17:05:06 +0200 Subject: [PATCH 03/11] updated github workflow scripts to support automatic version numbering with environment variable --- .github/workflows/conda_library.yaml | 2 +- .github/workflows/conda_python.yaml | 2 +- conda-recipes/build_conda.sh | 19 +++++++++++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/conda_library.yaml b/.github/workflows/conda_library.yaml index 23f94d467..807d7872b 100644 --- a/.github/workflows/conda_library.yaml +++ b/.github/workflows/conda_library.yaml @@ -33,7 +33,7 @@ jobs: run: conda config --set anaconda_upload no - name: Build - run: conda build conda-recipes/main-library --output-folder build_output + run: ./conda-recipes/build_conda.sh build_output main-library - name: Upload all Conda packages uses: actions/upload-artifact@v4 diff --git a/.github/workflows/conda_python.yaml b/.github/workflows/conda_python.yaml index d482b8e6f..df67552e1 100644 --- a/.github/workflows/conda_python.yaml +++ b/.github/workflows/conda_python.yaml @@ -33,7 +33,7 @@ jobs: run: conda config --set anaconda_upload no - name: Build - run: conda build conda-recipes/python-client --output-folder build_output + run: ./conda-recipes/build_conda.sh build_output python-client - name: Upload all Conda packages uses: actions/upload-artifact@v4 diff --git a/conda-recipes/build_conda.sh b/conda-recipes/build_conda.sh index 6915f89a9..7e6ab3f46 100755 --- a/conda-recipes/build_conda.sh +++ b/conda-recipes/build_conda.sh @@ -3,6 +3,21 @@ SCRIPTDIR=$(cd "$(dirname "$0")" && pwd) VERSION=$(cat $SCRIPTDIR/../VERSION) export VERSION -echo "building conda package version: $VERSION" +if [ -z "$1" ] +then + output_dir=$CONDA_PREFIX/conda-bld +else + output_dir=$1 +fi -conda build . +if [ -z "$2" ] +then + recipe=$SCRIPTDIR +else + recipe=$SCRIPTDIR/$2 +fi + +echo "building conda package version: $VERSION using recipe $recipe and writing output to $output_dir" + + +conda build $recipe --output-folder $output_dir From 497c3abfc24af91d3cc224db31b91a6324eda6f0 Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Wed, 23 Apr 2025 14:26:26 +0200 Subject: [PATCH 04/11] managed to load VERSION file in yaml file - simplifies things --- .github/workflows/conda_python.yaml | 2 +- conda-recipes/build_conda.sh | 23 ----------------------- conda-recipes/main-library/meta.yaml | 10 +++++----- conda-recipes/python-client/meta.yaml | 10 +++++----- pyproject.toml | 2 +- update_version.py | 14 -------------- 6 files changed, 12 insertions(+), 49 deletions(-) delete mode 100755 conda-recipes/build_conda.sh diff --git a/.github/workflows/conda_python.yaml b/.github/workflows/conda_python.yaml index df67552e1..778b18ad7 100644 --- a/.github/workflows/conda_python.yaml +++ b/.github/workflows/conda_python.yaml @@ -33,7 +33,7 @@ jobs: run: conda config --set anaconda_upload no - name: Build - run: ./conda-recipes/build_conda.sh build_output python-client + run: conda build ./conda-recipes/python-client --build-folder build_output - name: Upload all Conda packages uses: actions/upload-artifact@v4 diff --git a/conda-recipes/build_conda.sh b/conda-recipes/build_conda.sh deleted file mode 100755 index 7e6ab3f46..000000000 --- a/conda-recipes/build_conda.sh +++ /dev/null @@ -1,23 +0,0 @@ - -SCRIPTDIR=$(cd "$(dirname "$0")" && pwd) -VERSION=$(cat $SCRIPTDIR/../VERSION) -export VERSION - -if [ -z "$1" ] -then - output_dir=$CONDA_PREFIX/conda-bld -else - output_dir=$1 -fi - -if [ -z "$2" ] -then - recipe=$SCRIPTDIR -else - recipe=$SCRIPTDIR/$2 -fi - -echo "building conda package version: $VERSION using recipe $recipe and writing output to $output_dir" - - -conda build $recipe --output-folder $output_dir diff --git a/conda-recipes/main-library/meta.yaml b/conda-recipes/main-library/meta.yaml index 232f89b20..2c2c88058 100755 --- a/conda-recipes/main-library/meta.yaml +++ b/conda-recipes/main-library/meta.yaml @@ -1,11 +1,11 @@ -#{% set version = load_file('VERSION').strip %} -package: - name: sls_detector_software - version: {{ environ.get('VERSION') }} #2025.3.19 - source: path: ../.. +{% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\d+\.\d+\.\d+)').group(1) %} +package: + name: sls_detector_software + version: {{ version }} #2025.3.19 + build: number: 0 binary_relocation: True diff --git a/conda-recipes/python-client/meta.yaml b/conda-recipes/python-client/meta.yaml index 7daa969a6..cf4f3aa7b 100644 --- a/conda-recipes/python-client/meta.yaml +++ b/conda-recipes/python-client/meta.yaml @@ -1,10 +1,11 @@ +source: + path: ../.. + +{% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\d+\.\d+\.\d+)').group(1) %} package: name: slsdet - version: {{ environ.get('VERSION') }} #2025.3.19 - -source: - path: ../.. + version: {{ version }} # build: number: 0 @@ -18,7 +19,6 @@ requirements: - {{ stdlib("c") }} - {{ compiler('cxx') }} - host: - cmake - ninja diff --git a/pyproject.toml b/pyproject.toml index 5e11fdc45..776657c41 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build" [project] name = "slsdet" -version = "2025.3.19" +version = "0.0.0" [tool.cibuildwheel] before-all = "uname -a" diff --git a/update_version.py b/update_version.py index f5c28c5af..507857133 100644 --- a/update_version.py +++ b/update_version.py @@ -6,10 +6,7 @@ Script to update VERSION file with semantic versioning if provided as an argumen import sys import re -import os import toml -import yaml -from jinja2 import Template, Undefined def get_version(): @@ -26,31 +23,20 @@ def get_version(): return version - def write_version_to_file(version): with open("VERSION", "w") as version_file: version_file.write(version) print(f"Version {version} written to VERSION file.") -def define_environment_variable(version): - os.environ["VERSION"] = version - def update_pyproject_toml_file(version): pyproject = toml.load("pyproject.toml") pyproject["project"]["version"] = version toml.dump(pyproject, open("pyproject.toml", "w")) #write back print(f"Version in pyproject.toml set to {version}") -class NullUndefined(Undefined): - def __getattr__(self, key): - return '' - - - # Main script if __name__ == "__main__": version = get_version() write_version_to_file(version) - define_environment_variable(version) update_pyproject_toml_file(version) From 2571397c701515e3cc829d6473f555be933c9896 Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Wed, 23 Apr 2025 14:38:51 +0200 Subject: [PATCH 05/11] saving changes in git workflow failed --- .github/workflows/conda_library.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/conda_library.yaml b/.github/workflows/conda_library.yaml index 807d7872b..9bde3bb31 100644 --- a/.github/workflows/conda_library.yaml +++ b/.github/workflows/conda_library.yaml @@ -33,7 +33,7 @@ jobs: run: conda config --set anaconda_upload no - name: Build - run: ./conda-recipes/build_conda.sh build_output main-library + run: conda build ./conda-recipes/main-library --build-folder build_output - name: Upload all Conda packages uses: actions/upload-artifact@v4 From 99735c3ee518da7a111a9f7489ace0f0830cf5c4 Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Wed, 23 Apr 2025 14:46:12 +0200 Subject: [PATCH 06/11] got typo in github workflow --- .github/workflows/conda_library.yaml | 2 +- .github/workflows/conda_python.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/conda_library.yaml b/.github/workflows/conda_library.yaml index 9bde3bb31..23f94d467 100644 --- a/.github/workflows/conda_library.yaml +++ b/.github/workflows/conda_library.yaml @@ -33,7 +33,7 @@ jobs: run: conda config --set anaconda_upload no - name: Build - run: conda build ./conda-recipes/main-library --build-folder build_output + run: conda build conda-recipes/main-library --output-folder build_output - name: Upload all Conda packages uses: actions/upload-artifact@v4 diff --git a/.github/workflows/conda_python.yaml b/.github/workflows/conda_python.yaml index 778b18ad7..5dad7745a 100644 --- a/.github/workflows/conda_python.yaml +++ b/.github/workflows/conda_python.yaml @@ -33,7 +33,7 @@ jobs: run: conda config --set anaconda_upload no - name: Build - run: conda build ./conda-recipes/python-client --build-folder build_output + run: conda build ./conda-recipes/python-client --output-folder build_output - name: Upload all Conda packages uses: actions/upload-artifact@v4 From bace9edf8934a898a4fdba9769f2f68f72669c7f Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Wed, 23 Apr 2025 17:09:06 +0200 Subject: [PATCH 07/11] updatet regex pattern to support postfix --- .github/workflows/conda_python.yaml | 2 +- conda-recipes/main-library/meta.yaml | 2 +- conda-recipes/python-client/meta.yaml | 3 +-- update_version.py | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/conda_python.yaml b/.github/workflows/conda_python.yaml index 5dad7745a..4b12cb3ff 100644 --- a/.github/workflows/conda_python.yaml +++ b/.github/workflows/conda_python.yaml @@ -33,7 +33,7 @@ jobs: run: conda config --set anaconda_upload no - name: Build - run: conda build ./conda-recipes/python-client --output-folder build_output + run: conda build conda-recipes/python-client --output-folder build_output - name: Upload all Conda packages uses: actions/upload-artifact@v4 diff --git a/conda-recipes/main-library/meta.yaml b/conda-recipes/main-library/meta.yaml index 2c2c88058..3a45167cc 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+)').group(1) %} +{% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\d+\.\d+\.\d+(?:[\.\-][\.\w\-]+)?)').group(1) %} package: name: sls_detector_software version: {{ version }} #2025.3.19 diff --git a/conda-recipes/python-client/meta.yaml b/conda-recipes/python-client/meta.yaml index cf4f3aa7b..03c4b4436 100644 --- a/conda-recipes/python-client/meta.yaml +++ b/conda-recipes/python-client/meta.yaml @@ -1,8 +1,7 @@ source: path: ../.. -{% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\d+\.\d+\.\d+)').group(1) %} - +{% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\d+\.\d+\.\d+(?:[\.\w\-]+)?)').group(1) %} package: name: slsdet version: {{ version }} # diff --git a/update_version.py b/update_version.py index 507857133..c72099b3c 100644 --- a/update_version.py +++ b/update_version.py @@ -17,8 +17,8 @@ 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+$', version): - print("Error: Version argument must be in 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])") sys.exit(1) return version From 0e4cb7cbcd8482b872a24d46c3111637d4b5369e Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Thu, 24 Apr 2025 08:45:18 +0200 Subject: [PATCH 08/11] normalized version to PEP 440 specification in update_version.py --- conda-recipes/main-library/meta.yaml | 4 +--- conda-recipes/python-client/meta.yaml | 2 +- update_version.py | 14 ++++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/conda-recipes/main-library/meta.yaml b/conda-recipes/main-library/meta.yaml index 3a45167cc..bfc176363 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 @@ -49,8 +49,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}") From c3f1d050338ee7451131c7ff2e82ab1126ff1d40 Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Thu, 24 Apr 2025 09:16:32 +0200 Subject: [PATCH 09/11] bug did not support version 0.0.0 --- conda-recipes/main-library/meta.yaml | 2 +- conda-recipes/python-client/meta.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conda-recipes/main-library/meta.yaml b/conda-recipes/main-library/meta.yaml index bfc176363..5ac6967d2 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+)*+(?:[\+\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 diff --git a/conda-recipes/python-client/meta.yaml b/conda-recipes/python-client/meta.yaml index dd9ea031c..d3fed0b9a 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+)*+(?:[\+\w\.]+))').group(1) %} +{% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\d+(?:\.\d+)*(?:[\+\w\.]+))').group(1) %} package: name: slsdet version: {{ version }} # From 2815913d1051635182d3a1332163c80f077b85e1 Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Fri, 25 Apr 2025 10:48:16 +0200 Subject: [PATCH 10/11] added regex pattern matching to version in toml file --- conda-recipes/main-library/meta.yaml | 2 +- conda-recipes/python-client/meta.yaml | 2 +- pyproject.toml | 8 +++++++- update_version.py | 17 +++++++---------- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/conda-recipes/main-library/meta.yaml b/conda-recipes/main-library/meta.yaml index 5ac6967d2..8b11b4536 100755 --- a/conda-recipes/main-library/meta.yaml +++ b/conda-recipes/main-library/meta.yaml @@ -4,7 +4,7 @@ source: {% 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 + version: {{ version }} build: number: 0 diff --git a/conda-recipes/python-client/meta.yaml b/conda-recipes/python-client/meta.yaml index d3fed0b9a..c86f401ef 100644 --- a/conda-recipes/python-client/meta.yaml +++ b/conda-recipes/python-client/meta.yaml @@ -4,7 +4,7 @@ source: {% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\d+(?:\.\d+)*(?:[\+\w\.]+))').group(1) %} package: name: slsdet - version: {{ version }} # + version: {{ version }} build: number: 0 diff --git a/pyproject.toml b/pyproject.toml index 776657c41..8deb25dde 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,16 @@ +[tool.scikit-build.metadata.version] +provider = "scikit_build_core.metadata.regex" +input = "VERSION" +regex = '^(?P\d+(?:\.\d+)*(?:[\.\+\w]+)?)$' +result = "{version}" + [build-system] requires = [ "scikit-build-core>=0.10", "pybind11", "numpy",] build-backend = "scikit_build_core.build" [project] name = "slsdet" -version = "0.0.0" +dynamic = ["version"] [tool.cibuildwheel] before-all = "uname -a" diff --git a/update_version.py b/update_version.py index 914797a1d..2b5609198 100644 --- a/update_version.py +++ b/update_version.py @@ -5,10 +5,13 @@ Script to update VERSION file with semantic versioning if provided as an argumen """ import sys -import re -import toml +import os + from packaging.version import Version, InvalidVersion + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) + def get_version(): # Check at least one argument is passed @@ -26,19 +29,13 @@ def get_version(): def write_version_to_file(version): - with open("VERSION", "w") as version_file: + version_file_path = os.path.join(SCRIPT_DIR, "VERSION") + with open(version_file_path, "w") as version_file: 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"] = str(version) - toml.dump(pyproject, open("pyproject.toml", "w")) #write back - print(f"Version in pyproject.toml set to {version}") - # Main script if __name__ == "__main__": version = get_version() write_version_to_file(version) - update_pyproject_toml_file(version) From 27530fca31ccae8193cab4c4e77a62cb8181409d Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Tue, 29 Apr 2025 11:14:52 +0200 Subject: [PATCH 11/11] version now supports . before postfix --- update_version.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/update_version.py b/update_version.py index 2b5609198..6b3e1ebad 100644 --- a/update_version.py +++ b/update_version.py @@ -19,10 +19,11 @@ def get_version(): return "0.0.0" version = sys.argv[1] - + try: - v = Version(version) # normalize according to PEP 440 specification - return v + v = Version(version) # normalizcheck if version follows PEP 440 specification + #replace - + return version.replace("-", ".") 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) @@ -31,7 +32,7 @@ def get_version(): def write_version_to_file(version): version_file_path = os.path.join(SCRIPT_DIR, "VERSION") with open(version_file_path, "w") as version_file: - version_file.write(str(version)) + version_file.write(version) print(f"Version {version} written to VERSION file.") # Main script