Browse Source

switched to new pybind11.get_include() API; minor PEP8 fixes

master
Wenzel Jakob 9 years ago
parent
commit
f3531be87e
  1. 30
      setup.py

30
setup.py

@ -1,22 +1,38 @@
from setuptools import setup, Extension from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext from setuptools.command.build_ext import build_ext
from pip import locations
import os
import sys import sys
import setuptools import setuptools
class get_pybind_include(object):
"""Helper class to determine the pybind11 include path
The purpose of this class is to postpone importing pybind11
until it is actually installed, so that the ``get_include()``
method can be invoked. """
def __init__(self, user=False):
self.user = user
def __str__(self):
import pybind11
return pybind11.get_include(self.user)
ext_modules = [ ext_modules = [
Extension( Extension(
'pbtest', 'pbtest',
['py/main.cpp'], ['py/main.cpp'],
include_dirs=[ include_dirs=[
# Path to pybind11 headers # Path to pybind11 headers
os.path.dirname(locations.distutils_scheme('pybind11')['headers']) get_pybind_include(),
get_pybind_include(user=True)
], ],
language='c++', language='c++'
), ),
] ]
# As of Python 3.6, CCompiler has a `has_flag` method. # As of Python 3.6, CCompiler has a `has_flag` method.
# cf http://bugs.python.org/issue26689 # cf http://bugs.python.org/issue26689
def has_flag(compiler, flagname): def has_flag(compiler, flagname):
@ -32,6 +48,7 @@ def has_flag(compiler, flagname):
return False return False
return True return True
def cpp_flag(compiler): def cpp_flag(compiler):
"""Return the -std=c++[11/14] compiler flag. """Return the -std=c++[11/14] compiler flag.
@ -42,7 +59,8 @@ def cpp_flag(compiler):
elif has_flag(compiler, '-std=c++11'): elif has_flag(compiler, '-std=c++11'):
return '-std=c++11' return '-std=c++11'
else: else:
raise RuntimeError('Unsupported compiler -- at least C++11 support is needed!') raise RuntimeError('Unsupported compiler -- at least C++11 support '
'is needed!')
class BuildExt(build_ext): class BuildExt(build_ext):
@ -75,7 +93,7 @@ setup(
description='A test project using pybind11', description='A test project using pybind11',
long_description='', long_description='',
ext_modules=ext_modules, ext_modules=ext_modules,
install_requires=['pybind11'], install_requires=['pybind11>=1.7'],
cmdclass={'build_ext': BuildExt}, cmdclass={'build_ext': BuildExt},
zip_safe=False, zip_safe=False,
) )

Loading…
Cancel
Save