Commit 98698549 authored by Martin Reinecke's avatar Martin Reinecke

cleanup in setup.py

parent 7342ee68
from setuptools import setup, Extension, Distribution from setuptools import setup, Extension
import setuptools.command.build_ext
import sys import sys
import sysconfig import sysconfig
import os
import os.path import os.path
import distutils.sysconfig import distutils.sysconfig
import itertools
from glob import iglob
def _get_distutils_build_directory():
"""
Returns the directory distutils uses to build its files.
We need this directory since we build extensions which have to link
other ones.
"""
pattern = "lib.{platform}-{major}.{minor}"
return os.path.join(
'build', pattern.format(platform=sysconfig.get_platform(),
major=sys.version_info[0],
minor=sys.version_info[1]))
class _deferred_pybind11_include(object): class _deferred_pybind11_include(object):
...@@ -32,59 +15,31 @@ class _deferred_pybind11_include(object): ...@@ -32,59 +15,31 @@ class _deferred_pybind11_include(object):
return pybind11.get_include(self.user) return pybind11.get_include(self.user)
def _remove_strict_prototype_option_from_distutils_config():
strict_prototypes = '-Wstrict-prototypes'
config = distutils.sysconfig.get_config_vars()
for key, value in config.items():
if strict_prototypes in str(value):
config[key] = config[key].replace(strict_prototypes, '')
_remove_strict_prototype_option_from_distutils_config()
extra_compile_args = [] extra_compile_args = []
extra_cc_compile_args = []
include_dirs = ['./', _deferred_pybind11_include(), include_dirs = ['./', _deferred_pybind11_include(),
_deferred_pybind11_include(True)] _deferred_pybind11_include(True)]
library_dirs = [_get_distutils_build_directory()]
python_module_link_args = [] python_module_link_args = []
base_library_link_args = [] base_library_link_args = []
if sys.platform == 'darwin': if sys.platform == 'darwin':
extra_cc_compile_args.append('--std=c++11') extra_compile_args += ['--std=c++11', '--stdlib=libc++', '-mmacosx-version-min=10.9']
extra_cc_compile_args.append('--stdlib=libc++')
extra_compile_args.append('-mmacosx-version-min=10.9')
vars = distutils.sysconfig.get_config_vars() vars = distutils.sysconfig.get_config_vars()
vars['LDSHARED'] = vars['LDSHARED'].replace('-bundle', '') vars['LDSHARED'] = vars['LDSHARED'].replace('-bundle', '')
python_module_link_args.append('-bundle') python_module_link_args+=['-bundle']
builder = setuptools.command.build_ext.build_ext(Distribution()) base_library_link_args+=['-dynamiclib']
base_library_link_args.append('-dynamiclib')
else: else:
extra_compile_args += ['-march=native', '-O3', '-Wfatal-errors', '-Wno-ignored-attributes', '-DPOCKETFFT_OPENMP', '-fopenmp', '-Wfloat-conversion' ,'-Wsign-conversion', '-Wconversion' ,'-W', '-Wall'] 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'] python_module_link_args += ['-march=native', '-Wl,-rpath,$ORIGIN', '-fopenmp']
extra_cc_compile_args.append('--std=c++11')
python_module_link_args.append("-Wl,-rpath,$ORIGIN")
python_module_link_args.append('-fopenmp')
extra_cc_compile_args = extra_compile_args + extra_cc_compile_args
def get_extension_modules(): def get_extension_modules():
extension_modules = []
pocketfft_sources = ['pypocketfft.cc']
pocketfft_library = Extension('pypocketfft', pocketfft_library = Extension('pypocketfft',
sources=pocketfft_sources, sources=['pypocketfft.cc'],
include_dirs=include_dirs, include_dirs=include_dirs,
extra_compile_args=extra_cc_compile_args, extra_compile_args=extra_compile_args,
extra_link_args=python_module_link_args, extra_link_args=python_module_link_args)
library_dirs=library_dirs) return [pocketfft_library]
extension_modules.append(pocketfft_library)
return extension_modules
setup(name='pypocketfft', setup(name='pypocketfft',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment