2024-02-07 17:18:44 +00:00
|
|
|
from setuptools import setup, Extension
|
|
|
|
from setuptools.command.build_ext import build_ext
|
|
|
|
|
|
|
|
import subprocess
|
|
|
|
import os
|
|
|
|
|
|
|
|
from Cython.Build import cythonize
|
|
|
|
|
2024-02-09 14:40:34 +00:00
|
|
|
#os.environ['CXX'] = 'h5c++'
|
2024-02-08 08:52:51 +00:00
|
|
|
|
2024-02-07 17:18:44 +00:00
|
|
|
class BuildExtCommand(build_ext):
|
|
|
|
"""Custom build_ext command to ensure that the submodule is retrieved and built."""
|
|
|
|
|
|
|
|
def build_extensions(self):
|
2024-02-09 14:33:51 +00:00
|
|
|
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)
|
|
|
|
|
2024-02-07 17:18:44 +00:00
|
|
|
super().build_extensions()
|
|
|
|
|
|
|
|
def run(self):
|
2024-02-09 12:47:11 +00:00
|
|
|
if not os.path.exists('extern/limedriver/src'):
|
2024-02-07 17:18:44 +00:00
|
|
|
self.clone_limedriver()
|
|
|
|
|
|
|
|
super().run()
|
|
|
|
|
|
|
|
def clone_limedriver(self):
|
2024-02-09 13:43:35 +00:00
|
|
|
subprocess.check_call(['git', 'submodule', 'init'], shell=True)
|
|
|
|
subprocess.check_call(['git', 'submodule', 'update'], shell=True)
|
2024-02-07 17:18:44 +00:00
|
|
|
|
|
|
|
ext_modules = [
|
|
|
|
Extension(
|
2024-02-08 08:52:51 +00:00
|
|
|
'limedriver.binding',
|
2024-02-08 08:07:09 +00:00
|
|
|
sources=['src/limedriver/limedriver.pyx', 'extern/limedriver/src/limedriver.cpp'],
|
2024-02-09 14:12:02 +00:00
|
|
|
include_dirs=["extern/limedriver/src/", "/usr/include/hdf5/serial/"], # TODO: This is REALLY ugly.
|
2024-02-09 14:30:29 +00:00
|
|
|
library_dirs=["/usr/lib/"],
|
2024-02-09 14:21:10 +00:00
|
|
|
libraries=["LimeSuite"],
|
2024-02-08 08:07:09 +00:00
|
|
|
language="c++",
|
2024-02-07 17:18:44 +00:00
|
|
|
),
|
|
|
|
]
|
|
|
|
|
|
|
|
setup(
|
|
|
|
name='limedriver',
|
|
|
|
|
|
|
|
cmdclass={
|
|
|
|
'build_ext': BuildExtCommand,
|
|
|
|
},
|
|
|
|
|
|
|
|
ext_modules=cythonize(ext_modules),
|
|
|
|
)
|