mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-20 02:40:03 +02:00
dev: version from file to cmake and python (#1025)
- renamed conda-recipe folder - added a check to see if build and install folder exists in build.sh (conda recipe) - created VERSION file that has '0.0.0'for developer but can be updated using update_version.py that takes in a version. The script checks for semantic versioning and updates VERSION file - VERSION file also copied along with py files to slsdet in python cmakelist and build_pylib.sh (for conda), also copied in root folder for installations (for no coding purpose) - init.py and setup.py reads this file to get the version (a bit differently to find the VERSION file) - VERSION file read into cmake to get the version and also added to compile definition. So RELEASE removed from versionAPI.h (using SLS_DET_VERSION compile definiton instead) and also removed updateRelease script. - conda getting project version from environment variable SLS_DET_VERSION that is set in build_pylib.sh prior. - added 3.13 python to conda build - anything related to ctb removed from release notes as users will always use developer - sets 0.0.0 to VERSION file by running update_version.py without an argument
This commit is contained in:
parent
c57e835a41
commit
d9e8e1c1c2
@ -2,7 +2,15 @@
|
|||||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
cmake_minimum_required(VERSION 3.14)
|
cmake_minimum_required(VERSION 3.14)
|
||||||
project(slsDetectorPackage)
|
project(slsDetectorPackage)
|
||||||
set(PROJECT_VERSION 9.0.0)
|
|
||||||
|
# Read VERSION file into project version
|
||||||
|
set(VERSION_FILE "${CMAKE_SOURCE_DIR}/VERSION")
|
||||||
|
file(READ "${VERSION_FILE}" VERSION_CONTENT)
|
||||||
|
string(STRIP "${VERSION_CONTENT}" PROJECT_VERSION_STRING)
|
||||||
|
set(PROJECT_VERSION ${PROJECT_VERSION_STRING})
|
||||||
|
|
||||||
|
# Pass it to the compiler
|
||||||
|
add_compile_definitions(SLS_DET_VERSION="${PROJECT_VERSION}")
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||||
|
|
||||||
@ -347,3 +355,5 @@ if(SLS_MASTER_PROJECT)
|
|||||||
set(PROJECT_LIBRARIES slsSupportShared slsDetectorShared slsReceiverShared)
|
set(PROJECT_LIBRARIES slsSupportShared slsDetectorShared slsReceiverShared)
|
||||||
include(cmake/package_config.cmake)
|
include(cmake/package_config.cmake)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
install(FILES ${CMAKE_SOURCE_DIR}/VERSION DESTINATION ${CMAKE_INSTALL_PREFIX})
|
@ -1,6 +0,0 @@
|
|||||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
|
||||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
||||||
|
|
||||||
echo "|<-------- starting python build"
|
|
||||||
cd python
|
|
||||||
${PYTHON} setup.py install
|
|
@ -1,8 +1,12 @@
|
|||||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
|
|
||||||
mkdir build
|
if [ ! -d "build" ]; then
|
||||||
mkdir install
|
mkdir build
|
||||||
|
fi
|
||||||
|
if [ ! -d "install" ]; then
|
||||||
|
mkdir install
|
||||||
|
fi
|
||||||
cd build
|
cd build
|
||||||
cmake .. \
|
cmake .. \
|
||||||
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
|
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX \
|
14
conda-recipe/build_pylib.sh
Executable file
14
conda-recipe/build_pylib.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
|
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
|
|
||||||
|
echo "|<-------- starting python build"
|
||||||
|
|
||||||
|
cd python
|
||||||
|
|
||||||
|
# copy VERSION into slsdet for installation
|
||||||
|
cp ../VERSION slsdet/VERSION
|
||||||
|
|
||||||
|
# to be used to get project version in meta.yaml
|
||||||
|
export SLS_DET_VERSION=$(cat python/slsdet/VERSION)
|
||||||
|
|
||||||
|
${PYTHON} setup.py install
|
@ -4,4 +4,5 @@ python:
|
|||||||
- 3.10
|
- 3.10
|
||||||
- 3.11
|
- 3.11
|
||||||
- 3.12
|
- 3.12
|
||||||
|
- 3.13
|
||||||
|
|
@ -1,10 +1,14 @@
|
|||||||
|
|
||||||
|
{% set version = environ.get('SLS_DET_VERSION', '0.0.0') %}
|
||||||
|
|
||||||
|
|
||||||
package:
|
package:
|
||||||
name: sls_detector_software
|
name: sls_detector_software
|
||||||
version: {{ environ.get('GIT_DESCRIBE_TAG', '') }}
|
version: "{{ version }}"
|
||||||
|
|
||||||
|
|
||||||
source:
|
source:
|
||||||
- path: ..
|
path: ..
|
||||||
|
|
||||||
build:
|
build:
|
||||||
number: 0
|
number: 0
|
||||||
@ -61,13 +65,11 @@ outputs:
|
|||||||
- libstdcxx-ng
|
- libstdcxx-ng
|
||||||
- libgcc-ng
|
- libgcc-ng
|
||||||
|
|
||||||
|
|
||||||
run:
|
run:
|
||||||
- libstdcxx-ng
|
- libstdcxx-ng
|
||||||
- libgcc-ng
|
- libgcc-ng
|
||||||
|
|
||||||
- name: slsdet
|
- name: slsdet
|
||||||
|
|
||||||
script: build_pylib.sh
|
script: build_pylib.sh
|
||||||
|
|
||||||
requirements:
|
requirements:
|
||||||
@ -92,11 +94,11 @@ outputs:
|
|||||||
- numpy
|
- numpy
|
||||||
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
- {{ pin_subpackage('slsdetlib', exact=True) }}
|
||||||
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
imports:
|
imports:
|
||||||
- slsdet
|
- slsdet
|
||||||
|
|
||||||
|
|
||||||
- name: slsdetgui
|
- name: slsdetgui
|
||||||
script: copy_gui.sh
|
script: copy_gui.sh
|
||||||
requirements:
|
requirements:
|
@ -49,7 +49,6 @@ set( PYTHON_FILES
|
|||||||
slsdet/temperature.py
|
slsdet/temperature.py
|
||||||
slsdet/lookup.py
|
slsdet/lookup.py
|
||||||
slsdet/utils.py
|
slsdet/utils.py
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach(FILE ${PYTHON_FILES})
|
foreach(FILE ${PYTHON_FILES})
|
||||||
@ -58,7 +57,6 @@ foreach(FILE ${PYTHON_FILES})
|
|||||||
|
|
||||||
endforeach(FILE ${PYTHON_FILES})
|
endforeach(FILE ${PYTHON_FILES})
|
||||||
|
|
||||||
|
|
||||||
configure_file( scripts/basic.py
|
configure_file( scripts/basic.py
|
||||||
${CMAKE_BINARY_DIR}/basic.py
|
${CMAKE_BINARY_DIR}/basic.py
|
||||||
)
|
)
|
||||||
@ -66,6 +64,9 @@ configure_file( scripts/test_virtual.py
|
|||||||
${CMAKE_BINARY_DIR}/test_virtual.py
|
${CMAKE_BINARY_DIR}/test_virtual.py
|
||||||
)
|
)
|
||||||
|
|
||||||
|
configure_file( ${CMAKE_SOURCE_DIR}/VERSION
|
||||||
|
${CMAKE_BINARY_DIR}/bin/slsdet/VERSION
|
||||||
|
)
|
||||||
|
|
||||||
if(SLS_INSTALL_PYTHONEXT)
|
if(SLS_INSTALL_PYTHONEXT)
|
||||||
install(TARGETS _slsdet
|
install(TARGETS _slsdet
|
||||||
@ -74,4 +75,5 @@ if(SLS_INSTALL_PYTHONEXT)
|
|||||||
)
|
)
|
||||||
|
|
||||||
install(FILES ${PYTHON_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/python/slsdet)
|
install(FILES ${PYTHON_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/python/slsdet)
|
||||||
|
install(FILES ../VERSION DESTINATION ${CMAKE_INSTALL_PREFIX}/python/slsdet)
|
||||||
endif()
|
endif()
|
@ -10,14 +10,15 @@ import sys
|
|||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
from pybind11.setup_helpers import Pybind11Extension, build_ext
|
from pybind11.setup_helpers import Pybind11Extension, build_ext
|
||||||
|
|
||||||
|
def read_version():
|
||||||
import subprocess
|
|
||||||
def get_git_tag():
|
|
||||||
try:
|
try:
|
||||||
return subprocess.check_output(['git', 'describe', '--tags', '--abbrev=0']).strip().decode('utf-8')
|
version_file = os.path.join(os.path.dirname(__file__), 'slsdet', 'VERSION')
|
||||||
except subprocess.CalledProcessError:
|
with open(version_file, "r") as f:
|
||||||
return 'developer'
|
return f.read().strip()
|
||||||
__version__ = get_git_tag()
|
except:
|
||||||
|
raise RuntimeError("VERSION file not found in slsdet package from setup.py.")
|
||||||
|
|
||||||
|
__version__ = read_version()
|
||||||
|
|
||||||
|
|
||||||
def get_conda_path():
|
def get_conda_path():
|
||||||
@ -67,6 +68,9 @@ setup(
|
|||||||
description='Detector API for SLS Detector Group detectors',
|
description='Detector API for SLS Detector Group detectors',
|
||||||
long_description='',
|
long_description='',
|
||||||
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
|
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
|
||||||
|
package_data={
|
||||||
|
'slsdet': ['VERSION'],
|
||||||
|
},
|
||||||
ext_modules=ext_modules,
|
ext_modules=ext_modules,
|
||||||
cmdclass={"build_ext": build_ext},
|
cmdclass={"build_ext": build_ext},
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
|
@ -22,6 +22,7 @@ defs = _slsdet.slsDetectorDefs
|
|||||||
from .enums import *
|
from .enums import *
|
||||||
from .defines import *
|
from .defines import *
|
||||||
|
|
||||||
|
|
||||||
IpAddr = _slsdet.IpAddr
|
IpAddr = _slsdet.IpAddr
|
||||||
MacAddr = _slsdet.MacAddr
|
MacAddr = _slsdet.MacAddr
|
||||||
scanParameters = _slsdet.scanParameters
|
scanParameters = _slsdet.scanParameters
|
||||||
@ -29,12 +30,14 @@ currentSrcParameters = _slsdet.currentSrcParameters
|
|||||||
DurationWrapper = _slsdet.DurationWrapper
|
DurationWrapper = _slsdet.DurationWrapper
|
||||||
pedestalParameters = _slsdet.pedestalParameters
|
pedestalParameters = _slsdet.pedestalParameters
|
||||||
|
|
||||||
|
import os
|
||||||
import subprocess
|
def read_version():
|
||||||
def get_git_tag():
|
|
||||||
try:
|
try:
|
||||||
return subprocess.check_output(['git', 'describe', '--tags', '--abbrev=0']).strip().decode('utf-8')
|
version_file = os.path.join(os.path.dirname(__file__), 'VERSION')
|
||||||
except subprocess.CalledProcessError:
|
with open(version_file, "r") as f:
|
||||||
return 'developer'
|
return f.read().strip()
|
||||||
__version__ = get_git_tag()
|
except:
|
||||||
|
raise RuntimeError("VERSION file not found in slsdet package from init.py")
|
||||||
|
|
||||||
|
__version__ = read_version()
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ void Detector::setVirtualDetectorServers(int numServers,
|
|||||||
|
|
||||||
int Detector::getShmId() const { return pimpl->getDetectorIndex(); }
|
int Detector::getShmId() const { return pimpl->getDetectorIndex(); }
|
||||||
|
|
||||||
std::string Detector::getPackageVersion() const { return RELEASE; }
|
std::string Detector::getPackageVersion() const { return SLS_DET_VERSION; }
|
||||||
|
|
||||||
std::string Detector::getClientVersion() const {
|
std::string Detector::getClientVersion() const {
|
||||||
Version v(APILIB);
|
Version v(APILIB);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
/** API versions */
|
/** API versions */
|
||||||
#define RELEASE "developer"
|
|
||||||
#define APIRECEIVER "developer 0x241014"
|
#define APIRECEIVER "developer 0x241014"
|
||||||
#define APILIB "developer 0x241021"
|
#define APILIB "developer 0x241021"
|
||||||
#define APICTB "developer 0x241107"
|
#define APICTB "developer 0x241107"
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
# SPDX-License-Identifier: LGPL-3.0-or-other
|
|
||||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
||||||
|
|
||||||
API_FILE=$PWD/slsSupportLib/include/sls/versionAPI.h
|
|
||||||
CURR_BRANCH=$(cat $API_FILE | grep RELEASE | awk '{print $3}' )
|
|
||||||
|
|
||||||
# default branch is developer
|
|
||||||
if [ $# -eq 0 ]; then
|
|
||||||
declare -a NEW_BRANCH="developer"
|
|
||||||
else
|
|
||||||
declare -a NEW_BRANCH=${1}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# update branch
|
|
||||||
sed -i s/$CURR_BRANCH/\"$NEW_BRANCH\"/g $API_FILE
|
|
36
update_version.py
Normal file
36
update_version.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
|
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
|
"""
|
||||||
|
Script to update VERSION file with semantic versioning if provided as an argument, or with 0.0.0 if no argument is provided.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import re
|
||||||
|
|
||||||
|
def get_version():
|
||||||
|
|
||||||
|
# Check at least one argument is passed
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
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)")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
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.")
|
||||||
|
|
||||||
|
|
||||||
|
# Main script
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
version = get_version()
|
||||||
|
write_version_to_file(version)
|
Loading…
x
Reference in New Issue
Block a user