blob: 3325cd0eaded1d71cf5d91a4921e1e14bb8ab814 [file] [log] [blame]
Henry Schreinerfd61f502020-09-16 17:13:41 -04001#!/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
7import contextlib
8import glob
9import os
10import re
11import shutil
12import subprocess
13import sys
14import tempfile
15
16# Setuptools has to be before distutils
17from setuptools import setup
18
19from distutils.command.install_headers import install_headers
20
21class 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
34main_headers = glob.glob("pybind11/include/pybind11/*.h")
35detail_headers = glob.glob("pybind11/include/pybind11/detail/*.h")
36cmake_files = glob.glob("pybind11/share/cmake/pybind11/*.cmake")
37headers = main_headers + detail_headers
38
39cmdclass = {"install_headers": InstallHeadersNested}
40$extra_cmd
41
42setup(
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)