15
15
"""
16
16
17
17
from distutils .version import LooseVersion
18
- from enum import Enum
19
18
import functools
20
19
import json
21
20
import os
@@ -78,10 +77,7 @@ def paths_from_link_libpaths():
78
77
class build_ext (build_ext ):
79
78
80
79
def build_extensions (self ):
81
- try :
82
- import importlib .metadata as importlib_metadata
83
- except ImportError :
84
- import importlib_metadata
80
+ import pybind11
85
81
86
82
ext , = self .distribution .ext_modules
87
83
@@ -95,40 +91,8 @@ def build_extensions(self):
95
91
else :
96
92
ext .sources += [* map (str , Path ("src" ).glob ("*.cpp" ))]
97
93
ext .sources .remove ("src/_unity_build.cpp" )
98
- ext .language = "c++"
99
-
100
- # pybind11.get_include() is brittle (pybind #1425).
101
- pybind11_include_path = next (
102
- path for path in importlib_metadata .files ("pybind11" )
103
- if path .name == "pybind11.h" ).locate ().parents [1 ]
104
- if not (pybind11_include_path / "pybind11/pybind11.h" ).exists ():
105
- # egg-install from setup_requires:
106
- # importlib-metadata thinks the headers are at
107
- # .eggs/pybind11-VER-TAG.egg/pybind11-VER.data/headers/pybind11.h
108
- # but they're actually at
109
- # .eggs/pybind11-VER-TAG.egg/pybind11.h
110
- # pybind11_include_path is
111
- # /<...>/.eggs/pybind11-VER-TAG.egg/pybind11-VER.data
112
- # so just create the proper structure there.
113
- try :
114
- is_egg = (pybind11_include_path .relative_to (
115
- Path (__file__ ).resolve ().parent ).parts [0 ] == ".eggs" )
116
- except ValueError :
117
- # Arch Linux ships completely wrong metadata, but the headers
118
- # are in the default include paths, so just leave things as is.
119
- is_egg = False
120
- if is_egg :
121
- shutil .rmtree (pybind11_include_path / "pybind11" ,
122
- ignore_errors = True )
123
- for file in [* pybind11_include_path .parent .glob ("**/*" )]:
124
- if file .is_dir ():
125
- continue
126
- dest = (pybind11_include_path / "pybind11" /
127
- file .relative_to (pybind11_include_path .parent ))
128
- dest .parent .mkdir (parents = True , exist_ok = True )
129
- shutil .copy2 (file , dest )
130
94
131
- ext .include_dirs += [pybind11_include_path ]
95
+ ext .include_dirs += [pybind11 . get_include () ]
132
96
133
97
tmp_include_dir = Path (self .get_finalized_command ("build" ).build_base ,
134
98
"include" )
@@ -272,9 +236,8 @@ def exec_module(module):
272
236
ext_modules = [Extension ("mplcairo._mplcairo" , [])],
273
237
python_requires = ">=3.6" ,
274
238
setup_requires = [
275
- "importlib_metadata>=0.8; python_version<'3.8'" , # Added files().
276
239
"setuptools_scm" ,
277
- "pybind11>=2.2.4 " ,
240
+ "pybind11>=2.5.0 " ,
278
241
# Actually also a setup_requires on Linux, but in the manylinux build
279
242
# we need to shim it.
280
243
"pycairo>=1.16.0; sys_platform == 'darwin'" ,
0 commit comments