Enforce C++ compiler for Cython and fix Python binding

- Standardized the C++ compiler across build environments by setting it in `setup.py`, ensuring consistent compilation of Cython extensions.
- Transitioned to using `setuptools.build_meta` as the build backend in `pyproject.toml` for enhanced package build processes.
- Modified the extension module path in `setup.py` to align with the new Python binding structure.
- Introduced Python property decorators to `PyLimeConfig` class in `limedriver.pyx` for getter methods, enhancing the Pythonic interface of the Cython module.
- Facilitated direct import of the binding in `__init__.py`, streamlining the usage of the `limedriver` package.
This commit is contained in:
Kumi 2024-02-08 09:52:51 +01:00
parent 4e279892aa
commit 1f24eb3f64
Signed by: kumi
GPG key ID: ECBCC9082395383F
4 changed files with 10 additions and 3 deletions

View file

@ -18,4 +18,6 @@ requires = [
"setuptools",
"wheel",
"Cython"
]
]
build-backend = "setuptools.build_meta"

View file

@ -6,11 +6,12 @@ import os
from Cython.Build import cythonize
os.environ['CXX'] = 'h5c++'
class BuildExtCommand(build_ext):
"""Custom build_ext command to ensure that the submodule is retrieved and built."""
def build_extensions(self):
os.environ['CXX'] = 'h5c++'
super().build_extensions()
def run(self):
@ -31,7 +32,7 @@ class BuildExtCommand(build_ext):
ext_modules = [
Extension(
'limedriver',
'limedriver.binding',
sources=['src/limedriver/limedriver.pyx', 'extern/limedriver/src/limedriver.cpp'],
include_dirs=["extern/limedriver/src/"],
libraries=["LimeSuite"],

View file

@ -0,0 +1 @@
import limedriver.binding

View file

@ -156,6 +156,7 @@ cdef class PyLimeConfig:
def TX_IcorrDC(self, int value):
self._config.TX_IcorrDC = value
@property
def TX_QcorrDC(self):
return self._config.TX_QcorrDC
@ -234,6 +235,7 @@ cdef class PyLimeConfig:
for i in range(4):
self._config.RX_gain_rback[i] = values[i]
@property
def TX_gain_rback(self):
return [self._config.TX_gain_rback[i] for i in range(3)]
@ -297,3 +299,4 @@ cdef class PyLimeConfig:
@stamp_end.setter
def stamp_end(self, value):
self._config.stamp_end = value.encode('utf-8')