diff --git a/Framework/PythonInterface/mantid/CMakeLists.txt b/Framework/PythonInterface/mantid/CMakeLists.txt index b2e1fa8c0046..b5eecde9f362 100644 --- a/Framework/PythonInterface/mantid/CMakeLists.txt +++ b/Framework/PythonInterface/mantid/CMakeLists.txt @@ -22,6 +22,7 @@ add_subdirectory(geometry) add_subdirectory(api) add_subdirectory(dataobjects) add_subdirectory(_plugins) +add_subdirectory(utils/reflectometry) # Defines the target the will cause the Python bundle to be copied set(PYBUNDLE_POST_TARGET PythonModule) diff --git a/Framework/PythonInterface/mantid/utils/reflectometry/CMakeLists.txt b/Framework/PythonInterface/mantid/utils/reflectometry/CMakeLists.txt new file mode 100644 index 000000000000..27036e7a7ddf --- /dev/null +++ b/Framework/PythonInterface/mantid/utils/reflectometry/CMakeLists.txt @@ -0,0 +1,25 @@ +# _polarization_helpers Python module + +set(MODULE_TEMPLATE src/polarization_helpers.cpp.in) + +# Files containing export definitions, these are automatically processed -- Do NOT sort this list. The order defines the +# order in which the export definitions occur and some depend on their base classes being exported first -- +set(EXPORT_FILES src/Exports/PolarizationCorrectionHelpers.cpp) + +set(MODULE_DEFINITION ${CMAKE_CURRENT_BINARY_DIR}/polarization_helpers.cpp) +create_module(${MODULE_TEMPLATE} ${MODULE_DEFINITION} ${EXPORT_FILES}) + +# Create the target for this directory +add_library(PythonReflHelpersModule ${MODULE_DEFINITION} ${EXPORT_FILES} ${PYTHON_INSTALL_FILES}) +add_library(PythonReflectometryHelpersModule ALIAS PythonReflHelpersModule) + +set_python_properties(PythonReflHelpersModule _polarization_helpers) + +# Add the required dependencies +target_link_libraries(PythonReflHelpersModule PRIVATE Mantid::Algorithms Mantid::PythonInterfaceCore) + +# Installation settings +set_target_properties(PythonReflHelpersModule PROPERTIES INSTALL_RPATH "${EXT_INSTALL_RPATH}") +mtd_install_shared_library( + TARGETS PythonReflHelpersModule DESTINATION ${Python_SITELIB_RELPATH}/mantid/polarization_helpers.cpp +) diff --git a/Framework/PythonInterface/mantid/utils/reflectometry/__init__.py b/Framework/PythonInterface/mantid/utils/reflectometry/__init__.py index 42dad64e006a..bea9a7813786 100644 --- a/Framework/PythonInterface/mantid/utils/reflectometry/__init__.py +++ b/Framework/PythonInterface/mantid/utils/reflectometry/__init__.py @@ -1,6 +1,13 @@ # Mantid Repository : https://github.com/mantidproject/mantid # -# Copyright © 2023 ISIS Rutherford Appleton Laboratory UKRI, +# Copyright © 2024 ISIS Rutherford Appleton Laboratory UKRI, # NScD Oak Ridge National Laboratory, European Spallation Source, # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS # SPDX - License - Identifier: GPL - 3.0 + + +############################################################################### +# Load the C++ library and register the C++ class exports +############################################################################### +from mantid.utils import import_mantid_cext + +import_mantid_cext("._polarization_helpers", "mantid.utils.reflectometry", globals()) diff --git a/Framework/PythonInterface/mantid/utils/reflectometry/src/Exports/PolarizationCorrectionHelpers.cpp b/Framework/PythonInterface/mantid/utils/reflectometry/src/Exports/PolarizationCorrectionHelpers.cpp new file mode 100644 index 000000000000..b137ea42568f --- /dev/null +++ b/Framework/PythonInterface/mantid/utils/reflectometry/src/Exports/PolarizationCorrectionHelpers.cpp @@ -0,0 +1,26 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2024 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source, +// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS +// SPDX - License - Identifier: GPL - 3.0 + + +#include "MantidAlgorithms/PolarizationCorrections/PolarizationCorrectionsHelpers.h" +#include + +namespace { +class SpinStatesORSO {}; +} // namespace + +void export_SpinStatesORSO() { + using namespace boost::python; + + class_("SpinStatesORSO") + .def_readonly("PP", &Mantid::Algorithms::SpinStatesORSO::PP) + .def_readonly("PM", &Mantid::Algorithms::SpinStatesORSO::PM) + .def_readonly("MP", &Mantid::Algorithms::SpinStatesORSO::MP) + .def_readonly("MM", &Mantid::Algorithms::SpinStatesORSO::MM) + .def_readonly("PO", &Mantid::Algorithms::SpinStatesORSO::PO) + .def_readonly("MO", &Mantid::Algorithms::SpinStatesORSO::MO) + .def_readonly("LOG_NAME", &Mantid::Algorithms::SpinStatesORSO::LOG_NAME); +} diff --git a/Framework/PythonInterface/mantid/utils/reflectometry/src/polarization_helpers.cpp.in b/Framework/PythonInterface/mantid/utils/reflectometry/src/polarization_helpers.cpp.in new file mode 100644 index 000000000000..66213a987060 --- /dev/null +++ b/Framework/PythonInterface/mantid/utils/reflectometry/src/polarization_helpers.cpp.in @@ -0,0 +1,20 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2024 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source, +// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS +// SPDX - License - Identifier: GPL - 3.0 + + +@AUTO_GENERATE_WARNING@ +/********** Source = polarization_helpers.cpp.in **********************************************************/ + +#include +#include + +// Forward declare +@EXPORT_DECLARE@ + +BOOST_PYTHON_MODULE(_polarization_helpers) +{ +@EXPORT_FUNCTIONS@ +}