sysconfig.get_path

Here are the examples of the python api sysconfig.get_path taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

15 Examples 7

Example 1

Project: pymo Source File: test_sysconfig.py
Function: test_user_similar
    def test_user_similar(self):
        # Issue 8759 : make sure the posix scheme for the users
        # is similar to the global posix_prefix one
        base = get_config_var('base')
        user = get_config_var('userbase')
        for name in ('stdlib', 'platstdlib', 'purelib', 'platlib'):
            global_path = get_path(name, 'posix_prefix')
            user_path = get_path(name, 'posix_user')
            self.assertEqual(user_path, global_path.replace(base, user))

Example 2

Project: imagrium Source File: test_sysconfig.py
Function: test_user_similar
    def test_user_similar(self):
        # Issue #8759: make sure the posix scheme for the users
        # is similar to the global posix_prefix one
        base = get_config_var('base')
        user = get_config_var('userbase')
        # the global scheme mirrors the distinction between prefix and
        # exec-prefix but not the user scheme, so we have to adapt the paths
        # before comparing (issue #9100)
        adapt = sys.prefix != sys.exec_prefix
        for name in ('stdlib', 'platstdlib', 'purelib', 'platlib'):
            global_path = get_path(name, 'posix_prefix')
            if adapt:
                global_path = global_path.replace(sys.exec_prefix, sys.prefix)
                base = base.replace(sys.exec_prefix, sys.prefix)
            user_path = get_path(name, 'posix_user')
            self.assertEqual(user_path, global_path.replace(base, user, 1))

Example 3

Project: flit Source File: installfrom.py
def installfrom(address, user=None, python=sys.executable):
    if user is None:
        user = site.ENABLE_USER_SITE \
               and not os.access(sysconfig.get_path('purelib'), os.W_OK)

    try:
        return install_local(fetch(*parse_address(address)), user=user, python=python)
    except BadInput as e:
        print(e, file=sys.stderr)
        return 2

Example 4

Project: chipsec Source File: site.py
Function: getusersitepackages
def getusersitepackages():
    """Returns the user-specific site-packages directory path.

    If the global variable ``USER_SITE`` is not initialized yet, this
    function will also set it.
    """
    global USER_SITE
    user_base = getuserbase() # this will also set USER_BASE

    if USER_SITE is not None:
        return USER_SITE

    from sysconfig import get_path
    import os

    USER_SITE = get_path('purelib', '%s_user' % os.name)
    return USER_SITE

Example 5

Project: PyOpenWorm Source File: post_install.py
def get_library_location(package):
    # get abs path of a package in the library, rather than locally
    library_package_paths = glob(os.path.join(get_path('platlib'), '*'))
    sys.path = library_package_paths + sys.path
    package_path = get_loader(package).filename
    sys.path = sys.path[len(library_package_paths):]
    return package_path

Example 6

Project: PyOpenWorm Source File: __init__.py
Function: get_data
def get_data(path):
    # get a resource from the installed package location

    from sysconfig import get_path
    from pkgutil import get_loader
    from glob import glob
    package_paths = glob(os.path.join(get_path('platlib'), '*'))
    sys.path = package_paths + sys.path
    installed_package_root = get_loader('PyOpenWorm').filename
    sys.path = sys.path[len(package_paths):]
    filename = os.path.join(installed_package_root, path)
    return filename

Example 7

Project: PokemonGo-Bot-Desktop Source File: site.py
def getusersitepackages():
    """Returns the user-specific site-packages directory path.

    If the global variable ``USER_SITE`` is not initialized yet, this
    function will also set it.
    """
    global USER_SITE
    user_base = getuserbase() # this will also set USER_BASE

    if USER_SITE is not None:
        return USER_SITE

    from sysconfig import get_path
    import os

    if sys.platform == 'darwin':
        from sysconfig import get_config_var
        if get_config_var('PYTHONFRAMEWORK'):
            USER_SITE = get_path('purelib', 'osx_framework_user')
            return USER_SITE

    USER_SITE = get_path('purelib', '%s_user' % os.name)
    return USER_SITE

Example 8

Project: PyClassLessons Source File: bdist_egg.py
Function: get_purelib
    def _get_purelib():
        return get_path("purelib")

Example 9

Project: pymo Source File: test_sysconfig.py
Function: test_get_path
    def test_get_path(self):
        # xxx make real tests here
        for scheme in _INSTALL_SCHEMES:
            for name in _INSTALL_SCHEMES[scheme]:
                res = get_path(name, scheme)

Example 10

Project: flit Source File: install.py
    def _auto_user(self, python):
        """Default guess for whether to do user-level install.

        This should be True for system Python, and False in an env.
        """
        if python == sys.executable:
            user_site = site.ENABLE_USER_SITE
            lib_dir = sysconfig.get_path('purelib')
        else:
            out = self._run_python(code=
                ("import sysconfig, site; "
                 "print(site.ENABLE_USER_SITE); "
                 "print(sysconfig.get_path('purelib'))"))
            user_site, lib_dir = out.split('\n', 1)
            user_site = (user_site.strip() == 'True')
            lib_dir = lib_dir.strip()

        if not user_site:
            # No user site packages - probably a virtualenv
            log.debug('User site packages not available - env install')
            return False

        log.debug('Checking access to %s', lib_dir)
        return not test_writable_dir(lib_dir)

