Detect whether we are running in a Conda environment and adjust get_include() (#1877)

This commit is contained in:
Samuel Debionne 2019-08-19 12:43:33 +02:00 committed by Wenzel Jakob
parent 046267c629
commit 87fa6a4342

View File

@ -10,9 +10,17 @@ def get_include(user=False):
virtualenv = hasattr(sys, 'real_prefix') or \
sys.prefix != getattr(sys, "base_prefix", sys.prefix)
# Are we running in a conda environment?
conda = os.path.exists(os.path.join(sys.prefix, 'conda-meta'))
if virtualenv:
return os.path.join(sys.prefix, 'include', 'site',
'python' + sys.version[:3])
elif conda:
if os.name == 'nt':
return os.path.join(sys.prefix, 'Library', 'include')
else:
return os.path.join(sys.prefix, 'include')
else:
dist = Distribution({'name': 'pybind11'})
dist.parse_config_files()