LimeDriverBindings/setup.py
Kumi 261ccac1a0
Extend .gitignore and update build setup for C++ integration
The .gitignore file now ignores C++ build artifacts alongside existing ones. In setup.py, the build configuration for 'limedriver' was modified to include a new C++ source file, indicating a shift to or expansion of C++ code usage within the project. This change prepares the build process to handle and compile C++ code, potentially for performance improvements or new functionality that leverages C++ capabilities.
2024-02-08 09:07:09 +01:00

51 lines
1.2 KiB
Python

from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
import subprocess
import os
from Cython.Build import cythonize
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):
if not os.path.exists('extern/limedriver'):
self.clone_limedriver()
self.build_limedriver()
super().run()
def clone_limedriver(self):
subprocess.check_call(['git', 'submodule', 'init'])
subprocess.check_call(['git', 'submodule', 'update'])
def build_limedriver(self):
subprocess.check_call(['./configure'], cwd='extern/limedriver')
subprocess.check_call(['make'], cwd='extern/limedriver')
ext_modules = [
Extension(
'limedriver',
sources=['src/limedriver/limedriver.pyx', 'extern/limedriver/src/limedriver.cpp'],
include_dirs=["extern/limedriver/src/"],
libraries=["LimeSuite"],
language="c++",
),
]
setup(
name='limedriver',
cmdclass={
'build_ext': BuildExtCommand,
},
ext_modules=cythonize(ext_modules),
)