|
| 1 | +"""Setup.py inspired by https://thomastrapp.com/posts/building-a-pypi-package-for-a-modern-cpp-project/""" |
| 2 | +import os |
| 3 | +from setuptools import setup, dist |
| 4 | + |
| 5 | +PACKAGE_NAME = "librasr" # keyword to import |
| 6 | +LIBRASR_SUBDIR = os.path.join("src", "Tools", "LibRASR") |
| 7 | +LIBRASR_SO = "librasr.so" |
| 8 | + |
| 9 | +assert os.path.exists(os.path.join(LIBRASR_SUBDIR, LIBRASR_SO)), \ |
| 10 | + "Could not find librasr shared library. Did you compile it correctly?" |
| 11 | +class BinaryDistribution(dist.Distribution): |
| 12 | + """Helper class: We assume that librasr.so has already been compiled.""" |
| 13 | + def has_ext_modules(self) -> bool: |
| 14 | + return True |
| 15 | + |
| 16 | +# get README content for long description |
| 17 | +this_directory = os.path.abspath(os.path.dirname(__file__)) |
| 18 | +with open(os.path.join(this_directory, 'README')) as f: |
| 19 | + long_description = f.read() |
| 20 | + |
| 21 | +setup( |
| 22 | + name='RASR', |
| 23 | + |
| 24 | + # include shared library and link to lower case package name |
| 25 | + packages=[PACKAGE_NAME], |
| 26 | + package_dir={PACKAGE_NAME: LIBRASR_SUBDIR}, |
| 27 | + package_data={PACKAGE_NAME: [LIBRASR_SO]}, |
| 28 | + include_package_data=True, |
| 29 | + |
| 30 | + description="RASR as a python module.", |
| 31 | + long_description=long_description, |
| 32 | + long_description_content_type="text/markdown", |
| 33 | + |
| 34 | + # use custom distribution class to export librasr.so |
| 35 | + distclass=BinaryDistribution, |
| 36 | + |
| 37 | + version='0.0.1', |
| 38 | + url='https://github.com/rwth-i6/rasr', |
| 39 | + |
| 40 | +) |
0 commit comments