本文整理汇总了Python中sysconfig.get_path函数的典型用法代码示例。如果您正苦于以下问题:Python get_path函数的具体用法?Python get_path怎么用?Python get_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _find_libpy3_windows
def _find_libpy3_windows(self, env):
'''
Find python3 libraries on Windows and also verify that the arch matches
what we are building for.
'''
pyarch = sysconfig.get_platform()
arch = detect_cpu_family(env.coredata.compilers)
if arch == 'x86':
arch = '32'
elif arch == 'x86_64':
arch = '64'
else:
# We can't cross-compile Python 3 dependencies on Windows yet
mlog.log('Unknown architecture {!r} for'.format(arch),
mlog.bold(self.name))
self.is_found = False
return
# Pyarch ends in '32' or '64'
if arch != pyarch[-2:]:
mlog.log('Need', mlog.bold(self.name),
'for {}-bit, but found {}-bit'.format(arch, pyarch[-2:]))
self.is_found = False
return
inc = sysconfig.get_path('include')
platinc = sysconfig.get_path('platinclude')
self.compile_args = ['-I' + inc]
if inc != platinc:
self.compile_args.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.link_args = ['-L{}/libs'.format(basedir),
'-lpython{}'.format(vernum)]
self.version = sysconfig.get_config_var('py_version_short')
self.is_found = True
示例2: print_includes
def print_includes():
dirs = [sysconfig.get_path('include')]
if sysconfig.get_path('platinclude') not in dirs:
dirs.append(sysconfig.get_path('platinclude'))
if get_include() not in dirs:
dirs.append(get_include())
print(' '.join('-I' + d for d in dirs))
示例3: 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
if sys.platform == 'win32':
from sysconfig import _POSIX_BUILD
if _POSIX_BUILD:
USER_SITE = get_path('purelib', 'posix_user')
return USER_SITE
USER_SITE = get_path('purelib', '%s_user' % os.name)
return USER_SITE
示例4: 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.assertEquals(user_path, global_path.replace(base, user))
示例5: 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))
示例6: get_sys_path
def get_sys_path(location, name):
# Returns the sysconfig path for a distribution, or None
for scheme in sysconfig.get_scheme_names():
for path_type in ["platlib", "purelib"]:
path = sysconfig.get_path(path_type, scheme)
try:
if samefile(path, location):
return sysconfig.get_path(name, scheme)
except EnvironmentError:
pass
示例7: getusersitepackages
def getusersitepackages():
global USER_SITE
user_base = getuserbase()
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
示例8: print_includes
def print_includes():
dirs = [sysconfig.get_path('include'),
sysconfig.get_path('platinclude'),
get_include(),
get_include(True)]
# Make unique but preserve order
unique_dirs = []
for d in dirs:
if d not in unique_dirs:
unique_dirs.append(d)
print(' '.join('-I' + d for d in unique_dirs))
示例9: sysconfig2
def sysconfig2():
# import sysconfig module - Provide access to Python’s configuration information
import sysconfig
# returns an installation path corresponding to the path name
print("Path Name : ", sysconfig.get_path("stdlib"))
print()
# returns a string that identifies the current platform.
print("Current Platform : ", sysconfig.get_platform())
print()
# returns the MAJOR.MINOR Python version number as a string
print("Python Version Number : ", sysconfig.get_python_version())
print()
# returns a tuple containing all path names
print("Path Names : ", sysconfig.get_path_names())
print()
# returns a tuple containing all schemes
print("Scheme Names : ", sysconfig.get_scheme_names())
print()
# returns the value of a single variable name.
print("Variable name LIBDIR : ", sysconfig.get_config_var('LIBDIR'))
# returns the value of a single variable name.
print("Variable name LIBDEST : ", sysconfig.get_config_var('LIBDEST'))
示例10: create_build_env
def create_build_env(dirname='virtualenv'):
# Create virtualenv.
if not os.path.exists(dirname):
check_call(['virtualenv', dirname])
import sysconfig
scripts_dir = os.path.basename(sysconfig.get_path('scripts'))
activate_this_file = os.path.join(dirname, scripts_dir, 'activate_this.py')
with open(activate_this_file) as f:
exec(f.read(), dict(__file__=activate_this_file))
# Import get_distribution after activating virtualenv to get info about
# the correct packages.
from pkg_resources import get_distribution, DistributionNotFound
# Upgrade pip because installation of sphinx with pip 1.1 available on Travis
# is broken (see #207) and it doesn't support the show command.
pip_version = get_distribution('pip').version
if LooseVersion(pip_version) < LooseVersion('1.5.4'):
print("Updating pip")
check_call(['pip', 'install', '--upgrade', 'pip'])
# Upgrade distribute because installation of sphinx with distribute 0.6.24
# available on Travis is broken (see #207).
try:
distribute_version = get_distribution('distribute').version
if LooseVersion(distribute_version) <= LooseVersion('0.6.24'):
print("Updating distribute")
check_call(['pip', 'install', '--upgrade', 'distribute'])
except DistributionNotFound:
pass
# Install Sphinx and Breathe.
pip_install('sphinx-doc/sphinx', '12b83372ac9316e8cbe86e7fed889296a4cc29ee',
min_version='1.4.1.dev20160531')
pip_install('michaeljones/breathe',
'6b1c5bb7a1866f15fc328b8716258354b10c1daa',
min_version='4.2.0')
示例11: get_library_location
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 = os.path.dirname(get_loader(package).get_filename())
sys.path = sys.path[len(library_package_paths):]
return package_path
示例12: find_queries_path
def find_queries_path():
possible_paths = []
# Try all possible schemes where python expects data to stay.
for scheme in sysconfig.get_scheme_names():
default_path = sysconfig.get_path(name='data', scheme=scheme)
possible_paths.append(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]
示例13: setup
def setup(version=None, packages=None, after_install=None, scripts=None, install_requires=None, **kwargs):
for k, v in DEFAULT.items():
kwargs.setdefault(k, v)
if not packages:
# 自动搜索包
packages = setuptools.find_packages(exclude=("testing", "scripts"))
if not version:
# 自动获取版本
version = str(Ver.read_file())
if not install_requires: # 从repuires.txt 中获取依赖包
install_requires = _get_requires()
if not scripts:
scripts = [str(path) for path in Path(".").glob("scripts/*")]
# 安装程序
dist = distutils.core.setup(
scripts=scripts, packages=packages, install_requires=install_requires, version=version, **kwargs
)
# 处理脚本
if "install" in dist.have_run and os.name == "posix" and scripts:
from sysconfig import get_path
prefix = Path(get_path("scripts"))
for script in scripts:
script_name = prefix / (Path(script).name)
if script_name.lsuffix in [".py", ".pyw"] and script_name.exists():
script_name.replace(script_name.with_suffix(""))
if "install" in dist.have_run and after_install:
after_install(dist)
示例14: find_executable
def find_executable(executable, include_others=True):
# backwards compatibility
global dir_paths
if include_others:
from ..utils import sys_prefix_unfollowed
prefixes = [sys_prefix_unfollowed()]
if sys.prefix != prefixes[0]:
prefixes.append(sys.prefix)
dir_paths = [join(p, basename(sysconfig.get_path('scripts')))
for p in prefixes]
# Is this still needed?
if on_win:
dir_paths.append('C:\\cygwin\\bin')
else:
dir_paths = []
dir_paths.extend(os.environ[str('PATH')].split(os.pathsep))
for dir_path in dir_paths:
if on_win:
for ext in ('.exe', '.bat', ''):
path = join(dir_path, executable + ext)
if isfile(path):
return path
else:
path = join(dir_path, executable)
if isfile(expanduser(path)):
return expanduser(path)
return None
示例15: get_build_cflags
def get_build_cflags():
"""Synthesize a CFLAGS env var from the current python env for building of C modules."""
return '{} {} -I{}'.format(
sysconfig.get_config_var('BASECFLAGS'),
sysconfig.get_config_var('OPT'),
sysconfig.get_path('include')
)