diff --git a/CMakeLists.txt b/CMakeLists.txt index 132ac8d65..c79c4eab3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -294,7 +294,7 @@ if (SLS_USE_INTEGRATION_TESTS) endif (SLS_USE_INTEGRATION_TESTS) if (SLS_USE_PYTHON) - find_package (Python 3.6 COMPONENTS Interpreter Development) + find_package (Python 3.6 COMPONENTS Interpreter Development.Module) if(SLS_FETCH_PYBIND11_FROM_GITHUB) FetchContent_Declare( pybind11 diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 9079c932e..bcbbf1699 100755 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -19,7 +19,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 @@ -49,6 +49,7 @@ set( PYTHON_FILES slsdet/temperature.py slsdet/lookup.py slsdet/utils.py + setup.py ) @@ -58,7 +59,6 @@ foreach(FILE ${PYTHON_FILES}) endforeach(FILE ${PYTHON_FILES}) - configure_file( scripts/basic.py ${CMAKE_BINARY_DIR}/basic.py ) diff --git a/python/setup.py b/python/setup.py index 47c732e82..f2f7869fa 100755 --- a/python/setup.py +++ b/python/setup.py @@ -7,51 +7,16 @@ Build upon the pybind11 example found here: https://github.com/pybind/python_exa import os import sys -sys.path.append('../libs/pybind') +from pathlib import Path +# sys.path.append('../libs/pybind') from setuptools import setup, find_packages -from pybind11.setup_helpers import Pybind11Extension, build_ext + __version__ = os.environ.get('GIT_DESCRIBE_TAG', 'developer') -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', - ] - - - , - include_dirs=[ - os.path.join('../libs/pybind/include'), - os.path.join(get_conda_path(), 'include'), - - ], - libraries=['SlsDetector', 'SlsSupport', 'SlsReceiver', 'zmq'], - library_dirs=[ - os.path.join(get_conda_path(), 'lib'), - ], - language='c++' - ), -] - setup( name='slsdet', version=__version__, @@ -61,7 +26,7 @@ setup( description='Detector API for SLS Detector Group detectors', long_description='', packages=find_packages(exclude=['contrib', 'docs', 'tests']), - ext_modules=ext_modules, - cmdclass={"build_ext": build_ext}, + package_data={"":["*.so"]}, + include_package_data=True, zip_safe=False, ) diff --git a/python/slsdet/__init__.py b/python/slsdet/__init__.py index dd657ecf8..3877e9f0b 100755 --- a/python/slsdet/__init__.py +++ b/python/slsdet/__init__.py @@ -15,7 +15,7 @@ from .moench import Moench from .pattern import Pattern, patternParameters from .gaincaps import Mythen3GainCapsWrapper -import _slsdet +from . import _slsdet xy = _slsdet.xy defs = _slsdet.slsDetectorDefs diff --git a/python/slsdet/ctb.py b/python/slsdet/ctb.py index 74e4a59ee..53ae68e72 100644 --- a/python/slsdet/ctb.py +++ b/python/slsdet/ctb.py @@ -5,7 +5,7 @@ from .utils import element_if_equal from .dacs import DetectorDacs, NamedDacs from .voltages import DetectorVoltages, NamedVoltages from .slowadcs import DetectorSlowAdcs, NamedSlowAdcs -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 951bbb67b..1f516fecb 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..bea5aea75 100644 --- a/python/slsdet/enums.py +++ b/python/slsdet/enums.py @@ -15,8 +15,9 @@ if dt === detectorType.EIGER: """ -import _slsdet -for name, cls in _slsdet.slsDetectorDefs.__dict__.items(): +from . import _slsdet +import slsdet._slsdet +for name, cls in slsdet._slsdet.slsDetectorDefs.__dict__.items(): if isinstance(cls, type): exec(f'{name} = {cls.__module__}.{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/gotthard.py b/python/slsdet/gotthard.py index 9468c78a3..c7aa29d73 100644 --- a/python/slsdet/gotthard.py +++ b/python/slsdet/gotthard.py @@ -9,7 +9,7 @@ This file contains the specialization for the Moench detector from .detector import Detector, freeze from .dacs import DetectorDacs -import _slsdet +from . import _slsdet dacIndex = _slsdet.slsDetectorDefs.dacIndex from .detector_property import DetectorProperty 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 9da5b7771..8484d0dea 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/proxy.py b/python/slsdet/proxy.py index 90c9f4523..5c243b605 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/slowadcs.py b/python/slsdet/slowadcs.py index ae153a706..f2b3ba811 100755 --- a/python/slsdet/slowadcs.py +++ b/python/slsdet/slowadcs.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 SlowAdc(DetectorProperty): diff --git a/python/slsdet/utils.py b/python/slsdet/utils.py index 60bbbb2a7..5c0cd8830 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 diff --git a/python/slsdet/voltages.py b/python/slsdet/voltages.py index f545d5dd0..cc91b687d 100755 --- a/python/slsdet/voltages.py +++ b/python/slsdet/voltages.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 Voltage(DetectorProperty): diff --git a/slsDetectorSoftware/CMakeLists.txt b/slsDetectorSoftware/CMakeLists.txt index 692302d11..731f66a47 100755 --- a/slsDetectorSoftware/CMakeLists.txt +++ b/slsDetectorSoftware/CMakeLists.txt @@ -29,6 +29,7 @@ target_link_libraries(slsDetectorObject rt PRIVATE slsProjectWarnings + "$" ) set(DETECTOR_LIBRARY_TARGETS slsDetectorObject) diff --git a/slsReceiverSoftware/CMakeLists.txt b/slsReceiverSoftware/CMakeLists.txt index 8ff2b1e6b..f2364dd18 100755 --- a/slsReceiverSoftware/CMakeLists.txt +++ b/slsReceiverSoftware/CMakeLists.txt @@ -49,6 +49,7 @@ target_link_libraries(slsReceiverObject slsSupportStatic PRIVATE slsProjectWarnings #don't propagate warnigns + "$" ) # HDF5