1515"""
1616
1717from distutils .version import LooseVersion
18- from enum import Enum
1918import functools
2019import json
2120import os
@@ -78,10 +77,7 @@ def paths_from_link_libpaths():
7877class build_ext (build_ext ):
7978
8079 def build_extensions (self ):
81- try :
82- import importlib .metadata as importlib_metadata
83- except ImportError :
84- import importlib_metadata
80+ import pybind11
8581
8682 ext , = self .distribution .ext_modules
8783
@@ -95,40 +91,8 @@ def build_extensions(self):
9591 else :
9692 ext .sources += [* map (str , Path ("src" ).glob ("*.cpp" ))]
9793 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 )
13094
131- ext .include_dirs += [pybind11_include_path ]
95+ ext .include_dirs += [pybind11 . get_include () ]
13296
13397 tmp_include_dir = Path (self .get_finalized_command ("build" ).build_base ,
13498 "include" )
@@ -272,9 +236,8 @@ def exec_module(module):
272236 ext_modules = [Extension ("mplcairo._mplcairo" , [])],
273237 python_requires = ">=3.6" ,
274238 setup_requires = [
275- "importlib_metadata>=0.8; python_version<'3.8'" , # Added files().
276239 "setuptools_scm" ,
277- "pybind11>=2.2.4 " ,
240+ "pybind11>=2.5.0 " ,
278241 # Actually also a setup_requires on Linux, but in the manylinux build
279242 # we need to shim it.
280243 "pycairo>=1.16.0; sys_platform == 'darwin'" ,
0 commit comments