Henry Schreiner | fd61f50 | 2020-09-16 17:13:41 -0400 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # -*- coding: utf-8 -*- |
| 3 | |
| 4 | # Setup script for pybind11-global (in the sdist or in tools/setup_global.py in the repository) |
| 5 | # This package is targeted for easy use from CMake. |
| 6 | |
| 7 | import contextlib |
| 8 | import glob |
| 9 | import os |
| 10 | import re |
| 11 | import shutil |
| 12 | import subprocess |
| 13 | import sys |
| 14 | import tempfile |
| 15 | |
| 16 | # Setuptools has to be before distutils |
| 17 | from setuptools import setup |
| 18 | |
| 19 | from distutils.command.install_headers import install_headers |
| 20 | |
| 21 | class InstallHeadersNested(install_headers): |
| 22 | def run(self): |
| 23 | headers = self.distribution.headers or [] |
| 24 | for header in headers: |
| 25 | # Remove pybind11/include/ |
| 26 | short_header = header.split("/", 2)[-1] |
| 27 | |
| 28 | dst = os.path.join(self.install_dir, os.path.dirname(short_header)) |
| 29 | self.mkpath(dst) |
| 30 | (out, _) = self.copy_file(header, dst) |
| 31 | self.outfiles.append(out) |
| 32 | |
| 33 | |
| 34 | main_headers = glob.glob("pybind11/include/pybind11/*.h") |
| 35 | detail_headers = glob.glob("pybind11/include/pybind11/detail/*.h") |
| 36 | cmake_files = glob.glob("pybind11/share/cmake/pybind11/*.cmake") |
| 37 | headers = main_headers + detail_headers |
| 38 | |
| 39 | cmdclass = {"install_headers": InstallHeadersNested} |
| 40 | $extra_cmd |
| 41 | |
| 42 | setup( |
| 43 | name="pybind11_global", |
| 44 | version="$version", |
| 45 | packages=[], |
| 46 | headers=headers, |
| 47 | data_files=[ |
| 48 | ("share/cmake/pybind11", cmake_files), |
| 49 | ("include/pybind11", main_headers), |
| 50 | ("include/pybind11/detail", detail_headers), |
| 51 | ], |
| 52 | cmdclass=cmdclass, |
| 53 | ) |