diff --git a/.gitignore b/.gitignore index 3d01028..5ea46ba 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,5 @@ CMakeLists.txt.user *.code-workspace #used by PyCharm IDE .idea/ +wheelhouse/ +__pycache__/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 9905d85..2a8a033 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,13 +111,26 @@ endif() # ==============================================================================# -# install Python modules to correct platform-dependent directory (if installing to system prefix) -if( "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr" OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local" ) - set( install_path ${Python_SITEARCH} ) +if(SKBUILD) + install( FILES ${PROJECT_BINARY_DIR}/deviceaccess.pyi + DESTINATION "${PROJECT_SOURCE_DIR}/src/deviceaccess" + RENAME __init__.pyi ) + install( FILES ${PROJECT_BINARY_DIR}/deviceaccess.pyi + DESTINATION "${PROJECT_SOURCE_DIR}/src/deviceaccess" ) + install( FILES ${PROJECT_SOURCE_DIR}/mtca4u.py + DESTINATION "${PROJECT_SOURCE_DIR}/src/mtca4u" + RENAME __init__.py ) + install( TARGETS ${PROJECT_NAME} + LIBRARY DESTINATION "${PROJECT_SOURCE_DIR}/src/deviceaccess" ) else() - set( install_path "lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages" ) + # install Python modules to correct platform-dependent directory (if installing to system prefix) + if( "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr" OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local" ) + set( install_path ${Python_SITEARCH} ) + else() + set( install_path "lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages" ) + endif() + + install( FILES ${PROJECT_BINARY_DIR}/deviceaccess.pyi DESTINATION ${install_path} ) + install( FILES ${PROJECT_SOURCE_DIR}/mtca4u.py DESTINATION ${install_path} ) + install( TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${install_path} ) endif() - -install( FILES ${PROJECT_BINARY_DIR}/deviceaccess.pyi DESTINATION ${install_path} ) -install( FILES ${PROJECT_SOURCE_DIR}/mtca4u.py DESTINATION ${install_path} ) -install( TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${install_path} ) diff --git a/README.md b/README.md index 99a6da9..42102c0 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# Bindings for ChimeraTK DeviceAcess Library +# Bindings for ChimeraTK DeviceAccess Library Find API documentation [here](https://chimeratk.github.io/ChimeraTK-DeviceAccess-PythonBindings/head/html) diff --git a/pre_build_manylinux.sh b/pre_build_manylinux.sh new file mode 100755 index 0000000..3bf3f29 --- /dev/null +++ b/pre_build_manylinux.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +# For manylinux_2_28 + +# Dependencies versions +export CPPEXT_VERSION="01.07.00" +export EXPRTK_VERSION="01.04.02" +export NLOHMANN_JSON_VERSION="v3.12.0" +export DEVICEACCESS_VERSION="03.24.01" + +export PROJECT_PWD=`pwd` +export PROCS=`nproc` + +# Creating local build directories +rm -rf ${BUILD_DIR} +mkdir ${BUILD_DIR} +cd ${BUILD_DIR} + +# Helper function to build cmake-based projects +build_cmake () { + cd $1 + mkdir builddir + cd builddir/ + cmake -DCMAKE_BUILD_TYPE=Release -DJSON_BuildTests=OFF -DBUILD_TESTING=OFF -DBUILD_TESTS=OFF .. + make install -j${PROCS} + cd ${BUILD_DIR} +} + +# Install required system packages +dnf install -y epel-release +dnf -y install gcc-c++ gcc-toolset-14-libatomic-devel libxml++-devel boost1.78-devel + +g++ --version + +# Install cppext +git clone --recursive --depth 1 --branch ${CPPEXT_VERSION} https://github.com/ChimeraTK/cppext.git +build_cmake cppext + +# Install exprtk +git clone --recursive --depth 1 --branch ${EXPRTK_VERSION} https://github.com/ChimeraTK/exprtk-interface.git +build_cmake exprtk-interface + +# Install nlohmann-json +git clone --recursive --depth 1 --branch ${NLOHMANN_JSON_VERSION} https://github.com/nlohmann/json.git +build_cmake json + +# Install ChimeraTK-DeviceAccess +git clone --recursive --depth 1 --branch ${DEVICEACCESS_VERSION} https://github.com/ChimeraTK/DeviceAccess.git +build_cmake DeviceAccess + +cd ${PROJECT_PWD} + diff --git a/pyproject.toml b/pyproject.toml index 6dffe81..6c37ed0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,80 @@ +[build-system] +requires = [ + "scikit-build-core", + "numpy", + "pybind11>=3.0", + "mypy>=1.0" +] + +build-backend = "scikit_build_core.build" + +[project] +name = "deviceaccess" +version = "4.0.1" +dependencies = [ + "numpy", + "mypy>=1.0" +] +description = "Python bindings for the ChimeraTK's deviceaccess library" +long_description = "The package provides binding for the ChimeraTK's deviceaccess library" +requires-python = ">=3.8" +readme = "README.md" +license = {file = "LICENSE"} + +classifiers = [ +"Topic :: Software Development :: Libraries :: Python Modules", +"Development Status :: 5 - Production/Stable", +"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", +"Intended Audience :: Developers", +"Programming Language :: Python :: 3", +"Programming Language :: Python :: 3.8", +"Programming Language :: Python :: 3.9", +"Programming Language :: Python :: 3.10", +"Programming Language :: Python :: 3.11", +"Programming Language :: Python :: 3.12", +"Programming Language :: Python :: 3.13", +"Programming Language :: Python :: 3.14", +"Programming Language :: Python :: Implementation :: CPython", +"Topic :: Scientific/Engineering" +] + +[project.urls] +Homepage = "https://github.com/ChimeraTK/DeviceAccess-PythonBindings" +Documentation = "https://chimeratk.github.io/ChimeraTK-DeviceAccess-PythonBindings/head/html/" +Repository = "https://github.com/ChimeraTK/DeviceAccess-PythonBindings" + +[tool.scikit-build] +# Protect the configuration against future changes in scikit-build-core +minimum-version = "0.4" + +# Setuptools-style build caching in a local directory +build-dir = "build/{wheel_tag}" +wheel.packages = ["src/mtca4u", "src/deviceaccess"] + +[tool.cibuildwheel] +before-all = "bash pre_build_manylinux.sh" +skip = "cp314t-* *-win32 *_i686 *-musllinux_*" +manylinux-x86_64-image = "quay.io/pypa/manylinux_2_28_x86_64:2025.10.10-1" +manylinux-aarch64-image = "quay.io/pypa/manylinux_2_28_aarch64:2025.10.10-1" + +# Necessary to see build output from the actual compilation +build-verbosity = 1 + +## Run unittest to ensure that the package was correctly built +## tests disabled due to corruption on interpreter exit +## Note: tests are disabled at the moment since to make it work, the +## resource path of them should be made cwd -independent +# test-command = "python -m unittest discover -v {package}/tests" +test-skip = "*" + +[tool.cibuildwheel.linux.environment] + +# Add the build directory to the environment variables +BUILD_DIR="${HOME}/build" +PKG_CONFIG_PATH="${BUILD_DIR}/local/lib/pkgconfig/:/usr/lib/pkgconfig:${PKG_CONFIG_PATH}" +LD_LIBRARY_PATH="${BUILD_DIR}/local/lib/:${LD_LIBRARY_PATH}" +PATH="${BUILD_DIR}/local/bin/:${PATH}" + [tool.autopep8] -max_line_length = 120 \ No newline at end of file +max_line_length = 120 + diff --git a/src/deviceaccess/__init__.py b/src/deviceaccess/__init__.py new file mode 100644 index 0000000..0aef6ef --- /dev/null +++ b/src/deviceaccess/__init__.py @@ -0,0 +1,9 @@ +from . import deviceaccess + +try: + __all__ = tuple(deviceaccess.__all__) +except Exception: + __all__ = tuple(n for n in dir(deviceaccess) if not n.startswith("_")) + +# Populate the namespace eagerly +globals().update({name: getattr(deviceaccess, name) for name in __all__}) diff --git a/src/deviceaccess/py.typed b/src/deviceaccess/py.typed new file mode 100644 index 0000000..e69de29