Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Martin Reinecke
pypocketfft
Commits
98698549
Commit
98698549
authored
May 17, 2019
by
Martin Reinecke
Browse files
cleanup in setup.py
parent
7342ee68
Changes
1
Hide whitespace changes
Inline
Side-by-side
setup.py
View file @
98698549
from
setuptools
import
setup
,
Extension
,
Distribution
import
setuptools.command.build_ext
from
setuptools
import
setup
,
Extension
import
sys
import
sysconfig
import
os
import
os.path
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
):
...
...
@@ -32,59 +15,31 @@ class _deferred_pybind11_include(object):
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_cc_compile_args
=
[]
include_dirs
=
[
'./'
,
_deferred_pybind11_include
(),
_deferred_pybind11_include
(
True
)]
library_dirs
=
[
_get_distutils_build_directory
()]
python_module_link_args
=
[]
base_library_link_args
=
[]
if
sys
.
platform
==
'darwin'
:
extra_cc_compile_args
.
append
(
'--std=c++11'
)
extra_cc_compile_args
.
append
(
'--stdlib=libc++'
)
extra_compile_args
.
append
(
'-mmacosx-version-min=10.9'
)
extra_compile_args
+=
[
'--std=c++11'
,
'--stdlib=libc++'
,
'-mmacosx-version-min=10.9'
]
vars
=
distutils
.
sysconfig
.
get_config_vars
()
vars
[
'LDSHARED'
]
=
vars
[
'LDSHARED'
].
replace
(
'-bundle'
,
''
)
python_module_link_args
.
append
(
'-bundle'
)
builder
=
setuptools
.
command
.
build_ext
.
build_ext
(
Distribution
())
base_library_link_args
.
append
(
'-dynamiclib'
)
python_module_link_args
+=
[
'-bundle'
]
base_library_link_args
+=
[
'-dynamiclib'
]
else
:
extra_compile_args
+=
[
'-march=native'
,
'-O3'
,
'-Wfatal-errors'
,
'-Wno-ignored-attributes'
,
'-DPOCKETFFT_OPENMP'
,
'-fopenmp'
,
'-Wfloat-conversion'
,
'-Wsign-conversion'
,
'-Wconversion'
,
'-W'
,
'-Wall'
]
python_module_link_args
+=
[
'-march=native'
]
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
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'
]
def
get_extension_modules
():
extension_modules
=
[]
pocketfft_sources
=
[
'pypocketfft.cc'
]
pocketfft_library
=
Extension
(
'pypocketfft'
,
sources
=
pocketfft
_sources
,
sources
=
[
'py
pocketfft
.cc'
]
,
include_dirs
=
include_dirs
,
extra_compile_args
=
extra_cc_compile_args
,
extra_link_args
=
python_module_link_args
,
library_dirs
=
library_dirs
)
extension_modules
.
append
(
pocketfft_library
)
return
extension_modules
extra_compile_args
=
extra_compile_args
,
extra_link_args
=
python_module_link_args
)
return
[
pocketfft_library
]
setup
(
name
=
'pypocketfft'
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment