LimeDriverBindings/setup.py
Kumi d1b8c79acb
Removed static HDF5 library linkage in build
process

Reflecting a shift toward dynamic library usage, the build system has
been updated to omit hard-coded links to the HDF5 libraries. This change
simplifies dependency management and increases flexibility in various
build environments. It's important to ensure dependent projects are
aware of this change, as they might need to explicitly link HDF5 if they
don't dynamically load it.
2024-02-09 15:43:27 +01:00

52 lines
1.4 KiB
Python

from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
import subprocess
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):
rpath_flags = ['-Wl,-rpath,/usr/lib/']
for ext in self.extensions:
ext.extra_compile_args = rpath_flags
ext.extra_link_args = rpath_flags
build_ext.build_extensions(self)
super().build_extensions()
def run(self):
if not os.path.exists('extern/limedriver/src'):
self.clone_limedriver()
super().run()
def clone_limedriver(self):
subprocess.check_call(['git', 'submodule', 'init'], shell=True)
subprocess.check_call(['git', 'submodule', 'update'], shell=True)
ext_modules = [
Extension(
'limedriver.binding',
sources=['src/limedriver/limedriver.pyx', 'extern/limedriver/src/limedriver.cpp'],
include_dirs=["extern/limedriver/src/", "/usr/include/hdf5/serial/"], # TODO: This is REALLY ugly.
library_dirs=["/usr/lib/"],
libraries=["LimeSuite"],
language="c++",
),
]
setup(
name='limedriver',
cmdclass={
'build_ext': BuildExtCommand,
},
ext_modules=cythonize(ext_modules),
)