LimeDriverBindings/setup.py
Kumi a85671e1af
Updated submodule commands and linked against
hdf5_cpp library

Enabled the use of shell in 'git submodule' commands to ensure
cross-platform compatibility in the setup process. Also revised the
linked libraries for the 'limedriver.binding' extension, replacing
'hdf5' with 'hdf5_cpp' to properly utilize the C++ HDF5 library
interface. This change is expected to enhance compatibility and
performance when interacting with HDF5 files.
2024-02-09 14:43:35 +01:00

46 lines
1.1 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):
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/"],
libraries=["LimeSuite", "hdf5_cpp"],
language="c++",
),
]
setup(
name='limedriver',
cmdclass={
'build_ext': BuildExtCommand,
},
ext_modules=cythonize(ext_modules),
)