setup.py 1.64 KB
Newer Older
Martin Reinecke's avatar
Martin Reinecke committed
1
from setuptools import setup, Extension
Martin Reinecke's avatar
import  
Martin Reinecke committed
2
3
4
5
6
7
8
9
10
11
12
13
import sys


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

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


Martin Reinecke's avatar
Martin Reinecke committed
14
15
include_dirs = ['./', _deferred_pybind11_include(True),
                _deferred_pybind11_include()]
Martin Reinecke's avatar
import  
Martin Reinecke committed
16
17
18
19
extra_compile_args = []
python_module_link_args = []

if sys.platform == 'darwin':
Martin Reinecke's avatar
Martin Reinecke committed
20
    import distutils.sysconfig
21
    extra_compile_args += ['--std=c++11', '--stdlib=libc++', '-mmacosx-version-min=10.9']
Martin Reinecke's avatar
import  
Martin Reinecke committed
22
23
    vars = distutils.sysconfig.get_config_vars()
    vars['LDSHARED'] = vars['LDSHARED'].replace('-bundle', '')
Martin Reinecke's avatar
Martin Reinecke committed
24
    python_module_link_args+=['-bundle']
Martin Reinecke's avatar
import  
Martin Reinecke committed
25
else:
26
    extra_compile_args += ['--std=c++11', '-fopenmp', '-march=native', '-O3', '-ffast-math']
Martin Reinecke's avatar
Martin Reinecke committed
27
    python_module_link_args += ['-fopenmp', '-march=native', '-Wl,-rpath,$ORIGIN']
Martin Reinecke's avatar
import  
Martin Reinecke committed
28

Martin Reinecke's avatar
Martin Reinecke committed
29
30
# if you don't want debugging info, add "-s" to python_module_link_args

Martin Reinecke's avatar
import  
Martin Reinecke committed
31
32

def get_extension_modules():
Martin Reinecke's avatar
Martin Reinecke committed
33
34
35
36
37
    return [Extension('nifty_gridder',
                      sources=['nifty_gridder.cc'],
                      include_dirs=include_dirs,
                      extra_compile_args=extra_compile_args,
                      extra_link_args=python_module_link_args)]
Martin Reinecke's avatar
import  
Martin Reinecke committed
38
39
40
41
42
43
44
45

setup(name='nifty_gridder',
      version='0.0.1',
      description='Gridding/Degridding helper library for NIFTy',
      include_package_data=True,
      author='Martin Reinecke',
      author_email='martin@mpa-garching.mpg.de',
      packages=[],
Martin Reinecke's avatar
Martin Reinecke committed
46
      setup_requires=['numpy>=1.15.0', 'pybind11>=2.2.4'],
Martin Reinecke's avatar
import  
Martin Reinecke committed
47
      ext_modules=get_extension_modules(),
Martin Reinecke's avatar
Martin Reinecke committed
48
      install_requires=['numpy>=1.15.0', 'pybind11>=2.2.4']
Martin Reinecke's avatar
import  
Martin Reinecke committed
49
      )