From eb8c34f53b09cf9198d3c81c686c5cfe00c82b1b Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Tue, 18 Mar 2025 10:33:51 +0100 Subject: [PATCH 01/26] skeleton pyproject.toml --- CMakeLists.txt | 6 +++++- pyproject.toml | 22 ++++++++++++++++++++++ python/CMakeLists.txt | 15 ++++++++++++--- 3 files changed, 39 insertions(+), 4 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 0ae86941f..80a107ff4 100755 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -72,9 +72,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() \ No newline at end of file From bc187bb19842a53d6e98204b30b4b0e8b835a56d Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Tue, 18 Mar 2025 10:56:03 +0100 Subject: [PATCH 02/26] 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 80a107ff4..48a2d004f 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 d46354351..4b216ee62 100755 --- a/python/slsdet/__init__.py +++ b/python/slsdet/__init__.py @@ -14,7 +14,7 @@ from .pattern import Pattern, patternParameters from .gaincaps import Mythen3GainCapsWrapper from .PatternGenerator import PatternGenerator -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 459e4a25c..873485c88 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 f3e7ad71b..c0aa57900 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 d9a50ad9f4bdc661a77c679bb746e1fc339a14b4 Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Tue, 18 Mar 2025 13:21:46 +0100 Subject: [PATCH 03/26] 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 0f51da017..991a0644d 100644 --- a/conda-recipe/conda_build_config.yaml +++ b/conda-recipe/conda_build_config.yaml @@ -1,8 +1,8 @@ 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 076e37ebc..7f78b180e 100755 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -66,30 +66,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 2f390971e6dc755a1812bf80053998880c76e751 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/26] WI{ --- CMakeLists.txt | 9 +- conda-recipe/build.sh | 5 +- conda-recipe/conda_build_config.yaml | 8 + conda-recipe/meta.yaml | 123 ++++----- .../tests/test-SharedMemory.cpp | 236 +++++++++--------- 5 files changed, 199 insertions(+), 182 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 991a0644d..c953a95ed 100644 --- a/conda-recipe/conda_build_config.yaml +++ b/conda-recipe/conda_build_config.yaml @@ -6,3 +6,11 @@ python: # - 3.12 - 3.13 +c_compiler_version: # [unix] + - 11 # [linux] + +cxx_compiler_version: + - 11 # [linux] + +c_stdlib_version: # [linux] + - 2.17 # [linux] \ No newline at end of file diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index 7f78b180e..a83d42fa2 100755 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -15,8 +15,9 @@ build: requirements: build: - {{ compiler('c') }} - - {{compiler('cxx')}} + - {{ compiler('cxx') }} - cmake + - ninja - qt 5.* - xorg-libx11 - xorg-libice @@ -34,8 +35,8 @@ requirements: - expat host: - - libstdcxx-ng - - libgcc-ng + # - libstdcxx-ng + # - libgcc-ng - xorg-libx11 - xorg-libice - xorg-libxext @@ -44,10 +45,12 @@ requirements: - xorg-libxrender - xorg-libxfixes - expat + - libtiff + - libpng run: - - libstdcxx-ng - - libgcc-ng + # - libstdcxx-ng + # - libgcc-ng outputs: @@ -58,70 +61,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 \ No newline at end of file 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 4f62b1a05ccf24aafd202e2a984d2467afbbd5ab 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/26] 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 | 128 ------------------ 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(+), 194 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 c953a95ed..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] \ No newline at end of file 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 a83d42fa2..000000000 --- a/conda-recipe/meta.yaml +++ /dev/null @@ -1,128 +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 - - 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 - - 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 \ No newline at end of file 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 a0d540fd72c6af1b2ff985a9b22fafdbe76364bd 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/26] 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 608eb1a4364568b9ff2b765033b3901a1d975037 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/26] 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 0da508a8b7c2dd2b525d7fd5ec9e2ddd03b28df3 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/26] 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 0b3ead6353a78b2eef86a60c7b05f89fe6bcea05 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/26] 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 9f49ac6457d9a98dbb525c671edf68c58a9e54f6 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/26] 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 c3b197f2094aa2198fd7c178090c58b6db48aa60 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/26] 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 6dd0a5b0dd821a1971fb8363339e7b02df888c1f 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/26] 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 fada23365e1740a9287d2321c221d251f1a9af13 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/26] 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 dc8a34592a3202b9f1c8cbec67c5716b9eb876b7 Mon Sep 17 00:00:00 2001 From: Martin Mueller Date: Thu, 27 Mar 2025 17:03:36 +0100 Subject: [PATCH 14/26] started pattern docu --- docs/CMakeLists.txt | 1 + docs/src/index.rst | 1 + docs/src/pattern.rst | 96 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 docs/src/pattern.rst diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 861debc58..19f09b884 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -54,6 +54,7 @@ set(SPHINX_SOURCE_FILES src/serverdefaults.rst src/quick_start_guide.rst src/troubleshooting.rst + src/pattern.rst src/receivers.rst src/slsreceiver.rst src/udpheader.rst diff --git a/docs/src/index.rst b/docs/src/index.rst index aca6e711c..206b08eef 100644 --- a/docs/src/index.rst +++ b/docs/src/index.rst @@ -37,6 +37,7 @@ Welcome to slsDetectorPackage's documentation! pyenums pyexamples pyPatternGenerator + pattern .. toctree:: :caption: Command line diff --git a/docs/src/pattern.rst b/docs/src/pattern.rst new file mode 100644 index 000000000..c9548af1b --- /dev/null +++ b/docs/src/pattern.rst @@ -0,0 +1,96 @@ +Pattern +======================== + +This is a test and development feature implemented only for Ctb, Xilinx_Ctb and Mythen3. + +A pattern is a sequence of 64-bit words which is executed using a clock on the FPGA. Each of the 64 bits is connected to a pin or internal signal of the FPGA. The purpose of a pattern is to provide a way to change these 64 signals with precise timing. Commands run by the detector server could manipulate the same signals as the pattern, but they cannot enforce a change in a specific clock cycle. + +**Usage** + +A pattern is written to memory on the FPGA using the patword command. + +.. code-block:: + + patword 0x0000 0x000000000000000A + patword 0x0001 0x000000000000000B + patword 0x0002 0x000000000000000C + patword 0x0003 0x000000000000000D + patword 0x0004 0x000000000000000E + +The example above writes a five-word pattern into FPGA memory. The first argument is the memory address, the second argument is the content to be written into this address. Before executing a pattern one has to set the address limits of the pattern: + +.. code-block:: + + patlimits 0x0000 0x0004 + +This instructs the firmware to execute the commands from address 0 to 4 (including 0 and 4). The execution can be started from the GUI or with the commands + +.. code-block:: + + start [Ctb, Xilinx_Ctb] + patternstart [Mythen3] + +The maximal number of patword addresses is 8192. However, it is possible to extend the length of the pattern sequence using loops and wait commands. Loops can be configured with the following commands: + +.. code-block:: + + patloop 0 0x0001 0x0003 + patnloop 0 7 + +The first argument of both commands is the ID of the loop. Ctb and Xilinx_Ctb can have 6 loops (ID 0-5), Mythen3 can have 4 loop definitions. The commands above configure the loop with ID 0 to run 7 times and jump from the patword with address 3 to the patword with address 1. Important: if patnloop is set to 1 the addesses 0x1-0x3 will execute exactly once, if it is set to 0 the pattern addresses will be skipped. + +The same idea is used to introduce wait times. The example below causes the patword at address 0x0002 to be active for 9 clock cycles before the execution continues. + +.. code-block:: + + patwait 0 0x0002 + patwaittime 0 9 + +Waits can be placed inside a loop and loops can be nested. + +**patioctrl** + +The function of each bit in the sequence of 64-bit words depends on the connected detector and firmware version. Some of the 64 bits might connect directly to pads of a chip. The patioctrl command is used to configure the direction of some of these signals (not all of them !! See tables below). Signals where the corresponding bit in the argument of patioctrl is set to 1 will be driveen from the FPGA. + +**patsetbit and patmask** + +The functions patsetbit and patmask can be used to ignore a specific bit of the pattern. +Example: +.. code-block:: + + patmask 0x0101 + patsetbit 0x0001 + +Patmask configures bit 0 and 8 of the pattern to be set to their value in patsetbit. These bits will be ignored during pattern execution and will always be 0 (bit 8) and 1 (bit 0). + +**CTB Pattern Bit Positions** + +.. table:: + + +----+---+------+----+----------+-------------------+----------------+ + | 63 | 62| 61-57| 56 | 55-48 | 47-32 | 31-0 | + +----+---+------+----+----------+-------------------+----------------+ + | A | D| --- | T | EXTIO | DO, stream source | DIO | + +----+---+------+----+----------+-------------------+----------------+ + +DIO: Driving the 32 FPGA pins corresponding to the lowest 32 bits of the patioctrl command. If bits in patioctrl are 0, the same bit positions in DIO will switch to input pins and connect to dbit sampling. Additionally, some of these 32 bits have an automatic override by detector-specific statemachines which is active whenever these sm's are running (currently bits 7,8,11,14 and 20). + +DO: Directly connected to 16 FPGA pins. Output only. Not influenced by patioctrl. Also connected to bit 47-32 in all Ctb dbit samples. All of them can be used as dbit sample trigger. In Addition, every bit of DO can be selected as trigger for sending out a udp packet with samples to the receiver. + +EXTIO: Similar to DIO, but not used as input to the fpga. With the corresponding patioctrl bits set to 0 these pins will switch to a high impedance mode and be ignored by the firmware. + +T: Driving the trigger output + +D: enable signal for digital sampling + +A: adc enable + +Connections of the signals above to actual pads of a chip depend on the layout of the used detector adapter board. + +**Xilinx_CTB Pattern Positions** + +TODO + +**Mythen3 Pattern Positions** + +TODO From dc85a4886481e1f70ce6744b8af83c281a9cd6ff Mon Sep 17 00:00:00 2001 From: Martin Mueller Date: Thu, 27 Mar 2025 18:03:02 +0100 Subject: [PATCH 15/26] update xilinxCtb pattern bit mapping --- docs/src/pattern.rst | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/docs/src/pattern.rst b/docs/src/pattern.rst index c9548af1b..b45b361c6 100644 --- a/docs/src/pattern.rst +++ b/docs/src/pattern.rst @@ -63,7 +63,7 @@ Example: Patmask configures bit 0 and 8 of the pattern to be set to their value in patsetbit. These bits will be ignored during pattern execution and will always be 0 (bit 8) and 1 (bit 0). -**CTB Pattern Bit Positions** +**CTB Pattern Bit Mapping** .. table:: @@ -87,10 +87,19 @@ A: adc enable Connections of the signals above to actual pads of a chip depend on the layout of the used detector adapter board. -**Xilinx_CTB Pattern Positions** - -TODO - -**Mythen3 Pattern Positions** +**Xilinx_CTB Pattern Bit Mapping** + +.. table:: + + +-------+----------------+ + | 63-32 | 31-0 | + +-------+----------------+ + | --- | DIO | + +-------+----------------+ + +DIO: Driving the 32 FPGA pins corresponding to the lowest 32 bits of the patioctrl command. If bits in patioctrl are 0, the same bit positions in DIO will switch to input pins and connect to dbit sampling. Additionally, some of these 32 bits have an automatic override by detector-specific statemachines which is active whenever these sm's are running (currently bits 7,8,11,14 and 20). + + +**Mythen3 Pattern Bit Mapping** TODO From b5c82783d63f4103c8f4ae7ecd644570a4082120 Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Fri, 28 Mar 2025 09:26:55 +0100 Subject: [PATCH 16/26] 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 46152d2419a8593438d8beeeffe9bcd71223e1a4 Mon Sep 17 00:00:00 2001 From: Martin Mueller Date: Fri, 28 Mar 2025 09:35:25 +0100 Subject: [PATCH 17/26] added mythen3 pattern word table --- docs/src/pattern.rst | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/docs/src/pattern.rst b/docs/src/pattern.rst index b45b361c6..4708fe0ec 100644 --- a/docs/src/pattern.rst +++ b/docs/src/pattern.rst @@ -37,7 +37,7 @@ The maximal number of patword addresses is 8192. However, it is possible to exte patloop 0 0x0001 0x0003 patnloop 0 7 -The first argument of both commands is the ID of the loop. Ctb and Xilinx_Ctb can have 6 loops (ID 0-5), Mythen3 can have 4 loop definitions. The commands above configure the loop with ID 0 to run 7 times and jump from the patword with address 3 to the patword with address 1. Important: if patnloop is set to 1 the addesses 0x1-0x3 will execute exactly once, if it is set to 0 the pattern addresses will be skipped. +The first argument of both commands is the ID of the loop. Ctb and Xilinx_Ctb can have 6 loops (ID 0-5), Mythen3 can have 4 loop definitions. The commands above configure the loop with ID 0 to run 7 times and jump from the patword with address 3 to the patword with address 1. Important: If patnloop is set to 1, the addresses 0x1-0x3 will execute exactly once; if it is set to 0, the pattern addresses will be skipped. The same idea is used to introduce wait times. The example below causes the patword at address 0x0002 to be active for 9 clock cycles before the execution continues. @@ -50,18 +50,21 @@ Waits can be placed inside a loop and loops can be nested. **patioctrl** -The function of each bit in the sequence of 64-bit words depends on the connected detector and firmware version. Some of the 64 bits might connect directly to pads of a chip. The patioctrl command is used to configure the direction of some of these signals (not all of them !! See tables below). Signals where the corresponding bit in the argument of patioctrl is set to 1 will be driveen from the FPGA. +The function of each bit in the sequence of 64-bit words depends on the connected detector and firmware version. Some of the 64 bits might connect directly to pads of a chip. The patioctrl command is used to configure the direction of some of these signals (not all of them !! See tables below). Signals where the corresponding bit in the argument of patioctrl is set to 1 will be driven from the FPGA. **patsetbit and patmask** The functions patsetbit and patmask can be used to ignore a specific bit of the pattern. Example: + .. code-block:: patmask 0x0101 patsetbit 0x0001 -Patmask configures bit 0 and 8 of the pattern to be set to their value in patsetbit. These bits will be ignored during pattern execution and will always be 0 (bit 8) and 1 (bit 0). +Patmask configures bit 0 and 8 of the pattern to be set to their value in patsetbit. These bits will be ignored during pattern execution and will always be 0 (bit 8) and 1 (bit 0). + +The mappings of bit positions in the pattern word to signals/pads of the FPGA are listed below for the three detector types where patterns are used. In the case of the two CTB's, connections of the signals to actual pads of a chip depend on the layout of the used detector adapter board. Therefore, each type of detector adapter board adds an additional mapping layer. **CTB Pattern Bit Mapping** @@ -75,18 +78,16 @@ Patmask configures bit 0 and 8 of the pattern to be set to their value in patset DIO: Driving the 32 FPGA pins corresponding to the lowest 32 bits of the patioctrl command. If bits in patioctrl are 0, the same bit positions in DIO will switch to input pins and connect to dbit sampling. Additionally, some of these 32 bits have an automatic override by detector-specific statemachines which is active whenever these sm's are running (currently bits 7,8,11,14 and 20). -DO: Directly connected to 16 FPGA pins. Output only. Not influenced by patioctrl. Also connected to bit 47-32 in all Ctb dbit samples. All of them can be used as dbit sample trigger. In Addition, every bit of DO can be selected as trigger for sending out a udp packet with samples to the receiver. +DO: Directly connected to 16 FPGA pins. Output only. Not influenced by patioctrl. Also connected to bit 47-32 in all Ctb dbit samples. All of them can be used as dbit sample trigger. In addition, every bit of DO can be selected as trigger for sending out a udp packet with samples to the receiver. EXTIO: Similar to DIO, but not used as input to the fpga. With the corresponding patioctrl bits set to 0 these pins will switch to a high impedance mode and be ignored by the firmware. -T: Driving the trigger output +T: trigger output D: enable signal for digital sampling A: adc enable -Connections of the signals above to actual pads of a chip depend on the layout of the used detector adapter board. - **Xilinx_CTB Pattern Bit Mapping** .. table:: @@ -102,4 +103,20 @@ DIO: Driving the 32 FPGA pins corresponding to the lowest 32 bits of the patioct **Mythen3 Pattern Bit Mapping** -TODO +.. table:: + + +-------+--------+-------+--------+------------+----------+----------+-----+-----+ + | 63-33 | 32 | 31-25 | 24 | 23 | 22 | 21 | 20 | 19 | + +-------+--------+-------+--------+------------+----------+----------+-----+-----+ + | --- | signARD| --- | CHSclk | cnt_rst | sto_rst | STATLOAD | STO | SIN | + +-------+--------+-------+--------+------------+----------+----------+-----+-----+ + +.. table:: + + +---------+-----+-------+-------+----+-------+---------+--------+ + | 18 | 17 | 16-14 | 13 | 12 | 11 | 10 | 9-0 | + +---------+-----+-------+-------+----+-------+---------+--------+ + | SR_MODE | clk | EN | PULSE | RD | CHSIN | ANAMode | TBLOAD | + +---------+-----+-------+-------+----+-------+---------+--------+ + +For Mythen3 the pattern word only connects to output pins of the FPGA when the pattern is running. Afterwards the signals will switch back to other logic in the FPGA. Both CTB's hold the last executed pattern word until a new pattern is started. \ No newline at end of file From 3312adddd15b0eb715614ef98d841da28b35e96f Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Fri, 28 Mar 2025 15:43:09 +0100 Subject: [PATCH 18/26] 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 470e2633c3e657812faa633816bdef8f67da521d Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 28 Mar 2025 16:32:37 +0100 Subject: [PATCH 19/26] adding pmodules for 9.1.0 rhl8 --- psi-pmodules/DetectorSoftware/slsDetectorPackage/files/variants | 1 + 1 file changed, 1 insertion(+) diff --git a/psi-pmodules/DetectorSoftware/slsDetectorPackage/files/variants b/psi-pmodules/DetectorSoftware/slsDetectorPackage/files/variants index 9a01f5487..c20d6f7e1 100644 --- a/psi-pmodules/DetectorSoftware/slsDetectorPackage/files/variants +++ b/psi-pmodules/DetectorSoftware/slsDetectorPackage/files/variants @@ -12,5 +12,6 @@ slsDetectorPackage/8.0.1_rh8 stable cmake/3.15.5 Qt/5.12.10 slsDetectorPackage/8.0.2_rh7 stable cmake/3.15.5 Qt/5.12.10 slsDetectorPackage/8.0.2_rh8 stable cmake/3.15.5 Qt/5.12.10 slsDetectorPackage/9.0.0_rh8 stable cmake/3.15.5 Qt/5.12.10 +slsDetectorPackage/9.1.0_rh8 stable cmake/3.15.5 Qt/5.12.10 From 95e11d668a1aaec7e6c3d4c1b423f4deb42f7871 Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Fri, 28 Mar 2025 18:26:45 +0100 Subject: [PATCH 20/26] 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 04583acb21850db64121b54d50da64b29d72849d Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Tue, 1 Apr 2025 14:17:07 +0200 Subject: [PATCH 21/26] 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 5f14eb32aa83ddd72e52a27499be787f874dadcb Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Tue, 1 Apr 2025 16:57:47 +0200 Subject: [PATCH 22/26] 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 d0ccf236c036d708ad31a48953880c3c9aff8431 Mon Sep 17 00:00:00 2001 From: froejdh_e Date: Tue, 1 Apr 2025 17:20:35 +0200 Subject: [PATCH 23/26] 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 0b3cd499a8a6fbf424f53e25a76251564d142ccf Mon Sep 17 00:00:00 2001 From: Martin Mueller Date: Wed, 2 Apr 2025 10:18:57 +0200 Subject: [PATCH 24/26] Dhanya's comments --- docs/src/pattern.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/pattern.rst b/docs/src/pattern.rst index 4708fe0ec..471a3e570 100644 --- a/docs/src/pattern.rst +++ b/docs/src/pattern.rst @@ -23,7 +23,7 @@ The example above writes a five-word pattern into FPGA memory. The first argumen patlimits 0x0000 0x0004 -This instructs the firmware to execute the commands from address 0 to 4 (including 0 and 4). The execution can be started from the GUI or with the commands +This instructs the firmware to execute the commands from address 0 to 4 (including 0 and 4). The execution can be started from the pyctbgui or with the commands .. code-block:: @@ -76,7 +76,7 @@ The mappings of bit positions in the pattern word to signals/pads of the FPGA ar | A | D| --- | T | EXTIO | DO, stream source | DIO | +----+---+------+----+----------+-------------------+----------------+ -DIO: Driving the 32 FPGA pins corresponding to the lowest 32 bits of the patioctrl command. If bits in patioctrl are 0, the same bit positions in DIO will switch to input pins and connect to dbit sampling. Additionally, some of these 32 bits have an automatic override by detector-specific statemachines which is active whenever these sm's are running (currently bits 7,8,11,14 and 20). +DIO: Driving the 32 FPGA pins corresponding to the lowest 32 bits of the patioctrl command. If bits in patioctrl are 0, the same bit positions in DIO will switch to input pins and connect to dbit sampling. Additionally, some of these 32 bits have an automatic override by detector-specific statemachines which is active whenever one of these statemachines is running (currently bits 7,8,11,14 and 20). DO: Directly connected to 16 FPGA pins. Output only. Not influenced by patioctrl. Also connected to bit 47-32 in all Ctb dbit samples. All of them can be used as dbit sample trigger. In addition, every bit of DO can be selected as trigger for sending out a udp packet with samples to the receiver. From 5ab2c1693ec46df6d98579ebf53c100b3dadb94e 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 25/26] 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 4b216ee62..a3097eda4 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 7c8639b8ae823ab9d5e89cfbd9c1a0138822f838 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 9 Apr 2025 18:20:58 +0200 Subject: [PATCH 26/26] formatting --- slsDetectorSoftware/include/sls/Pattern.h | 2 +- slsDetectorSoftware/src/Pattern.cpp | 15 +++++++-------- slsSupportLib/include/sls/versionAPI.h | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/slsDetectorSoftware/include/sls/Pattern.h b/slsDetectorSoftware/include/sls/Pattern.h index 4a8cb6f47..90d6aae12 100644 --- a/slsDetectorSoftware/include/sls/Pattern.h +++ b/slsDetectorSoftware/include/sls/Pattern.h @@ -23,7 +23,7 @@ typedef struct __attribute__((packed)) { #ifdef __cplusplus class Pattern { patternParameters *pat = new patternParameters{}; - std::ostream& stream(std::ostream &os) const; + std::ostream &stream(std::ostream &os) const; public: Pattern(); diff --git a/slsDetectorSoftware/src/Pattern.cpp b/slsDetectorSoftware/src/Pattern.cpp index 4083df7fa..1a5f7b80c 100644 --- a/slsDetectorSoftware/src/Pattern.cpp +++ b/slsDetectorSoftware/src/Pattern.cpp @@ -243,10 +243,10 @@ size_t Pattern::load(const std::string &fname) { return numPatWords; } -std::ostream& Pattern::stream(std::ostream &os) const{ +std::ostream &Pattern::stream(std::ostream &os) const { for (uint32_t i = pat->limits[0]; i <= pat->limits[1]; ++i) { os << "patword " << ToStringHex(i, 4) << " " - << ToStringHex(pat->word[i], 16) << std::endl; + << ToStringHex(pat->word[i], 16) << std::endl; } // patioctrl @@ -254,13 +254,12 @@ std::ostream& Pattern::stream(std::ostream &os) const{ // patlimits os << "patlimits " << ToStringHex(pat->limits[0], 4) << " " - << ToStringHex(pat->limits[1], 4) << std::endl; + << ToStringHex(pat->limits[1], 4) << std::endl; for (size_t i = 0; i < MAX_PATTERN_LEVELS; ++i) { // patloop - os << "patloop " << i << " " - << ToStringHex(pat->startloop[i], 4) << " " - << ToStringHex(pat->stoploop[i], 4) << std::endl; + os << "patloop " << i << " " << ToStringHex(pat->startloop[i], 4) << " " + << ToStringHex(pat->stoploop[i], 4) << std::endl; // patnloop os << "patnloop " << i << " " << pat->nloop[i] << std::endl; } @@ -268,10 +267,10 @@ std::ostream& Pattern::stream(std::ostream &os) const{ for (size_t i = 0; i < MAX_PATTERN_LEVELS; ++i) { // patwait os << "patwait " << i << " " << ToStringHex(pat->wait[i], 4) - << std::endl; + << std::endl; // patwaittime os << "patwaittime " << i << " " << pat->waittime[i]; - if (i