mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
Install headers using both headers and package_data (#1995)
This commit is contained in:
committed by
Wenzel Jakob
parent
a60648223d
commit
3735249122
68
setup.py
68
setup.py
@@ -4,40 +4,43 @@
|
||||
|
||||
from setuptools import setup
|
||||
from distutils.command.install_headers import install_headers
|
||||
from distutils.command.build_py import build_py
|
||||
from pybind11 import __version__
|
||||
import os
|
||||
|
||||
package_data = [
|
||||
'include/pybind11/detail/class.h',
|
||||
'include/pybind11/detail/common.h',
|
||||
'include/pybind11/detail/descr.h',
|
||||
'include/pybind11/detail/init.h',
|
||||
'include/pybind11/detail/internals.h',
|
||||
'include/pybind11/detail/typeid.h',
|
||||
'include/pybind11/attr.h',
|
||||
'include/pybind11/buffer_info.h',
|
||||
'include/pybind11/cast.h',
|
||||
'include/pybind11/chrono.h',
|
||||
'include/pybind11/common.h',
|
||||
'include/pybind11/complex.h',
|
||||
'include/pybind11/eigen.h',
|
||||
'include/pybind11/embed.h',
|
||||
'include/pybind11/eval.h',
|
||||
'include/pybind11/functional.h',
|
||||
'include/pybind11/iostream.h',
|
||||
'include/pybind11/numpy.h',
|
||||
'include/pybind11/operators.h',
|
||||
'include/pybind11/options.h',
|
||||
'include/pybind11/pybind11.h',
|
||||
'include/pybind11/pytypes.h',
|
||||
'include/pybind11/stl.h',
|
||||
'include/pybind11/stl_bind.h',
|
||||
]
|
||||
|
||||
# Prevent installation of pybind11 headers by setting
|
||||
# PYBIND11_USE_CMAKE.
|
||||
if os.environ.get('PYBIND11_USE_CMAKE'):
|
||||
headers = []
|
||||
else:
|
||||
headers = [
|
||||
'include/pybind11/detail/class.h',
|
||||
'include/pybind11/detail/common.h',
|
||||
'include/pybind11/detail/descr.h',
|
||||
'include/pybind11/detail/init.h',
|
||||
'include/pybind11/detail/internals.h',
|
||||
'include/pybind11/detail/typeid.h',
|
||||
'include/pybind11/attr.h',
|
||||
'include/pybind11/buffer_info.h',
|
||||
'include/pybind11/cast.h',
|
||||
'include/pybind11/chrono.h',
|
||||
'include/pybind11/common.h',
|
||||
'include/pybind11/complex.h',
|
||||
'include/pybind11/eigen.h',
|
||||
'include/pybind11/embed.h',
|
||||
'include/pybind11/eval.h',
|
||||
'include/pybind11/functional.h',
|
||||
'include/pybind11/iostream.h',
|
||||
'include/pybind11/numpy.h',
|
||||
'include/pybind11/operators.h',
|
||||
'include/pybind11/options.h',
|
||||
'include/pybind11/pybind11.h',
|
||||
'include/pybind11/pytypes.h',
|
||||
'include/pybind11/stl.h',
|
||||
'include/pybind11/stl_bind.h',
|
||||
]
|
||||
headers = package_data
|
||||
|
||||
|
||||
class InstallHeaders(install_headers):
|
||||
@@ -55,6 +58,16 @@ class InstallHeaders(install_headers):
|
||||
self.outfiles.append(out)
|
||||
|
||||
|
||||
# Install the headers inside the package as well
|
||||
class BuildPy(build_py):
|
||||
def build_package_data(self):
|
||||
build_py.build_package_data(self)
|
||||
for header in package_data:
|
||||
target = os.path.join(self.build_lib, 'pybind11', header)
|
||||
self.mkpath(os.path.dirname(target))
|
||||
self.copy_file(header, target, preserve_mode=False)
|
||||
|
||||
|
||||
setup(
|
||||
name='pybind11',
|
||||
version=__version__,
|
||||
@@ -66,7 +79,8 @@ setup(
|
||||
packages=['pybind11'],
|
||||
license='BSD',
|
||||
headers=headers,
|
||||
cmdclass=dict(install_headers=InstallHeaders),
|
||||
zip_safe=False,
|
||||
cmdclass=dict(install_headers=InstallHeaders, build_py=BuildPy),
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Intended Audience :: Developers',
|
||||
|
||||
Reference in New Issue
Block a user