setup.py 1.86 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
14
15
16
17
18
19
20
21
22
23
24
25

import sys
import sysconfig
import os.path
import distutils.sysconfig


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

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


extra_compile_args = []
include_dirs = ['./', _deferred_pybind11_include(),
                _deferred_pybind11_include(True)]

python_module_link_args = []
base_library_link_args = []

if sys.platform == 'darwin':
Martin Reinecke's avatar
Martin Reinecke committed
26
    extra_compile_args += ['--std=c++11', '--stdlib=libc++', '-mmacosx-version-min=10.9']
Martin Reinecke's avatar
Martin Reinecke committed
27
28
    vars = distutils.sysconfig.get_config_vars()
    vars['LDSHARED'] = vars['LDSHARED'].replace('-bundle', '')
Martin Reinecke's avatar
Martin Reinecke committed
29
30
    python_module_link_args+=['-bundle']
    base_library_link_args+=['-dynamiclib']
Martin Reinecke's avatar
Martin Reinecke committed
31
else:
Martin Reinecke's avatar
Martin Reinecke committed
32
33
    extra_compile_args += ['--std=c++11', '-march=native', '-O3', '-Wfatal-errors', '-Wno-ignored-attributes', '-DPOCKETFFT_OPENMP', '-fopenmp', '-Wfloat-conversion' ,'-Wsign-conversion', '-Wconversion' ,'-W', '-Wall']
    python_module_link_args += ['-march=native', '-Wl,-rpath,$ORIGIN', '-fopenmp']
Martin Reinecke's avatar
Martin Reinecke committed
34
35
36
37


def get_extension_modules():
    pocketfft_library = Extension('pypocketfft',
Martin Reinecke's avatar
Martin Reinecke committed
38
                                sources=['pypocketfft.cc'],
Martin Reinecke's avatar
Martin Reinecke committed
39
                                include_dirs=include_dirs,
Martin Reinecke's avatar
Martin Reinecke committed
40
41
42
                                extra_compile_args=extra_compile_args,
                                extra_link_args=python_module_link_args)
    return [pocketfft_library]
Martin Reinecke's avatar
Martin Reinecke committed
43
44
45
46
47
48
49
50
51
52
53
54
55


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=[],
      setup_requires=['numpy>=1.10.4', 'pybind11>=2.2.1'],
      ext_modules=get_extension_modules(),
      install_requires=['numpy>=1.10.4', 'pybind11>=2.2.1']
      )