From d4c09bfd214e9c0696e70e3bbe3cb2278f02374e Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Tue, 18 Mar 2025 10:33:51 +0100 Subject: [PATCH 01/42] skeleton pyproject.toml --- CMakeLists.txt | 6 +++++- pyproject.toml | 22 ++++++++++++++++++++++ python/CMakeLists.txt | 16 ++++++++++++---- 3 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 pyproject.toml diff --git a/CMakeLists.txt b/CMakeLists.txt index 5676ec92d..c15f1fcb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # SPDX-License-Identifier: LGPL-3.0-or-other # Copyright (C) 2021 Contributors to the SLS Detector Package -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.15) project(slsDetectorPackage) # Read VERSION file into project version @@ -29,6 +29,10 @@ include(FetchContent) option(SLS_FETCH_ZMQ_FROM_GITHUB "Fetch zmq from github" OFF) option(SLS_FETCH_PYBIND11_FROM_GITHUB "Fetch pybind11 from github" OFF) +if(${SKBUILD}) + message(STATUS "Building with scikit-build") +endif() + if(SLS_FETCH_ZMQ_FROM_GITHUB) # Opt in to pull down a zmq version from github instead of # using the bundled verison diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..e626be8c0 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,22 @@ +[build-system] +requires = ["scikit-build-core>=0.10", "pybind11", "numpy"] +build-backend = "scikit_build_core.build" + +[project] +name = "slsDetectorPackage" +version = "2025.2.18" + + +[tool.scikit-build] +cmake.verbose = true +cmake.build-type = "Release" +install.components = ["python"] + + +[tool.scikit-build.cmake.define] +SLS_USE_RECEIVER = "OFF" +SLS_USE_RECEIVER_BINARIES = "OFF" +SLS_USE_TEXTCLIENT = "OFF" +SLS_USE_PYTHON = "ON" +SLS_INSTALL_PYTHONEXT = "ON" +SLS_BUILD_SHARED_LIBRARIES = "OFF" \ No newline at end of file diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 9765e55d1..afb7267a7 100755 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -75,10 +75,18 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/../VERSION if(SLS_INSTALL_PYTHONEXT) install(TARGETS _slsdet EXPORT "${TARGETS_EXPORT_NAME}" - LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/python + LIBRARY DESTINATION slsdet + COMPONENT python ) + install( + FILES ${PYTHON_FILES} + DESTINATION slsdet + COMPONENT python + ) + install( + FILES ../VERSION + DESTINATION slsdet + COMPONENT python + ) - install(FILES ${PYTHON_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/python/slsdet) - install(FILES ../VERSION DESTINATION ${CMAKE_INSTALL_PREFIX}/python/slsdet) endif() - From ef62155207361cf8b6af3aebf3d36087f09a75bd Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Tue, 18 Mar 2025 10:56:03 +0100 Subject: [PATCH 02/42] moved compiled extension into slsdet --- pyproject.toml | 8 +++++--- python/CMakeLists.txt | 2 +- python/slsdet/__init__.py | 2 +- python/slsdet/ctb.py | 2 +- python/slsdet/dacs.py | 2 +- python/slsdet/detector.py | 8 ++++---- python/slsdet/eiger.py | 2 +- python/slsdet/enums.py | 4 ++-- python/slsdet/gaincaps.py | 2 +- python/slsdet/gotthard2.py | 2 +- python/slsdet/jungfrau.py | 2 +- python/slsdet/moench.py | 2 +- python/slsdet/mythen3.py | 2 +- python/slsdet/pattern.py | 4 ++-- python/slsdet/powers.py | 2 +- python/slsdet/proxy.py | 2 +- python/slsdet/utils.py | 2 +- 17 files changed, 26 insertions(+), 24 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e626be8c0..df5a2a852 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["scikit-build-core>=0.10", "pybind11", "numpy"] build-backend = "scikit_build_core.build" [project] -name = "slsDetectorPackage" +name = "slsdet" version = "2025.2.18" @@ -14,9 +14,11 @@ 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_BUILD_SHARED_LIBRARIES = "OFF" \ No newline at end of file +SLS_INSTALL_PYTHONEXT = "ON" \ No newline at end of file diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index afb7267a7..2e6a485e7 100755 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -20,7 +20,7 @@ target_link_libraries(_slsdet PUBLIC set_target_properties(_slsdet PROPERTIES - LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/slsdet ) #Copy Python code diff --git a/python/slsdet/__init__.py b/python/slsdet/__init__.py index 96a734ff9..85a147db6 100755 --- a/python/slsdet/__init__.py +++ b/python/slsdet/__init__.py @@ -14,7 +14,7 @@ from .moench import Moench from .pattern import Pattern, patternParameters from .gaincaps import Mythen3GainCapsWrapper -import _slsdet +from . import _slsdet xy = _slsdet.xy defs = _slsdet.slsDetectorDefs diff --git a/python/slsdet/ctb.py b/python/slsdet/ctb.py index ad671a93e..1295af9cb 100644 --- a/python/slsdet/ctb.py +++ b/python/slsdet/ctb.py @@ -4,7 +4,7 @@ from .detector import Detector, freeze from .utils import element_if_equal from .dacs import DetectorDacs, NamedDacs from .powers import DetectorPowers, NamedPowers -import _slsdet +from . import _slsdet dacIndex = _slsdet.slsDetectorDefs.dacIndex from .detector_property import DetectorProperty diff --git a/python/slsdet/dacs.py b/python/slsdet/dacs.py index 961d0bebe..547a43277 100755 --- a/python/slsdet/dacs.py +++ b/python/slsdet/dacs.py @@ -3,7 +3,7 @@ from .detector_property import DetectorProperty from functools import partial import numpy as np -import _slsdet +from . import _slsdet from .detector import freeze dacIndex = _slsdet.slsDetectorDefs.dacIndex class Dac(DetectorProperty): diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index 5a070b011..da2901ed6 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -1,8 +1,8 @@ # SPDX-License-Identifier: LGPL-3.0-or-other # Copyright (C) 2021 Contributors to the SLS Detector Package -from _slsdet import CppDetectorApi -from _slsdet import slsDetectorDefs -from _slsdet import IpAddr, MacAddr +from ._slsdet import CppDetectorApi +from ._slsdet import slsDetectorDefs +from ._slsdet import IpAddr, MacAddr runStatus = slsDetectorDefs.runStatus timingMode = slsDetectorDefs.timingMode @@ -15,7 +15,7 @@ defs = slsDetectorDefs from .utils import element_if_equal, all_equal, get_set_bits, list_to_bitmask from .utils import Geometry, to_geo, element, reduce_time, is_iterable, hostname_list -from _slsdet import xy +from ._slsdet import xy from .gaincaps import Mythen3GainCapsWrapper from . import utils as ut from .proxy import JsonProxy, SlowAdcProxy, ClkDivProxy, MaxPhaseProxy, ClkFreqProxy, PatLoopProxy, PatNLoopProxy, PatWaitProxy, PatWaitTimeProxy diff --git a/python/slsdet/eiger.py b/python/slsdet/eiger.py index a65532677..db12b7909 100755 --- a/python/slsdet/eiger.py +++ b/python/slsdet/eiger.py @@ -11,7 +11,7 @@ Created on Wed Dec 6 11:51:18 2017 from .detector import Detector from .temperature import Temperature, DetectorTemperature from .dacs import DetectorDacs -import _slsdet +from . import _slsdet dacIndex = _slsdet.slsDetectorDefs.dacIndex from .detector_property import DetectorProperty diff --git a/python/slsdet/enums.py b/python/slsdet/enums.py index 02e3c5126..41dcd5dec 100644 --- a/python/slsdet/enums.py +++ b/python/slsdet/enums.py @@ -15,8 +15,8 @@ if dt === detectorType.EIGER: """ -import _slsdet +from . import _slsdet for name, cls in _slsdet.slsDetectorDefs.__dict__.items(): if isinstance(cls, type): - exec(f'{name} = {cls.__module__}.{cls.__qualname__}') + exec(f'{name} = _slsdet.{cls.__qualname__}') diff --git a/python/slsdet/gaincaps.py b/python/slsdet/gaincaps.py index ab3acd381..900503624 100644 --- a/python/slsdet/gaincaps.py +++ b/python/slsdet/gaincaps.py @@ -1,6 +1,6 @@ -import _slsdet +from . import _slsdet gc = _slsdet.slsDetectorDefs.M3_GainCaps diff --git a/python/slsdet/gotthard2.py b/python/slsdet/gotthard2.py index bdb36097f..fb2786faf 100644 --- a/python/slsdet/gotthard2.py +++ b/python/slsdet/gotthard2.py @@ -11,7 +11,7 @@ from .detector import Detector, freeze # from .adcs import Adc, DetectorAdcs from .dacs import DetectorDacs -import _slsdet +from . import _slsdet dacIndex = _slsdet.slsDetectorDefs.dacIndex from .detector_property import DetectorProperty diff --git a/python/slsdet/jungfrau.py b/python/slsdet/jungfrau.py index c8e3f43f9..1021a55f1 100644 --- a/python/slsdet/jungfrau.py +++ b/python/slsdet/jungfrau.py @@ -11,7 +11,7 @@ from .detector import Detector, freeze # from .adcs import Adc, DetectorAdcs from .dacs import DetectorDacs -import _slsdet +from . import _slsdet dacIndex = _slsdet.slsDetectorDefs.dacIndex from .detector_property import DetectorProperty diff --git a/python/slsdet/moench.py b/python/slsdet/moench.py index 6ed49a43d..7e93bee65 100644 --- a/python/slsdet/moench.py +++ b/python/slsdet/moench.py @@ -9,7 +9,7 @@ This file contains the specialization for the Moench detector from .detector import Detector, freeze from .dacs import DetectorDacs -import _slsdet +from . import _slsdet dacIndex = _slsdet.slsDetectorDefs.dacIndex from .detector_property import DetectorProperty diff --git a/python/slsdet/mythen3.py b/python/slsdet/mythen3.py index 369d6ac99..14e1294ea 100644 --- a/python/slsdet/mythen3.py +++ b/python/slsdet/mythen3.py @@ -11,7 +11,7 @@ from .detector import Detector, freeze # from .adcs import Adc, DetectorAdcs from .dacs import DetectorDacs -import _slsdet +from . import _slsdet dacIndex = _slsdet.slsDetectorDefs.dacIndex gc_enums = _slsdet.slsDetectorDefs.M3_GainCaps from .detector_property import DetectorProperty diff --git a/python/slsdet/pattern.py b/python/slsdet/pattern.py index a2d80fdfe..273865c65 100644 --- a/python/slsdet/pattern.py +++ b/python/slsdet/pattern.py @@ -1,8 +1,8 @@ # SPDX-License-Identifier: LGPL-3.0-or-other # Copyright (C) 2021 Contributors to the SLS Detector Package -import _slsdet +from . import _slsdet -from _slsdet import Pattern +from ._slsdet import Pattern class patternParameters(_slsdet.patternParameters): diff --git a/python/slsdet/powers.py b/python/slsdet/powers.py index 8de1781c7..a513eedbe 100755 --- a/python/slsdet/powers.py +++ b/python/slsdet/powers.py @@ -3,7 +3,7 @@ from .detector_property import DetectorProperty from functools import partial import numpy as np -import _slsdet +from . import _slsdet from .detector import freeze dacIndex = _slsdet.slsDetectorDefs.dacIndex class Power(DetectorProperty): diff --git a/python/slsdet/proxy.py b/python/slsdet/proxy.py index cd10cb38a..316c1dbe3 100644 --- a/python/slsdet/proxy.py +++ b/python/slsdet/proxy.py @@ -3,7 +3,7 @@ from .utils import element_if_equal from .enums import dacIndex from .defines import M3_MAX_PATTERN_LEVELS, MAX_PATTERN_LEVELS -from _slsdet import slsDetectorDefs +from ._slsdet import slsDetectorDefs detectorType = slsDetectorDefs.detectorType diff --git a/python/slsdet/utils.py b/python/slsdet/utils.py index 89a7651bc..4648abd5a 100755 --- a/python/slsdet/utils.py +++ b/python/slsdet/utils.py @@ -6,7 +6,7 @@ but not directly used in controlling the detector """ from collections import namedtuple -import _slsdet #C++ lib +from . import _slsdet #C++ lib import functools import datetime as dt import pathlib From 106f9a989e4b421d1d51b7345b41fc8d8a026a13 Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Tue, 18 Mar 2025 13:21:46 +0100 Subject: [PATCH 03/42] WIP --- conda-recipe/conda_build_config.yaml | 10 ++-- conda-recipe/meta.yaml | 24 +++++---- python/setup.py | 77 ---------------------------- 3 files changed, 18 insertions(+), 93 deletions(-) delete mode 100755 python/setup.py diff --git a/conda-recipe/conda_build_config.yaml b/conda-recipe/conda_build_config.yaml index 6e37cf5c5..7cd2f4894 100644 --- a/conda-recipe/conda_build_config.yaml +++ b/conda-recipe/conda_build_config.yaml @@ -1,9 +1,9 @@ python: - - 3.8 - - 3.9 - - 3.10 - - 3.11 - - 3.12 + # - 3.8 + # - 3.9 + # - 3.10 + # - 3.11 + # - 3.12 - 3.13 diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index 8dde14f70..37e7992cc 100755 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -50,30 +50,32 @@ outputs: - libgcc-ng - name: slsdet - script: build_pylib.sh + script: + - unset CMAKE_GENERATOR && {{ PYTHON }} -m pip install . -vv # [not win] requirements: build: - - python + - python {{python}} - {{ compiler('c') }} - {{compiler('cxx')}} - - {{ pin_subpackage('slsdetlib', exact=True) }} - - setuptools - - pybind11=2.13 + # - {{ pin_subpackage('slsdetlib', exact=True) }} #discuss keeping pinning for simplicity? + - pybind11>=2.13 host: - - python - - {{ pin_subpackage('slsdetlib', exact=True) }} + - cmake + - ninja + - python {{python}} + - pip - setuptools - - pybind11=2.13 + - pybind11>=2.13 + - scikit-build-core run: - libstdcxx-ng - libgcc-ng - - python - - numpy - - {{ pin_subpackage('slsdetlib', exact=True) }} + - python {{python}} + test: imports: diff --git a/python/setup.py b/python/setup.py deleted file mode 100755 index 1be1ac809..000000000 --- a/python/setup.py +++ /dev/null @@ -1,77 +0,0 @@ -# SPDX-License-Identifier: LGPL-3.0-or-other -# Copyright (C) 2021 Contributors to the SLS Detector Package -""" -Setup file for slsdet -Build upon the pybind11 example found here: https://github.com/pybind/python_example -""" - -import os -import sys -from setuptools import setup, find_packages -from pybind11.setup_helpers import Pybind11Extension, build_ext - -def read_version(): - try: - version_file = os.path.join(os.path.dirname(__file__), 'slsdet', 'VERSION') - with open(version_file, "r") as f: - return f.read().strip() - except: - raise RuntimeError("VERSION file not found in slsdet package from setup.py.") - -__version__ = read_version() - - -def get_conda_path(): - """ - Keep this a function if we need some fancier logic later - """ - print('Prefix: ', os.environ['CONDA_PREFIX']) - return os.environ['CONDA_PREFIX'] - - -#TODO migrate to CMake build or fetch files from cmake? -ext_modules = [ - Pybind11Extension( - '_slsdet', - ['src/main.cpp', - 'src/enums.cpp', - 'src/current.cpp', - 'src/detector.cpp', - 'src/network.cpp', - 'src/pattern.cpp', - 'src/scan.cpp', - 'src/duration.cpp', - 'src/DurationWrapper.cpp', - 'src/pedestal.cpp', - ] - - - , - include_dirs=[ - os.path.join(get_conda_path(), 'include'), - - ], - libraries=['SlsDetector', 'SlsSupport', 'SlsReceiver'], - library_dirs=[ - os.path.join(get_conda_path(), 'lib'), - ], - language='c++' - ), -] - -setup( - name='slsdet', - version=__version__, - author='Erik Frojdh', - author_email='erik.frojdh@psi.ch', - url='https://github.com/slsdetectorgroup/slsDetectorPackage', - description='Detector API for SLS Detector Group detectors', - long_description='', - packages=find_packages(exclude=['contrib', 'docs', 'tests']), - package_data={ - 'slsdet': ['VERSION'], - }, - ext_modules=ext_modules, - cmdclass={"build_ext": build_ext}, - zip_safe=False, -) From 910b440d2fecd1bce2a396e4ea8282ab0bf91df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=B6jd=20Lars=20Erik?= Date: Wed, 19 Mar 2025 16:37:37 +0100 Subject: [PATCH 04/42] WI{ --- CMakeLists.txt | 9 +- conda-recipe/build.sh | 5 +- conda-recipe/conda_build_config.yaml | 6 +- conda-recipe/meta.yaml | 137 +++++----- .../tests/test-SharedMemory.cpp | 236 +++++++++--------- 5 files changed, 202 insertions(+), 191 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c15f1fcb4..f3055e34f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,8 @@ set(PROJECT_VERSION ${PROJECT_VERSION_STRING}) add_compile_definitions(SLS_DET_VERSION="${PROJECT_VERSION}") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) cmake_policy(SET CMP0074 NEW) @@ -58,6 +60,11 @@ set(ENABLE_CPACK OFF CACHE BOOL "") set(ENABLE_CLANG OFF CACHE BOOL "") set(ENABLE_CURVE OFF CACHE BOOL "") set(ENABLE_DRAFTS OFF CACHE BOOL "") +set(ENABLE_PRECOMPILED OFF CACHE BOOL "") +set(WITH_DOC OFF CACHE BOOL "") +set(WITH_DOCS OFF CACHE BOOL "") + + # Using GetProperties and Populate to be able to exclude zmq # from install (not possible with FetchContent_MakeAvailable(libzmq)) @@ -195,7 +202,7 @@ endif() # to control options for the libraries if(NOT TARGET slsProjectOptions) add_library(slsProjectOptions INTERFACE) - target_compile_features(slsProjectOptions INTERFACE cxx_std_11) +# target_compile_features(slsProjectOptions INTERFACE cxx_std_11) endif() if (NOT TARGET slsProjectWarnings) diff --git a/conda-recipe/build.sh b/conda-recipe/build.sh index 251b04477..5c3995d91 100755 --- a/conda-recipe/build.sh +++ b/conda-recipe/build.sh @@ -8,12 +8,12 @@ if [ ! -d "install" ]; then mkdir install fi cd build -cmake .. \ +cmake .. -G Ninja \ -DCMAKE_PREFIX_PATH=$CONDA_PREFIX \ -DCMAKE_INSTALL_PREFIX=install \ -DSLS_USE_TEXTCLIENT=ON \ -DSLS_USE_RECEIVER=ON \ - -DSLS_USE_GUI=ON \ + -DSLS_USE_GUI=OFF \ -DSLS_USE_MOENCH=ON\ -DSLS_USE_TESTS=ON \ -DSLS_USE_PYTHON=OFF \ @@ -25,4 +25,5 @@ echo "Building using: ${NCORES} cores" cmake --build . -- -j${NCORES} cmake --build . --target install +export SLSDETNAME=automated_tests CTEST_OUTPUT_ON_FAILURE=1 ctest -j 1 diff --git a/conda-recipe/conda_build_config.yaml b/conda-recipe/conda_build_config.yaml index 7cd2f4894..2edc7c4e1 100644 --- a/conda-recipe/conda_build_config.yaml +++ b/conda-recipe/conda_build_config.yaml @@ -6,9 +6,11 @@ python: # - 3.12 - 3.13 +c_compiler_version: # [unix] + - 11 # [linux] -c_stdlib: - - sysroot # [linux] +cxx_compiler_version: + - 11 # [linux] c_stdlib_version: # [linux] - 2.17 # [linux] diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index 37e7992cc..8ce88eea3 100755 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -15,23 +15,28 @@ build: requirements: build: - {{ compiler('c') }} - - {{stdlib('c')}} - - {{compiler('cxx')}} + - {{ compiler('cxx') }} - cmake<=3.28 - ninja - qt 5.* host: - - libstdcxx-ng - - libgcc-ng - - libgl-devel - - libtiff - - zlib + # - libstdcxx-ng + # - libgcc-ng + - xorg-libx11 + - xorg-libice + - xorg-libxext + - xorg-libsm + - xorg-libxau + - xorg-libxrender + - xorg-libxfixes - expat - + - libtiff + - libpng + run: - - libstdcxx-ng - - libgcc-ng + # - libstdcxx-ng + # - libgcc-ng outputs: @@ -42,72 +47,68 @@ outputs: build: - {{ compiler('c') }} - {{compiler('cxx')}} - - libstdcxx-ng - - libgcc-ng + # - libstdcxx-ng + # - libgcc-ng run: - - libstdcxx-ng - - libgcc-ng + # - libstdcxx-ng + # - libgcc-ng - - name: slsdet - script: - - unset CMAKE_GENERATOR && {{ PYTHON }} -m pip install . -vv # [not win] + # - name: slsdet + # script: build_pylib.sh - requirements: - build: - - python {{python}} - - {{ compiler('c') }} - - {{compiler('cxx')}} - # - {{ pin_subpackage('slsdetlib', exact=True) }} #discuss keeping pinning for simplicity? - - pybind11>=2.13 + # requirements: + # build: + # - python + # - {{ compiler('c') }} + # - {{compiler('cxx')}} + # - {{ pin_subpackage('slsdetlib', exact=True) }} + # - setuptools + # - pybind11=2.13 - host: - - cmake - - ninja - - python {{python}} - - pip - - setuptools - - pybind11>=2.13 - - scikit-build-core + # host: + # - python + # - {{ pin_subpackage('slsdetlib', exact=True) }} + # - setuptools + # - pybind11=2.13 - run: - - libstdcxx-ng - - libgcc-ng - - python {{python}} + # run: + # - libstdcxx-ng + # - libgcc-ng + # - python + # - numpy + # - {{ pin_subpackage('slsdetlib', exact=True) }} + + # test: + # imports: + # - slsdet - test: - imports: - - slsdet + # - name: slsdetgui + # script: copy_gui.sh + # requirements: + + # build: + # - {{ compiler('c') }} + # - {{compiler('cxx')}} + # - {{ pin_subpackage('slsdetlib', exact=True) }} + + # run: + # - {{ pin_subpackage('slsdetlib', exact=True) }} + # - qt 5.* + # - expat + + # - name: moenchzmq + # script: copy_moench.sh + # requirements: + + # build: + # - {{ compiler('c') }} + # - {{compiler('cxx')}} + # - {{ pin_subpackage('slsdetlib', exact=True) }} - - name: slsdetgui - script: copy_gui.sh - requirements: - - build: - - {{ compiler('c') }} - - {{compiler('cxx')}} - - {{ pin_subpackage('slsdetlib', exact=True) }} - - - run: - - {{ pin_subpackage('slsdetlib', exact=True) }} - - qt 5.* - - expat - - - name: moenchzmq - script: copy_moench.sh - requirements: - - build: - - {{ compiler('c') }} - - {{compiler('cxx')}} - - {{ pin_subpackage('slsdetlib', exact=True) }} - - - run: - - {{ pin_subpackage('slsdetlib', exact=True) }} - - expat - + # run: + # - {{ pin_subpackage('slsdetlib', exact=True) }} + # - expat diff --git a/slsDetectorSoftware/tests/test-SharedMemory.cpp b/slsDetectorSoftware/tests/test-SharedMemory.cpp index 5ba3c20a2..b16a41b25 100644 --- a/slsDetectorSoftware/tests/test-SharedMemory.cpp +++ b/slsDetectorSoftware/tests/test-SharedMemory.cpp @@ -17,155 +17,155 @@ struct Data { constexpr int shm_id = 10; -TEST_CASE("Create SharedMemory read and write", "[detector]") { +// TEST_CASE("Create SharedMemory read and write", "[detector]") { - SharedMemory shm(shm_id, -1); - shm.createSharedMemory(); - CHECK(shm.getName() == std::string("/slsDetectorPackage_detector_") + - std::to_string(shm_id)); +// SharedMemory shm(shm_id, -1); +// shm.createSharedMemory(); +// CHECK(shm.getName() == std::string("/slsDetectorPackage_detector_") + +// std::to_string(shm_id)); - shm()->x = 3; - shm()->y = 5.7; - strcpy_safe(shm()->mess, "Some string"); +// shm()->x = 3; +// shm()->y = 5.7; +// strcpy_safe(shm()->mess, "Some string"); - CHECK(shm()->x == 3); - CHECK(shm()->y == 5.7); - CHECK(std::string(shm()->mess) == "Some string"); +// CHECK(shm()->x == 3); +// CHECK(shm()->y == 5.7); +// CHECK(std::string(shm()->mess) == "Some string"); - shm.unmapSharedMemory(); - shm.removeSharedMemory(); +// shm.unmapSharedMemory(); +// shm.removeSharedMemory(); - CHECK(shm.exists() == false); -} +// CHECK(shm.exists() == false); +// } -TEST_CASE("Open existing SharedMemory and read", "[detector]") { +// TEST_CASE("Open existing SharedMemory and read", "[detector]") { - { - SharedMemory shm(shm_id, -1); - shm.createSharedMemory(); - *shm() = 5.3; - } +// { +// SharedMemory shm(shm_id, -1); +// shm.createSharedMemory(); +// *shm() = 5.3; +// } - SharedMemory shm2(shm_id, -1); - shm2.openSharedMemory(true); - CHECK(*shm2() == 5.3); +// SharedMemory shm2(shm_id, -1); +// shm2.openSharedMemory(true); +// CHECK(*shm2() == 5.3); - shm2.removeSharedMemory(); -} +// shm2.removeSharedMemory(); +// } -TEST_CASE("Creating a second shared memory with the same name throws", - "[detector]") { +// TEST_CASE("Creating a second shared memory with the same name throws", +// "[detector]") { - SharedMemory shm0(shm_id, -1); - SharedMemory shm1(shm_id, -1); +// SharedMemory shm0(shm_id, -1); +// SharedMemory shm1(shm_id, -1); - shm0.createSharedMemory(); - CHECK_THROWS(shm1.createSharedMemory()); - shm0.removeSharedMemory(); -} +// shm0.createSharedMemory(); +// CHECK_THROWS(shm1.createSharedMemory()); +// shm0.removeSharedMemory(); +// } -TEST_CASE("Open two shared memories to the same place", "[detector]") { +// TEST_CASE("Open two shared memories to the same place", "[detector]") { - // Create the first shared memory - SharedMemory shm(shm_id, -1); - shm.createSharedMemory(); - shm()->x = 5; - CHECK(shm()->x == 5); +// // Create the first shared memory +// SharedMemory shm(shm_id, -1); +// shm.createSharedMemory(); +// shm()->x = 5; +// CHECK(shm()->x == 5); - // Open the second shared memory with the same name - SharedMemory shm2(shm_id, -1); - shm2.openSharedMemory(true); - CHECK(shm2()->x == 5); - CHECK(shm.getName() == shm2.getName()); +// // Open the second shared memory with the same name +// SharedMemory shm2(shm_id, -1); +// shm2.openSharedMemory(true); +// CHECK(shm2()->x == 5); +// CHECK(shm.getName() == shm2.getName()); - // Check that they still point to the same place - shm2()->x = 7; - CHECK(shm()->x == 7); +// // Check that they still point to the same place +// shm2()->x = 7; +// CHECK(shm()->x == 7); - // Remove only needs to be done once since they refer - // to the same memory - shm2.removeSharedMemory(); - CHECK(shm.exists() == false); - CHECK(shm2.exists() == false); -} +// // Remove only needs to be done once since they refer +// // to the same memory +// shm2.removeSharedMemory(); +// CHECK(shm.exists() == false); +// CHECK(shm2.exists() == false); +// } -TEST_CASE("Move SharedMemory", "[detector]") { +// TEST_CASE("Move SharedMemory", "[detector]") { - SharedMemory shm(shm_id, -1); - CHECK(shm.getName() == std::string("/slsDetectorPackage_detector_") + - std::to_string(shm_id)); - shm.createSharedMemory(); - shm()->x = 9; +// SharedMemory shm(shm_id, -1); +// CHECK(shm.getName() == std::string("/slsDetectorPackage_detector_") + +// std::to_string(shm_id)); +// shm.createSharedMemory(); +// shm()->x = 9; - SharedMemory shm2(shm_id + 1, -1); - shm2 = std::move(shm); // shm is now a moved from object! +// SharedMemory shm2(shm_id + 1, -1); +// shm2 = std::move(shm); // shm is now a moved from object! - CHECK(shm2()->x == 9); - REQUIRE_THROWS( - shm()); // trying to access should throw instead of returning a nullptr - CHECK(shm2.getName() == std::string("/slsDetectorPackage_detector_") + - std::to_string(shm_id)); - shm2.removeSharedMemory(); -} +// CHECK(shm2()->x == 9); +// REQUIRE_THROWS( +// shm()); // trying to access should throw instead of returning a nullptr +// CHECK(shm2.getName() == std::string("/slsDetectorPackage_detector_") + +// std::to_string(shm_id)); +// shm2.removeSharedMemory(); +// } -TEST_CASE("Create several shared memories", "[detector]") { - constexpr int N = 5; - std::vector> v; - v.reserve(N); - for (int i = 0; i != N; ++i) { - v.emplace_back(shm_id + i, -1); - CHECK(v[i].exists() == false); - v[i].createSharedMemory(); - *v[i]() = i; - CHECK(*v[i]() == i); - } +// TEST_CASE("Create several shared memories", "[detector]") { +// constexpr int N = 5; +// std::vector> v; +// v.reserve(N); +// for (int i = 0; i != N; ++i) { +// v.emplace_back(shm_id + i, -1); +// CHECK(v[i].exists() == false); +// v[i].createSharedMemory(); +// *v[i]() = i; +// CHECK(*v[i]() == i); +// } - for (int i = 0; i != N; ++i) { - CHECK(*v[i]() == i); - CHECK(v[i].getName() == std::string("/slsDetectorPackage_detector_") + - std::to_string(i + shm_id)); - } +// for (int i = 0; i != N; ++i) { +// CHECK(*v[i]() == i); +// CHECK(v[i].getName() == std::string("/slsDetectorPackage_detector_") + +// std::to_string(i + shm_id)); +// } - for (int i = 0; i != N; ++i) { - v[i].removeSharedMemory(); - CHECK(v[i].exists() == false); - } -} +// for (int i = 0; i != N; ++i) { +// v[i].removeSharedMemory(); +// CHECK(v[i].exists() == false); +// } +// } -TEST_CASE("Create create a shared memory with a tag") { - SharedMemory shm(0, -1, "ctbdacs"); - REQUIRE(shm.getName() == "/slsDetectorPackage_detector_0_ctbdacs"); -} +// TEST_CASE("Create create a shared memory with a tag") { +// SharedMemory shm(0, -1, "ctbdacs"); +// REQUIRE(shm.getName() == "/slsDetectorPackage_detector_0_ctbdacs"); +// } -TEST_CASE("Create create a shared memory with a tag when SLSDETNAME is set") { +// TEST_CASE("Create create a shared memory with a tag when SLSDETNAME is set") { - // if SLSDETNAME is already set we unset it but - // save the value - std::string old_slsdetname; - if (getenv(SHM_ENV_NAME)) - old_slsdetname = getenv(SHM_ENV_NAME); - unsetenv(SHM_ENV_NAME); - setenv(SHM_ENV_NAME, "myprefix", 1); +// // if SLSDETNAME is already set we unset it but +// // save the value +// std::string old_slsdetname; +// if (getenv(SHM_ENV_NAME)) +// old_slsdetname = getenv(SHM_ENV_NAME); +// unsetenv(SHM_ENV_NAME); +// setenv(SHM_ENV_NAME, "myprefix", 1); - SharedMemory shm(0, -1, "ctbdacs"); - REQUIRE(shm.getName() == "/slsDetectorPackage_detector_0_myprefix_ctbdacs"); +// SharedMemory shm(0, -1, "ctbdacs"); +// REQUIRE(shm.getName() == "/slsDetectorPackage_detector_0_myprefix_ctbdacs"); - // Clean up after us - if (old_slsdetname.empty()) - unsetenv(SHM_ENV_NAME); - else - setenv(SHM_ENV_NAME, old_slsdetname.c_str(), 1); -} +// // Clean up after us +// if (old_slsdetname.empty()) +// unsetenv(SHM_ENV_NAME); +// else +// setenv(SHM_ENV_NAME, old_slsdetname.c_str(), 1); +// } -TEST_CASE("map int64 to int32 throws") { - SharedMemory shm(shm_id, -1); - shm.createSharedMemory(); - *shm() = 7; +// TEST_CASE("map int64 to int32 throws") { +// SharedMemory shm(shm_id, -1); +// shm.createSharedMemory(); +// *shm() = 7; - SharedMemory shm2(shm_id, -1); - REQUIRE_THROWS(shm2.openSharedMemory(true)); +// SharedMemory shm2(shm_id, -1); +// REQUIRE_THROWS(shm2.openSharedMemory(true)); - shm.removeSharedMemory(); -} +// shm.removeSharedMemory(); +// } } // namespace sls From a230c95b0e9f2b8ed626aeb4719a621ca06789d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=B6jd=20Lars=20Erik?= Date: Wed, 19 Mar 2025 21:49:12 +0100 Subject: [PATCH 05/42] separated the recipes --- conda-recipe/build_pylib.sh | 11 -- conda-recipe/conda_build_config.yaml | 16 --- conda-recipe/copy_ctbgui.sh | 11 -- conda-recipe/copy_lib.sh | 23 ---- conda-recipe/meta.yaml | 114 ------------------ conda-recipe/run_test.sh | 3 - .../main-library}/build.sh | 2 +- .../main-library/conda_build_config.yaml | 26 ++++ .../main-library}/copy_gui.sh | 0 conda-recipes/main-library/copy_lib.sh | 23 ++++ .../main-library}/copy_moench.sh | 0 conda-recipes/main-library/meta.yaml | 104 ++++++++++++++++ .../python-client/conda_build_config.yaml | 26 ++++ conda-recipes/python-client/meta.yaml | 46 +++++++ pyproject.toml | 2 +- 15 files changed, 227 insertions(+), 180 deletions(-) delete mode 100755 conda-recipe/build_pylib.sh delete mode 100644 conda-recipe/conda_build_config.yaml delete mode 100644 conda-recipe/copy_ctbgui.sh delete mode 100755 conda-recipe/copy_lib.sh delete mode 100755 conda-recipe/meta.yaml delete mode 100755 conda-recipe/run_test.sh rename {conda-recipe => conda-recipes/main-library}/build.sh (96%) create mode 100644 conda-recipes/main-library/conda_build_config.yaml rename {conda-recipe => conda-recipes/main-library}/copy_gui.sh (100%) create mode 100755 conda-recipes/main-library/copy_lib.sh rename {conda-recipe => conda-recipes/main-library}/copy_moench.sh (100%) create mode 100755 conda-recipes/main-library/meta.yaml create mode 100644 conda-recipes/python-client/conda_build_config.yaml create mode 100644 conda-recipes/python-client/meta.yaml diff --git a/conda-recipe/build_pylib.sh b/conda-recipe/build_pylib.sh deleted file mode 100755 index 18b0615ab..000000000 --- a/conda-recipe/build_pylib.sh +++ /dev/null @@ -1,11 +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 - -# copy VERSION into slsdet for installation -cp ../VERSION slsdet/VERSION - -${PYTHON} setup.py install diff --git a/conda-recipe/conda_build_config.yaml b/conda-recipe/conda_build_config.yaml deleted file mode 100644 index 2edc7c4e1..000000000 --- a/conda-recipe/conda_build_config.yaml +++ /dev/null @@ -1,16 +0,0 @@ -python: - # - 3.8 - # - 3.9 - # - 3.10 - # - 3.11 - # - 3.12 - - 3.13 - -c_compiler_version: # [unix] - - 11 # [linux] - -cxx_compiler_version: - - 11 # [linux] - -c_stdlib_version: # [linux] - - 2.17 # [linux] diff --git a/conda-recipe/copy_ctbgui.sh b/conda-recipe/copy_ctbgui.sh deleted file mode 100644 index b4f52efce..000000000 --- a/conda-recipe/copy_ctbgui.sh +++ /dev/null @@ -1,11 +0,0 @@ -# SPDX-License-Identifier: LGPL-3.0-or-other -# Copyright (C) 2021 Contributors to the SLS Detector Package -mkdir $PREFIX/lib -mkdir $PREFIX/bin -mkdir $PREFIX/include - - - -cp build/bin/ctbGui $PREFIX/bin/. -cp build/bin/libctbRootLib.so $PREFIX/lib/. - diff --git a/conda-recipe/copy_lib.sh b/conda-recipe/copy_lib.sh deleted file mode 100755 index 5836146f6..000000000 --- a/conda-recipe/copy_lib.sh +++ /dev/null @@ -1,23 +0,0 @@ -# SPDX-License-Identifier: LGPL-3.0-or-other -# Copyright (C) 2021 Contributors to the SLS Detector Package - -mkdir -p $PREFIX/lib -mkdir -p $PREFIX/bin -mkdir -p $PREFIX/include/sls -# mkdir $PREFIX/include/slsDetectorPackage - -#Shared and static libraries -cp build/install/lib/* $PREFIX/lib/ - -#Binaries -cp build/install/bin/sls_detector_acquire $PREFIX/bin/. -cp build/install/bin/sls_detector_acquire_zmq $PREFIX/bin/. -cp build/install/bin/sls_detector_get $PREFIX/bin/. -cp build/install/bin/sls_detector_put $PREFIX/bin/. -cp build/install/bin/sls_detector_help $PREFIX/bin/. -cp build/install/bin/slsReceiver $PREFIX/bin/. -cp build/install/bin/slsMultiReceiver $PREFIX/bin/. - - -cp build/install/include/sls/* $PREFIX/include/sls -cp -rv build/install/share $PREFIX diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml deleted file mode 100755 index 8ce88eea3..000000000 --- a/conda-recipe/meta.yaml +++ /dev/null @@ -1,114 +0,0 @@ -package: - name: sls_detector_software - version: {{ environ.get('GIT_DESCRIBE_TAG', '') }} - - -source: - path: .. - -build: - number: 0 - binary_relocation: True - rpaths: - - lib/ - -requirements: - build: - - {{ compiler('c') }} - - {{ compiler('cxx') }} - - cmake<=3.28 - - ninja - - qt 5.* - - host: - # - libstdcxx-ng - # - libgcc-ng - - xorg-libx11 - - xorg-libice - - xorg-libxext - - xorg-libsm - - xorg-libxau - - xorg-libxrender - - xorg-libxfixes - - expat - - libtiff - - libpng - - run: - # - libstdcxx-ng - # - libgcc-ng - - -outputs: - - name: slsdetlib - script: copy_lib.sh - - requirements: - build: - - {{ compiler('c') }} - - {{compiler('cxx')}} - # - libstdcxx-ng - # - libgcc-ng - - run: - # - libstdcxx-ng - # - libgcc-ng - - # - name: slsdet - # script: build_pylib.sh - - # requirements: - # build: - # - python - # - {{ compiler('c') }} - # - {{compiler('cxx')}} - # - {{ pin_subpackage('slsdetlib', exact=True) }} - # - setuptools - # - pybind11=2.13 - - # host: - # - python - # - {{ pin_subpackage('slsdetlib', exact=True) }} - # - setuptools - # - pybind11=2.13 - - - # run: - # - libstdcxx-ng - # - libgcc-ng - # - python - # - numpy - # - {{ pin_subpackage('slsdetlib', exact=True) }} - - # test: - # imports: - # - slsdet - - - # - name: slsdetgui - # script: copy_gui.sh - # requirements: - - # build: - # - {{ compiler('c') }} - # - {{compiler('cxx')}} - # - {{ pin_subpackage('slsdetlib', exact=True) }} - - # run: - # - {{ pin_subpackage('slsdetlib', exact=True) }} - # - qt 5.* - # - expat - - # - name: moenchzmq - # script: copy_moench.sh - # requirements: - - # build: - # - {{ compiler('c') }} - # - {{compiler('cxx')}} - # - {{ pin_subpackage('slsdetlib', exact=True) }} - - - # run: - # - {{ pin_subpackage('slsdetlib', exact=True) }} - # - expat diff --git a/conda-recipe/run_test.sh b/conda-recipe/run_test.sh deleted file mode 100755 index 24068d625..000000000 --- a/conda-recipe/run_test.sh +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-License-Identifier: LGPL-3.0-or-other -# Copyright (C) 2021 Contributors to the SLS Detector Package -ctest -j2 \ No newline at end of file diff --git a/conda-recipe/build.sh b/conda-recipes/main-library/build.sh similarity index 96% rename from conda-recipe/build.sh rename to conda-recipes/main-library/build.sh index 5c3995d91..f2505361a 100755 --- a/conda-recipe/build.sh +++ b/conda-recipes/main-library/build.sh @@ -13,7 +13,7 @@ cmake .. -G Ninja \ -DCMAKE_INSTALL_PREFIX=install \ -DSLS_USE_TEXTCLIENT=ON \ -DSLS_USE_RECEIVER=ON \ - -DSLS_USE_GUI=OFF \ + -DSLS_USE_GUI=ON \ -DSLS_USE_MOENCH=ON\ -DSLS_USE_TESTS=ON \ -DSLS_USE_PYTHON=OFF \ diff --git a/conda-recipes/main-library/conda_build_config.yaml b/conda-recipes/main-library/conda_build_config.yaml new file mode 100644 index 000000000..46fa5230e --- /dev/null +++ b/conda-recipes/main-library/conda_build_config.yaml @@ -0,0 +1,26 @@ +python: + # - 3.8 + # - 3.9 + # - 3.10 + # - 3.11 + # - 3.12 + - 3.13 + +c_compiler: + - gcc # [linux] + +c_compiler_version: + - 13 # [linux] + +c_stdlib: + - sysroot # [linux] + +cxx_compiler: + - gxx # [linux] + + +cxx_compiler_version: + - 13 # [linux] + +c_stdlib_version: # [linux] + - 2.17 # [linux] \ No newline at end of file diff --git a/conda-recipe/copy_gui.sh b/conda-recipes/main-library/copy_gui.sh similarity index 100% rename from conda-recipe/copy_gui.sh rename to conda-recipes/main-library/copy_gui.sh diff --git a/conda-recipes/main-library/copy_lib.sh b/conda-recipes/main-library/copy_lib.sh new file mode 100755 index 000000000..ad5de9f47 --- /dev/null +++ b/conda-recipes/main-library/copy_lib.sh @@ -0,0 +1,23 @@ +# # SPDX-License-Identifier: LGPL-3.0-or-other +# # Copyright (C) 2021 Contributors to the SLS Detector Package + +# mkdir -p $PREFIX/lib +# mkdir -p $PREFIX/bin +# mkdir -p $PREFIX/include/sls +# # mkdir $PREFIX/include/slsDetectorPackage + +# #Shared and static libraries +# cp build/install/lib/* $PREFIX/lib/ + +# #Binaries +# cp build/install/bin/sls_detector_acquire $PREFIX/bin/. +# cp build/install/bin/sls_detector_acquire_zmq $PREFIX/bin/. +# cp build/install/bin/sls_detector_get $PREFIX/bin/. +# cp build/install/bin/sls_detector_put $PREFIX/bin/. +# cp build/install/bin/sls_detector_help $PREFIX/bin/. +# cp build/install/bin/slsReceiver $PREFIX/bin/. +# cp build/install/bin/slsMultiReceiver $PREFIX/bin/. + + +# cp build/install/include/sls/* $PREFIX/include/sls +# cp -rv build/install/share $PREFIX diff --git a/conda-recipe/copy_moench.sh b/conda-recipes/main-library/copy_moench.sh similarity index 100% rename from conda-recipe/copy_moench.sh rename to conda-recipes/main-library/copy_moench.sh diff --git a/conda-recipes/main-library/meta.yaml b/conda-recipes/main-library/meta.yaml new file mode 100755 index 000000000..762ce7d9f --- /dev/null +++ b/conda-recipes/main-library/meta.yaml @@ -0,0 +1,104 @@ +package: + name: sls_detector_software + version: 2025.3.19 + + +source: + path: ../.. + +build: + number: 0 + binary_relocation: True + rpaths: + - lib/ + +requirements: + build: + - {{ compiler('c') }} + - {{ stdlib("c") }} + - {{ compiler('cxx') }} + + - cmake + - ninja + - qt 5.* + # - xorg-libx11 + # - xorg-libice + # - xorg-libxext + # - xorg-libsm + # - xorg-libxau + # - xorg-libxrender + # - xorg-libxfixes + # - {{ cdt('mesa-libgl-devel') }} # [linux] + # - {{ cdt('mesa-libegl-devel') }} # [linux] + # - {{ cdt('mesa-dri-drivers') }} # [linux] + # - {{ cdt('libselinux') }} # [linux] + # - {{ cdt('libxdamage') }} # [linux] + # - {{ cdt('libxxf86vm') }} # [linux] + # - expat + + host: + - libstdcxx-ng + - libgcc-ng + - libgl-devel # [linux] + # - xorg-libx11 + # - xorg-libice + # - xorg-libxext + # - xorg-libsm + # - xorg-libxau + # - xorg-libxrender + # - xorg-libxfixes + # - expat + - libtiff + # - libpng + + run: + # - libstdcxx-ng + # - libgcc-ng + + +outputs: + - name: slsdetlib + script: copy_lib.sh + + requirements: + build: + - {{ compiler('c') }} + - {{ stdlib("c") }} + - {{ compiler('cxx') }} + # - libstdcxx-ng + # - libgcc-ng + + run: + # - libstdcxx-ng + # - libgcc-ng + + + + + - name: slsdetgui + script: copy_gui.sh + requirements: + + build: + - {{ compiler('c') }} + - {{compiler('cxx')}} + - {{ pin_subpackage('slsdetlib', exact=True) }} + + run: + - {{ pin_subpackage('slsdetlib', exact=True) }} + - qt 5.* + - expat + + - name: moenchzmq + script: copy_moench.sh + requirements: + + build: + - {{ compiler('c') }} + - {{compiler('cxx')}} + - {{ pin_subpackage('slsdetlib', exact=True) }} + + + run: + - {{ pin_subpackage('slsdetlib', exact=True) }} + - expat \ No newline at end of file diff --git a/conda-recipes/python-client/conda_build_config.yaml b/conda-recipes/python-client/conda_build_config.yaml new file mode 100644 index 000000000..46fa5230e --- /dev/null +++ b/conda-recipes/python-client/conda_build_config.yaml @@ -0,0 +1,26 @@ +python: + # - 3.8 + # - 3.9 + # - 3.10 + # - 3.11 + # - 3.12 + - 3.13 + +c_compiler: + - gcc # [linux] + +c_compiler_version: + - 13 # [linux] + +c_stdlib: + - sysroot # [linux] + +cxx_compiler: + - gxx # [linux] + + +cxx_compiler_version: + - 13 # [linux] + +c_stdlib_version: # [linux] + - 2.17 # [linux] \ No newline at end of file diff --git a/conda-recipes/python-client/meta.yaml b/conda-recipes/python-client/meta.yaml new file mode 100644 index 000000000..9add4b13b --- /dev/null +++ b/conda-recipes/python-client/meta.yaml @@ -0,0 +1,46 @@ +package: + name: slsdet + version: 2025.2.18 #TODO! how to not duplicate this? + +source: + path: ../.. + +build: + number: 0 + script: + - unset CMAKE_GENERATOR && {{ PYTHON }} -m pip install . -vv # [not win] + - {{ PYTHON }} -m pip install . -vv # [win] + +requirements: + build: + - python {{python}} + - {{ compiler('c') }} + - {{ stdlib("c") }} + - {{ compiler('cxx') }} + + + host: + - cmake + - ninja + - python {{python}} + - pip + - scikit-build-core + - pybind11 >=2.13.0 + - fmt + - zeromq + - nlohmann_json + - catch2 + + run: + - python {{python}} + - numpy + + +test: + imports: + - slsdet + + +about: + summary: An example project built with pybind11 and scikit-build. + # license_file: LICENSE \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index df5a2a852..35709dae1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build" [project] name = "slsdet" -version = "2025.2.18" +version = "2025.3.19" [tool.scikit-build] From daf5cb336935b4182dc0d0fed853ad702e6dd974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=B6jd=20Lars=20Erik?= Date: Wed, 19 Mar 2025 21:59:30 +0100 Subject: [PATCH 06/42] restored comments, cleanup --- CMakeLists.txt | 7 +- conda-recipes/main-library/build.sh | 1 - conda-recipes/main-library/copy_lib.sh | 35 ++- .../tests/test-SharedMemory.cpp | 236 +++++++++--------- 4 files changed, 136 insertions(+), 143 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f3055e34f..0aa6dcd5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,8 +13,6 @@ set(PROJECT_VERSION ${PROJECT_VERSION_STRING}) add_compile_definitions(SLS_DET_VERSION="${PROJECT_VERSION}") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) cmake_policy(SET CMP0074 NEW) @@ -31,9 +29,6 @@ include(FetchContent) option(SLS_FETCH_ZMQ_FROM_GITHUB "Fetch zmq from github" OFF) option(SLS_FETCH_PYBIND11_FROM_GITHUB "Fetch pybind11 from github" OFF) -if(${SKBUILD}) - message(STATUS "Building with scikit-build") -endif() if(SLS_FETCH_ZMQ_FROM_GITHUB) # Opt in to pull down a zmq version from github instead of @@ -202,7 +197,7 @@ endif() # to control options for the libraries if(NOT TARGET slsProjectOptions) add_library(slsProjectOptions INTERFACE) -# target_compile_features(slsProjectOptions INTERFACE cxx_std_11) + target_compile_features(slsProjectOptions INTERFACE cxx_std_11) endif() if (NOT TARGET slsProjectWarnings) diff --git a/conda-recipes/main-library/build.sh b/conda-recipes/main-library/build.sh index f2505361a..730271b6e 100755 --- a/conda-recipes/main-library/build.sh +++ b/conda-recipes/main-library/build.sh @@ -25,5 +25,4 @@ echo "Building using: ${NCORES} cores" cmake --build . -- -j${NCORES} cmake --build . --target install -export SLSDETNAME=automated_tests CTEST_OUTPUT_ON_FAILURE=1 ctest -j 1 diff --git a/conda-recipes/main-library/copy_lib.sh b/conda-recipes/main-library/copy_lib.sh index ad5de9f47..72343b565 100755 --- a/conda-recipes/main-library/copy_lib.sh +++ b/conda-recipes/main-library/copy_lib.sh @@ -1,23 +1,22 @@ -# # SPDX-License-Identifier: LGPL-3.0-or-other -# # Copyright (C) 2021 Contributors to the SLS Detector Package +# SPDX-License-Identifier: LGPL-3.0-or-other +# Copyright (C) 2021 Contributors to the SLS Detector Package -# mkdir -p $PREFIX/lib -# mkdir -p $PREFIX/bin -# mkdir -p $PREFIX/include/sls -# # mkdir $PREFIX/include/slsDetectorPackage +mkdir -p $PREFIX/lib +mkdir -p $PREFIX/bin +mkdir -p $PREFIX/include/sls -# #Shared and static libraries -# cp build/install/lib/* $PREFIX/lib/ +#Shared and static libraries +cp build/install/lib/* $PREFIX/lib/ -# #Binaries -# cp build/install/bin/sls_detector_acquire $PREFIX/bin/. -# cp build/install/bin/sls_detector_acquire_zmq $PREFIX/bin/. -# cp build/install/bin/sls_detector_get $PREFIX/bin/. -# cp build/install/bin/sls_detector_put $PREFIX/bin/. -# cp build/install/bin/sls_detector_help $PREFIX/bin/. -# cp build/install/bin/slsReceiver $PREFIX/bin/. -# cp build/install/bin/slsMultiReceiver $PREFIX/bin/. +#Binaries +cp build/install/bin/sls_detector_acquire $PREFIX/bin/. +cp build/install/bin/sls_detector_acquire_zmq $PREFIX/bin/. +cp build/install/bin/sls_detector_get $PREFIX/bin/. +cp build/install/bin/sls_detector_put $PREFIX/bin/. +cp build/install/bin/sls_detector_help $PREFIX/bin/. +cp build/install/bin/slsReceiver $PREFIX/bin/. +cp build/install/bin/slsMultiReceiver $PREFIX/bin/. -# cp build/install/include/sls/* $PREFIX/include/sls -# cp -rv build/install/share $PREFIX +cp build/install/include/sls/* $PREFIX/include/sls +cp -rv build/install/share $PREFIX diff --git a/slsDetectorSoftware/tests/test-SharedMemory.cpp b/slsDetectorSoftware/tests/test-SharedMemory.cpp index b16a41b25..5ba3c20a2 100644 --- a/slsDetectorSoftware/tests/test-SharedMemory.cpp +++ b/slsDetectorSoftware/tests/test-SharedMemory.cpp @@ -17,155 +17,155 @@ struct Data { constexpr int shm_id = 10; -// TEST_CASE("Create SharedMemory read and write", "[detector]") { +TEST_CASE("Create SharedMemory read and write", "[detector]") { -// SharedMemory shm(shm_id, -1); -// shm.createSharedMemory(); -// CHECK(shm.getName() == std::string("/slsDetectorPackage_detector_") + -// std::to_string(shm_id)); + SharedMemory shm(shm_id, -1); + shm.createSharedMemory(); + CHECK(shm.getName() == std::string("/slsDetectorPackage_detector_") + + std::to_string(shm_id)); -// shm()->x = 3; -// shm()->y = 5.7; -// strcpy_safe(shm()->mess, "Some string"); + shm()->x = 3; + shm()->y = 5.7; + strcpy_safe(shm()->mess, "Some string"); -// CHECK(shm()->x == 3); -// CHECK(shm()->y == 5.7); -// CHECK(std::string(shm()->mess) == "Some string"); + CHECK(shm()->x == 3); + CHECK(shm()->y == 5.7); + CHECK(std::string(shm()->mess) == "Some string"); -// shm.unmapSharedMemory(); -// shm.removeSharedMemory(); + shm.unmapSharedMemory(); + shm.removeSharedMemory(); -// CHECK(shm.exists() == false); -// } + CHECK(shm.exists() == false); +} -// TEST_CASE("Open existing SharedMemory and read", "[detector]") { +TEST_CASE("Open existing SharedMemory and read", "[detector]") { -// { -// SharedMemory shm(shm_id, -1); -// shm.createSharedMemory(); -// *shm() = 5.3; -// } + { + SharedMemory shm(shm_id, -1); + shm.createSharedMemory(); + *shm() = 5.3; + } -// SharedMemory shm2(shm_id, -1); -// shm2.openSharedMemory(true); -// CHECK(*shm2() == 5.3); + SharedMemory shm2(shm_id, -1); + shm2.openSharedMemory(true); + CHECK(*shm2() == 5.3); -// shm2.removeSharedMemory(); -// } + shm2.removeSharedMemory(); +} -// TEST_CASE("Creating a second shared memory with the same name throws", -// "[detector]") { +TEST_CASE("Creating a second shared memory with the same name throws", + "[detector]") { -// SharedMemory shm0(shm_id, -1); -// SharedMemory shm1(shm_id, -1); + SharedMemory shm0(shm_id, -1); + SharedMemory shm1(shm_id, -1); -// shm0.createSharedMemory(); -// CHECK_THROWS(shm1.createSharedMemory()); -// shm0.removeSharedMemory(); -// } + shm0.createSharedMemory(); + CHECK_THROWS(shm1.createSharedMemory()); + shm0.removeSharedMemory(); +} -// TEST_CASE("Open two shared memories to the same place", "[detector]") { +TEST_CASE("Open two shared memories to the same place", "[detector]") { -// // Create the first shared memory -// SharedMemory shm(shm_id, -1); -// shm.createSharedMemory(); -// shm()->x = 5; -// CHECK(shm()->x == 5); + // Create the first shared memory + SharedMemory shm(shm_id, -1); + shm.createSharedMemory(); + shm()->x = 5; + CHECK(shm()->x == 5); -// // Open the second shared memory with the same name -// SharedMemory shm2(shm_id, -1); -// shm2.openSharedMemory(true); -// CHECK(shm2()->x == 5); -// CHECK(shm.getName() == shm2.getName()); + // Open the second shared memory with the same name + SharedMemory shm2(shm_id, -1); + shm2.openSharedMemory(true); + CHECK(shm2()->x == 5); + CHECK(shm.getName() == shm2.getName()); -// // Check that they still point to the same place -// shm2()->x = 7; -// CHECK(shm()->x == 7); + // Check that they still point to the same place + shm2()->x = 7; + CHECK(shm()->x == 7); -// // Remove only needs to be done once since they refer -// // to the same memory -// shm2.removeSharedMemory(); -// CHECK(shm.exists() == false); -// CHECK(shm2.exists() == false); -// } + // Remove only needs to be done once since they refer + // to the same memory + shm2.removeSharedMemory(); + CHECK(shm.exists() == false); + CHECK(shm2.exists() == false); +} -// TEST_CASE("Move SharedMemory", "[detector]") { +TEST_CASE("Move SharedMemory", "[detector]") { -// SharedMemory shm(shm_id, -1); -// CHECK(shm.getName() == std::string("/slsDetectorPackage_detector_") + -// std::to_string(shm_id)); -// shm.createSharedMemory(); -// shm()->x = 9; + SharedMemory shm(shm_id, -1); + CHECK(shm.getName() == std::string("/slsDetectorPackage_detector_") + + std::to_string(shm_id)); + shm.createSharedMemory(); + shm()->x = 9; -// SharedMemory shm2(shm_id + 1, -1); -// shm2 = std::move(shm); // shm is now a moved from object! + SharedMemory shm2(shm_id + 1, -1); + shm2 = std::move(shm); // shm is now a moved from object! -// CHECK(shm2()->x == 9); -// REQUIRE_THROWS( -// shm()); // trying to access should throw instead of returning a nullptr -// CHECK(shm2.getName() == std::string("/slsDetectorPackage_detector_") + -// std::to_string(shm_id)); -// shm2.removeSharedMemory(); -// } + CHECK(shm2()->x == 9); + REQUIRE_THROWS( + shm()); // trying to access should throw instead of returning a nullptr + CHECK(shm2.getName() == std::string("/slsDetectorPackage_detector_") + + std::to_string(shm_id)); + shm2.removeSharedMemory(); +} -// TEST_CASE("Create several shared memories", "[detector]") { -// constexpr int N = 5; -// std::vector> v; -// v.reserve(N); -// for (int i = 0; i != N; ++i) { -// v.emplace_back(shm_id + i, -1); -// CHECK(v[i].exists() == false); -// v[i].createSharedMemory(); -// *v[i]() = i; -// CHECK(*v[i]() == i); -// } +TEST_CASE("Create several shared memories", "[detector]") { + constexpr int N = 5; + std::vector> v; + v.reserve(N); + for (int i = 0; i != N; ++i) { + v.emplace_back(shm_id + i, -1); + CHECK(v[i].exists() == false); + v[i].createSharedMemory(); + *v[i]() = i; + CHECK(*v[i]() == i); + } -// for (int i = 0; i != N; ++i) { -// CHECK(*v[i]() == i); -// CHECK(v[i].getName() == std::string("/slsDetectorPackage_detector_") + -// std::to_string(i + shm_id)); -// } + for (int i = 0; i != N; ++i) { + CHECK(*v[i]() == i); + CHECK(v[i].getName() == std::string("/slsDetectorPackage_detector_") + + std::to_string(i + shm_id)); + } -// for (int i = 0; i != N; ++i) { -// v[i].removeSharedMemory(); -// CHECK(v[i].exists() == false); -// } -// } + for (int i = 0; i != N; ++i) { + v[i].removeSharedMemory(); + CHECK(v[i].exists() == false); + } +} -// TEST_CASE("Create create a shared memory with a tag") { -// SharedMemory shm(0, -1, "ctbdacs"); -// REQUIRE(shm.getName() == "/slsDetectorPackage_detector_0_ctbdacs"); -// } +TEST_CASE("Create create a shared memory with a tag") { + SharedMemory shm(0, -1, "ctbdacs"); + REQUIRE(shm.getName() == "/slsDetectorPackage_detector_0_ctbdacs"); +} -// TEST_CASE("Create create a shared memory with a tag when SLSDETNAME is set") { +TEST_CASE("Create create a shared memory with a tag when SLSDETNAME is set") { -// // if SLSDETNAME is already set we unset it but -// // save the value -// std::string old_slsdetname; -// if (getenv(SHM_ENV_NAME)) -// old_slsdetname = getenv(SHM_ENV_NAME); -// unsetenv(SHM_ENV_NAME); -// setenv(SHM_ENV_NAME, "myprefix", 1); + // if SLSDETNAME is already set we unset it but + // save the value + std::string old_slsdetname; + if (getenv(SHM_ENV_NAME)) + old_slsdetname = getenv(SHM_ENV_NAME); + unsetenv(SHM_ENV_NAME); + setenv(SHM_ENV_NAME, "myprefix", 1); -// SharedMemory shm(0, -1, "ctbdacs"); -// REQUIRE(shm.getName() == "/slsDetectorPackage_detector_0_myprefix_ctbdacs"); + SharedMemory shm(0, -1, "ctbdacs"); + REQUIRE(shm.getName() == "/slsDetectorPackage_detector_0_myprefix_ctbdacs"); -// // Clean up after us -// if (old_slsdetname.empty()) -// unsetenv(SHM_ENV_NAME); -// else -// setenv(SHM_ENV_NAME, old_slsdetname.c_str(), 1); -// } + // Clean up after us + if (old_slsdetname.empty()) + unsetenv(SHM_ENV_NAME); + else + setenv(SHM_ENV_NAME, old_slsdetname.c_str(), 1); +} -// TEST_CASE("map int64 to int32 throws") { -// SharedMemory shm(shm_id, -1); -// shm.createSharedMemory(); -// *shm() = 7; +TEST_CASE("map int64 to int32 throws") { + SharedMemory shm(shm_id, -1); + shm.createSharedMemory(); + *shm() = 7; -// SharedMemory shm2(shm_id, -1); -// REQUIRE_THROWS(shm2.openSharedMemory(true)); + SharedMemory shm2(shm_id, -1); + REQUIRE_THROWS(shm2.openSharedMemory(true)); -// shm.removeSharedMemory(); -// } + shm.removeSharedMemory(); +} } // namespace sls From 59069a29c528857aeb1f269c8d1572c019107c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=B6jd=20Lars=20Erik?= Date: Wed, 19 Mar 2025 22:03:22 +0100 Subject: [PATCH 07/42] cleaned meta yaml --- conda-recipes/main-library/meta.yaml | 36 ++++------------------------ 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/conda-recipes/main-library/meta.yaml b/conda-recipes/main-library/meta.yaml index 762ce7d9f..cdbe70405 100755 --- a/conda-recipes/main-library/meta.yaml +++ b/conda-recipes/main-library/meta.yaml @@ -21,39 +21,16 @@ requirements: - cmake - ninja - qt 5.* - # - xorg-libx11 - # - xorg-libice - # - xorg-libxext - # - xorg-libsm - # - xorg-libxau - # - xorg-libxrender - # - xorg-libxfixes - # - {{ cdt('mesa-libgl-devel') }} # [linux] - # - {{ cdt('mesa-libegl-devel') }} # [linux] - # - {{ cdt('mesa-dri-drivers') }} # [linux] - # - {{ cdt('libselinux') }} # [linux] - # - {{ cdt('libxdamage') }} # [linux] - # - {{ cdt('libxxf86vm') }} # [linux] - # - expat host: - libstdcxx-ng - libgcc-ng - libgl-devel # [linux] - # - xorg-libx11 - # - xorg-libice - # - xorg-libxext - # - xorg-libsm - # - xorg-libxau - # - xorg-libxrender - # - xorg-libxfixes - # - expat - libtiff - # - libpng run: - # - libstdcxx-ng - # - libgcc-ng + - libstdcxx-ng + - libgcc-ng outputs: @@ -65,12 +42,10 @@ outputs: - {{ compiler('c') }} - {{ stdlib("c") }} - {{ compiler('cxx') }} - # - libstdcxx-ng - # - libgcc-ng run: - # - libstdcxx-ng - # - libgcc-ng + - libstdcxx-ng + - libgcc-ng @@ -87,7 +62,7 @@ outputs: run: - {{ pin_subpackage('slsdetlib', exact=True) }} - qt 5.* - - expat + - name: moenchzmq script: copy_moench.sh @@ -101,4 +76,3 @@ outputs: run: - {{ pin_subpackage('slsdetlib', exact=True) }} - - expat \ No newline at end of file From c8efe5d10c975745226315551ebee5c202aa5648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=B6jd=20Lars=20Erik?= Date: Wed, 19 Mar 2025 22:05:19 +0100 Subject: [PATCH 08/42] added back some python versions --- conda-recipes/main-library/conda_build_config.yaml | 7 ------- conda-recipes/python-client/conda_build_config.yaml | 7 ++----- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/conda-recipes/main-library/conda_build_config.yaml b/conda-recipes/main-library/conda_build_config.yaml index 46fa5230e..2bf732748 100644 --- a/conda-recipes/main-library/conda_build_config.yaml +++ b/conda-recipes/main-library/conda_build_config.yaml @@ -1,10 +1,3 @@ -python: - # - 3.8 - # - 3.9 - # - 3.10 - # - 3.11 - # - 3.12 - - 3.13 c_compiler: - gcc # [linux] diff --git a/conda-recipes/python-client/conda_build_config.yaml b/conda-recipes/python-client/conda_build_config.yaml index 46fa5230e..264e093ef 100644 --- a/conda-recipes/python-client/conda_build_config.yaml +++ b/conda-recipes/python-client/conda_build_config.yaml @@ -1,9 +1,6 @@ python: - # - 3.8 - # - 3.9 - # - 3.10 - # - 3.11 - # - 3.12 + - 3.11 + - 3.12 - 3.13 c_compiler: From 445df01b826204d744c8bdfb8e955f9cba3fd691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=B6jd=20Lars=20Erik?= Date: Thu, 20 Mar 2025 13:10:27 +0100 Subject: [PATCH 09/42] conda build of main library --- .github/workflows/conda_library.yml | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/conda_library.yml diff --git a/.github/workflows/conda_library.yml b/.github/workflows/conda_library.yml new file mode 100644 index 000000000..e1f3082c2 --- /dev/null +++ b/.github/workflows/conda_library.yml @@ -0,0 +1,42 @@ +name: Build slsdetlib + +on: [pull_request] + +jobs: + build: + strategy: + fail-fast: false + matrix: + platform: [ubuntu-latest, ] # macos-12, windows-2019] + python-version: ["3.12",] + + runs-on: ${{ matrix.platform }} + + # The setup-miniconda action needs this to activate miniconda + defaults: + run: + shell: "bash -l {0}" + + steps: + - uses: actions/checkout@v4 + + - name: Get conda + uses: conda-incubator/setup-miniconda@v3.0.4 + with: + python-version: ${{ matrix.python-version }} + channels: conda-forge + + - name: Prepare + run: conda install conda-build=24.9 conda-verify pytest anaconda-client + + - name: Disable upload + run: conda config --set anaconda_upload no + + - name: Build + run: conda build conda-recipe/main-library --output-folder build_output + + - name: Upload all Conda packages + uses: actions/upload-artifact@v4 + with: + name: conda-packages + path: build_output/** # Uploads all packages \ No newline at end of file From 62dc04204089848539b45839723c6c2b59f7e136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=B6jd=20Lars=20Erik?= Date: Thu, 20 Mar 2025 13:12:42 +0100 Subject: [PATCH 10/42] fixed typo --- .github/workflows/conda_library.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/conda_library.yml b/.github/workflows/conda_library.yml index e1f3082c2..9cffbd74b 100644 --- a/.github/workflows/conda_library.yml +++ b/.github/workflows/conda_library.yml @@ -33,7 +33,7 @@ jobs: run: conda config --set anaconda_upload no - name: Build - run: conda build conda-recipe/main-library --output-folder build_output + run: conda build conda-recipes/main-library --output-folder build_output - name: Upload all Conda packages uses: actions/upload-artifact@v4 From 92cae4c00090d255b171126c7b0f33583b71ca3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=B6jd=20Lars=20Erik?= Date: Thu, 20 Mar 2025 13:28:46 +0100 Subject: [PATCH 11/42] removed conda build pin --- .github/workflows/conda_library.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/conda_library.yml b/.github/workflows/conda_library.yml index 9cffbd74b..23f94d467 100644 --- a/.github/workflows/conda_library.yml +++ b/.github/workflows/conda_library.yml @@ -27,7 +27,7 @@ jobs: channels: conda-forge - name: Prepare - run: conda install conda-build=24.9 conda-verify pytest anaconda-client + run: conda install conda-build conda-verify pytest anaconda-client - name: Disable upload run: conda config --set anaconda_upload no From 0f9a784448771618a9d5d3539c8acc46190479a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=B6jd=20Lars=20Erik?= Date: Thu, 20 Mar 2025 13:39:51 +0100 Subject: [PATCH 12/42] added zlib --- conda-recipes/main-library/build.sh | 2 +- conda-recipes/main-library/meta.yaml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/conda-recipes/main-library/build.sh b/conda-recipes/main-library/build.sh index 730271b6e..229067c3b 100755 --- a/conda-recipes/main-library/build.sh +++ b/conda-recipes/main-library/build.sh @@ -18,7 +18,7 @@ cmake .. -G Ninja \ -DSLS_USE_TESTS=ON \ -DSLS_USE_PYTHON=OFF \ -DCMAKE_BUILD_TYPE=Release \ - -DSLS_USE_HDF5=OFF\ + -DSLS_USE_HDF5=OFF \ NCORES=$(getconf _NPROCESSORS_ONLN) echo "Building using: ${NCORES} cores" diff --git a/conda-recipes/main-library/meta.yaml b/conda-recipes/main-library/meta.yaml index cdbe70405..87a9a4f50 100755 --- a/conda-recipes/main-library/meta.yaml +++ b/conda-recipes/main-library/meta.yaml @@ -27,6 +27,7 @@ requirements: - libgcc-ng - libgl-devel # [linux] - libtiff + - zlib run: - libstdcxx-ng From 674ec61806134116c5058cf3de34abb72e50c8ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=B6jd=20Lars=20Erik?= Date: Thu, 20 Mar 2025 13:56:46 +0100 Subject: [PATCH 13/42] added workflow for python lib --- .github/workflows/cmake.yml | 2 +- .github/workflows/conda_python.yml | 42 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/conda_python.yml diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 9826f4b13..5e99d1f35 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -1,4 +1,4 @@ -name: CMake +name: Native CMake Build on: [push, pull_request] diff --git a/.github/workflows/conda_python.yml b/.github/workflows/conda_python.yml new file mode 100644 index 000000000..d482b8e6f --- /dev/null +++ b/.github/workflows/conda_python.yml @@ -0,0 +1,42 @@ +name: slsdet + +on: [pull_request] + +jobs: + build: + strategy: + fail-fast: false + matrix: + platform: [ubuntu-latest, ] # macos-12, windows-2019] + python-version: ["3.12",] + + runs-on: ${{ matrix.platform }} + + # The setup-miniconda action needs this to activate miniconda + defaults: + run: + shell: "bash -l {0}" + + steps: + - uses: actions/checkout@v4 + + - name: Get conda + uses: conda-incubator/setup-miniconda@v3.0.4 + with: + python-version: ${{ matrix.python-version }} + channels: conda-forge + + - name: Prepare + run: conda install conda-build conda-verify pytest anaconda-client + + - name: Disable upload + run: conda config --set anaconda_upload no + + - name: Build + run: conda build conda-recipes/python-client --output-folder build_output + + - name: Upload all Conda packages + uses: actions/upload-artifact@v4 + with: + name: conda-packages + path: build_output/** # Uploads all packages \ No newline at end of file From 78611b287e76474585f7543b44fc1f2eca0ed00f Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Fri, 28 Mar 2025 09:26:55 +0100 Subject: [PATCH 14/42] patching libzmq and cleaned up cmake --- CMakeLists.txt | 37 ++++++++++++++++++++++---- libs/libzmq/libzmq_cmake_version.patch | 17 ++++++++++++ pyproject.toml | 9 ++++--- 3 files changed, 55 insertions(+), 8 deletions(-) create mode 100644 libs/libzmq/libzmq_cmake_version.patch diff --git a/CMakeLists.txt b/CMakeLists.txt index 0aa6dcd5d..2861c4546 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,20 +30,41 @@ option(SLS_FETCH_ZMQ_FROM_GITHUB "Fetch zmq from github" OFF) option(SLS_FETCH_PYBIND11_FROM_GITHUB "Fetch pybind11 from github" OFF) + + + + +# Allow FetchContent_Populate to be called with a single argument +# otherwise deprecated warning is issued +# Note: From cmake 3.28 we can pass EXCLUDE_FROM_ALL to FetchContent_Declare +# and avoid direct use of Populate +if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.30") + cmake_policy(SET CMP0169 OLD) +endif() + +# Patch libzmq to set minimum cmake version to 3.15 to avoid warnings +# with newer cmake versions +set(zmq_patch_version git apply ${CMAKE_CURRENT_SOURCE_DIR}/libs/libzmq/libzmq_cmake_version.patch) + +set(SLS_LIBZMQ_VERSION "4.3.4") + + if(SLS_FETCH_ZMQ_FROM_GITHUB) # Opt in to pull down a zmq version from github instead of # using the bundled verison FetchContent_Declare( libzmq GIT_REPOSITORY https://github.com/zeromq/libzmq.git - GIT_TAG v4.3.4 + GIT_TAG v${SLS_LIBZMQ_VERSION} + PATCH_COMMAND ${zmq_patch_version} ) else() # Standard behaviour use libzmq included in this repo (libs/libzmq) FetchContent_Declare( libzmq - URL ${CMAKE_CURRENT_SOURCE_DIR}/libs/libzmq/libzmq-4.3.4.tar.gz + URL ${CMAKE_CURRENT_SOURCE_DIR}/libs/libzmq/libzmq-${SLS_LIBZMQ_VERSION}.tar.gz URL_HASH MD5=cc20b769ac10afa352e5ed2769bb23b3 + PATCH_COMMAND ${zmq_patch_version} ) endif() @@ -335,9 +356,15 @@ if (SLS_USE_CTBGUI) add_subdirectory(pyctbgui) endif(SLS_USE_CTBGUI) -configure_file( .clang-tidy - ${CMAKE_BINARY_DIR}/.clang-tidy -) +# Workaround for file note being copied to build directory +# when issuing a python -m build +# TODO! Proper fix +if(EXISTS ".clang-tidy") + configure_file(.clang-tidy + ${CMAKE_BINARY_DIR}/.clang-tidy + ) +endif() + if (SLS_BUILD_EXAMPLES) add_subdirectory(sample) diff --git a/libs/libzmq/libzmq_cmake_version.patch b/libs/libzmq/libzmq_cmake_version.patch new file mode 100644 index 000000000..901078fe8 --- /dev/null +++ b/libs/libzmq/libzmq_cmake_version.patch @@ -0,0 +1,17 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index dd3d8eb9..75c321fd 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,11 +1,7 @@ + # CMake build script for ZeroMQ + project(ZeroMQ) + +-if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin) +- cmake_minimum_required(VERSION 3.0.2) +-else() +- cmake_minimum_required(VERSION 2.8.12) +-endif() ++cmake_minimum_required(VERSION 3.15) + + include(CheckIncludeFiles) + include(CheckCCompilerFlag) diff --git a/pyproject.toml b/pyproject.toml index 35709dae1..eafffa9f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,13 +7,16 @@ name = "slsdet" version = "2025.3.19" -[tool.scikit-build] -cmake.verbose = true +[tool.cibuildwheel] +before-all = "uname -a" + +[tool.scikit-build-core] +build.verbose = true cmake.build-type = "Release" install.components = ["python"] -[tool.scikit-build.cmake.define] +[tool.scikit-build-core.cmake.define] #Only build the control software and python ext SLS_USE_RECEIVER = "OFF" SLS_USE_RECEIVER_BINARIES = "OFF" From af90ddb88f98f4327509552b27e96691966e1af0 Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Fri, 28 Mar 2025 15:43:09 +0100 Subject: [PATCH 15/42] removed compiler version --- CMakeLists.txt | 9 +++------ conda-recipes/main-library/conda_build_config.yaml | 6 ------ conda-recipes/python-client/conda_build_config.yaml | 7 ------- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2861c4546..8d6947522 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,9 +31,6 @@ option(SLS_FETCH_PYBIND11_FROM_GITHUB "Fetch pybind11 from github" OFF) - - - # Allow FetchContent_Populate to be called with a single argument # otherwise deprecated warning is issued # Note: From cmake 3.28 we can pass EXCLUDE_FROM_ALL to FetchContent_Declare @@ -44,7 +41,7 @@ endif() # Patch libzmq to set minimum cmake version to 3.15 to avoid warnings # with newer cmake versions -set(zmq_patch_version git apply ${CMAKE_CURRENT_SOURCE_DIR}/libs/libzmq/libzmq_cmake_version.patch) +set(ZMQ_PATCH_CMAKE git apply ${CMAKE_CURRENT_LIST_DIR}/libs/libzmq/libzmq_cmake_version.patch) set(SLS_LIBZMQ_VERSION "4.3.4") @@ -56,7 +53,7 @@ if(SLS_FETCH_ZMQ_FROM_GITHUB) libzmq GIT_REPOSITORY https://github.com/zeromq/libzmq.git GIT_TAG v${SLS_LIBZMQ_VERSION} - PATCH_COMMAND ${zmq_patch_version} + PATCH_COMMAND ${ZMQ_PATCH_CMAKE} ) else() # Standard behaviour use libzmq included in this repo (libs/libzmq) @@ -64,7 +61,7 @@ else() libzmq URL ${CMAKE_CURRENT_SOURCE_DIR}/libs/libzmq/libzmq-${SLS_LIBZMQ_VERSION}.tar.gz URL_HASH MD5=cc20b769ac10afa352e5ed2769bb23b3 - PATCH_COMMAND ${zmq_patch_version} + PATCH_COMMAND ${ZMQ_PATCH_CMAKE} ) endif() diff --git a/conda-recipes/main-library/conda_build_config.yaml b/conda-recipes/main-library/conda_build_config.yaml index 2bf732748..149897ca1 100644 --- a/conda-recipes/main-library/conda_build_config.yaml +++ b/conda-recipes/main-library/conda_build_config.yaml @@ -2,9 +2,6 @@ c_compiler: - gcc # [linux] -c_compiler_version: - - 13 # [linux] - c_stdlib: - sysroot # [linux] @@ -12,8 +9,5 @@ cxx_compiler: - gxx # [linux] -cxx_compiler_version: - - 13 # [linux] - c_stdlib_version: # [linux] - 2.17 # [linux] \ No newline at end of file diff --git a/conda-recipes/python-client/conda_build_config.yaml b/conda-recipes/python-client/conda_build_config.yaml index 264e093ef..0c957b631 100644 --- a/conda-recipes/python-client/conda_build_config.yaml +++ b/conda-recipes/python-client/conda_build_config.yaml @@ -6,18 +6,11 @@ python: c_compiler: - gcc # [linux] -c_compiler_version: - - 13 # [linux] - c_stdlib: - sysroot # [linux] cxx_compiler: - gxx # [linux] - -cxx_compiler_version: - - 13 # [linux] - c_stdlib_version: # [linux] - 2.17 # [linux] \ No newline at end of file From 54fc6ca7f7a299c6e76cb8c63c538eddf625fdff Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Fri, 28 Mar 2025 18:26:45 +0100 Subject: [PATCH 16/42] switched patch tool --- CMakeLists.txt | 11 ++++++----- conda-recipes/main-library/meta.yaml | 2 +- libs/libzmq/libzmq_cmake_version.patch | 5 +++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d6947522..b1d035d76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,19 +41,19 @@ endif() # Patch libzmq to set minimum cmake version to 3.15 to avoid warnings # with newer cmake versions -set(ZMQ_PATCH_CMAKE git apply ${CMAKE_CURRENT_LIST_DIR}/libs/libzmq/libzmq_cmake_version.patch) - +# Patch is applied in the FetchContent_Declare set(SLS_LIBZMQ_VERSION "4.3.4") if(SLS_FETCH_ZMQ_FROM_GITHUB) # Opt in to pull down a zmq version from github instead of - # using the bundled verison + # using the bundled version FetchContent_Declare( libzmq GIT_REPOSITORY https://github.com/zeromq/libzmq.git GIT_TAG v${SLS_LIBZMQ_VERSION} - PATCH_COMMAND ${ZMQ_PATCH_CMAKE} + PATCH_COMMAND ${CMAKE_COMMAND} -E chdir patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/libs/libzmq/libzmq_cmake_version.patch + UPDATE_DISCONNECTED 1 ) else() # Standard behaviour use libzmq included in this repo (libs/libzmq) @@ -61,7 +61,8 @@ else() libzmq URL ${CMAKE_CURRENT_SOURCE_DIR}/libs/libzmq/libzmq-${SLS_LIBZMQ_VERSION}.tar.gz URL_HASH MD5=cc20b769ac10afa352e5ed2769bb23b3 - PATCH_COMMAND ${ZMQ_PATCH_CMAKE} + PATCH_COMMAND ${CMAKE_COMMAND} -E chdir patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/libs/libzmq/libzmq_cmake_version.patch + UPDATE_DISCONNECTED 1 ) endif() diff --git a/conda-recipes/main-library/meta.yaml b/conda-recipes/main-library/meta.yaml index 87a9a4f50..2ddc76a6f 100755 --- a/conda-recipes/main-library/meta.yaml +++ b/conda-recipes/main-library/meta.yaml @@ -17,7 +17,7 @@ requirements: - {{ compiler('c') }} - {{ stdlib("c") }} - {{ compiler('cxx') }} - + - git - cmake - ninja - qt 5.* diff --git a/libs/libzmq/libzmq_cmake_version.patch b/libs/libzmq/libzmq_cmake_version.patch index 901078fe8..4e421d322 100644 --- a/libs/libzmq/libzmq_cmake_version.patch +++ b/libs/libzmq/libzmq_cmake_version.patch @@ -1,8 +1,8 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index dd3d8eb9..75c321fd 100644 +index dd3d8eb9..c0187747 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -1,11 +1,7 @@ +@@ -1,11 +1,8 @@ # CMake build script for ZeroMQ project(ZeroMQ) @@ -12,6 +12,7 @@ index dd3d8eb9..75c321fd 100644 - cmake_minimum_required(VERSION 2.8.12) -endif() +cmake_minimum_required(VERSION 3.15) ++message(STATUS "Patched cmake version") include(CheckIncludeFiles) include(CheckCCompilerFlag) From e1d4edf836e6b70d08aa562c5f16226be1629da8 Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Tue, 1 Apr 2025 14:17:07 +0200 Subject: [PATCH 17/42] reverted to scikit-build in pyproject.toml --- conda-recipes/python-client/meta.yaml | 3 +-- pyproject.toml | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/conda-recipes/python-client/meta.yaml b/conda-recipes/python-client/meta.yaml index 9add4b13b..3b710151c 100644 --- a/conda-recipes/python-client/meta.yaml +++ b/conda-recipes/python-client/meta.yaml @@ -1,6 +1,6 @@ package: name: slsdet - version: 2025.2.18 #TODO! how to not duplicate this? + version: 2025.3.19 #TODO! how to not duplicate this? source: path: ../.. @@ -9,7 +9,6 @@ build: number: 0 script: - unset CMAKE_GENERATOR && {{ PYTHON }} -m pip install . -vv # [not win] - - {{ PYTHON }} -m pip install . -vv # [win] requirements: build: diff --git a/pyproject.toml b/pyproject.toml index eafffa9f4..3d128f18e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,13 +10,13 @@ version = "2025.3.19" [tool.cibuildwheel] before-all = "uname -a" -[tool.scikit-build-core] +[tool.scikit-build] build.verbose = true cmake.build-type = "Release" install.components = ["python"] -[tool.scikit-build-core.cmake.define] +[tool.scikit-build.cmake.define] #Only build the control software and python ext SLS_USE_RECEIVER = "OFF" SLS_USE_RECEIVER_BINARIES = "OFF" From 000857be424669fc60d489b964692874449e52a9 Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Tue, 1 Apr 2025 16:57:47 +0200 Subject: [PATCH 18/42] added sls_detector bin --- .github/workflows/{conda_library.yml => conda_library.yaml} | 0 .github/workflows/{conda_python.yml => conda_python.yaml} | 0 conda-recipes/main-library/copy_lib.sh | 1 + 3 files changed, 1 insertion(+) rename .github/workflows/{conda_library.yml => conda_library.yaml} (100%) rename .github/workflows/{conda_python.yml => conda_python.yaml} (100%) diff --git a/.github/workflows/conda_library.yml b/.github/workflows/conda_library.yaml similarity index 100% rename from .github/workflows/conda_library.yml rename to .github/workflows/conda_library.yaml diff --git a/.github/workflows/conda_python.yml b/.github/workflows/conda_python.yaml similarity index 100% rename from .github/workflows/conda_python.yml rename to .github/workflows/conda_python.yaml diff --git a/conda-recipes/main-library/copy_lib.sh b/conda-recipes/main-library/copy_lib.sh index 72343b565..be6c13f47 100755 --- a/conda-recipes/main-library/copy_lib.sh +++ b/conda-recipes/main-library/copy_lib.sh @@ -14,6 +14,7 @@ cp build/install/bin/sls_detector_acquire_zmq $PREFIX/bin/. cp build/install/bin/sls_detector_get $PREFIX/bin/. cp build/install/bin/sls_detector_put $PREFIX/bin/. cp build/install/bin/sls_detector_help $PREFIX/bin/. +cp build/install/bin/sls_detector $PREFIX/bin/. cp build/install/bin/slsReceiver $PREFIX/bin/. cp build/install/bin/slsMultiReceiver $PREFIX/bin/. From 2bff4c40ac3b711b4ef8bbe302c36f4c08653b62 Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Tue, 1 Apr 2025 17:20:35 +0200 Subject: [PATCH 19/42] added sync, renamed action --- .github/workflows/{cmake.yml => cmake.yaml} | 0 conda-recipes/main-library/copy_lib.sh | 1 + 2 files changed, 1 insertion(+) rename .github/workflows/{cmake.yml => cmake.yaml} (100%) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yaml similarity index 100% rename from .github/workflows/cmake.yml rename to .github/workflows/cmake.yaml diff --git a/conda-recipes/main-library/copy_lib.sh b/conda-recipes/main-library/copy_lib.sh index be6c13f47..88beafdfe 100755 --- a/conda-recipes/main-library/copy_lib.sh +++ b/conda-recipes/main-library/copy_lib.sh @@ -17,6 +17,7 @@ cp build/install/bin/sls_detector_help $PREFIX/bin/. cp build/install/bin/sls_detector $PREFIX/bin/. cp build/install/bin/slsReceiver $PREFIX/bin/. cp build/install/bin/slsMultiReceiver $PREFIX/bin/. +cp build/install/bin/slsFrameSynchronizer $PREFIX/bin/. cp build/install/include/sls/* $PREFIX/include/sls From 9bd9711dcc0c34a6f24eee5c3b67bab527fc53e6 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 22 May 2025 17:52:01 +0200 Subject: [PATCH 20/42] update cmake<=3.28 in conda build requirements --- conda-recipes/main-library/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda-recipes/main-library/meta.yaml b/conda-recipes/main-library/meta.yaml index 2ddc76a6f..d427bbfe7 100755 --- a/conda-recipes/main-library/meta.yaml +++ b/conda-recipes/main-library/meta.yaml @@ -18,7 +18,7 @@ requirements: - {{ stdlib("c") }} - {{ compiler('cxx') }} - git - - cmake + - cmake<=3.28 - ninja - qt 5.* From 0c3435a2c4b29dea0abb13d464224a440e3d6924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=B6jdh?= Date: Thu, 3 Apr 2025 12:00:57 +0200 Subject: [PATCH 21/42] Fixed broken import in typecaster.h (#1181) - Fixed the broken import _slsdet --> slsdet._slsdet caused by a previous upgrade - Added tests that exercises the conversion from python to C++ and from C++ to python - Python unit tests now run in CI (!) --- .github/workflows/cmake.yaml | 19 ++++++--- python/slsdet/__init__.py | 3 ++ python/src/duration.cpp | 22 +++++++++++ python/src/typecaster.h | 9 ++++- python/tests/test_DurationWrapper.py | 58 ++++++++++++++++++++++++++++ 5 files changed, 104 insertions(+), 7 deletions(-) create mode 100644 python/tests/test_DurationWrapper.py diff --git a/.github/workflows/cmake.yaml b/.github/workflows/cmake.yaml index 5e99d1f35..00d6a4b86 100644 --- a/.github/workflows/cmake.yaml +++ b/.github/workflows/cmake.yaml @@ -14,7 +14,13 @@ jobs: runs-on: ubuntu-latest name: Configure and build using cmake steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.12 + cache: 'pip' + - run: pip install pytest numpy + - uses: awalsh128/cache-apt-pkgs-action@latest with: packages: libhdf5-dev qtbase5-dev qt5-qmake libqt5svg5-dev libpng-dev libtiff-dev @@ -27,12 +33,15 @@ jobs: - name: Build # Build your program with the given configuration - run: cmake --build ${{github.workspace}}/build -j2 --config ${{env.BUILD_TYPE}} + run: cmake --build ${{github.workspace}}/build -j4 --config ${{env.BUILD_TYPE}} - - name: Test + - name: C++ unit tests working-directory: ${{github.workspace}}/build - # Execute tests defined by the CMake configuration. - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail run: ctest -C ${{env.BUILD_TYPE}} -j1 + - name: Python unit tests + working-directory: ${{github.workspace}}/build/bin + run: | + python -m pytest ${{github.workspace}}/python/tests + diff --git a/python/slsdet/__init__.py b/python/slsdet/__init__.py index 85a147db6..18921735b 100755 --- a/python/slsdet/__init__.py +++ b/python/slsdet/__init__.py @@ -41,3 +41,6 @@ def read_version(): __version__ = read_version() + + + diff --git a/python/src/duration.cpp b/python/src/duration.cpp index db6da3d06..ed8927c90 100644 --- a/python/src/duration.cpp +++ b/python/src/duration.cpp @@ -1,3 +1,4 @@ +#include #include "py_headers.h" #include "DurationWrapper.h" @@ -19,4 +20,25 @@ void init_duration(py::module &m) { << " count: " << self.count() << ")"; return ss.str(); }); + + m.def( + "test_return_DurationWrapper", + []() { + DurationWrapper t(1.3); + return t; + }, + R"( + Test function to return a DurationWrapper object. Ensures that the automatic conversion in typecaster.h works. + )"); + + m.def( + "test_duration_to_ns", + [](const std::chrono::nanoseconds t) { + //Duration wrapper is used to be able to convert from time in python to chrono::nanoseconds + //return count to have something to test + return t.count(); + }, + R"( + Test function convert DurationWrapper or number to chrono::ns. Ensures that the automatic conversion in typecaster.h works. + )"); // default value to test the default constructor } diff --git a/python/src/typecaster.h b/python/src/typecaster.h index 5eba7b436..6412afa72 100644 --- a/python/src/typecaster.h +++ b/python/src/typecaster.h @@ -54,11 +54,16 @@ template <> struct type_caster { value = duration_cast(duration(PyFloat_AsDouble(src.ptr()))); return true; } + // If invoked with an int we assume it is nanoseconds and convert, same as in chrono.h + if (PyLong_Check(src.ptr())) { + value = duration_cast(duration(PyLong_AsLongLong(src.ptr()))); + return true; + } // Lastly if we were actually called with a DurationWrapper object we get // the number of nanoseconds and create a std::chrono::nanoseconds from it - py::object py_cls = py::module::import("_slsdet").attr("DurationWrapper"); + py::object py_cls = py::module::import("slsdet._slsdet").attr("DurationWrapper"); if (py::isinstance(src, py_cls)){ sls::DurationWrapper *cls = src.cast(); value = nanoseconds(cls->count()); @@ -77,7 +82,7 @@ template <> struct type_caster { * set the count from chrono::nanoseconds and return */ static handle cast(std::chrono::nanoseconds src, return_value_policy /* policy */, handle /* parent */) { - py::object py_cls = py::module::import("_slsdet").attr("DurationWrapper"); + py::object py_cls = py::module::import("slsdet._slsdet").attr("DurationWrapper"); py::object* obj = new py::object; *obj = py_cls(); sls::DurationWrapper *dur = obj->cast(); diff --git a/python/tests/test_DurationWrapper.py b/python/tests/test_DurationWrapper.py new file mode 100644 index 000000000..f6902da26 --- /dev/null +++ b/python/tests/test_DurationWrapper.py @@ -0,0 +1,58 @@ +import pytest + +from slsdet import DurationWrapper + +#import the compiled extension to use test functions for the automatic conversion +from slsdet import _slsdet + + +def test_default_construction_of_DurationWrapper(): + """Test default construction of DurationWrapper""" + t = DurationWrapper() + assert t.count() == 0 + assert t.total_seconds() == 0 + +def test_construction_of_DurationWrapper(): + """Test construction of DurationWrapper with total_seconds""" + t = DurationWrapper(5) + assert t.count() == 5e9 + assert t.total_seconds() == 5 + +def test_set_count_on_DurationWrapper(): + """Test set_count on DurationWrapper""" + t = DurationWrapper() + t.set_count(10) + assert t.count() == 10 + assert t.total_seconds() == 10e-9 + t.set_count(0) + assert t.count() == 0 + assert t.total_seconds() == 0 + + +def test_return_a_DurationWrapper_from_cpp(): + """Test returning a DurationWrapper from C++""" + t = _slsdet.test_return_DurationWrapper() + assert t.count() == 1.3e9 + assert t.total_seconds() == 1.3 + +def test_call_a_cpp_function_with_a_duration_wrapper(): + """C++ functions can accept a DurationWrapper""" + t = DurationWrapper(5) + assert _slsdet.test_duration_to_ns(t) == 5e9 + +def test_call_a_cpp_function_converting_number_to_DurationWrapper(): + """int and float can be converted to std::chrono::nanoseconds""" + assert _slsdet.test_duration_to_ns(0) == 0 + assert _slsdet.test_duration_to_ns(3) == 3e9 + assert _slsdet.test_duration_to_ns(1.3) == 1.3e9 + assert _slsdet.test_duration_to_ns(10e-9) == 10 + +def test_call_a_cpp_function_with_datetime_timedelta(): + """datetime.timedelta can be converted to std::chrono::nanoseconds""" + import datetime + t = datetime.timedelta(seconds=5) + assert _slsdet.test_duration_to_ns(t) == 5e9 + t = datetime.timedelta(seconds=0) + assert _slsdet.test_duration_to_ns(t) == 0 + t = datetime.timedelta(seconds=1.3) + assert _slsdet.test_duration_to_ns(t) == 1.3e9 \ No newline at end of file From 46420f54c8e8ff74cdc407b236981ca3aeae8804 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 23 May 2025 10:52:20 +0200 Subject: [PATCH 22/42] removed 3.28 restriction on cmake in meta.yaml --- conda-recipes/main-library/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda-recipes/main-library/meta.yaml b/conda-recipes/main-library/meta.yaml index d427bbfe7..2ddc76a6f 100755 --- a/conda-recipes/main-library/meta.yaml +++ b/conda-recipes/main-library/meta.yaml @@ -18,7 +18,7 @@ requirements: - {{ stdlib("c") }} - {{ compiler('cxx') }} - git - - cmake<=3.28 + - cmake - ninja - qt 5.* From e12f71c000f1ee165b6a1013b6bac6a01aa868b2 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Mon, 26 May 2025 10:50:54 +0200 Subject: [PATCH 23/42] from #1216 to 9.1.1.rc that got lost in merge from develoepr, added expat to host section to fix conda build --- conda-recipes/main-library/meta.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/conda-recipes/main-library/meta.yaml b/conda-recipes/main-library/meta.yaml index d427bbfe7..c77620714 100755 --- a/conda-recipes/main-library/meta.yaml +++ b/conda-recipes/main-library/meta.yaml @@ -28,6 +28,7 @@ requirements: - libgl-devel # [linux] - libtiff - zlib + - expat run: - libstdcxx-ng From 1532df9a2e67318137aa2339cb670f80e8535733 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Mon, 26 May 2025 14:37:33 +0200 Subject: [PATCH 24/42] back with the cmake restriction --- conda-recipes/main-library/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda-recipes/main-library/meta.yaml b/conda-recipes/main-library/meta.yaml index ffa6bedb5..c77620714 100755 --- a/conda-recipes/main-library/meta.yaml +++ b/conda-recipes/main-library/meta.yaml @@ -18,7 +18,7 @@ requirements: - {{ stdlib("c") }} - {{ compiler('cxx') }} - git - - cmake + - cmake<=3.28 - ninja - qt 5.* From 43b1cef6840315ea3131f20ef3c3c6feb413b4ac Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 27 May 2025 11:22:37 +0200 Subject: [PATCH 25/42] fixing gotthard1 import --- python/slsdet/gotthard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/slsdet/gotthard.py b/python/slsdet/gotthard.py index 9468c78a3..c7aa29d73 100644 --- a/python/slsdet/gotthard.py +++ b/python/slsdet/gotthard.py @@ -9,7 +9,7 @@ This file contains the specialization for the Moench detector from .detector import Detector, freeze from .dacs import DetectorDacs -import _slsdet +from . import _slsdet dacIndex = _slsdet.slsDetectorDefs.dacIndex from .detector_property import DetectorProperty From 76156986771bb5f228b7e1e5cc1fce6fba983de3 Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Tue, 22 Apr 2025 14:00:45 +0200 Subject: [PATCH 26/42] version number automated for python build --- conda-recipes/build_conda.sh | 8 ++++++++ conda-recipes/main-library/meta.yaml | 6 +++--- conda-recipes/python-client/meta.yaml | 4 ++-- pyproject.toml | 18 +++++++++--------- update_version.py | 22 +++++++++++++++++++++- 5 files changed, 43 insertions(+), 15 deletions(-) create mode 100755 conda-recipes/build_conda.sh diff --git a/conda-recipes/build_conda.sh b/conda-recipes/build_conda.sh new file mode 100755 index 000000000..6915f89a9 --- /dev/null +++ b/conda-recipes/build_conda.sh @@ -0,0 +1,8 @@ + +SCRIPTDIR=$(cd "$(dirname "$0")" && pwd) +VERSION=$(cat $SCRIPTDIR/../VERSION) +export VERSION + +echo "building conda package version: $VERSION" + +conda build . diff --git a/conda-recipes/main-library/meta.yaml b/conda-recipes/main-library/meta.yaml index c77620714..31c9d5e83 100755 --- a/conda-recipes/main-library/meta.yaml +++ b/conda-recipes/main-library/meta.yaml @@ -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: ../.. diff --git a/conda-recipes/python-client/meta.yaml b/conda-recipes/python-client/meta.yaml index 3b710151c..c5e2cbb38 100644 --- a/conda-recipes/python-client/meta.yaml +++ b/conda-recipes/python-client/meta.yaml @@ -1,7 +1,7 @@ + package: name: slsdet - version: 2025.3.19 #TODO! how to not duplicate this? - + version: 0.0.0 source: path: ../.. diff --git a/pyproject.toml b/pyproject.toml index 3d128f18e..5e11fdc45 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" \ No newline at end of file +SLS_INSTALL_PYTHONEXT = "ON" diff --git a/update_version.py b/update_version.py index c074ae542..f5c28c5af 100644 --- a/update_version.py +++ b/update_version.py @@ -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) \ No newline at end of file + write_version_to_file(version) + define_environment_variable(version) + update_pyproject_toml_file(version) From adb5498254e88be6e60292df24572f91bdb25879 Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Tue, 22 Apr 2025 15:43:01 +0200 Subject: [PATCH 27/42] mistakenly set version back to 0.0.0 --- conda-recipes/python-client/meta.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conda-recipes/python-client/meta.yaml b/conda-recipes/python-client/meta.yaml index c5e2cbb38..7daa969a6 100644 --- a/conda-recipes/python-client/meta.yaml +++ b/conda-recipes/python-client/meta.yaml @@ -1,7 +1,8 @@ package: name: slsdet - version: 0.0.0 + version: {{ environ.get('VERSION') }} #2025.3.19 + source: path: ../.. From 97a63a30536e150f2abab3fa1e5e04ef8eac73b0 Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Tue, 22 Apr 2025 17:05:06 +0200 Subject: [PATCH 28/42] updated github workflow scripts to support automatic version numbering with environment variable --- .github/workflows/conda_library.yaml | 2 +- .github/workflows/conda_python.yaml | 2 +- conda-recipes/build_conda.sh | 19 +++++++++++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/conda_library.yaml b/.github/workflows/conda_library.yaml index 23f94d467..807d7872b 100644 --- a/.github/workflows/conda_library.yaml +++ b/.github/workflows/conda_library.yaml @@ -33,7 +33,7 @@ jobs: run: conda config --set anaconda_upload no - name: Build - run: conda build conda-recipes/main-library --output-folder build_output + run: ./conda-recipes/build_conda.sh build_output main-library - name: Upload all Conda packages uses: actions/upload-artifact@v4 diff --git a/.github/workflows/conda_python.yaml b/.github/workflows/conda_python.yaml index d482b8e6f..df67552e1 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-recipes/build_conda.sh build_output python-client - name: Upload all Conda packages uses: actions/upload-artifact@v4 diff --git a/conda-recipes/build_conda.sh b/conda-recipes/build_conda.sh index 6915f89a9..7e6ab3f46 100755 --- a/conda-recipes/build_conda.sh +++ b/conda-recipes/build_conda.sh @@ -3,6 +3,21 @@ SCRIPTDIR=$(cd "$(dirname "$0")" && pwd) VERSION=$(cat $SCRIPTDIR/../VERSION) export VERSION -echo "building conda package version: $VERSION" +if [ -z "$1" ] +then + output_dir=$CONDA_PREFIX/conda-bld +else + output_dir=$1 +fi -conda build . +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 From 3a405c218100ce46d717caac0f88152223251552 Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Wed, 23 Apr 2025 14:26:26 +0200 Subject: [PATCH 29/42] 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 31c9d5e83..42a60aa7c 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) From b740a082b415ac4070a00a1822ae11bd450aa6b8 Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Wed, 23 Apr 2025 14:38:51 +0200 Subject: [PATCH 30/42] saving changes in git workflow failed --- .github/workflows/conda_library.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/conda_library.yaml b/.github/workflows/conda_library.yaml index 807d7872b..9bde3bb31 100644 --- a/.github/workflows/conda_library.yaml +++ b/.github/workflows/conda_library.yaml @@ -33,7 +33,7 @@ jobs: run: conda config --set anaconda_upload no - name: Build - run: ./conda-recipes/build_conda.sh build_output main-library + run: conda build ./conda-recipes/main-library --build-folder build_output - name: Upload all Conda packages uses: actions/upload-artifact@v4 From 12863738946a9da8e15ee699d665f78e313fb24d Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Wed, 23 Apr 2025 14:46:12 +0200 Subject: [PATCH 31/42] got typo in github workflow --- .github/workflows/conda_library.yaml | 2 +- .github/workflows/conda_python.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/conda_library.yaml b/.github/workflows/conda_library.yaml index 9bde3bb31..23f94d467 100644 --- a/.github/workflows/conda_library.yaml +++ b/.github/workflows/conda_library.yaml @@ -33,7 +33,7 @@ jobs: run: conda config --set anaconda_upload no - name: Build - run: conda build ./conda-recipes/main-library --build-folder build_output + run: conda build conda-recipes/main-library --output-folder build_output - name: Upload all Conda packages uses: actions/upload-artifact@v4 diff --git a/.github/workflows/conda_python.yaml b/.github/workflows/conda_python.yaml index 778b18ad7..5dad7745a 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 --build-folder build_output + run: conda build ./conda-recipes/python-client --output-folder build_output - name: Upload all Conda packages uses: actions/upload-artifact@v4 From f3be9557637e60beac2328b3b29067a250b880c0 Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Wed, 23 Apr 2025 17:09:06 +0200 Subject: [PATCH 32/42] updatet regex pattern to support postfix --- .github/workflows/conda_python.yaml | 2 +- conda-recipes/main-library/meta.yaml | 2 +- conda-recipes/python-client/meta.yaml | 3 +-- update_version.py | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/conda_python.yaml b/.github/workflows/conda_python.yaml index 5dad7745a..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 42a60aa7c..e210e6710 100755 --- a/conda-recipes/main-library/meta.yaml +++ b/conda-recipes/main-library/meta.yaml @@ -1,7 +1,7 @@ source: path: ../.. -{% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\d+\.\d+\.\d+)').group(1) %} +{% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\d+\.\d+\.\d+(?:[\.\-][\.\w\-]+)?)').group(1) %} package: name: sls_detector_software version: {{ version }} #2025.3.19 diff --git a/conda-recipes/python-client/meta.yaml b/conda-recipes/python-client/meta.yaml index cf4f3aa7b..03c4b4436 100644 --- a/conda-recipes/python-client/meta.yaml +++ b/conda-recipes/python-client/meta.yaml @@ -1,8 +1,7 @@ source: path: ../.. -{% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\d+\.\d+\.\d+)').group(1) %} - +{% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\d+\.\d+\.\d+(?:[\.\w\-]+)?)').group(1) %} package: name: slsdet version: {{ version }} # diff --git a/update_version.py b/update_version.py index 507857133..c72099b3c 100644 --- a/update_version.py +++ b/update_version.py @@ -17,8 +17,8 @@ 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+$', version): - print("Error: Version argument must be in 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])") sys.exit(1) return version From 96f39d502817a61ad7b69b3368d3e7637b2fb2db Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Thu, 24 Apr 2025 08:45:18 +0200 Subject: [PATCH 33/42] normalized version to PEP 440 specification in update_version.py --- conda-recipes/main-library/meta.yaml | 4 +--- conda-recipes/python-client/meta.yaml | 2 +- update_version.py | 14 ++++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/conda-recipes/main-library/meta.yaml b/conda-recipes/main-library/meta.yaml index e210e6710..364a89a36 100755 --- a/conda-recipes/main-library/meta.yaml +++ b/conda-recipes/main-library/meta.yaml @@ -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: diff --git a/conda-recipes/python-client/meta.yaml b/conda-recipes/python-client/meta.yaml index 03c4b4436..dd9ea031c 100644 --- a/conda-recipes/python-client/meta.yaml +++ b/conda-recipes/python-client/meta.yaml @@ -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 }} # diff --git a/update_version.py b/update_version.py index c72099b3c..914797a1d 100644 --- a/update_version.py +++ b/update_version.py @@ -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}") From 0996f366fd007bb33468481b8752ac313113c3cf Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Thu, 24 Apr 2025 09:16:32 +0200 Subject: [PATCH 34/42] bug did not support version 0.0.0 --- conda-recipes/main-library/meta.yaml | 2 +- conda-recipes/python-client/meta.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conda-recipes/main-library/meta.yaml b/conda-recipes/main-library/meta.yaml index 364a89a36..aa1fe2d68 100755 --- a/conda-recipes/main-library/meta.yaml +++ b/conda-recipes/main-library/meta.yaml @@ -1,7 +1,7 @@ source: path: ../.. -{% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\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 diff --git a/conda-recipes/python-client/meta.yaml b/conda-recipes/python-client/meta.yaml index dd9ea031c..d3fed0b9a 100644 --- a/conda-recipes/python-client/meta.yaml +++ b/conda-recipes/python-client/meta.yaml @@ -1,7 +1,7 @@ source: path: ../.. -{% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\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 }} # From 948116c9e29751fc2a7d31906cdb7bc9e66da4e9 Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Fri, 25 Apr 2025 10:48:16 +0200 Subject: [PATCH 35/42] added regex pattern matching to version in toml file --- conda-recipes/main-library/meta.yaml | 2 +- conda-recipes/python-client/meta.yaml | 2 +- pyproject.toml | 8 +++++++- update_version.py | 17 +++++++---------- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/conda-recipes/main-library/meta.yaml b/conda-recipes/main-library/meta.yaml index aa1fe2d68..63508e8fa 100755 --- a/conda-recipes/main-library/meta.yaml +++ b/conda-recipes/main-library/meta.yaml @@ -4,7 +4,7 @@ source: {% 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 + version: {{ version }} build: number: 0 diff --git a/conda-recipes/python-client/meta.yaml b/conda-recipes/python-client/meta.yaml index d3fed0b9a..c86f401ef 100644 --- a/conda-recipes/python-client/meta.yaml +++ b/conda-recipes/python-client/meta.yaml @@ -4,7 +4,7 @@ source: {% set version = load_file_regex(load_file = 'VERSION', regex_pattern = '(\d+(?:\.\d+)*(?:[\+\w\.]+))').group(1) %} package: name: slsdet - version: {{ version }} # + version: {{ version }} build: number: 0 diff --git a/pyproject.toml b/pyproject.toml index 776657c41..8deb25dde 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,16 @@ +[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",] build-backend = "scikit_build_core.build" [project] name = "slsdet" -version = "0.0.0" +dynamic = ["version"] [tool.cibuildwheel] before-all = "uname -a" diff --git a/update_version.py b/update_version.py index 914797a1d..2b5609198 100644 --- a/update_version.py +++ b/update_version.py @@ -5,10 +5,13 @@ Script to update VERSION file with semantic versioning if provided as an argumen """ import sys -import re -import toml +import os + from packaging.version import Version, InvalidVersion + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) + def get_version(): # Check at least one argument is passed @@ -26,19 +29,13 @@ def get_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(str(version)) print(f"Version {version} written to VERSION file.") -def update_pyproject_toml_file(version): - pyproject = toml.load("pyproject.toml") - pyproject["project"]["version"] = str(version) - toml.dump(pyproject, open("pyproject.toml", "w")) #write back - print(f"Version in pyproject.toml set to {version}") - # Main script if __name__ == "__main__": version = get_version() write_version_to_file(version) - update_pyproject_toml_file(version) From 0bbff8f9b0211130bd38e54c2a8eab0d6ceb69b0 Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Tue, 29 Apr 2025 11:14:52 +0200 Subject: [PATCH 36/42] version now supports . before postfix --- update_version.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/update_version.py b/update_version.py index 2b5609198..6b3e1ebad 100644 --- a/update_version.py +++ b/update_version.py @@ -19,10 +19,11 @@ def get_version(): return "0.0.0" version = sys.argv[1] - + try: - v = Version(version) # normalize according to PEP 440 specification - return v + 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) @@ -31,7 +32,7 @@ def get_version(): def write_version_to_file(version): version_file_path = os.path.join(SCRIPT_DIR, "VERSION") with open(version_file_path, "w") as version_file: - version_file.write(str(version)) + version_file.write(version) print(f"Version {version} written to VERSION file.") # Main script From d450db5911540e1abcbf0257764a1ec9c33547c4 Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Thu, 15 May 2025 16:35:09 +0200 Subject: [PATCH 37/42] updates api version based on version file & converted shell script files to python --- slsDetectorServers/compileAllServers.sh | 23 +++--- .../compileAllServers_noAPIUpdate.sh | 19 +---- slsDetectorServers/ctbDetectorServer/Makefile | 6 +- slsSupportLib/include/sls/Version.h | 2 +- slsSupportLib/src/Version.cpp | 3 +- slsSupportLib/tests/CMakeLists.txt | 1 + slsSupportLib/tests/test-Version.cpp | 19 +++++ tests/scripts/test_frame_synchronizer.py | 23 +++--- tests/scripts/utils_for_test.py | 4 +- updateAPIVersion.py | 81 +++++++++++++++++++ updateAPIVersion.sh | 65 --------------- updateClientAPIVersion.py | 34 ++++++++ updateClientAPIVersion.sh | 59 -------------- 13 files changed, 167 insertions(+), 172 deletions(-) mode change 100644 => 100755 slsDetectorServers/compileAllServers.sh create mode 100644 slsSupportLib/tests/test-Version.cpp create mode 100644 updateAPIVersion.py delete mode 100755 updateAPIVersion.sh create mode 100644 updateClientAPIVersion.py delete mode 100755 updateClientAPIVersion.sh diff --git a/slsDetectorServers/compileAllServers.sh b/slsDetectorServers/compileAllServers.sh old mode 100644 new mode 100755 index eec8907bf..97b03bc6e --- a/slsDetectorServers/compileAllServers.sh +++ b/slsDetectorServers/compileAllServers.sh @@ -1,18 +1,18 @@ # SPDX-License-Identifier: LGPL-3.0-or-other # Copyright (C) 2021 Contributors to the SLS Detector Package -# empty branch = developer branch in updateAPIVersion.sh -branch="" det_list=("ctbDetectorServer gotthardDetectorServer gotthard2DetectorServer jungfrauDetectorServer mythen3DetectorServer moenchDetectorServer - xilinx_ctbDetectorServer" + xilinx_ctbDetectorServer" ) -usage="\nUsage: compileAllServers.sh [server|all(opt)] [branch(opt)]. \n\tNo arguments mean all servers with 'developer' branch. \n\tNo 'branch' input means 'developer branch'" +usage="\nUsage: compileAllServers.sh [server|all(opt)] [update_api(opt)]. \n\tNo arguments mean all servers with 'developer' branch. \n\tupdate_api if true updates the api to version in VERSION file" +update_api=false +target=clean # arguments if [ $# -eq 0 ]; then # no argument, all servers @@ -35,15 +35,13 @@ elif [ $# -eq 1 ] || [ $# -eq 2 ]; then declare -a det=("${1}") #echo "Compiling only $1" fi - # branch + if [ $# -eq 2 ]; then - # arg in list - if [[ $det_list == *$2* ]]; then - echo -e "Invalid argument 2: $2. $usage" - return 1 + update_api=$2 + if $update_api ; then + target=version + echo "updating api to $(cat ../VERSION)" fi - branch+=$2 - #echo "with branch $branch" fi else echo -e "Too many arguments.$usage" @@ -62,8 +60,7 @@ do file="${i}_developer" echo -e "Compiling $dir [$file]" cd $dir - make clean - if make version API_BRANCH=$branch; then + if make $target; then deterror[$idet]="OK" else deterror[$idet]="FAIL" diff --git a/slsDetectorServers/compileAllServers_noAPIUpdate.sh b/slsDetectorServers/compileAllServers_noAPIUpdate.sh index ecfbdf6fb..9bef8400e 100644 --- a/slsDetectorServers/compileAllServers_noAPIUpdate.sh +++ b/slsDetectorServers/compileAllServers_noAPIUpdate.sh @@ -1,8 +1,6 @@ # SPDX-License-Identifier: LGPL-3.0-or-other # Copyright (C) 2021 Contributors to the SLS Detector Package -# empty branch = developer branch in updateAPIVersion.sh -branch="" det_list=("ctbDetectorServer" "gotthardDetectorServer" "gotthard2DetectorServer" @@ -11,14 +9,14 @@ det_list=("ctbDetectorServer" "moenchDetectorServer" "xilinx_ctbDetectorServer" ) -usage="\nUsage: compileAllServers.sh [server|all(opt)] [branch(opt)]. \n\tNo arguments mean all servers with 'developer' branch. \n\tNo 'branch' input means 'developer branch'" +usage="\nUsage: compileAllServers.sh [server|all(opt)]. \n\tNo arguments mean all servers with 'developer' branch." # arguments if [ $# -eq 0 ]; then # no argument, all servers declare -a det=${det_list[@]} echo "Compiling all servers" -elif [ $# -eq 1 ] || [ $# -eq 2 ]; then +elif [ $# -eq 1 ]; then # 'all' servers if [[ $1 == "all" ]]; then declare -a det=${det_list[@]} @@ -33,16 +31,6 @@ elif [ $# -eq 1 ] || [ $# -eq 2 ]; then declare -a det=("${1}") #echo "Compiling only $1" fi - # branch - if [ $# -eq 2 ]; then - # arg in list - if [[ $det_list == *$2* ]]; then - echo -e "Invalid argument 2: $2. $usage" - return -1 - fi - branch+=$2 - #echo "with branch $branch" - fi else echo -e "Too many arguments.$usage" return -1 @@ -60,8 +48,7 @@ do file="${i}_developer" echo -e "Compiling $dir [$file]" cd $dir - make clean - if make API_BRANCH=$branch; then + if make clean; then deterror[$idet]="OK" else deterror[$idet]="FAIL" diff --git a/slsDetectorServers/ctbDetectorServer/Makefile b/slsDetectorServers/ctbDetectorServer/Makefile index 5bdb5679d..22547fdc5 100755 --- a/slsDetectorServers/ctbDetectorServer/Makefile +++ b/slsDetectorServers/ctbDetectorServer/Makefile @@ -25,15 +25,15 @@ version: clean versioning $(PROGS) boot: $(OBJS) -version_branch=$(API_BRANCH) version_name=APICTB version_path=slsDetectorServers/ctbDetectorServer versioning: - cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;` + cd ../../ && echo $(PWD) && echo `tput setaf 6; python updateAPIVersion.py $(version_name) $(version_path); tput sgr0;` $(PROGS): $(OBJS) # echo $(OBJS) + cd $(current_dir) mkdir -p $(DESTDIR) $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS) mv $(PROGS) $(DESTDIR) @@ -41,7 +41,7 @@ $(PROGS): $(OBJS) rm $(main_src)*.o $(md5_dir)*.o clean: - rm -rf $(DESTDIR)/$(PROGS) *.o *.gdb $(main_src)*.o $(md5_dir)*.o + cd $(current_dir) && rm -rf $(DESTDIR)/$(PROGS) *.o *.gdb $(main_src)*.o $(md5_dir)*.o diff --git a/slsSupportLib/include/sls/Version.h b/slsSupportLib/include/sls/Version.h index 33d10c27e..e4ec31631 100644 --- a/slsSupportLib/include/sls/Version.h +++ b/slsSupportLib/include/sls/Version.h @@ -11,7 +11,7 @@ class Version { private: std::string version_; std::string date_; - const std::string defaultBranch_ = "developer"; + inline static const std::string defaultBranch_[] = {"developer", "0.0.0"}; public: explicit Version(const std::string &s); diff --git a/slsSupportLib/src/Version.cpp b/slsSupportLib/src/Version.cpp index 2be4e6c3e..3ace46217 100644 --- a/slsSupportLib/src/Version.cpp +++ b/slsSupportLib/src/Version.cpp @@ -21,7 +21,8 @@ Version::Version(const std::string &s) { } bool Version::hasSemanticVersioning() const { - return version_ != defaultBranch_; + + return (version_ != defaultBranch_[0]) && (version_ != defaultBranch_[1]); } std::string Version::getVersion() const { return version_; } diff --git a/slsSupportLib/tests/CMakeLists.txt b/slsSupportLib/tests/CMakeLists.txt index 4fae7a346..827db97ff 100755 --- a/slsSupportLib/tests/CMakeLists.txt +++ b/slsSupportLib/tests/CMakeLists.txt @@ -14,6 +14,7 @@ target_sources(tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/test-TypeTraits.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-UdpRxSocket.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-logger.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test-Version.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-ZmqSocket.cpp ) diff --git a/slsSupportLib/tests/test-Version.cpp b/slsSupportLib/tests/test-Version.cpp new file mode 100644 index 000000000..9c1f1d3f8 --- /dev/null +++ b/slsSupportLib/tests/test-Version.cpp @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package +#include "catch.hpp" +#include "sls/Version.h" + +namespace sls { + +TEST_CASE("check if version is semantic", "[.version]") { + + auto [version_string, has_semantic_version] = + GENERATE(std::make_tuple("developer 0x250512", false), + std::make_tuple("0.0.0 0x250512", false)); + + Version version(version_string); + + CHECK(version.hasSemanticVersioning() == has_semantic_version); +} + +} // namespace sls diff --git a/tests/scripts/test_frame_synchronizer.py b/tests/scripts/test_frame_synchronizer.py index 87c784cf7..b53e3f1de 100644 --- a/tests/scripts/test_frame_synchronizer.py +++ b/tests/scripts/test_frame_synchronizer.py @@ -44,16 +44,14 @@ def startFrameSynchronizer(num_mods, fp): time.sleep(1) -def acquire(fp): +def acquire(fp, det): Log(LogLevel.INFO, 'Acquiring') Log(LogLevel.INFO, 'Acquiring', fp) - d = Detector() - d.acquire() + det.acquire() -def testFramesCaught(name, num_frames): - d = Detector() - fnum = d.rx_framescaught[0] +def testFramesCaught(name, det, num_frames): + fnum = det.rx_framescaught[0] if fnum != num_frames: raise RuntimeException(f"{name} caught only {fnum}. Expected {num_frames}") @@ -61,7 +59,7 @@ def testFramesCaught(name, num_frames): Log(LogLevel.INFOGREEN, f'Frames caught test passed for {name}', fp) -def testZmqHeadetTypeCount(name, num_mods, num_frames, fp): +def testZmqHeadetTypeCount(name, det, num_mods, num_frames, fp): Log(LogLevel.INFO, f"Testing Zmq Header type count for {name}") Log(LogLevel.INFO, f"Testing Zmq Header type count for {name}", fp) @@ -88,8 +86,7 @@ def testZmqHeadetTypeCount(name, num_mods, num_frames, fp): continue # test if file contents matches expected counts - d = Detector() - num_ports_per_module = 1 if name == "gotthard2" else d.numinterfaces + num_ports_per_module = 1 if name == "gotthard2" else det.numinterfaces total_num_frame_parts = num_ports_per_module * num_mods * num_frames for htype, expected_count in [("header", num_mods), ("series_end", num_mods), ("module", total_num_frame_parts)]: if htype_counts[htype] != expected_count: @@ -111,10 +108,10 @@ def startTestsForAll(args, fp): startDetectorVirtualServer(server, args.num_mods, fp) startFrameSynchronizerPullSocket(server, fp) startFrameSynchronizer(args.num_mods, fp) - loadConfig(name=server, rx_hostname=args.rx_hostname, settingsdir=args.settingspath, fp=fp, num_mods=args.num_mods, num_frames=args.num_frames) - acquire(fp) - testFramesCaught(server, args.num_frames) - testZmqHeadetTypeCount(server, args.num_mods, args.num_frames, fp) + d = loadConfig(name=server, rx_hostname=args.rx_hostname, settingsdir=args.settingspath, fp=fp, num_mods=args.num_mods, num_frames=args.num_frames) + acquire(fp, d) + testFramesCaught(server, d, args.num_frames) + testZmqHeadetTypeCount(server, d, args.num_mods, args.num_frames, fp) Log(LogLevel.INFO, '\n') except Exception as e: raise RuntimeException(f'Synchronizer Tests failed') from e diff --git a/tests/scripts/utils_for_test.py b/tests/scripts/utils_for_test.py index 389bfad4a..b3c4ddabf 100644 --- a/tests/scripts/utils_for_test.py +++ b/tests/scripts/utils_for_test.py @@ -142,7 +142,7 @@ def startDetectorVirtualServer(name :str, num_mods, fp): cmd = [name + 'DetectorServer_virtual', '-p', str(port_no)] if name == 'gotthard': cmd += ['-m', '1'] - startProcessInBackground(cmd, fp) + startProcessInBackgroundWithLogFile(cmd, fp, "/tmp/virtual_det_" + name + str(i) + ".txt") match name: case 'jungfrau': time.sleep(7) @@ -206,6 +206,8 @@ def loadConfig(name, rx_hostname, settingsdir, fp, num_mods = 1, num_frames = 1) d.frames = num_frames except Exception as e: raise RuntimeException(f'Could not load config for {name}. Error: {str(e)}') from e + + return d def ParseArguments(description, default_num_mods=1): diff --git a/updateAPIVersion.py b/updateAPIVersion.py new file mode 100644 index 000000000..934df081d --- /dev/null +++ b/updateAPIVersion.py @@ -0,0 +1,81 @@ +# SPDX-License-Identifier: LGPL-3.0-or-other +# Copyright (C) 2025 Contributors to the SLS Detector Package +""" +Script to update API VERSION file based on the version in VERSION file. +""" + +import argparse +import sys +import os +import re +import time +from datetime import datetime + + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) + +API_FILE = SCRIPT_DIR + "/slsSupportLib/include/sls/versionAPI.h" + +VERSION_FILE = SCRIPT_DIR + "/VERSION" + +parser = argparse.ArgumentParser(description = 'updates API version') +parser.add_argument('api_module_name', choices=["APILIB", "APIRECEIVER", "APICTB", "APIGOTTHARD2", "APIMOENCH", "APIEIGER", "APIXILINXCTB", "APIJUNGFRAU", "APIMYTHEN3"], help = 'module name to change api version options are: ["APILIB", "APIRECEIVER", "APICTB", "APIGOTTHARD2", "APIMOENCH", "APIEIGER", "APIXILINXCTB", "APIJUNGFRAU", "APIMYTHEN3"]') +parser.add_argument('api_dir', help = 'Relative or absolut path to the module code') + +def update_api_file(new_api : str, api_module_name : str, api_file_name : str): + + regex_pattern = re.compile(rf'#define\s+{api_module_name}\s+') + with open(api_file_name, "r") as api_file: + lines = api_file.readlines() + + with open(api_file_name, "w") as api_file: + for line in lines: + if regex_pattern.match(line): + api_file.write(f'#define {api_module_name} "{new_api}"\n') + else: + api_file.write(line) + +def get_latest_modification_date(directory : str): + latest_time = 0 + latest_date = None + + for root, dirs, files in os.walk(directory): + for file in files: + if file.endswith(".o"): + continue + full_path = os.path.join(root, file) + try: + mtime = os.path.getmtime(full_path) + if mtime > latest_time: + latest_time = mtime + except FileNotFoundError: + continue + + latest_date = datetime.fromtimestamp(latest_time).strftime("%y%m%d") + + return latest_date + + +def update_api_version(api_module_name : str, api_dir : str): + api_date = get_latest_modification_date(api_dir) + api_date = "0x"+str(api_date) + + with open(VERSION_FILE, "r") as version_file: + api_version = version_file.read().strip() + + api_version = api_version + " " + api_date #not sure if we should give an argument option version_branch + + update_api_file(api_version, api_module_name, API_FILE) + + print(f"updated {api_module_name} api version to: {api_version}") + +if __name__ == "__main__": + + args = parser.parse_args() + + api_dir = SCRIPT_DIR + "/" + args.api_dir + + + update_api_version(args.api_module_name, api_dir) + + diff --git a/updateAPIVersion.sh b/updateAPIVersion.sh deleted file mode 100755 index 8c45e0c48..000000000 --- a/updateAPIVersion.sh +++ /dev/null @@ -1,65 +0,0 @@ -# SPDX-License-Identifier: LGPL-3.0-or-other -# Copyright (C) 2021 Contributors to the SLS Detector Package -usage="\nUsage: updateAPIVersion.sh [API_NAME] [API_DIR] [API_BRANCH(opt)]." - -if [ $# -lt 2 ]; then - echo -e "Requires atleast 2 arguments. $usage" - return [-1] -fi - -API_NAME=$1 -PACKAGE_DIR=$PWD -API_DIR=$PACKAGE_DIR/$2 -API_FILE=$PACKAGE_DIR/slsSupportLib/include/sls/versionAPI.h -CURR_DIR=$PWD - -if [ ! -d "$API_DIR" ]; then - echo "[API_DIR] does not exist. $usage" - return [-1] -fi - -#go to directory -cd $API_DIR - -#deleting line from file -NUM=$(sed -n '/'$API_NAME' /=' $API_FILE) -#echo $NUM - - -if [ "$NUM" -gt 0 ]; then - sed -i ${NUM}d $API_FILE -fi - -#find new API date -API_DATE="find . -printf \"%T@ %CY-%Cm-%Cd\n\"| sort -nr | cut -d' ' -f2- | egrep -v '(\.)o' | head -n 1" - -API_DATE=`eval $API_DATE` - -API_DATE=$(sed "s/-//g" <<< $API_DATE | awk '{print $1;}' ) - -#extracting only date -API_DATE=${API_DATE:2:6} - -#prefix of 0x -API_DATE=${API_DATE/#/0x} -echo "date="$API_DATE - - -# API_VAL concatenates branch and date -API_VAL="" -# API branch is defined (3rd argument) -if [ $# -eq 3 ]; then - API_BRANCH=$3 - echo "branch="$API_BRANCH - API_VAL+="\"$API_BRANCH $API_DATE\"" -else - # API branch not defined (default is developer) - echo "branch=developer" - API_VAL+="\"developer $API_DATE\"" -fi - -#copy it to versionAPI.h -echo "#define "$API_NAME $API_VAL >> $API_FILE - -#go back to original directory -cd $CURR_DIR diff --git a/updateClientAPIVersion.py b/updateClientAPIVersion.py new file mode 100644 index 000000000..d7764cff9 --- /dev/null +++ b/updateClientAPIVersion.py @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: LGPL-3.0-or-other +# Copyright (C) 2025 Contributors to the SLS Detector Package +""" +Script to update API VERSION for slsReceiverSoftware or slsDetectorSoftware +""" + +import argparse +import os + +from updateAPIVersion import update_api_version + +SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) + +parser = argparse.ArgumentParser(description = 'updates API version') +parser.add_argument('module_name', nargs="?", choices=["slsDetectorSoftware", "slsReceiverSoftware", "all"], default="all", help = 'module name to change api version options are: ["slsDetectorSoftware", "slsReceiverSoftware, "all"]') + +if __name__ == "__main__": + args = parser.parse_args() + + if args.module_name == "all": + client_names = ["APILIB", "APIRECEIVER"] + client_directories = [SCRIPT_DIR+"/slsDetectorSoftware", SCRIPT_DIR+"/slsReceiverSoftware"] + elif args.module_name == "slsDetectorSoftware": + client_names = ["APILIB"] + client_directories = [SCRIPT_DIR+"/slsDetectorSoftware"] + else: + client_names = ["APIRECEIVER"] + client_directories = [SCRIPT_DIR+"/slsReceiverSoftware"] + + for client_name, client_directory in zip(client_names, client_directories): + update_api_version(client_name, client_directory) + + + diff --git a/updateClientAPIVersion.sh b/updateClientAPIVersion.sh deleted file mode 100755 index bed281622..000000000 --- a/updateClientAPIVersion.sh +++ /dev/null @@ -1,59 +0,0 @@ -# SPDX-License-Identifier: LGPL-3.0-or-other -# Copyright (C) 2021 Contributors to the SLS Detector Package -branch="" -client_list=("slsDetectorSoftware" "slsReceiverSoftware") -usage="\nUsage: updateClientAPI.sh [all|slsDetectorSoftware|slsReceiverSoftware] [branch]. \n\tNo arguments means all with 'developer' branch. \n\tNo 'branch' input means 'developer branch'" - -# arguments -if [ $# -eq 0 ]; then - declare -a client=${client_list[@]} - echo "API Versioning all" -elif [ $# -eq 1 ] || [ $# -eq 2 ]; then - # 'all' client - if [[ $1 == "all" ]]; then - declare -a client=${client_list[@]} - echo "API Versioning all" - else - # only one server - if [[ $client_list != *$1* ]]; then - echo -e "Invalid argument 1: $1. $usage" - return -1 - fi - declare -a client=("${1}") - #echo "Versioning only $1" - fi - if [ $# -eq 2 ]; then - if [[ $client_list == *$2* ]]; then - echo -e "Invalid argument 2: $2. $usage" - return -1 - fi - branch+=$2 - #echo "with branch $branch" - fi -else - echo -e "Too many arguments.$usage" - return -1 -fi - -#echo "list is: ${client[@]}" - -# versioning each client -for i in ${client[@]} -do - dir=$i - case $dir in - slsDetectorSoftware) - declare -a name=APILIB - ;; - slsReceiverSoftware) - declare -a name=APIRECEIVER - ;; - *) - echo -n "unknown client argument $i" - return -1 - ;; - esac - echo -e "Versioning $dir [$name]" - ./updateAPIVersion.sh $name $dir $branch -done - From f1fc7ae0ec242ebb31efae156f5f427aed99f39a Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Thu, 15 May 2025 17:08:27 +0200 Subject: [PATCH 38/42] updated all makefiles --- slsDetectorServers/compileAllServers.sh | 1 + .../compileAllServers_noAPIUpdate.sh | 74 ------------------- slsDetectorServers/compileEigerServer.sh | 18 +++-- .../eigerDetectorServer/Makefile | 3 +- .../gotthard2DetectorServer/Makefile | 3 +- .../gotthardDetectorServer/Makefile | 2 +- .../jungfrauDetectorServer/Makefile | 3 +- .../moenchDetectorServer/Makefile | 3 +- .../mythen3DetectorServer/Makefile | 3 +- .../xilinx_ctbDetectorServer/Makefile | 3 +- 10 files changed, 20 insertions(+), 93 deletions(-) delete mode 100644 slsDetectorServers/compileAllServers_noAPIUpdate.sh mode change 100644 => 100755 slsDetectorServers/compileEigerServer.sh diff --git a/slsDetectorServers/compileAllServers.sh b/slsDetectorServers/compileAllServers.sh index 97b03bc6e..489c6be92 100755 --- a/slsDetectorServers/compileAllServers.sh +++ b/slsDetectorServers/compileAllServers.sh @@ -60,6 +60,7 @@ do file="${i}_developer" echo -e "Compiling $dir [$file]" cd $dir + make clean if make $target; then deterror[$idet]="OK" else diff --git a/slsDetectorServers/compileAllServers_noAPIUpdate.sh b/slsDetectorServers/compileAllServers_noAPIUpdate.sh deleted file mode 100644 index 9bef8400e..000000000 --- a/slsDetectorServers/compileAllServers_noAPIUpdate.sh +++ /dev/null @@ -1,74 +0,0 @@ -# SPDX-License-Identifier: LGPL-3.0-or-other -# Copyright (C) 2021 Contributors to the SLS Detector Package - -det_list=("ctbDetectorServer" - "gotthardDetectorServer" - "gotthard2DetectorServer" - "jungfrauDetectorServer" - "mythen3DetectorServer" - "moenchDetectorServer" - "xilinx_ctbDetectorServer" - ) -usage="\nUsage: compileAllServers.sh [server|all(opt)]. \n\tNo arguments mean all servers with 'developer' branch." - -# arguments -if [ $# -eq 0 ]; then - # no argument, all servers - declare -a det=${det_list[@]} - echo "Compiling all servers" -elif [ $# -eq 1 ]; then - # 'all' servers - if [[ $1 == "all" ]]; then - declare -a det=${det_list[@]} - echo "Compiling all servers" - else - # only one server - # arg not in list - if [[ $det_list != *$1* ]]; then - echo -e "Invalid argument 1: $1. $usage" - return -1 - fi - declare -a det=("${1}") - #echo "Compiling only $1" - fi -else - echo -e "Too many arguments.$usage" - return -1 -fi - -declare -a deterror=("OK" "OK" "OK" "OK" "OK" "OK") - -echo -e "list is ${det[@]}" - -# compile each server -idet=0 -for i in ${det[@]} -do - dir=$i - file="${i}_developer" - echo -e "Compiling $dir [$file]" - cd $dir - if make clean; then - deterror[$idet]="OK" - else - deterror[$idet]="FAIL" - fi - mv bin/$dir bin/$file - git add -f bin/$file - cp bin/$file /tftpboot/ - cd .. - echo -e "\n\n" - ((++idet)) -done - -echo -e "Results:" -idet=0 -for i in ${det[@]} -do - printf "%s\t\t= %s\n" "$i" "${deterror[$idet]}" - ((++idet)) -done - - - - diff --git a/slsDetectorServers/compileEigerServer.sh b/slsDetectorServers/compileEigerServer.sh old mode 100644 new mode 100755 index 35aff3f80..37aefee6a --- a/slsDetectorServers/compileEigerServer.sh +++ b/slsDetectorServers/compileEigerServer.sh @@ -3,21 +3,27 @@ deterror="OK" dir="eigerDetectorServer" file="${dir}_developer" -branch="" + +usage="\nUsage: compileAllServers.sh [update_api(opt)]. \n\t update_api if true updates the api to version in VERSION file" + +update_api=false +target=clean # arguments if [ $# -eq 1 ]; then - branch+=$1 - #echo "with branch $branch" + update_api=$1 + if $update_api ; then + target=version + echo "updating api to $(cat ../VERSION)" + fi elif [ ! $# -eq 0 ]; then - echo -e "Only one optional argument allowed for branch." + echo -e "Only one optional argument allowed for update_api." return -1 fi echo -e "Compiling $dir [$file]" cd $dir -make clean -if make version API_BRANCH=$branch; then +if make $target; then deterror="OK" else deterror="FAIL" diff --git a/slsDetectorServers/eigerDetectorServer/Makefile b/slsDetectorServers/eigerDetectorServer/Makefile index 5d896249f..63910c6f9 100755 --- a/slsDetectorServers/eigerDetectorServer/Makefile +++ b/slsDetectorServers/eigerDetectorServer/Makefile @@ -25,11 +25,10 @@ version: clean versioning $(PROGS) #hv9m_blackfin_server boot: $(OBJS) -version_branch=$(API_BRANCH) version_name=APIEIGER version_path=slsDetectorServers/eigerDetectorServer versioning: - cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;` + cd ../../ && echo $(PWD) && echo `tput setaf 6; python updateAPIVersion.py $(version_name) $(version_path); tput sgr0;` $(PROGS): $(OBJS) diff --git a/slsDetectorServers/gotthard2DetectorServer/Makefile b/slsDetectorServers/gotthard2DetectorServer/Makefile index f5fa63f14..b5670a658 100755 --- a/slsDetectorServers/gotthard2DetectorServer/Makefile +++ b/slsDetectorServers/gotthard2DetectorServer/Makefile @@ -24,11 +24,10 @@ version: clean versioning $(PROGS) boot: $(OBJS) -version_branch=$(API_BRANCH) version_name=APIGOTTHARD2 version_path=slsDetectorServers/gotthard2DetectorServer versioning: - cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;` + cd ../../ && echo $(PWD) && echo `tput setaf 6; python updateAPIVersion.py $(version_name) $(version_path); tput sgr0;` $(PROGS): $(OBJS) diff --git a/slsDetectorServers/gotthardDetectorServer/Makefile b/slsDetectorServers/gotthardDetectorServer/Makefile index 57ead7418..a280b6cd7 100755 --- a/slsDetectorServers/gotthardDetectorServer/Makefile +++ b/slsDetectorServers/gotthardDetectorServer/Makefile @@ -27,7 +27,7 @@ version_branch=$(API_BRANCH) version_name=APIGOTTHARD version_path=slsDetectorServers/gotthardDetectorServer versioning: - cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;` + cd ../../ && echo $(PWD) && echo `tput setaf 6; python updateAPIVersion.py $(version_name) $(version_path); tput sgr0;` $(PROGS): $(OBJS) diff --git a/slsDetectorServers/jungfrauDetectorServer/Makefile b/slsDetectorServers/jungfrauDetectorServer/Makefile index b54c0c188..881f2e660 100755 --- a/slsDetectorServers/jungfrauDetectorServer/Makefile +++ b/slsDetectorServers/jungfrauDetectorServer/Makefile @@ -24,11 +24,10 @@ version: clean versioning $(PROGS) boot: $(OBJS) -version_branch=$(API_BRANCH) version_name=APIJUNGFRAU version_path=slsDetectorServers/jungfrauDetectorServer versioning: - cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;` + cd ../../ && echo $(PWD) && echo `tput setaf 6; python updateAPIVersion.py $(version_name) $(version_path); tput sgr0;` $(PROGS): $(OBJS) diff --git a/slsDetectorServers/moenchDetectorServer/Makefile b/slsDetectorServers/moenchDetectorServer/Makefile index 5f7457c19..71ebbf4fd 100755 --- a/slsDetectorServers/moenchDetectorServer/Makefile +++ b/slsDetectorServers/moenchDetectorServer/Makefile @@ -24,11 +24,10 @@ version: clean versioning $(PROGS) boot: $(OBJS) -version_branch=$(API_BRANCH) version_name=APIMOENCH version_path=slsDetectorServers/moenchDetectorServer versioning: - cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;` + cd ../../ && echo $(PWD) && echo `tput setaf 6; python updateAPIVersion.py $(version_name) $(version_path); tput sgr0;` $(PROGS): $(OBJS) diff --git a/slsDetectorServers/mythen3DetectorServer/Makefile b/slsDetectorServers/mythen3DetectorServer/Makefile index fb03c9d12..b6d68fac0 100755 --- a/slsDetectorServers/mythen3DetectorServer/Makefile +++ b/slsDetectorServers/mythen3DetectorServer/Makefile @@ -25,11 +25,10 @@ version: clean versioning $(PROGS) boot: $(OBJS) -version_branch=$(API_BRANCH) version_name=APIMYTHEN3 version_path=slsDetectorServers/mythen3DetectorServer versioning: - cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;` + cd ../../ && echo $(PWD) && echo `tput setaf 6; python updateAPIVersion.py $(version_name) $(version_path); tput sgr0;` $(PROGS): $(OBJS) diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/Makefile b/slsDetectorServers/xilinx_ctbDetectorServer/Makefile index c271efdfe..075c649a6 100755 --- a/slsDetectorServers/xilinx_ctbDetectorServer/Makefile +++ b/slsDetectorServers/xilinx_ctbDetectorServer/Makefile @@ -36,11 +36,10 @@ version: clean versioning $(PROGS) boot: $(OBJS) -version_branch=$(API_BRANCH) version_name=APIXILINXCTB version_path=slsDetectorServers/xilinx_ctbDetectorServer versioning: - cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;` + cd ../../ && echo $(PWD) && echo `tput setaf 6; python updateAPIVersion.py $(version_name) $(version_path); tput sgr0;` $(PROGS): $(OBJS) From 5d48c3fcd8545ab4cd566ffc255ac7ae9cfe0c40 Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Fri, 23 May 2025 11:41:56 +0200 Subject: [PATCH 39/42] adresses review comments --- slsDetectorServers/compileAllServers.sh | 16 ++++++++++------ slsDetectorServers/compileEigerServer.sh | 15 +++++++++------ slsDetectorServers/ctbDetectorServer/Makefile | 3 +-- slsSupportLib/include/sls/Version.h | 2 +- slsSupportLib/src/Version.cpp | 2 +- updateAPIVersion.py | 2 +- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/slsDetectorServers/compileAllServers.sh b/slsDetectorServers/compileAllServers.sh index 489c6be92..005c0d623 100755 --- a/slsDetectorServers/compileAllServers.sh +++ b/slsDetectorServers/compileAllServers.sh @@ -11,8 +11,11 @@ det_list=("ctbDetectorServer ) usage="\nUsage: compileAllServers.sh [server|all(opt)] [update_api(opt)]. \n\tNo arguments mean all servers with 'developer' branch. \n\tupdate_api if true updates the api to version in VERSION file" -update_api=false -target=clean +update_api=true +target=version + + + # arguments if [ $# -eq 0 ]; then # no argument, all servers @@ -38,9 +41,8 @@ elif [ $# -eq 1 ] || [ $# -eq 2 ]; then if [ $# -eq 2 ]; then update_api=$2 - if $update_api ; then - target=version - echo "updating api to $(cat ../VERSION)" + if not $update_api ; then + target=clean fi fi else @@ -52,6 +54,9 @@ declare -a deterror=("OK" "OK" "OK" "OK" "OK" "OK") echo -e "list is ${det[@]}" +if $update_api; then + echo "updating api to $(cat ../VERSION)" +fi # compile each server idet=0 for i in ${det[@]} @@ -68,7 +73,6 @@ do fi mv bin/$dir bin/$file git add -f bin/$file - cp bin/$file /tftpboot/ cd .. echo -e "\n\n" ((++idet)) diff --git a/slsDetectorServers/compileEigerServer.sh b/slsDetectorServers/compileEigerServer.sh index 37aefee6a..f5873dff8 100755 --- a/slsDetectorServers/compileEigerServer.sh +++ b/slsDetectorServers/compileEigerServer.sh @@ -6,21 +6,25 @@ file="${dir}_developer" usage="\nUsage: compileAllServers.sh [update_api(opt)]. \n\t update_api if true updates the api to version in VERSION file" -update_api=false -target=clean +update_api=true +target=version # arguments if [ $# -eq 1 ]; then update_api=$1 - if $update_api ; then - target=version - echo "updating api to $(cat ../VERSION)" + if not $update_api ; then + target=clean + fi elif [ ! $# -eq 0 ]; then echo -e "Only one optional argument allowed for update_api." return -1 fi +if $update_api; then + echo "updating api to $(cat ../VERSION)" +fi + echo -e "Compiling $dir [$file]" cd $dir if make $target; then @@ -31,7 +35,6 @@ fi mv bin/$dir bin/$file git add -f bin/$file -cp bin/$file /tftpboot/ cd .. echo -e "\n\n" printf "Result:\t\t= %s\n" "${deterror}" diff --git a/slsDetectorServers/ctbDetectorServer/Makefile b/slsDetectorServers/ctbDetectorServer/Makefile index 22547fdc5..0b56dd825 100755 --- a/slsDetectorServers/ctbDetectorServer/Makefile +++ b/slsDetectorServers/ctbDetectorServer/Makefile @@ -33,7 +33,6 @@ versioning: $(PROGS): $(OBJS) # echo $(OBJS) - cd $(current_dir) mkdir -p $(DESTDIR) $(CC) -o $@ $^ $(CFLAGS) $(LDLIBS) mv $(PROGS) $(DESTDIR) @@ -41,7 +40,7 @@ $(PROGS): $(OBJS) rm $(main_src)*.o $(md5_dir)*.o clean: - cd $(current_dir) && rm -rf $(DESTDIR)/$(PROGS) *.o *.gdb $(main_src)*.o $(md5_dir)*.o + rm -rf $(DESTDIR)/$(PROGS) *.o *.gdb $(main_src)*.o $(md5_dir)*.o diff --git a/slsSupportLib/include/sls/Version.h b/slsSupportLib/include/sls/Version.h index e4ec31631..6e97873e4 100644 --- a/slsSupportLib/include/sls/Version.h +++ b/slsSupportLib/include/sls/Version.h @@ -11,7 +11,7 @@ class Version { private: std::string version_; std::string date_; - inline static const std::string defaultBranch_[] = {"developer", "0.0.0"}; + inline static const std::string defaultVersion_[] = {"developer", "0.0.0"}; public: explicit Version(const std::string &s); diff --git a/slsSupportLib/src/Version.cpp b/slsSupportLib/src/Version.cpp index 3ace46217..03aeb5339 100644 --- a/slsSupportLib/src/Version.cpp +++ b/slsSupportLib/src/Version.cpp @@ -22,7 +22,7 @@ Version::Version(const std::string &s) { bool Version::hasSemanticVersioning() const { - return (version_ != defaultBranch_[0]) && (version_ != defaultBranch_[1]); + return (version_ != defaultVersion_[0]) && (version_ != defaultVersion_[1]); } std::string Version::getVersion() const { return version_; } diff --git a/updateAPIVersion.py b/updateAPIVersion.py index 934df081d..4d0cf7ccf 100644 --- a/updateAPIVersion.py +++ b/updateAPIVersion.py @@ -20,7 +20,7 @@ VERSION_FILE = SCRIPT_DIR + "/VERSION" parser = argparse.ArgumentParser(description = 'updates API version') parser.add_argument('api_module_name', choices=["APILIB", "APIRECEIVER", "APICTB", "APIGOTTHARD2", "APIMOENCH", "APIEIGER", "APIXILINXCTB", "APIJUNGFRAU", "APIMYTHEN3"], help = 'module name to change api version options are: ["APILIB", "APIRECEIVER", "APICTB", "APIGOTTHARD2", "APIMOENCH", "APIEIGER", "APIXILINXCTB", "APIJUNGFRAU", "APIMYTHEN3"]') -parser.add_argument('api_dir', help = 'Relative or absolut path to the module code') +parser.add_argument('api_dir', help = 'Relative or absolute path to the module code') def update_api_file(new_api : str, api_module_name : str, api_file_name : str): From a541b0c5fe88658c007fc285c94ae477c3394311 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 27 May 2025 12:31:54 +0200 Subject: [PATCH 40/42] updated release version and the api lib version --- VERSION | 2 +- slsSupportLib/include/sls/versionAPI.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 8ce0f0f36..85f864fe8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -9.1.1 \ No newline at end of file +9.2.0 \ No newline at end of file diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index 77eba3c20..0b39ad96f 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -8,6 +8,6 @@ #define APICTB "9.1.0 0x250204" #define APIXILINXCTB "9.1.0 0x250204" #define APIJUNGFRAU "9.1.0 0x250318" -#define APILIB "9.1.0 0x250325" +#define APILIB "9.2.0 0x250527" #define APIMYTHEN3 "9.1.1 0x250409" #define APIRECEIVER "9.1.1 0x250513" From e44d23a56b5096d3ee62f27d9f29197c6d680fb5 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 27 May 2025 15:05:37 +0200 Subject: [PATCH 41/42] raise an exception if the pull socket python script had errors at startup (for eg if pyzmq was not installed) --- tests/scripts/test_frame_synchronizer.py | 4 ++++ tests/scripts/utils_for_test.py | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/scripts/test_frame_synchronizer.py b/tests/scripts/test_frame_synchronizer.py index b53e3f1de..8d2915f0a 100644 --- a/tests/scripts/test_frame_synchronizer.py +++ b/tests/scripts/test_frame_synchronizer.py @@ -20,6 +20,7 @@ from utils_for_test import ( cleanSharedmemory, startProcessInBackground, startProcessInBackgroundWithLogFile, + checkLogForErrors, startDetectorVirtualServer, loadConfig, ParseArguments @@ -34,6 +35,9 @@ def startFrameSynchronizerPullSocket(name, fp): fname = PULL_SOCKET_PREFIX_FNAME + name + '.txt' cmd = ['python', '-u', 'frameSynchronizerPullSocket.py'] startProcessInBackgroundWithLogFile(cmd, fp, fname) + time.sleep(1) + checkLogForErrors(fp, fname) + def startFrameSynchronizer(num_mods, fp): diff --git a/tests/scripts/utils_for_test.py b/tests/scripts/utils_for_test.py index b3c4ddabf..bc703648a 100644 --- a/tests/scripts/utils_for_test.py +++ b/tests/scripts/utils_for_test.py @@ -104,7 +104,7 @@ def startProcessInBackground(cmd, fp): raise RuntimeException(f'Failed to start {cmd}:{str(e)}') from e -def startProcessInBackgroundWithLogFile(cmd, fp, log_file_name): +def startProcessInBackgroundWithLogFile(cmd, fp, log_file_name: str): Log(LogLevel.INFOBLUE, 'Starting up ' + ' '.join(cmd) + '. Log: ' + log_file_name) Log(LogLevel.INFOBLUE, 'Starting up ' + ' '.join(cmd) + '. Log: ' + log_file_name, fp) try: @@ -114,6 +114,22 @@ def startProcessInBackgroundWithLogFile(cmd, fp, log_file_name): raise RuntimeException(f'Failed to start {cmd}:{str(e)}') from e +def checkLogForErrors(fp, log_file_path: str): + try: + with open(log_file_path, 'r') as log_file: + for line in log_file: + if 'Error' in line: + Log(LogLevel.ERROR, f"Error found in log: {line.strip()}") + Log(LogLevel.ERROR, f"Error found in log: {line.strip()}", fp) + raise RuntimeException("Error found in log file") + except FileNotFoundError: + print(f"Log file not found: {log_file_path}") + raise + except Exception as e: + print(f"Exception while reading log: {e}") + raise + + def runProcessWithLogFile(name, cmd, fp, log_file_name): Log(LogLevel.INFOBLUE, 'Running ' + name + '. Log: ' + log_file_name) Log(LogLevel.INFOBLUE, 'Running ' + name + '. Log: ' + log_file_name, fp) From 9338625d8e1b76b78eef59708f9d9d53508a904d Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Tue, 27 May 2025 16:31:20 +0200 Subject: [PATCH 42/42] cmake<=3.28 not required anymore --- conda-recipes/main-library/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda-recipes/main-library/meta.yaml b/conda-recipes/main-library/meta.yaml index 63508e8fa..fd53933c1 100755 --- a/conda-recipes/main-library/meta.yaml +++ b/conda-recipes/main-library/meta.yaml @@ -18,7 +18,7 @@ requirements: - {{ stdlib("c") }} - {{ compiler('cxx') }} - git - - cmake<=3.28 + - cmake - ninja - qt 5.*