Example 11

Project: brython Source File: test_sysconfig.py
Function: test_get_path
    def test_get_path(self):
        # XXX make real tests here
        for scheme in _INSTALL_SCHEMES:
            for name in _INSTALL_SCHEMES[scheme]:
                res = get_path(name, scheme)

Example 12

Project: brython Source File: test_sysconfig.py
Function: test_user_similar
    def test_user_similar(self):
        # Issue #8759: make sure the posix scheme for the users
        # is similar to the global posix_prefix one
        base = get_config_var('base')
        user = get_config_var('userbase')
        # the global scheme mirrors the distinction between prefix and
        # exec-prefix but not the user scheme, so we have to adapt the paths
        # before comparing (issue #9100)
        adapt = sys.base_prefix != sys.base_exec_prefix
        for name in ('stdlib', 'platstdlib', 'purelib', 'platlib'):
            global_path = get_path(name, 'posix_prefix')
            if adapt:
                global_path = global_path.replace(sys.exec_prefix, sys.base_prefix)
                base = base.replace(sys.exec_prefix, sys.base_prefix)
            elif sys.base_prefix != sys.prefix:
                # virtual environment? Likewise, we have to adapt the paths
                # before comparing
                global_path = global_path.replace(sys.base_prefix, sys.prefix)
                base = base.replace(sys.base_prefix, sys.prefix)
            user_path = get_path(name, 'posix_user')
            self.assertEqual(user_path, global_path.replace(base, user, 1))

Example 13

Project: tract_querier Source File: __init__.py
def find_queries_path():
    default_path = sysconfig.get_path(name='data')
    possible_paths = [os.path.join(default_path, 'tract_querier', 'queries')]

    # Try to manage Virtual Environments on some OSes,
    # where data is not put the 'local' subdirectory,
    # but at the root of the virtual environment.
    if default_path.endswith('local'):
        possible_paths.append(os.path.join(default_path.rsplit('local', 1)[0],
                                           'tract_querier', 'queries'))

    # Case where the Tract_querier is cloned from git and simply
    # added to the python path, without installation.
    possible_paths.append(os.path.abspath(os.path.join(
                                          os.path.dirname(__file__), 'data')))

    paths_found = [path for path in possible_paths if os.path.exists(path)]

    if not paths_found:
        raise Exception('Default path for queries not found')

    return paths_found[0]

Example 14

Project: ironpython3 Source File: site.py
Function: getusersitepackages
def getusersitepackages():
    """Returns the user-specific site-packages directory path.

    If the global variable ``USER_SITE`` is not initialized yet, this
    function will also set it.
    """
    global USER_SITE
    user_base = getuserbase() # this will also set USER_BASE

    if USER_SITE is not None:
        return USER_SITE

    from sysconfig import get_path

    if sys.platform == 'darwin':
        from sysconfig import get_config_var
        if get_config_var('PYTHONFRAMEWORK'):
            USER_SITE = get_path('purelib', 'osx_framework_user')
            return USER_SITE

    USER_SITE = get_path('purelib', '%s_user' % os.name)
    return USER_SITE

Example 15

Project: meson Source File: dependencies.py
Function: init
    def __init__(self, environment, kwargs):
        super().__init__('python3')
        self.name = 'python3'
        self.is_found = False
        self.version = "3.something_maybe"
        try:
            pkgdep = PkgConfigDependency('python3', environment, kwargs)
            if pkgdep.found():
                self.cargs = pkgdep.cargs
                self.libs = pkgdep.libs
                self.version = pkgdep.get_version()
                self.is_found = True
                return
        except Exception:
            pass
        if not self.is_found:
            if mesonlib.is_windows():
                inc = sysconfig.get_path('include')
                platinc = sysconfig.get_path('platinclude')
                self.cargs = ['-I' + inc]
                if inc != platinc:
                    self.cargs.append('-I' + platinc)
                # Nothing exposes this directly that I coulf find
                basedir = sysconfig.get_config_var('base')
                vernum = sysconfig.get_config_var('py_version_nodot')
                self.libs = ['-L{}/libs'.format(basedir),
                             '-lpython{}'.format(vernum)]
                self.is_found = True
                self.version = sysconfig.get_config_var('py_version_short')
            elif mesonlib.is_osx():
                # In OSX the Python 3 framework does not have a version
                # number in its name.
                fw = ExtraFrameworkDependency('python', False)
                if fw.found():
                    self.cargs = fw.get_compile_args()
                    self.libs = fw.get_link_args()
                    self.is_found = True
        if self.is_found:
            mlog.log('Dependency', mlog.bold(self.name), 'found:', mlog.green('YES'))
        else:
            mlog.log('Dependency', mlog.bold(self.name), 'found:', mlog.red('NO'))