File tree 1 file changed +24
-7
lines changed 1 file changed +24
-7
lines changed Original file line number Diff line number Diff line change 1
1
from ._version import version_info , __version__ # noqa: F401 imported but unused
2
2
3
3
4
- def get_include (* args , ** kwargs ):
4
+ def get_include (user = False ):
5
+ from distutils .dist import Distribution
5
6
import os
6
- try :
7
- from pip import locations
8
- return os .path .dirname (
9
- locations .distutils_scheme ('pybind11' , * args , ** kwargs )['headers' ])
10
- except ImportError :
11
- return 'include'
7
+ import sys
8
+
9
+ # Are we running in a virtual environment?
10
+ virtualenv = hasattr (sys , 'real_prefix' ) or \
11
+ sys .prefix != getattr (sys , "base_prefix" , sys .prefix )
12
+
13
+ if virtualenv :
14
+ return os .path .join (sys .prefix , 'include' , 'site' ,
15
+ 'python' + sys .version [:3 ], 'pybind11' )
16
+ else :
17
+ dist = Distribution ({'name' : 'pybind11' })
18
+ dist .parse_config_files ()
19
+
20
+ dist_cobj = dist .get_command_obj ('install' , create = True )
21
+
22
+ # Search for packages in user's home directory?
23
+ if user :
24
+ dist_cobj .user = user
25
+ dist_cobj .prefix = ""
26
+ dist_cobj .finalize_options ()
27
+
28
+ return dist_cobj .install_headers
You can’t perform that action at this time.
0 commit comments