Python distutils.sysconfig.get_python_lib() Examples
The following are 30
code examples of distutils.sysconfig.get_python_lib().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
distutils.sysconfig
, or try the search function
.
Example #1
Source File: compat.py From hupper with MIT License | 7 votes |
def get_site_packages(): # pragma: no cover try: paths = site.getsitepackages() if site.ENABLE_USER_SITE: paths.append(site.getusersitepackages()) return paths # virtualenv does not ship with a getsitepackages impl so we fallback # to using distutils if we can # https://github.com/pypa/virtualenv/issues/355 except Exception: try: from distutils.sysconfig import get_python_lib return [get_python_lib()] # just incase, don't fail here, it's not worth it except Exception: return [] ################################################ # cross-compatible metaclass implementation # Copyright (c) 2010-2012 Benjamin Peterson
Example #2
Source File: imports.py From python-netsurv with MIT License | 6 votes |
def _compute_site_packages(): def _normalized_path(path): return os.path.normcase(os.path.abspath(path)) paths = set() real_prefix = getattr(sys, "real_prefix", None) for prefix in filter(None, (real_prefix, sys.prefix)): path = sysconfig.get_python_lib(prefix=prefix) path = _normalized_path(path) paths.add(path) # Handle Debian's derivatives /usr/local. if os.path.isfile("/etc/debian_version"): for prefix in filter(None, (real_prefix, sys.prefix)): libpython = os.path.join( prefix, "local", "lib", "python" + sysconfig.get_python_version(), "dist-packages", ) paths.add(libpython) return paths
Example #3
Source File: build_env.py From pipenv with MIT License | 6 votes |
def __init__(self, path): # type: (str) -> None self.path = path self.setup = False self.bin_dir = get_paths( 'nt' if os.name == 'nt' else 'posix_prefix', vars={'base': path, 'platbase': path} )['scripts'] # Note: prefer distutils' sysconfig to get the # library paths so PyPy is correctly supported. purelib = get_python_lib(plat_specific=False, prefix=path) platlib = get_python_lib(plat_specific=True, prefix=path) if purelib == platlib: self.lib_dirs = [purelib] else: self.lib_dirs = [purelib, platlib]
Example #4
Source File: build_env.py From deepWordBug with Apache License 2.0 | 6 votes |
def __init__(self, path): # type: (str) -> None self.path = path self.setup = False self.bin_dir = get_paths( 'nt' if os.name == 'nt' else 'posix_prefix', vars={'base': path, 'platbase': path} )['scripts'] # Note: prefer distutils' sysconfig to get the # library paths so PyPy is correctly supported. purelib = get_python_lib(plat_specific=False, prefix=path) platlib = get_python_lib(plat_specific=True, prefix=path) if purelib == platlib: self.lib_dirs = [purelib] else: self.lib_dirs = [purelib, platlib]
Example #5
Source File: requirements.py From pipenv with MIT License | 6 votes |
def vcsrepo(self, repo): # type (VCSRepository) -> None self._vcsrepo = repo ireq = self.ireq wheel_kwargs = self.wheel_kwargs.copy() wheel_kwargs["src_dir"] = repo.checkout_directory with pip_shims.shims.global_tempdir_manager(), temp_path(): ireq.ensure_has_source_dir(wheel_kwargs["src_dir"]) sys.path = [repo.checkout_directory, "", ".", get_python_lib(plat_specific=0)] setupinfo = SetupInfo.create( repo.checkout_directory, ireq=ireq, subdirectory=self.subdirectory, kwargs=wheel_kwargs, ) self._setup_info = setupinfo self._setup_info.reload()
Example #6
Source File: build_env.py From pex with Apache License 2.0 | 6 votes |
def __init__(self, path): # type: (str) -> None self.path = path self.setup = False self.bin_dir = get_paths( 'nt' if os.name == 'nt' else 'posix_prefix', vars={'base': path, 'platbase': path} )['scripts'] # Note: prefer distutils' sysconfig to get the # library paths so PyPy is correctly supported. purelib = get_python_lib(plat_specific=False, prefix=path) platlib = get_python_lib(plat_specific=True, prefix=path) if purelib == platlib: self.lib_dirs = [purelib] else: self.lib_dirs = [purelib, platlib]
Example #7
Source File: pex.py From pex with Apache License 2.0 | 6 votes |
def _extras_paths(cls): standard_lib = sysconfig.get_python_lib(standard_lib=True) try: makefile = sysconfig.parse_makefile(sysconfig.get_makefile_filename()) except (AttributeError, IOError): # This is not available by default in PyPy's distutils.sysconfig or it simply is # no longer available on the system (IOError ENOENT) makefile = {} extras_paths = filter(None, makefile.get('EXTRASPATH', '').split(':')) for path in extras_paths: yield os.path.join(standard_lib, path) # Handle .pth injected paths as extras. sitedirs = cls._get_site_packages() for pth_path in cls._scan_pth_files(sitedirs): TRACER.log('Found .pth file: %s' % pth_path, V=3) for extras_path in iter_pth_paths(pth_path): yield extras_path
Example #8
Source File: imports.py From python-netsurv with MIT License | 6 votes |
def _compute_site_packages(): def _normalized_path(path): return os.path.normcase(os.path.abspath(path)) paths = set() real_prefix = getattr(sys, "real_prefix", None) for prefix in filter(None, (real_prefix, sys.prefix)): path = sysconfig.get_python_lib(prefix=prefix) path = _normalized_path(path) paths.add(path) # Handle Debian's derivatives /usr/local. if os.path.isfile("/etc/debian_version"): for prefix in filter(None, (real_prefix, sys.prefix)): libpython = os.path.join( prefix, "local", "lib", "python" + sysconfig.get_python_version(), "dist-packages", ) paths.add(libpython) return paths
Example #9
Source File: package_names.py From pydeps with BSD 2-Clause "Simplified" License | 6 votes |
def find_package_names(): site_packages = sysconfig.get_python_lib() # initialize with well-known packages that don't seem to have a top_level.txt res = { 'yaml': 'PyYAML', 'Crypto': 'pycrypto', } for pth in os.listdir(site_packages): if not pth.endswith('.dist-info'): continue pkgname = pth.split('-', 1)[0].replace('_', '-') top_level_fname = os.path.join(site_packages, pth, 'top_level.txt') if not os.path.exists(top_level_fname): if pkgname not in res.values(): print("ERR:", pth, 'has not top_level.txt') continue for modname in open(top_level_fname).read().split(): modname = modname.replace('/', '.') if modname.startswith(r'win32\lib'): modname = modname.rsplit('\\')[1] res[modname] = pkgname return res
Example #10
Source File: build_env.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def __init__(self, path): # type: (str) -> None self.path = path self.setup = False self.bin_dir = get_paths( 'nt' if os.name == 'nt' else 'posix_prefix', vars={'base': path, 'platbase': path} )['scripts'] # Note: prefer distutils' sysconfig to get the # library paths so PyPy is correctly supported. purelib = get_python_lib(plat_specific=False, prefix=path) platlib = get_python_lib(plat_specific=True, prefix=path) if purelib == platlib: self.lib_dirs = [purelib] else: self.lib_dirs = [purelib, platlib]
Example #11
Source File: build_env.py From Building-Recommendation-Systems-with-Python with MIT License | 6 votes |
def __init__(self, path): # type: (str) -> None self.path = path self.setup = False self.bin_dir = get_paths( 'nt' if os.name == 'nt' else 'posix_prefix', vars={'base': path, 'platbase': path} )['scripts'] # Note: prefer distutils' sysconfig to get the # library paths so PyPy is correctly supported. purelib = get_python_lib(plat_specific=False, prefix=path) platlib = get_python_lib(plat_specific=True, prefix=path) if purelib == platlib: self.lib_dirs = [purelib] else: self.lib_dirs = [purelib, platlib]
Example #12
Source File: build_env.py From Building-Recommendation-Systems-with-Python with MIT License | 6 votes |
def __init__(self, path): # type: (str) -> None self.path = path self.setup = False self.bin_dir = get_paths( 'nt' if os.name == 'nt' else 'posix_prefix', vars={'base': path, 'platbase': path} )['scripts'] # Note: prefer distutils' sysconfig to get the # library paths so PyPy is correctly supported. purelib = get_python_lib(plat_specific=False, prefix=path) platlib = get_python_lib(plat_specific=True, prefix=path) if purelib == platlib: self.lib_dirs = [purelib] else: self.lib_dirs = [purelib, platlib]
Example #13
Source File: build_env.py From scylla with Apache License 2.0 | 6 votes |
def __init__(self, path): # type: (str) -> None self.path = path self.setup = False self.bin_dir = get_paths( 'nt' if os.name == 'nt' else 'posix_prefix', vars={'base': path, 'platbase': path} )['scripts'] # Note: prefer distutils' sysconfig to get the # library paths so PyPy is correctly supported. purelib = get_python_lib(plat_specific=False, prefix=path) platlib = get_python_lib(plat_specific=True, prefix=path) if purelib == platlib: self.lib_dirs = [purelib] else: self.lib_dirs = [purelib, platlib]
Example #14
Source File: build_env.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def __init__(self, path): # type: (str) -> None self.path = path self.setup = False self.bin_dir = get_paths( 'nt' if os.name == 'nt' else 'posix_prefix', vars={'base': path, 'platbase': path} )['scripts'] # Note: prefer distutils' sysconfig to get the # library paths so PyPy is correctly supported. purelib = get_python_lib(plat_specific=False, prefix=path) platlib = get_python_lib(plat_specific=True, prefix=path) if purelib == platlib: self.lib_dirs = [purelib] else: self.lib_dirs = [purelib, platlib]
Example #15
Source File: imports.py From linter-pylama with MIT License | 6 votes |
def _compute_site_packages(): def _normalized_path(path): return os.path.normcase(os.path.abspath(path)) paths = set() real_prefix = getattr(sys, 'real_prefix', None) for prefix in filter(None, (real_prefix, sys.prefix)): path = sysconfig.get_python_lib(prefix=prefix) path = _normalized_path(path) paths.add(path) # Handle Debian's derivatives /usr/local. if os.path.isfile("/etc/debian_version"): for prefix in filter(None, (real_prefix, sys.prefix)): libpython = os.path.join(prefix, "local", "lib", "python" + sysconfig.get_python_version(), "dist-packages") paths.add(libpython) return paths
Example #16
Source File: bdist_egg.py From scylla with Apache License 2.0 | 5 votes |
def _get_purelib(): return get_python_lib(False)
Example #17
Source File: __init__.py From telegram-robot-rss with Mozilla Public License 2.0 | 5 votes |
def get_stdlib(): paths = [ sysconfig.get_python_lib(standard_lib=True), sysconfig.get_python_lib(standard_lib=True, plat_specific=True), ] return set(filter(bool, paths))
Example #18
Source File: build_env.py From pySINDy with MIT License | 5 votes |
def __enter__(self): self.save_path = os.environ.get('PATH', None) self.save_pythonpath = os.environ.get('PYTHONPATH', None) self.save_nousersite = os.environ.get('PYTHONNOUSERSITE', None) install_scheme = 'nt' if (os.name == 'nt') else 'posix_prefix' install_dirs = get_paths(install_scheme, vars={ 'base': self.path, 'platbase': self.path, }) scripts = install_dirs['scripts'] if self.save_path: os.environ['PATH'] = scripts + os.pathsep + self.save_path else: os.environ['PATH'] = scripts + os.pathsep + os.defpath # Note: prefer distutils' sysconfig to get the # library paths so PyPy is correctly supported. purelib = get_python_lib(plat_specific=0, prefix=self.path) platlib = get_python_lib(plat_specific=1, prefix=self.path) if purelib == platlib: lib_dirs = purelib else: lib_dirs = purelib + os.pathsep + platlib if self.save_pythonpath: os.environ['PYTHONPATH'] = lib_dirs + os.pathsep + \ self.save_pythonpath else: os.environ['PYTHONPATH'] = lib_dirs os.environ['PYTHONNOUSERSITE'] = '1' return self.path
Example #19
Source File: test_sysconfig.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_get_python_lib(self): # XXX doesn't work on Linux when Python was never installed before #self.assertTrue(os.path.isdir(lib_dir), lib_dir) # test for pythonxx.lib? self.assertNotEqual(sysconfig.get_python_lib(), sysconfig.get_python_lib(prefix=TESTFN))
Example #20
Source File: ModuleEnvironment.py From royal-chaos with MIT License | 5 votes |
def create_environement_file(self, fileName): ''' Creates the set environment file to help users to call the Bake built modules. ''' script = "#!/bin/bash \n#### \n# Environment setting script. Automatically generated by Bake\n####\n\n" script = script + "echo \"> Call with . " + fileName + " or source " + fileName + "\"\n" self._binpaths.add(self._bin_path()) self._libpaths.add(self._lib_path()) if len(self._libpaths) > 0: script = script + self.add_onPath("LD_LIBRARY_PATH", self._libpaths) + "\n" if len(self._binpaths) > 0: script = script + self.add_onPath("PATH", self._binpaths) + "\n" if len(self._pkgpaths) > 0: script = script + self.add_onPath("PKG_CONFIG_PATH", self._pkgpaths) + "\n" from distutils.sysconfig import get_python_lib localLibPath='' libDir=get_python_lib() if libDir: begin=libDir.lower().index('python') localLibPath=os.path.join(self._lib_path(),libDir[begin:]) script = script + self.add_onPath("PYTHONPATH", [sys.path[0],self._lib_path(),localLibPath]) + "\n" for element in self._variables: script = script + " export " + element + "\n" fout = open(fileName, "w") fout.write(script) fout.close() os.chmod(fileName, 0o755) return script
Example #21
Source File: pycallgraph.py From pyFileFixity with MIT License | 5 votes |
def is_module_stdlib(file_name): """Returns True if the file_name is in the lib directory.""" # TODO: Move these calls away from this function so it doesn't have to run # every time. lib_path = sysconfig.get_python_lib() path = os.path.split(lib_path) if path[1] == 'site-packages': lib_path = path[0] return file_name.lower().startswith(lib_path.lower())
Example #22
Source File: build_env.py From hacktoberfest2018 with GNU General Public License v3.0 | 5 votes |
def __enter__(self): self._temp_dir.create() self.save_path = os.environ.get('PATH', None) self.save_pythonpath = os.environ.get('PYTHONPATH', None) self.save_nousersite = os.environ.get('PYTHONNOUSERSITE', None) install_scheme = 'nt' if (os.name == 'nt') else 'posix_prefix' install_dirs = get_paths(install_scheme, vars={ 'base': self.path, 'platbase': self.path, }) scripts = install_dirs['scripts'] if self.save_path: os.environ['PATH'] = scripts + os.pathsep + self.save_path else: os.environ['PATH'] = scripts + os.pathsep + os.defpath # Note: prefer distutils' sysconfig to get the # library paths so PyPy is correctly supported. purelib = get_python_lib(plat_specific=0, prefix=self.path) platlib = get_python_lib(plat_specific=1, prefix=self.path) if purelib == platlib: lib_dirs = purelib else: lib_dirs = purelib + os.pathsep + platlib if self.save_pythonpath: os.environ['PYTHONPATH'] = lib_dirs + os.pathsep + \ self.save_pythonpath else: os.environ['PYTHONPATH'] = lib_dirs os.environ['PYTHONNOUSERSITE'] = '1' return self.path
Example #23
Source File: bdist_egg.py From deepWordBug with Apache License 2.0 | 5 votes |
def _get_purelib(): return get_python_lib(False)
Example #24
Source File: bdist_egg.py From pex with Apache License 2.0 | 5 votes |
def _get_purelib(): return get_python_lib(False)
Example #25
Source File: pex.py From pex with Apache License 2.0 | 5 votes |
def site_libs(cls): site_libs = cls._get_site_packages() site_libs.update([sysconfig.get_python_lib(plat_specific=False), sysconfig.get_python_lib(plat_specific=True)]) # On windows getsitepackages() returns the python stdlib too. if sys.prefix in site_libs: site_libs.remove(sys.prefix) real_site_libs = set(os.path.realpath(path) for path in site_libs) return site_libs | real_site_libs
Example #26
Source File: bdist_egg.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def _get_purelib(): return get_python_lib(False)
Example #27
Source File: py31compat.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def get_path(name): if name not in ('platlib', 'purelib'): raise ValueError("Name must be purelib or platlib") return get_python_lib(name == 'platlib')
Example #28
Source File: __init__.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def get_stdlib(): paths = [ sysconfig.get_python_lib(standard_lib=True), sysconfig.get_python_lib(standard_lib=True, plat_specific=True), ] return set(filter(bool, paths))
Example #29
Source File: bdist_egg.py From anpr with Creative Commons Attribution 4.0 International | 5 votes |
def _get_purelib(): return get_python_lib(False)
Example #30
Source File: py31compat.py From anpr with Creative Commons Attribution 4.0 International | 5 votes |
def get_path(name): if name not in ('platlib', 'purelib'): raise ValueError("Name must be purelib or platlib") return get_python_lib(name == 'platlib')