|
3 | 3 | # Setup script for PyPI; use CMakeFile.txt to build extension modules
|
4 | 4 |
|
5 | 5 | from setuptools import setup
|
| 6 | +from distutils.command.install_headers import install_headers |
6 | 7 | from pybind11 import __version__
|
7 | 8 | import os
|
8 | 9 |
|
|
17 | 18 | 'include/pybind11/detail/descr.h',
|
18 | 19 | 'include/pybind11/detail/init.h',
|
19 | 20 | 'include/pybind11/detail/internals.h',
|
20 |
| - 'include/pybind11/detail/typeid.h' |
| 21 | + 'include/pybind11/detail/typeid.h', |
21 | 22 | 'include/pybind11/attr.h',
|
22 | 23 | 'include/pybind11/buffer_info.h',
|
23 | 24 | 'include/pybind11/cast.h',
|
|
36 | 37 | 'include/pybind11/stl_bind.h',
|
37 | 38 | ]
|
38 | 39 |
|
| 40 | + |
| 41 | +class InstallHeaders(install_headers): |
| 42 | + """Use custom header installer because the default one flattens subdirectories""" |
| 43 | + def run(self): |
| 44 | + if not self.distribution.headers: |
| 45 | + return |
| 46 | + |
| 47 | + for header in self.distribution.headers: |
| 48 | + subdir = os.path.dirname(os.path.relpath(header, 'include/pybind11')) |
| 49 | + install_dir = os.path.join(self.install_dir, subdir) |
| 50 | + self.mkpath(install_dir) |
| 51 | + |
| 52 | + (out, _) = self.copy_file(header, install_dir) |
| 53 | + self.outfiles.append(out) |
| 54 | + |
| 55 | + |
39 | 56 | setup(
|
40 | 57 | name='pybind11',
|
41 | 58 | version=__version__,
|
|
47 | 64 | packages=['pybind11'],
|
48 | 65 | license='BSD',
|
49 | 66 | headers=headers,
|
| 67 | + cmdclass=dict(install_headers=InstallHeaders), |
50 | 68 | classifiers=[
|
51 | 69 | 'Development Status :: 5 - Production/Stable',
|
52 | 70 | 'Intended Audience :: Developers',
|
|
0 commit comments