本文整理汇总了Python中site.getusersitepackages函数的典型用法代码示例。如果您正苦于以下问题:Python getusersitepackages函数的具体用法?Python getusersitepackages怎么用?Python getusersitepackages使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getusersitepackages函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: list_site_packages_paths
def list_site_packages_paths():
site_packages_paths = set([site.USER_SITE])
try:
site_packages_paths.update(site.getsitepackages())
except AttributeError:
pass
try:
user_site = site.getusersitepackages()
if isinstance(user_site, str):
site_packages_paths.add(user_site)
else:
site_packages_paths.update(user_site)
except AttributeError:
pass
try:
virtualenv_path = os.environ['VIRTUAL_ENV']
except KeyError:
pass
else:
virtualenv_src_path = os.path.join(virtualenv_path, 'src')
site_packages_paths.update(
path
for path in sys.path
if path.startswith(virtualenv_path) and (
'site-packages' in path or
path.startswith(virtualenv_src_path)
)
)
return site_packages_paths
开发者ID:spoqa,项目名称:import-order,代码行数:29,代码来源:listing.py
示例2: getopts
def getopts(argv):
'''returns command line options as tuple.'''
user = False
set_env = True
version = WAF_VERSION
tools = WAF_TOOLS
bindir = BINDIR
libdir = LIBDIR
opts, args = getopt.getopt(argv[1:], 'hv:t:us', ['help', 'version=', 'tools=', 'user', 'skip-env'])
for opt, arg in opts:
if opt in ('-h', '--help'):
usage()
sys.exit()
elif opt in ('-v', '--version'):
version = arg
elif opt in ('-t', '--tools'):
tools = arg
elif opt in ('-u', '--user'):
user = True
elif opt in ('-s', '--skip-env'):
set_env = False
if user:
# install in home directory but not on windows or virtualenv
if sys.platform != "win32" and not hasattr(sys, 'real_prefix'):
bindir = "~/.local/bin"
libdir = site.getusersitepackages()
return (version, tools, bindir, libdir, set_env)
开发者ID:guysherman,项目名称:basic-cpp-template,代码行数:30,代码来源:wafinstall.py
示例3: __init__
def __init__(self, verbose=True):
self.plugin_types = ('wralea', 'plugin', 'adapters', 'interfaces')
self.groups = set()
self.managers = {}
self._services = {}
self._interfaces = {}
self._lowername = {}
# list all path supporting python modules
paths = site.getsitepackages()
usersite = site.getusersitepackages()
if isinstance(usersite, basestring):
paths.append(usersite)
elif isinstance(usersite, (tuple, list)):
paths += list(usersite)
paths += sys.path
# scan all entry_point and list different groups
for path in set(paths):
distribs = pkg_resources.find_distributions(path)
for distrib in distribs :
for group in distrib.get_entry_map():
self.groups.add(group)
self.groups = [group for group in self.groups]
self.tags = self._clean_lst(self.groups)
self._load_interfaces()
开发者ID:VirtualPlants,项目名称:openalea,代码行数:29,代码来源:catalog.py
示例4: create_sitecustomize
def create_sitecustomize(path):
extra_sitepacks = []
sitepacks = ensure_list(site.getsitepackages())
user_sitepacks = ensure_list(site.getusersitepackages())
fp = open("bin/sitecustomize.py", "w")
print >>fp, 'import os, site, sys'
print >>fp, 'EXTRA_SITE_PACKAGES = ' + str(EXTRA_SITE_PACKAGES)
print >>fp, 'SYSTEM_SITE_PACKAGES = ' + str(SYSTEM_SITE_PACKAGES)
print >>fp, 'USER_SITE_PACKAGES = ' + str(USER_SITE_PACKAGES)
if extra_sitepacks:
print >>fp, 'extra_sitepacks = ["' + '", "'.join(extra_sitepacks) + '"]'
else:
print >>fp, 'extra_sitepacks = [ ]'
if sitepacks:
print >>fp, 'sitepacks = ["' + '", "'.join(sitepacks) + '"]'
else:
print >>fp, 'sitepacks = [ ]'
if user_sitepacks:
print >>fp, 'user_sitepacks = ["' + '", "'.join(user_sitepacks) + '"]'
else:
print >>fp, 'user_sitepacks = [ ]'
print >>fp, site_script
fp.close()
开发者ID:michs,项目名称:localenv,代码行数:29,代码来源:localpyenv.py
示例5: test_no_home_directory
def test_no_home_directory(self):
# bpo-10496: getuserbase() and getusersitepackages() must not fail if
# the current user has no home directory (if expanduser() returns the
# path unchanged).
site.USER_SITE = None
site.USER_BASE = None
with EnvironmentVarGuard() as environ, \
mock.patch('os.path.expanduser', lambda path: path):
del environ['PYTHONUSERBASE']
del environ['APPDATA']
user_base = site.getuserbase()
self.assertTrue(user_base.startswith('~' + os.sep),
user_base)
user_site = site.getusersitepackages()
self.assertTrue(user_site.startswith(user_base), user_site)
with mock.patch('os.path.isdir', return_value=False) as mock_isdir, \
mock.patch.object(site, 'addsitedir') as mock_addsitedir, \
support.swap_attr(site, 'ENABLE_USER_SITE', True):
# addusersitepackages() must not add user_site to sys.path
# if it is not an existing directory
known_paths = set()
site.addusersitepackages(known_paths)
mock_isdir.assert_called_once_with(user_site)
mock_addsitedir.assert_not_called()
self.assertFalse(known_paths)
开发者ID:Victor-Savu,项目名称:cpython,代码行数:32,代码来源:test_site.py
示例6: fixate
def fixate():
"puts activation code to usercustomize.py for user"
print_message('Fixate')
import site
userdir = site.getusersitepackages()
if not userdir:
raise PundleException('Can`t fixate due user have not site package directory')
try:
makedirs(userdir)
except OSError:
pass
template = FIXATE_TEMPLATE.replace('op.dirname(__file__)', "'%s'" % op.abspath(op.dirname(__file__)))
usercustomize_file = op.join(userdir, 'usercustomize.py')
print_message('Will edit %s file' % usercustomize_file)
if op.exists(usercustomize_file):
content = open(usercustomize_file).read()
if '# pundle user customization start' in content:
regex = re.compile(r'\n# pundle user customization start.*# pundle user customization end\n', re.DOTALL)
content, res = regex.subn(template, content)
open(usercustomize_file, 'w').write(content)
else:
open(usercustomize_file, 'a').write(content)
else:
open(usercustomize_file, 'w').write(template)
link_file = op.join(userdir, 'pundle.py')
if op.lexists(link_file):
print_message('Remove exist link to pundle')
os.unlink(link_file)
print_message('Create link to pundle %s' % link_file)
os.symlink(op.abspath(__file__), link_file)
print_message('Complete')
开发者ID:Deepwalker,项目名称:pundler,代码行数:31,代码来源:pundle.py
示例7: check_installed
def check_installed():
"Check that we're installed, if not, install"
s = site.getusersitepackages()
# There should be a symlink
sym = os.path.join( s, "sr" )
# to here:
target = os.path.abspath( os.path.join( os.path.dirname(__file__),
"..", "python" ) )
if not os.path.exists( s ):
os.makedirs( s )
if os.path.exists(sym):
try:
cur_target = os.readlink( sym )
c = os.path.abspath( cur_target )
if c == target:
"Installed, and pointing at the right place"
return
# Wrong target directory -- rewrite it
os.unlink( sym )
except OSError:
print >>sys.stderr, "Error: %s is not a symlink. Refusing to continue." % sym
exit(1)
print >>sys.stderr, "Installing SR python usersitepackage"
os.symlink( target, sym )
开发者ID:Scarzy,项目名称:tools,代码行数:31,代码来源:sitepackage.py
示例8: pytest_report_header
def pytest_report_header(config):
print('PYDEVD_USE_CYTHON: %s' % (TEST_CYTHON,))
print('PYDEVD_TEST_JYTHON: %s' % (TEST_JYTHON,))
try:
import multiprocessing
except ImportError:
pass
else:
print('Number of processors: %s' % (multiprocessing.cpu_count(),))
print('Relevant system paths:')
print('sys.prefix: %s' % (sys.prefix,))
if hasattr(sys, 'base_prefix'):
print('sys.base_prefix: %s' % (sys.base_prefix,))
if hasattr(sys, 'real_prefix'):
print('sys.real_prefix: %s' % (sys.real_prefix,))
if hasattr(site, 'getusersitepackages'):
print('site.getusersitepackages(): %s' % (site.getusersitepackages(),))
if hasattr(site, 'getsitepackages'):
print('site.getsitepackages(): %s' % (site.getsitepackages(),))
for path in sys.path:
if os.path.exists(path) and os.path.basename(path) == 'site-packages':
print('Folder with "site-packages" in sys.path: %s' % (path,))
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:28,代码来源:conftest.py
示例9: _get_default_library_roots
def _get_default_library_roots(cls):
# Provide sensible defaults if not in env vars.
import site
roots = [sys.prefix]
if hasattr(sys, 'base_prefix'):
roots.append(sys.base_prefix)
if hasattr(sys, 'real_prefix'):
roots.append(sys.real_prefix)
if hasattr(site, 'getusersitepackages'):
site_paths = site.getusersitepackages()
if isinstance(site_paths, (list, tuple)):
for site_path in site_paths:
roots.append(site_path)
else:
roots.append(site_paths)
if hasattr(site, 'getsitepackages'):
site_paths = site.getsitepackages()
if isinstance(site_paths, (list, tuple)):
for site_path in site_paths:
roots.append(site_path)
else:
roots.append(site_paths)
for path in sys.path:
if os.path.exists(path) and os.path.basename(path) == 'site-packages':
roots.append(path)
return sorted(set(roots))
开发者ID:ku5ic,项目名称:dotfiles,代码行数:30,代码来源:pydevd_filtering.py
示例10: getopts
def getopts(argv):
"""returns command line options as tuple."""
user = False
set_env = True
version = WAF_VERSION
tools = WAF_TOOLS
bindir = BINDIR
libdir = LIBDIR
opts, args = getopt.getopt(argv[1:], "hv:t:us", ["help", "version=", "tools=", "user", "skip-env"])
for opt, arg in opts:
if opt in ("-h", "--help"):
usage()
sys.exit()
elif opt in ("-v", "--version"):
version = arg
elif opt in ("-t", "--tools"):
tools = arg
elif opt in ("-u", "--user"):
user = True
elif opt in ("-s", "--skip-env"):
set_env = False
if user:
# install in home directory but not on windows or virtualenv
if sys.platform != "win32" and not hasattr(sys, "real_prefix"):
bindir = "~/.local/bin"
libdir = site.getusersitepackages()
return (version, tools, bindir, libdir, set_env)
开发者ID:mixtile,项目名称:xskit,代码行数:30,代码来源:wafinstall.py
示例11: run
def run(self):
_install.run(self)
if '--user' in sys.argv[-1] :
userdir = site.getusersitepackages()+"/pyasp/bin"
self.get_binaries(userdir)
cmd="chmod +x "+userdir+"/*"
print(cmd)
os.system(cmd)
else :
py_version = "%s.%s" % (sys.version_info[0], sys.version_info[1])
paths = []
paths.append(sys.prefix+"/lib/python%s/dist-packages/pyasp/bin" % py_version)
paths.append(sys.prefix+"/lib/python%s/site-packages/pyasp/bin" % py_version)
paths.append(sys.prefix+"/local/lib/python%s/dist-packages/pyasp/bin" % py_version)
paths.append(sys.prefix+"/local/lib/python%s/site-packages/pyasp/bin" % py_version)
paths.append("/Library/Python/%s/site-packages/pyasp/bin" % py_version)
cmd = None
for path in paths:
if os.path.exists(path):
self.get_binaries(path)
cmd = "chmod +x "+path+"/*"
break
if cmd:
print(cmd)
os.system(cmd)
else:
print("pyasp binaries path not found. You need to download and put in place the binaries for gringo3, gringo4 and clasp in order to start using pyasp.")
开发者ID:cfrioux,项目名称:pyasp,代码行数:30,代码来源:setup.py
示例12: binaries_directory
def binaries_directory():
"""Return the installation directory, or None"""
if '--user' in sys.argv:
paths = (site.getusersitepackages(),)
else:
py_version = '%s.%s' % (sys.version_info[0], sys.version_info[1])
paths = (s % (py_version) for s in (
sys.prefix + '/lib/python%s/dist-packages/',
sys.prefix + '/lib/python%s/site-packages/',
sys.prefix + '/local/lib/python%s/dist-packages/',
sys.prefix + '/local/lib/python%s/site-packages/',
'/Library/Python/%s/site-packages/',
))
# yield the first valid path
for path in paths:
# add the package and bin subdir and, if exists, return it
path = os.path.join(path, '%s/%s' % (info.__pkg_name__, constant.REL_DIR_BIN))
if os.path.exists(path):
return path
logging.getLogger().error(
'pyasp binaries path not found. You need to download and'
' put in place the binaries for gringo3, gringo4 and clasp'
' in order to start using pyasp.'
' You can find binaries from ' + BINARIES_BASE_URL +
' or https://sourceforge.net/projects/potassco/files/,'
' or compile them yourself.'
)
exit()
return None
开发者ID:Aluriak,项目名称:pyasp,代码行数:30,代码来源:setup.py
示例13: AddToPath
def AddToPath(self, package):
# Find all 'site-packages' directories.
sp = getsitepackages()
sp.append(getusersitepackages())
for path in sp:
if path not in sys.path and os.path.exists(path):
sys.path.append(path)
# Add package to sys.path.
def _AddToPath(name, version):
for path in sp:
packageFileName = name + '-' + version
files = DirFileSet(path, [packageFileName + '*.egg', packageFileName + '*.zip'], withRootDirName = True)
for fn in files:
if fn not in sys.path and os.path.exists(fn):
sys.path.append(fn)
_AddToPath(package.artifactId, package.version)
_AddToPath(package.artifactId.replace('-', '_'), package.version)
# Try to add all the packages that are missing in
# sys.path but are listed in: easy-install.pth.
for path in sp:
pth = os.path.join(path, 'easy-install.pth')
try:
pth = OS.LoadFile(pth)
pth = pth.split('\n')
for fn in pth:
if not fn.startswith(('#', "import ", "import\t")):
fn = os.path.realpath(os.path.join(path, fn))
if fn not in sys.path and os.path.exists(fn):
sys.path.append(fn)
except Exception as E:
#self.Log(str(E), level = LogLevel.VERBOSE)
pass
开发者ID:boguslawski-piotr,项目名称:atta,代码行数:34,代码来源:PyInstall.py
示例14: test_getusersitepackages
def test_getusersitepackages(self):
site.USER_SITE = None
site.USER_BASE = None
user_site = site.getusersitepackages()
# the call sets USER_BASE *and* USER_SITE
self.assertEqual(site.USER_SITE, user_site)
self.assertTrue(user_site.startswith(site.USER_BASE), user_site)
开发者ID:pogigroo,项目名称:py3k-__format__,代码行数:8,代码来源:test_site.py
示例15: _user_site_packages
def _user_site_packages():
if not _in_virtualenv():
return site.getusersitepackages()
else:
home = _find_user_home()
major = sys.version_info.major
minor = sys.version_info.minor
path = '/.local/lib/python{major}.{minor}/site-packages'.format(major=major, minor=minor)
return home+path
开发者ID:jupyter-gallery,项目名称:ipydeps,代码行数:9,代码来源:__init__.py
示例16: main
def main():
locations = [site.getusersitepackages()]
locations.extend(site.getsitepackages())
for root in locations:
if os.path.isdir(root):
for name in os.listdir(root):
if PKGNAME in name:
abspath = os.path.join(root, name)
rmpath(abspath)
开发者ID:Marketing1by1,项目名称:pyftpdlib,代码行数:9,代码来源:purge_installation.py
示例17: main
def main():
qmakePath = getEnv("QMAKE", "qmake")
sipPath = getEnv("SIP", "sip")
sipConfig = sipconfig.Configuration()
config = Config(qmakePath)
projectPath = getEnv("PROJECT_PATH", "../..")
libraryPath = getEnv("LIBRARY_PATH", projectPath + "/fakevim")
sipFilePath = getEnv("SIP_FILE_PATH", projectPath + "/python/fakevim.sip")
pyQtIncludePath = getEnv("PYQT_INCLUDE_PATH", "/usr/share/sip/PyQt" + (config.hasQt5() and "5" or "4"))
commandOutput(
sipPath,
config.sipFlags().split(" ")
+ ["-I", pyQtIncludePath, "-b", "fakevim_python.pro", "-o", "-c", ".", sipFilePath],
)
with open("fakevim_python.pro", "a") as pro:
pro.write(
"""
TEMPLATE = lib
CONFIG += release plugin no_plugin_name_prefix
QT += widgets
TARGET = $$target
HEADERS = $$headers "{projectPythonInclude}/fakevimproxy.h"
SOURCES = $$sources "{projectPythonInclude}/fakevimproxy.cpp"
INCLUDEPATH += "{sipInclude}" "{pythonInclude}" "{projectInclude}" "{projectPythonInclude}"
LIBS += -Wl,-rpath,"{libraryPath}" -L"{libraryPath}" -lfakevim "{pythonLibrary}"
DEFINES += FAKEVIM_PYQT_MAJOR_VERSION={qtVersion}
isEmpty(PREFIX) {{
PREFIX = "{installPath}"
}}
target.path = $$PREFIX
INSTALLS += target
""".format(
pythonInclude=sysconfig.get_python_inc(),
sipInclude=sipConfig.sip_inc_dir,
projectInclude=projectPath,
projectPythonInclude=projectPath + "/python",
libraryPath=libraryPath,
pythonLibrary=sysconfig.get_config_var("LIBDIR")
+ "/"
+ sysconfig.get_config_var("MULTIARCH")
+ "/"
+ sysconfig.get_config_var("LDLIBRARY"),
qtVersion=config.hasQt5() and 5 or 4,
installPath=site.getusersitepackages(),
).replace(
"\n ", "\n"
)
)
开发者ID:yanghuicpp,项目名称:FakeVim,代码行数:56,代码来源:configure.py
示例18: python_env
def python_env(options, unset_env=False):
"""
Setup our overrides_hack.py as sitecustomize.py script in user
site-packages if unset_env=False, else unset, previously set
env.
"""
subprojects_path = os.path.join(options.builddir, "subprojects")
gst_python_path = os.path.join(SCRIPTDIR, "subprojects", "gst-python")
if not os.path.exists(os.path.join(subprojects_path, "gst-python")) or \
not os.path.exists(gst_python_path):
return False
if in_venv ():
sitepackages = get_python_lib()
else:
sitepackages = site.getusersitepackages()
if not sitepackages:
return False
sitecustomize = os.path.join(sitepackages, "sitecustomize.py")
overrides_hack = os.path.join(gst_python_path, "testsuite", "overrides_hack.py")
mesonconfig = os.path.join(gst_python_path, "testsuite", "mesonconfig.py")
mesonconfig_link = os.path.join(sitepackages, "mesonconfig.py")
if not unset_env:
if os.path.exists(sitecustomize):
if os.path.realpath(sitecustomize) == overrides_hack:
print("Customize user site script already linked to the GStreamer one")
return False
old_sitecustomize = os.path.join(sitepackages,
"old.sitecustomize.gstuninstalled.py")
shutil.move(sitecustomize, old_sitecustomize)
elif not os.path.exists(sitepackages):
os.makedirs(sitepackages)
os.symlink(overrides_hack, sitecustomize)
os.symlink(mesonconfig, mesonconfig_link)
return os.path.realpath(sitecustomize) == overrides_hack
else:
if not os.path.realpath(sitecustomize) == overrides_hack:
return False
os.remove(sitecustomize)
os.remove (mesonconfig_link)
old_sitecustomize = os.path.join(sitepackages,
"old.sitecustomize.gstuninstalled.py")
if os.path.exists(old_sitecustomize):
shutil.move(old_sitecustomize, sitecustomize)
return True
开发者ID:MustafaMunir,项目名称:gst-build,代码行数:53,代码来源:gst-uninstalled.py
示例19: search_cheat
def search_cheat (self):
available = []
import site
site_system = site.getsitepackages()
site_user = site.getusersitepackages()
for name in [site_user] + site_system:
path = os.path.join(name, 'cheat')
if not os.path.exists(path):
continue
path = os.path.join(path, 'cheatsheets')
if not os.path.exists(path):
continue
available.append(path)
return available
开发者ID:skywind3000,项目名称:vim,代码行数:14,代码来源:cheat.py
示例20: get_kaizen_pth_path
def get_kaizen_pth_path(self):
if self._kaizen_pth is None:
import site
k_site = None
for c_site in site.PREFIXES:
if os.access(c_site, os.W_OK):
k_site = c_site
break
if not k_site:
if hasattr(site, "getusersitepackages"):
k_site = site.getusersitepackages()
else:
k_site = site.USER_SITE
self._kaizen_pth = os.path.join(k_site, "kaizen-rules.pth")
return self._kaizen_pth
开发者ID:bjoernricks,项目名称:kaizen,代码行数:15,代码来源:systems.py
注:本文中的site.getusersitepackages函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论