diff --git a/.github/workflows/conda_python.yaml b/.github/workflows/conda_python.yaml index d482b8e6f..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 2ddc76a6f..8b11b4536 100755 --- a/conda-recipes/main-library/meta.yaml +++ b/conda-recipes/main-library/meta.yaml @@ -1,11 +1,11 @@ -package: - name: sls_detector_software - version: 2025.3.19 - - source: path: ../.. +{% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\d+(?:\.\d+)*(?:[\+\w\.]+))').group(1) %} +package: + name: sls_detector_software + version: {{ version }} + build: number: 0 binary_relocation: True @@ -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 3b710151c..c86f401ef 100644 --- a/conda-recipes/python-client/meta.yaml +++ b/conda-recipes/python-client/meta.yaml @@ -1,10 +1,11 @@ -package: - name: slsdet - version: 2025.3.19 #TODO! how to not duplicate this? - source: path: ../.. +{% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\d+(?:\.\d+)*(?:[\+\w\.]+))').group(1) %} +package: + name: slsdet + version: {{ version }} + build: number: 0 script: @@ -17,7 +18,6 @@ requirements: - {{ stdlib("c") }} - {{ compiler('cxx') }} - host: - cmake - ninja diff --git a/pyproject.toml b/pyproject.toml index 3d128f18e..8deb25dde 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,27 +1,33 @@ +[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"] +requires = [ "scikit-build-core>=0.10", "pybind11", "numpy",] build-backend = "scikit_build_core.build" [project] name = "slsdet" -version = "2025.3.19" - +dynamic = ["version"] [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..6b3e1ebad 100644 --- a/update_version.py +++ b/update_version.py @@ -5,7 +5,12 @@ Script to update VERSION file with semantic versioning if provided as an argumen """ import sys -import re +import os + +from packaging.version import Version, InvalidVersion + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) def get_version(): @@ -14,23 +19,24 @@ def get_version(): return "0.0.0" 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)") + + try: + 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) - return 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(version) print(f"Version {version} written to VERSION file.") - # Main script if __name__ == "__main__": version = get_version() - write_version_to_file(version) \ No newline at end of file + write_version_to_file(version)