setup.py 2.08 KB
Newer Older
Martin Reinecke's avatar
Martin Reinecke committed
1
from setuptools import setup, Extension
Martin Reinecke's avatar
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
Martin Reinecke committed
16
extra_compile_args = ['--std=c++11', '-march=native', '-O3']
Martin Reinecke's avatar
Martin Reinecke committed
17
python_module_link_args = []
18
define_macros = [('POCKETFFT_PTHREADS', None)]
Martin Reinecke's avatar
Martin Reinecke committed
19
20

if sys.platform == 'darwin':
Martin Reinecke's avatar
Martin Reinecke committed
21
    import distutils.sysconfig
Martin Reinecke's avatar
Martin Reinecke committed
22
    extra_compile_args += ['--stdlib=libc++', '-mmacosx-version-min=10.9']
Martin Reinecke's avatar
Martin Reinecke committed
23
24
    vars = distutils.sysconfig.get_config_vars()
    vars['LDSHARED'] = vars['LDSHARED'].replace('-bundle', '')
Martin Reinecke's avatar
Martin Reinecke committed
25
    python_module_link_args += ['-bundle']
Peter Bell's avatar
Peter Bell committed
26
27
28
elif sys.platform == 'win32':
    define_macros = []
    extra_compile_args = ['/Ox', '/EHsc']
Martin Reinecke's avatar
Martin Reinecke committed
29
else:
Peter Bell's avatar
Peter Bell committed
30
31
    extra_compile_args += ['-Wfatal-errors', '-Wfloat-conversion', '-Wsign-conversion', '-Wconversion' ,'-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']
Martin Reinecke's avatar
Martin Reinecke committed
32

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

Martin Reinecke's avatar
Martin Reinecke committed
35
36

def get_extension_modules():
Martin Reinecke's avatar
Martin Reinecke committed
37
    return [Extension('pypocketfft',
Martin Reinecke's avatar
Martin Reinecke committed
38
                      language='c++',
Martin Reinecke's avatar
Martin Reinecke committed
39
                      sources=['pypocketfft.cc'],
Martin Reinecke's avatar
fixes  
Martin Reinecke committed
40
                      depends=['pocketfft_hdronly.h'],
Martin Reinecke's avatar
Martin Reinecke committed
41
                      include_dirs=include_dirs,
42
                      define_macros=define_macros,
Martin Reinecke's avatar
Martin Reinecke committed
43
44
                      extra_compile_args=extra_compile_args,
                      extra_link_args=python_module_link_args)]
Martin Reinecke's avatar
Martin Reinecke committed
45
46
47
48
49
50
51
52
53


setup(name='pypocketfft',
      version='0.0.1',
      description='Python interface for pocketfft',
      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.15.0', 'pybind11>=2.2.4'],
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.15.0', 'pybind11>=2.2.4']
Martin Reinecke's avatar
Martin Reinecke committed
57
      )