Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from Aug 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions pybind11/__init__.py
Expand Up @@ -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:
Copy link
Collaborator

@ax3l ax3l Aug 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sdebionne maybe that's a stupid question but let me ask it anyway:
can one be inside conda and therein as well within a virtualenv? Not that I would do that... conda has its one environments. But if so, how to handle this gracefully (or does this already work)? Or shall we just not support such a constellation?
(The opposite case is not possible, I guess.)

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()
Expand Down