setup.py 2.98 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 = 'ducc0'
10
version = '0.1.0'
Martin Reinecke's avatar
Martin Reinecke committed
11

Martin Reinecke's avatar
cleanup  
Martin Reinecke committed
12

Martin Reinecke's avatar
Martin Reinecke committed
13
14
15
16
17
18
19
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
20
include_dirs = ['.', './src/',
21
22
23
                pybind11.get_include(True),
                pybind11.get_include(False)]

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

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

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

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']
35
36
    cfg_vars = distutils.sysconfig.get_config_vars()
    cfg_vars['LDSHARED'] = cfg_vars['LDSHARED'].replace('-bundle', '')
Martin Reinecke's avatar
Martin Reinecke committed
37
38
39
elif sys.platform == 'win32':
    extra_compile_args = ['/Ox', '/EHsc', '/std:c++17']
else:
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
    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
55

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

61
62
63
64
65
66
67
68
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
69
70


Martin Reinecke's avatar
fixes  
Martin Reinecke committed
71
72
73
74
75
this_directory = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(this_directory, 'README.md'), encoding='utf-8') as f:
    long_description = f.read()


76
setup(name=pkgname,
77
      version=version,
Martin Reinecke's avatar
Martin Reinecke committed
78
      description='Distinctly useful code collection',
Martin Reinecke's avatar
fixes  
Martin Reinecke committed
79
80
      long_description=long_description,
      long_description_content_type='text/markdown',
81
      url='https://gitlab.mpcdf.mpg.de/mtr/ducc',
Martin Reinecke's avatar
Martin Reinecke committed
82
83
84
85
      include_package_data=True,
      author='Martin Reinecke',
      author_email='martin@mpa-garching.mpg.de',
      packages=[],
86
87
      python_requires=">=3.6",
      ext_modules=extensions,
88
      install_requires=['numpy>=1.17.0'],
Martin Reinecke's avatar
cleanup  
Martin Reinecke committed
89
      license="GPLv2",
Martin Reinecke's avatar
Martin Reinecke committed
90
      )