-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsetup.py
More file actions
73 lines (67 loc) · 2.56 KB
/
setup.py
File metadata and controls
73 lines (67 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import os, sys
from pip import locations
from setuptools import setup, Extension
from distutils import sysconfig
# Remove the "-Wstrict-prototypes" compiler option, which isn't valid for C++.
import distutils.sysconfig
cfg_vars = distutils.sysconfig.get_config_vars()
for key, value in cfg_vars.items():
if type(value) == str:
cfg_vars[key] = value.replace("-Wstrict-prototypes", "")
kwds = dict(
# pybind11 produces smaller binaries with C++14, but that's not available
# on our target platform and I'm too lazy to add conditional flags for
# a package that's mostly about reading rather than using the code.
# Using -fvisibility-hidden has similar benefits, but that's thwarted
# by distutils' requirement that the same compiler options be used for
# all object files in an Extension, combined with my preference for putting
# the C++ library code in the Python modules themselves instead of a
# separate shared library.
# In other words, don't use this as an example for how to compile pybind11
# code; look at the pybind11 FAQ instead.
extra_compile_args=['-std=c++11'],
include_dirs=[
os.path.join('..', 'include'),
os.path.join('include'),
os.path.dirname(locations.distutils_scheme('pybind11')['headers'])
],
)
if sys.platform == 'darwin':
# Miniconda 3.19 provided Python on OSX is built against OSX deployment target version 10.5
# this doesn't work with C++11 in libc++. Compiling without the following directive
# then gives a clang: error:
# invalid deployment target for -stdlib=libc++ (requires OS X 10.7 or later)
kwds["extra_compile_args"].append('-mmacosx-version-min=10.7')
kwds["extra_compile_args"].append('-stdlib=libc++')
ext_modules = [
Extension(
'challenge.basics',
sources=[
os.path.join('challenge', 'basics.cpp'),
os.path.join('..', 'src', 'basics.cpp')
],
**kwds
),
Extension(
'challenge.containers',
sources=[
os.path.join('challenge', 'containers.cpp'),
os.path.join('..', 'src', 'containers.cpp')
],
**kwds
),
Extension(
'challenge.converters', ['challenge/converters.i'],
swig_opts=["-modern", "-c++", "-Ichallenge/include", "-noproxy"],
**kwds
),
]
setup(
name='challenge',
version='0.0.1',
author='Pim Schellart',
test_suite="tests",
description='Solution to the Python C++ bindings challenge with pybind11.',
ext_modules=ext_modules,
)