From 497c3abfc24af91d3cc224db31b91a6324eda6f0 Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Wed, 23 Apr 2025 14:26:26 +0200 Subject: [PATCH] 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)