setup.py 2.72 KB
Newer Older
Martin Reinecke's avatar
Martin Reinecke committed
1
import sys
Martin Reinecke's avatar
Martin Reinecke committed
2 3 4
import os.path
import itertools
from glob import iglob
Martin Reinecke's avatar
Martin Reinecke committed
5

6 7
from setuptools import setup, Extension
import pybind11
Martin Reinecke's avatar
Martin Reinecke committed
8

Martin Reinecke's avatar
Martin Reinecke committed
9
pkgname = 'ducc_0_1'
10
version = '0.1.0'
Martin Reinecke's avatar
Martin Reinecke committed
11

Martin Reinecke's avatar
Martin Reinecke committed
12 13 14 15 16 17 18
def _get_files_by_suffix(directory, suffix):
    path = directory
    iterable_sources = (iglob(os.path.join(root, '*.'+suffix))
                        for root, dirs, files in os.walk(path))
    return list(itertools.chain.from_iterable(iterable_sources))


Martin Reinecke's avatar
Martin Reinecke committed
19
include_dirs = ['.', './src/',
20 21 22
                pybind11.get_include(True),
                pybind11.get_include(False)]

Martin Reinecke's avatar
Martin Reinecke committed
23
extra_compile_args = ['--std=c++17', '-march=native', '-ffast-math', '-O3']
24

Martin Reinecke's avatar
Martin Reinecke committed
25
python_module_link_args = []
26 27 28

define_macros = [("PKGNAME", pkgname),
                 ("PKGVERSION", '"%s"' % version)]
Martin Reinecke's avatar
Martin Reinecke committed
29 30 31 32 33

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']
34 35
    cfg_vars = distutils.sysconfig.get_config_vars()
    cfg_vars['LDSHARED'] = cfg_vars['LDSHARED'].replace('-bundle', '')
Martin Reinecke's avatar
Martin Reinecke committed
36 37 38
elif sys.platform == 'win32':
    extra_compile_args = ['/Ox', '/EHsc', '/std:c++17']
else:
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
    extra_compile_args += ['-Wfatal-errors',
                           '-Wfloat-conversion',
                           '-W',
                           '-Wall',
                           '-Wstrict-aliasing=2',
                           '-Wwrite-strings',
                           '-Wredundant-decls',
                           '-Woverloaded-virtual',
                           '-Wcast-qual',
                           '-Wcast-align',
                           '-Wpointer-arith']

    python_module_link_args += ['-march=native',
                                '-Wl,-rpath,$ORIGIN',
                                '-s']
Martin Reinecke's avatar
Martin Reinecke committed
54

Martin Reinecke's avatar
cleanup  
Martin Reinecke committed
55
# if you want debugging info, remove the "-s" from python_module_link_args
56 57 58
depfiles = (_get_files_by_suffix('.', 'h') +
            _get_files_by_suffix('.', 'cc') +
            ['setup.py'])
Martin Reinecke's avatar
Martin Reinecke committed
59

60 61 62 63 64 65 66 67
extensions = [Extension(pkgname,
                        language='c++',
                        sources=['python/ducc.cc'],
                        depends=depfiles,
                        include_dirs=include_dirs,
                        define_macros=define_macros,
                        extra_compile_args=extra_compile_args,
                        extra_link_args=python_module_link_args)]
Martin Reinecke's avatar
Martin Reinecke committed
68 69


70
setup(name=pkgname,
71
      version=version,
Martin Reinecke's avatar
Martin Reinecke committed
72
      description='Definitely useful code collection',
73
      url='https://gitlab.mpcdf.mpg.de/mtr/ducc',
Martin Reinecke's avatar
Martin Reinecke committed
74 75 76 77
      include_package_data=True,
      author='Martin Reinecke',
      author_email='martin@mpa-garching.mpg.de',
      packages=[],
78 79
      python_requires=">=3.6",
      ext_modules=extensions,
80
      install_requires=['numpy>=1.17.0'],
Martin Reinecke's avatar
cleanup  
Martin Reinecke committed
81
      license="GPLv2",
Martin Reinecke's avatar
Martin Reinecke committed
82
      )