setup.py 2.06 KB
Newer Older
Martin Reinecke's avatar
Martin Reinecke committed
1 2 3
from setuptools import setup, Extension
import sys

Martin Reinecke's avatar
Martin Reinecke committed
4
pkgname = 'ducc_0_1'
Martin Reinecke's avatar
Martin Reinecke committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

class _deferred_pybind11_include(object):
    def __init__(self, user=False):
        self.user = user

    def __str__(self):
        import pybind11
        return pybind11.get_include(self.user)


include_dirs = ['./src/',
                _deferred_pybind11_include(True),
                _deferred_pybind11_include()]
extra_compile_args = ['--std=c++17', '-march=native', '-ffast-math', '-O3']
python_module_link_args = []
Martin Reinecke's avatar
Martin Reinecke committed
20
define_macros = [("PKGNAME", pkgname)]
Martin Reinecke's avatar
Martin Reinecke committed
21 22 23 24 25 26 27 28 29 30 31

if sys.platform == 'darwin':
    import distutils.sysconfig
    extra_compile_args += ['-mmacosx-version-min=10.9']
    python_module_link_args += ['-mmacosx-version-min=10.9', '-bundle']
    vars = distutils.sysconfig.get_config_vars()
    vars['LDSHARED'] = vars['LDSHARED'].replace('-bundle', '')
elif sys.platform == 'win32':
    extra_compile_args = ['/Ox', '/EHsc', '/std:c++17']
else:
    extra_compile_args += ['-Wfatal-errors', '-Wfloat-conversion', '-W', '-Wall', '-Wstrict-aliasing=2', '-Wwrite-strings', '-Wredundant-decls', '-Woverloaded-virtual', '-Wcast-qual', '-Wcast-align', '-Wpointer-arith']
32
    python_module_link_args += ['-march=native', '-Wl,-rpath,$ORIGIN', '-s']
Martin Reinecke's avatar
Martin Reinecke committed
33 34 35 36

# if you don't want debugging info, add "-s" to python_module_link_args

def get_extension_modules():
37
    return [Extension(pkgname,
Martin Reinecke's avatar
Martin Reinecke committed
38
                      language='c++',
Martin Reinecke's avatar
Martin Reinecke committed
39
                      sources=['module.cc'],
40
                      depends=[],
Martin Reinecke's avatar
Martin Reinecke committed
41 42 43
                      include_dirs=include_dirs,
                      define_macros=define_macros,
                      extra_compile_args=extra_compile_args,
Martin Reinecke's avatar
Martin Reinecke committed
44
                      extra_link_args=python_module_link_args)]
Martin Reinecke's avatar
Martin Reinecke committed
45 46


47
setup(name=pkgname,
Martin Reinecke's avatar
Martin Reinecke committed
48 49
      version='0.1.0',
      description='Definitely useful code collection',
Martin Reinecke's avatar
Martin Reinecke committed
50 51 52 53
      include_package_data=True,
      author='Martin Reinecke',
      author_email='martin@mpa-garching.mpg.de',
      packages=[],
Martin Reinecke's avatar
Martin Reinecke committed
54
      setup_requires=['numpy>=1.17.0', 'pybind11>=2.5.0'],
Martin Reinecke's avatar
Martin Reinecke committed
55
      ext_modules=get_extension_modules(),
Martin Reinecke's avatar
Martin Reinecke committed
56
      install_requires=['numpy>=1.17.0', 'pybind11>=2.5.0']
Martin Reinecke's avatar
Martin Reinecke committed
57
      )