mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-07 10:30:41 +02:00
normalized version to PEP 440 specification in update_version.py
This commit is contained in:
parent
f3be955763
commit
96f39d5028
@ -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:
|
||||
|
@ -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 }} #
|
||||
|
@ -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}")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user