__init__.py revision 14299:2fbea9df56d2
1from ._version import version_info, __version__  # noqa: F401 imported but unused
2
3
4def get_include(user=False):
5    from distutils.dist import Distribution
6    import os
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    # Are we running in a conda environment?
14    conda = os.path.exists(os.path.join(sys.prefix, 'conda-meta'))
15
16    if virtualenv:
17        return os.path.join(sys.prefix, 'include', 'site',
18                            'python' + sys.version[:3])
19    elif conda:
20        if os.name == 'nt':
21            return os.path.join(sys.prefix, 'Library', 'include')
22        else:
23            return os.path.join(sys.prefix, 'include')
24    else:
25        dist = Distribution({'name': 'pybind11'})
26        dist.parse_config_files()
27
28        dist_cobj = dist.get_command_obj('install', create=True)
29
30        # Search for packages in user's home directory?
31        if user:
32            dist_cobj.user = user
33            dist_cobj.prefix = ""
34        dist_cobj.finalize_options()
35
36        return os.path.dirname(dist_cobj.install_headers)
37