version number automated for python build

This commit is contained in:
mazzol_a 2025-04-22 14:00:45 +02:00
parent 7c8639b8ae
commit da760b2b93
5 changed files with 43 additions and 15 deletions

8
conda-recipes/build_conda.sh Executable file
View File

@ -0,0 +1,8 @@
SCRIPTDIR=$(cd "$(dirname "$0")" && pwd)
VERSION=$(cat $SCRIPTDIR/../VERSION)
export VERSION
echo "building conda package version: $VERSION"
conda build .

View File

@ -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: ../..

View File

@ -1,7 +1,7 @@
package:
name: slsdet
version: 2025.3.19 #TODO! how to not duplicate this?
version: 0.0.0
source:
path: ../..

View File

@ -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"
SLS_INSTALL_PYTHONEXT = "ON"

View File

@ -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)
write_version_to_file(version)
define_environment_variable(version)
update_pyproject_toml_file(version)