44
55from setuptools import setup
66from distutils .command .install_headers import install_headers
7+ from distutils .command .build_py import build_py
78from pybind11 import __version__
89import os
910
11+ package_data = [
12+ 'include/pybind11/detail/class.h' ,
13+ 'include/pybind11/detail/common.h' ,
14+ 'include/pybind11/detail/descr.h' ,
15+ 'include/pybind11/detail/init.h' ,
16+ 'include/pybind11/detail/internals.h' ,
17+ 'include/pybind11/detail/typeid.h' ,
18+ 'include/pybind11/attr.h' ,
19+ 'include/pybind11/buffer_info.h' ,
20+ 'include/pybind11/cast.h' ,
21+ 'include/pybind11/chrono.h' ,
22+ 'include/pybind11/common.h' ,
23+ 'include/pybind11/complex.h' ,
24+ 'include/pybind11/eigen.h' ,
25+ 'include/pybind11/embed.h' ,
26+ 'include/pybind11/eval.h' ,
27+ 'include/pybind11/functional.h' ,
28+ 'include/pybind11/iostream.h' ,
29+ 'include/pybind11/numpy.h' ,
30+ 'include/pybind11/operators.h' ,
31+ 'include/pybind11/options.h' ,
32+ 'include/pybind11/pybind11.h' ,
33+ 'include/pybind11/pytypes.h' ,
34+ 'include/pybind11/stl.h' ,
35+ 'include/pybind11/stl_bind.h' ,
36+ ]
37+
1038# Prevent installation of pybind11 headers by setting
1139# PYBIND11_USE_CMAKE.
1240if os .environ .get ('PYBIND11_USE_CMAKE' ):
1341 headers = []
1442else :
15- headers = [
16- 'include/pybind11/detail/class.h' ,
17- 'include/pybind11/detail/common.h' ,
18- 'include/pybind11/detail/descr.h' ,
19- 'include/pybind11/detail/init.h' ,
20- 'include/pybind11/detail/internals.h' ,
21- 'include/pybind11/detail/typeid.h' ,
22- 'include/pybind11/attr.h' ,
23- 'include/pybind11/buffer_info.h' ,
24- 'include/pybind11/cast.h' ,
25- 'include/pybind11/chrono.h' ,
26- 'include/pybind11/common.h' ,
27- 'include/pybind11/complex.h' ,
28- 'include/pybind11/eigen.h' ,
29- 'include/pybind11/embed.h' ,
30- 'include/pybind11/eval.h' ,
31- 'include/pybind11/functional.h' ,
32- 'include/pybind11/iostream.h' ,
33- 'include/pybind11/numpy.h' ,
34- 'include/pybind11/operators.h' ,
35- 'include/pybind11/options.h' ,
36- 'include/pybind11/pybind11.h' ,
37- 'include/pybind11/pytypes.h' ,
38- 'include/pybind11/stl.h' ,
39- 'include/pybind11/stl_bind.h' ,
40- ]
43+ headers = package_data
4144
4245
4346class InstallHeaders (install_headers ):
@@ -55,6 +58,16 @@ def run(self):
5558 self .outfiles .append (out )
5659
5760
61+ # Install the headers inside the package as well
62+ class BuildPy (build_py ):
63+ def build_package_data (self ):
64+ build_py .build_package_data (self )
65+ for header in package_data :
66+ target = os .path .join (self .build_lib , 'pybind11' , header )
67+ self .mkpath (os .path .dirname (target ))
68+ self .copy_file (header , target , preserve_mode = False )
69+
70+
5871setup (
5972 name = 'pybind11' ,
6073 version = __version__ ,
@@ -66,7 +79,8 @@ def run(self):
6679 packages = ['pybind11' ],
6780 license = 'BSD' ,
6881 headers = headers ,
69- cmdclass = dict (install_headers = InstallHeaders ),
82+ zip_safe = False ,
83+ cmdclass = dict (install_headers = InstallHeaders , build_py = BuildPy ),
7084 classifiers = [
7185 'Development Status :: 5 - Production/Stable' ,
7286 'Intended Audience :: Developers' ,
0 commit comments