def test_get_python_lib(self):
lib_dir = sysconfig.get_python_lib()
# 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))
_sysconfig = __import__('sysconfig')
res = sysconfig.get_python_lib(True, True)
self.assertEqual(_sysconfig.get_path('platstdlib'), res)
python类get_python_lib()的实例源码
def install(name):
package_path = xlsconfig.DEPENDENCIES.get(name)
if package_path is None:
print "???????????'%s'" % (name, )
return
output_path = xlsconfig.TEMP_PATH
file_name = os.path.splitext(os.path.basename(package_path))[0]
setup_path = os.path.join(output_path, file_name)
if os.path.exists(setup_path):
shutil.rmtree(setup_path, True)
with ZipFile(package_path, "r") as zf:
zf.extractall(output_path)
if not os.path.exists(os.path.join(setup_path, "setup.py")):
print "????????????'%s/setup.py'" % setup_path
return False
old_cwd = os.getcwd()
os.chdir(setup_path)
try:
_install_in_path()
except:
os.chdir(old_cwd)
traceback.print_exc()
return False
os.chdir(old_cwd)
for fname in os.listdir(get_python_lib()):
if fname.startswith(name):
return True
return False
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))
def get_path(name):
if name not in ('platlib', 'purelib'):
raise ValueError("Name must be purelib or platlib")
return get_python_lib(name == 'platlib')
def _get_purelib():
return get_python_lib(False)
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))
def get_path(name):
if name not in ('platlib', 'purelib'):
raise ValueError("Name must be purelib or platlib")
return get_python_lib(name == 'platlib')
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))
def get_path(name):
if name not in ('platlib', 'purelib'):
raise ValueError("Name must be purelib or platlib")
return get_python_lib(name == 'platlib')
def _get_purelib():
return get_python_lib(False)
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))
def get_path(name):
if name not in ('platlib', 'purelib'):
raise ValueError("Name must be purelib or platlib")
return get_python_lib(name == 'platlib')
def _get_purelib():
return get_python_lib(False)
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))
def get_path(name):
if name not in ('platlib', 'purelib'):
raise ValueError("Name must be purelib or platlib")
return get_python_lib(name == 'platlib')
def _get_purelib():
return get_python_lib(False)
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))
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))
def get_path(name):
if name not in ('platlib', 'purelib'):
raise ValueError("Name must be purelib or platlib")
return get_python_lib(name == 'platlib')
def _get_purelib():
return get_python_lib(False)