From 0568a820afae609413b5f889c382bd2ded0e54a0 Mon Sep 17 00:00:00 2001 From: Kumi Date: Sat, 10 Feb 2024 18:02:07 +0100 Subject: [PATCH] Simplify build and link HDF5 libraries Removed custom BuildExtCommand class from setup.py, simplifying the build process by relying on standard build_ext behavior. The custom command handling of submodule initialization and build extension modifications were deemed unnecessary. Additionally, extended the library dependencies to include 'hdf5_cpp' and 'hdf5' to ensure correct linking for HDF5 support. This change makes the build process more straightforward and maintainable. --- setup.py | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/setup.py b/setup.py index 8dc773c..dbd5afb 100644 --- a/setup.py +++ b/setup.py @@ -8,45 +8,18 @@ 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"], + libraries=["LimeSuite", "hdf5_cpp", "hdf5"], language="c++", ), ] setup( name='limedriver', - - cmdclass={ - 'build_ext': BuildExtCommand, - }, - ext_modules=cythonize(ext_modules), )