本文整理汇总了Python中site.getsitepackages函数的典型用法代码示例。如果您正苦于以下问题:Python getsitepackages函数的具体用法?Python getsitepackages怎么用?Python getsitepackages使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getsitepackages函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main():
mode = sys.argv[1]
print mode
rootdir = "/Users/kgeorge/Dropbox/cars/tentative"
if mode == "b":
rootdir = "/Users/kgeorge/Dropbox/cars/bad"
elif mode == "c":
rootdir = "/Users/kgeorge/Dropbox/cars/crossvalidate"
builddir = os.path.join(rootdir, "build")
print site.getsitepackages()
for root, dirs, files in os.walk(rootdir):
(h, t) = os.path.split(root)
if t.endswith("_delme"):
continue
for f in files:
(p, e) = os.path.splitext(f)
if ((e.lower() == ".png") or (e.lower() == ".jpg") or (e.lower() == ".jpeg")) and not p.endswith(
"canonical"
):
try:
processImage2(builddir, root, f)
except AttributeError, e:
print e
pass
开发者ID:kgeorge,项目名称:kgeorge-cv,代码行数:26,代码来源:preprocessImages.py
示例2: test_getsitepackages
def test_getsitepackages(self):
site.PREFIXES = ['xoxo']
dirs = site.getsitepackages()
if sys.platform in ('os2emx', 'riscos'):
self.assertEqual(len(dirs), 1)
wanted = os.path.join('xoxo', 'Lib', 'site-packages')
self.assertEqual(dirs[0], wanted)
elif os.sep == '/':
self.assertEqual(len(dirs), 2)
wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3],
'site-packages')
self.assertEqual(dirs[0], wanted)
wanted = os.path.join('xoxo', 'lib', 'site-python')
self.assertEqual(dirs[1], wanted)
else:
self.assertEqual(len(dirs), 2)
self.assertEqual(dirs[0], 'xoxo')
wanted = os.path.join('xoxo', 'lib', 'site-packages')
self.assertEqual(dirs[1], wanted)
# let's try the specific Apple location
if (sys.platform == "darwin" and
sysconfig.get_config_var("PYTHONFRAMEWORK")):
site.PREFIXES = ['Python.framework']
dirs = site.getsitepackages()
self.assertEqual(len(dirs), 3)
wanted = os.path.join('/Library', 'Python', sys.version[:3],
'site-packages')
self.assertEqual(dirs[2], wanted)
开发者ID:pogigroo,项目名称:py3k-__format__,代码行数:30,代码来源:test_site.py
示例3: build
def build(buildargs=['-y', '-windowed', '--onedir', '--clean', '--icon="icons/desuratools.ico"', '--noupx',
'--version-file=versioninfo.txt'], package=True):
pyinstaller = os.path.join(site.getsitepackages()[0], "Scripts", "pyinstaller-script.py")
dependencies = ['PySide', 'PIL', 'win32api', 'win32gui', 'win32ui', 'win32con', 'requests']
imageformats = os.path.join(site.getsitepackages()[1], "PySide", "plugins", "imageformats")
buildargs.insert(0, 'desuratools.py')
buildargs.insert(0, pyinstaller)
buildargs.insert(0, "python")
dist_folder = os.path.join(os.getcwd(), "dist")
output_folder = os.path.join(os.getcwd(), "dist", "desuratools")
if not os.path.exists(pyinstaller):
raise IOError("PyInstaller is required to build for windows")
print "PyInstaller check passed"
for module in dependencies:
try:
imp.find_module(module)
except ImportError:
raise ImportError("Dependency {0} is required".format(module))
print "Dependency check passed"
print "Building DesuraTools"
subprocess.call(' '.join(buildargs))
print "Copying imageformat plugins"
imageformats_dist = os.path.join(output_folder, "imageformats")
distutils.dir_util.copy_tree(imageformats, imageformats_dist, verbose=1)
print "Copying icon"
images_dist = os.path.join(output_folder, "desuratools_256.png")
shutil.copyfile("desuratools_256.png", images_dist)
if package:
package_app(dist_folder, output_folder)
开发者ID:RonnChyran,项目名称:DesuraTools-py,代码行数:33,代码来源:build_win.py
示例4: find_DST
def find_DST():
"""Find where this package should be installed to.
"""
if SYS_NAME == "Windows":
return os.path.join(site.getsitepackages()[1], PKG_NAME)
elif SYS_NAME in ["Darwin", "Linux"]:
return os.path.join(site.getsitepackages()[0], PKG_NAME)
开发者ID:MacHu-GWU,项目名称:numpymate-project,代码行数:7,代码来源:zzz_manual_install.py
示例5: test_s_option
def test_s_option(self):
usersite = site.USER_SITE
self.assertIn(usersite, sys.path)
env = os.environ.copy()
rc = subprocess.call([sys.executable, '-c',
'import sys; sys.exit(%r in sys.path)' % usersite],
env=env)
self.assertEqual(rc, 1)
env = os.environ.copy()
rc = subprocess.call([sys.executable, '-s', '-c',
'import sys; sys.exit(%r in sys.path)' % usersite],
env=env)
if usersite == site.getsitepackages()[0]:
self.assertEqual(rc, 1)
else:
self.assertEqual(rc, 0)
env = os.environ.copy()
env["PYTHONNOUSERSITE"] = "1"
rc = subprocess.call([sys.executable, '-c',
'import sys; sys.exit(%r in sys.path)' % usersite],
env=env)
if usersite == site.getsitepackages()[0]:
self.assertEqual(rc, 1)
else:
self.assertEqual(rc, 0)
env = os.environ.copy()
env["PYTHONUSERBASE"] = "/tmp"
rc = subprocess.call([sys.executable, '-c',
'import sys, site; sys.exit(site.USER_BASE.startswith("/tmp"))'],
env=env)
self.assertEqual(rc, 1)
开发者ID:Daetalus,项目名称:cpython,代码行数:35,代码来源:test_site.py
示例6: test_getsitepackages
def test_getsitepackages(self):
site.PREFIXES = ['xoxo']
dirs = site.getsitepackages()
if (sys.platform == "darwin" and
sysconfig.get_config_var("PYTHONFRAMEWORK")):
# OS X framework builds
site.PREFIXES = ['Python.framework']
dirs = site.getsitepackages()
self.assertEqual(len(dirs), 2)
wanted = os.path.join('/Library',
sysconfig.get_config_var("PYTHONFRAMEWORK"),
'%d.%d' % sys.version_info[:2],
'site-packages')
self.assertEqual(dirs[1], wanted)
elif os.sep == '/':
# OS X non-framwework builds, Linux, FreeBSD, etc
self.assertEqual(len(dirs), 1)
wanted = os.path.join('xoxo', 'lib',
'python%d.%d' % sys.version_info[:2],
'site-packages')
self.assertEqual(dirs[0], wanted)
else:
# other platforms
self.assertEqual(len(dirs), 2)
self.assertEqual(dirs[0], 'xoxo')
wanted = os.path.join('xoxo', 'lib', 'site-packages')
self.assertEqual(dirs[1], wanted)
开发者ID:Daetalus,项目名称:cpython,代码行数:28,代码来源:test_site.py
示例7: test_getsitepackages
def test_getsitepackages(self):
site.PREFIXES = ["xoxo"]
dirs = site.getsitepackages()
if sys.platform in ("os2emx", "riscos"):
self.assertEqual(len(dirs), 1)
wanted = os.path.join("xoxo", "Lib", "site-packages")
self.assertEquals(dirs[0], wanted)
elif os.sep == "/":
self.assertEqual(len(dirs), 2)
wanted = os.path.join("xoxo", "lib", "python" + sys.version[:3], "site-packages")
self.assertEquals(dirs[0], wanted)
wanted = os.path.join("xoxo", "lib", "site-python")
self.assertEquals(dirs[1], wanted)
else:
self.assertEqual(len(dirs), 2)
self.assertEquals(dirs[0], "xoxo")
wanted = os.path.join("xoxo", "lib", "site-packages")
self.assertEquals(dirs[1], wanted)
# let's try the specific Apple location
if sys.platform == "darwin" and sysconfig.get_config_var("PYTHONFRAMEWORK"):
site.PREFIXES = ["Python.framework"]
dirs = site.getsitepackages()
self.assertEqual(len(dirs), 3)
wanted = os.path.join("/Library", "Python", sys.version[:3], "site-packages")
self.assertEquals(dirs[2], wanted)
开发者ID:vladistan,项目名称:py3k-__format__-sprint,代码行数:27,代码来源:test_site.py
示例8: plotgraph
def plotgraph(plotvar, divid, omc, resultfile):
if (resultfile is not None):
checkdygraph = os.path.join(os.getcwd(), 'dygraph-combined.js')
if not os.path.exists(checkdygraph):
if (sys.platform == 'win32'):
try:
sitepath = site.getsitepackages()[1]
dygraphfile = os.path.join(sitepath, 'openmodelica_kernel', 'dygraph-combined.js').replace('\\', '/')
shutil.copy2(dygraphfile, os.getcwd())
# print 'copied file'
except Exception as e:
print(e)
else:
try:
sitepath = site.getsitepackages()[0]
dygraphfile = os.path.join(sitepath, 'openmodelica_kernel', 'dygraph-combined.js').replace('\\', '/')
shutil.copy2(dygraphfile, os.getcwd())
# print 'copied file'
except Exception as e:
print(e)
try:
divheader = " ".join(['<div id=' + str(divid) + '>', '</div>'])
readResult = omc.sendExpression("readSimulationResult(\"" + resultfile + "\",{time," + plotvar + "})")
omc.sendExpression("closeSimulationResultFile()")
plotlabels = ['Time']
exp = '(\s?,\s?)(?=[^\[]*\])|(\s?,\s?)(?=[^\(]*\))'
# print 'inside_plot1'
subexp = re.sub(exp, '$#', plotvar)
plotvalsplit = subexp.split(',')
# print plotvalsplit
for z in range(len(plotvalsplit)):
val = plotvalsplit[z].replace('$#', ',')
plotlabels.append(val)
plotlabel1 = [str(x) for x in plotlabels]
plots = []
for i in range(len(readResult)):
x = readResult[i]
d = []
for z in range(len(x)):
tu = x[z]
d.append((tu,))
plots.append(d)
n = numpy.array(plots)
numpy.set_printoptions(threshold=numpy.inf)
dygraph_array = repr(numpy.hstack(n)).replace('array', ' ').replace('(', ' ').replace(')', ' ')
dygraphoptions = " ".join(['{', 'legend:"always",', 'labels:', str(plotlabel1), '}'])
data = "".join(['<script type="text/javascript"> g = new Dygraph(document.getElementById(' + '"' + str(divid) + '"' + '),', str(dygraph_array), ',', dygraphoptions, ')', '</script>'])
htmlhead = '''<html> <head> <script src="dygraph-combined.js"> </script> </head>'''
divcontent = "\n".join([htmlhead, divheader, str(data),'</html>'])
except BaseException:
error = omc.sendExpression("getErrorString()")
divcontent = "".join(['<p>', error, '</p>'])
else:
divcontent = "".join(['<p>', 'No result File Generated', '</p>'])
return divcontent
开发者ID:OpenModelica,项目名称:jupyter-openmodelica,代码行数:59,代码来源:kernel.py
示例9: create_singlejar
def create_singlejar(output_path, classpath, runpy):
jars = classpath
jars.extend(find_jython_jars())
site_path = site.getsitepackages()[0]
with JarPth() as jar_pth:
for jar_path in sorted(jar_pth.itervalues()):
jars.append(os.path.join(site_path, jar_path))
with JarCopy(output_path=output_path, runpy=runpy) as singlejar:
singlejar.copy_jars(jars)
log.debug("Copying standard library")
for relpath, realpath in find_jython_lib_files():
singlejar.copy_file(relpath, realpath)
# FOR NOW: copy everything in site-packages into Lib/ in the built jar;
# this is because Jython in standalone mode has the limitation that it can
# only properly find packages under Lib/ and cannot process .pth files
# THIS SHOULD BE FIXED
sitepackage = site.getsitepackages()[0]
# copy top level packages
for item in os.listdir(sitepackage):
path = os.path.join(sitepackage, item)
if path.endswith(".egg") or path.endswith(".egg-info") or path.endswith(".pth") or path == "jars":
continue
log.debug("Copying package %s", path)
for pkg_relpath, pkg_realpath in find_package_libs(path):
log.debug("Copy package file %s %s", pkg_relpath, pkg_realpath)
singlejar.copy_file(os.path.join("Lib", item, pkg_relpath), pkg_realpath)
# copy eggs
for path in read_pth(os.path.join(sitepackage, "easy-install.pth")).itervalues():
relpath = "/".join(os.path.normpath(os.path.join("Lib", path)).split(os.sep)) # ZIP only uses /
path = os.path.realpath(os.path.normpath(os.path.join(sitepackage, path)))
if copy_zip_file(path, singlejar):
log.debug("Copying %s (zipped file)", path) # tiny lie - already copied, but keeping consistent!
continue
log.debug("Copying egg %s", path)
for pkg_relpath, pkg_realpath in find_package_libs(path):
# Filter out egg metadata
parts = pkg_relpath.split(os.sep)
head = parts[0]
if head == "EGG-INFO" or head.endswith(".egg-info"):
continue
singlejar.copy_file(os.path.join("Lib", pkg_relpath), pkg_realpath)
if runpy and os.path.exists(runpy):
singlejar.copy_file("__run__.py", runpy)
开发者ID:Techcable,项目名称:clamp,代码行数:51,代码来源:build.py
示例10: echo_server
def echo_server(address, authkey):
print "loading server"
print sys.executable
print site.getsitepackages()
serv = Listener(address, authkey=authkey)
print "started listener"
while True:
try:
client = serv.accept()
print "got something"
if echo_client(client) == False:
break
except Exception:
traceback.print_exc()
开发者ID:testiddd,项目名称:ShaniXBMCWork,代码行数:14,代码来源:pyCryptoAndroid.py
示例11: resDataSave
def resDataSave(bo_url , cmdstr ,workspace_name, passQ = False , dumptype='CSV', dump_filename='dump.csv'):
if passQ == False:
confirmStr= "=============\nSize of data exceeded display limit, dump to csv format? (yes/no)"
import fileinput
print confirmStr
while True:
choice=raw_input()
if choice=="yes" or choice=="y":
break
elif choice=="no" or choice=="n":
return False
else:
print confirmStr
#bo_host = bo_url.split(":")[1][2:]
#bo_port = bo_url.split(":")[2][:-4]
import subprocess
import os
import signal
from distutils.sysconfig import get_python_lib
boshcwd =os.getcwd()
#lib_path = get_python_lib()
import site
lib_path = site.getsitepackages()[0]
# print("lib_path " +lib_path)
if str(workspace_name) == "":
workspace_name = '\"\"'
rest = subprocess.Popen(["python", lib_path + "/dumpRes/borestful.py" , bo_url , cmdstr , str(workspace_name)], stdout=subprocess.PIPE)
tocsv = subprocess.Popen(["python", lib_path + "/dumpRes/bojson2file.py", dumptype, boshcwd + "/" + dump_filename] , stdin=rest.stdout)
print("dumping the data to " + dump_filename + " , type: " + dumptype + " ...")
rest.wait()
tocsv.wait()
return True
开发者ID:bigobject-inc,项目名称:bosh,代码行数:33,代码来源:rpcshell.py
示例12: installMissingPackage
def installMissingPackage(packageList):
a = site.getsitepackages()
a = a[0]
a = a.split('/')
for el in a:
if 'python' in el:
b = el.replace('python', '')
b = int(float(b))
os.system('sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose')
if b == 2:
try:
os.system('sudo easy_install numpy scipy Sphinx numpydoc nose pykalman')
os.system('sudo pip install cma')
os.system('sudo easy_install cython')
os.system('sudo pip install distlib')
except:
pass
elif b == 3:
try:
os
os.system('sudo easy_install3 numpy scipy Sphinx numpydoc nose pykalman')
os.system('sudo pip3 install cma')
os.system('sudo easy_install3 cython')
os.system('sudo pip3 install distlib')
except:
pass
os.system('clear')
开发者ID:kosenhitatchi,项目名称:ArmModelPython-cython,代码行数:27,代码来源:install.py
示例13: __init__
def __init__(self, fileName=None):
self.lexicon = {}
packageFileName = str(distutils.sysconfig.get_python_lib())+"/"+PACKAGE+"/"+LOCAL+"/brill-lexicon.dat"
localFileName = PACKAGE+"/"+LOCAL+"/brill-lexicon.dat"
# allows looking for the package in, eg, /usr/local/lib
siteFileNames = []
for dir in site.getsitepackages():
siteFileName = dir+"/"+PACKAGE+"/"+LOCAL+"/brill-lexicon.dat"
if (os.path.isfile(siteFileName)):
fileName = siteFileName
break
if fileName != None:
pass
elif os.path.isfile(packageFileName):
fileName = packageFileName
elif os.path.isfile(localFileName):
fileName = localFileName
else:
sys.stderr.write("ERROR: Could not find default Brill lexicon.")
lexiconFile = open(fileName, "r")
for line in lexiconFile.readlines():
if not line.startswith("#"):
col = line.split()
self.lexicon[col[0]] = col[1:]
开发者ID:mtancret,项目名称:pySentencizer,代码行数:28,代码来源:pysentencizer.py
示例14: fetch_Landsat8_scene_list
def fetch_Landsat8_scene_list():
"""
Simple downloads and extracts the most recent version of the scene_list
text file for reference
http://landsat-pds.s3.amazonaws.com/scene_list.gz
:return scene_list_text_data: returns a text data object with all
the data on scene inventory on amazon WS.
"""
print("Updating scene list")
# define save path for new scene list
directory = site.getsitepackages()[1]
gz_path = "{0}/dnppy/landsat/metadata/scene_list.gz".format(directory)
txt_path = "{0}/dnppy/landsat/metadata/scene_list.txt".format(directory)
# download then extract the gz file to a txt file.
download_url("http://landsat-pds.s3.amazonaws.com/scene_list.gz", gz_path)
with gzip.open(gz_path,'rb') as gz:
content = gz.read()
with open(txt_path, 'wb+') as f:
f.writelines(content)
# build a new text data object from the fresh scene list
scene_list_text_data = textio.text_data()
scene_list_text_data.read_csv(txt_path, delim = ",", has_headers = True)
return scene_list_text_data
开发者ID:henrykironde,项目名称:dnppy,代码行数:29,代码来源:fetch_Landsat8.py
示例15: _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
示例16: uninstall
def uninstall():
"""Uninstall psutil"""
# Uninstalling psutil on Windows seems to be tricky.
# On "import psutil" tests may import a psutil version living in
# C:\PythonXY\Lib\site-packages which is not what we want, so
# we try both "pip uninstall psutil" and manually remove stuff
# from site-packages.
clean()
install_pip()
here = os.getcwd()
try:
os.chdir('C:\\')
while True:
try:
import psutil # NOQA
except ImportError:
break
else:
sh("%s -m pip uninstall -y psutil" % PYTHON)
finally:
os.chdir(here)
for dir in site.getsitepackages():
for name in os.listdir(dir):
if name.startswith('psutil'):
rm(os.path.join(dir, name))
开发者ID:marcinkuzminski,项目名称:psutil,代码行数:26,代码来源:winmake.py
示例17: __init__
def __init__(self, **kwargs):
plugin_path = ""
if sys.platform == "win32":
if hasattr(sys, "frozen"):
plugin_path = os.path.join(os.path.dirname(os.path.abspath(sys.executable)), "PyQt5", "plugins")
Logger.log("i", "Adding QT5 plugin path: %s" % (plugin_path))
QCoreApplication.addLibraryPath(plugin_path)
else:
import site
for dir in site.getsitepackages():
QCoreApplication.addLibraryPath(os.path.join(dir, "PyQt5", "plugins"))
elif sys.platform == "darwin":
plugin_path = os.path.join(Application.getInstallPrefix(), "Resources", "plugins")
if plugin_path:
Logger.log("i", "Adding QT5 plugin path: %s" % (plugin_path))
QCoreApplication.addLibraryPath(plugin_path)
os.environ["QSG_RENDER_LOOP"] = "basic"
super().__init__(sys.argv, **kwargs)
self._plugins_loaded = False #Used to determine when it's safe to use the plug-ins.
self._main_qml = "main.qml"
self._engine = None
self._renderer = None
self._main_window = None
self._shutting_down = False
self._qml_import_paths = []
self._qml_import_paths.append(os.path.join(os.path.dirname(sys.executable), "qml"))
self._qml_import_paths.append(os.path.join(Application.getInstallPrefix(), "Resources", "qml"))
self.setAttribute(Qt.AA_UseDesktopOpenGL)
try:
self._splash = self._createSplashScreen()
except FileNotFoundError:
self._splash = None
else:
self._splash.show()
self.processEvents()
signal.signal(signal.SIGINT, signal.SIG_DFL)
# This is done here as a lot of plugins require a correct gl context. If you want to change the framework,
# these checks need to be done in your <framework>Application.py class __init__().
i18n_catalog = i18nCatalog("uranium")
self.showSplashMessage(i18n_catalog.i18nc("@info:progress", "Loading plugins..."))
self._loadPlugins()
self.parseCommandLine()
Logger.log("i", "Command line arguments: %s", self._parsed_command_line)
self._plugin_registry.checkRequiredPlugins(self.getRequiredPlugins())
self.showSplashMessage(i18n_catalog.i18nc("@info:progress", "Loading preferences..."))
try:
file = Resources.getPath(Resources.Preferences, self.getApplicationName() + ".cfg")
Preferences.getInstance().readFromFile(file)
except FileNotFoundError:
pass
开发者ID:TimurAykutYildirim,项目名称:Uranium,代码行数:60,代码来源:QtApplication.py
示例18: __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
示例19: run
def run(self):
if not self.distribution.clamp:
raise DistutilsOptionError("Specify the modules to be built into a jar with the 'clamp' setup keyword")
jar_dir = os.path.join(site.getsitepackages()[0], "jars")
if not os.path.exists(jar_dir):
os.mkdir(jar_dir)
if self.output_jar_pth:
jar_pth_path = os.path.join(site.getsitepackages()[0], "jar.pth")
paths = read_pth(jar_pth_path)
print "paths in jar.pth", paths
paths[self.distribution.metadata.get_name()] = os.path.join("./jars", self.get_jar_name())
write_jar_pth(jar_pth_path, paths)
with closing(JarBuilder(output_path=self.output)) as builder:
clamp.register_builder(builder)
for module in self.distribution.clamp:
__import__(module)
开发者ID:philk,项目名称:clamp,代码行数:16,代码来源:build.py
示例20: 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
注:本文中的site.getsitepackages函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论