我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用distutils.sysconfig.get_python_lib()。
def __init__(self, qt_toolkit='pyside'): """ :param qt_toolkit: Toolkit used to generate files: ``'pyside'`` or ``'pyqt'`` """ if qt_toolkit.lower() == 'pyside': if sys.platform.startswith('win'): PYPATH = os.path.dirname(sys.executable) PYSIDEPATH = os.path.join(get_python_lib(), 'PySide') self.PYUIC = os.path.join(PYPATH, "Scripts/pyside-uic") self.PYRCC = os.path.join(PYSIDEPATH, "pyside-rcc") else: self.PYUIC = "pyside-uic" self.PYRCC = "pyside-rcc" else: # pyqt if sys.platform.startswith('win'): PYQTPATH = os.path.join(get_python_lib(), 'PyQt4') self.PYUIC = os.path.join(PYQTPATH, "pyuic4") self.PYRCC = os.path.join(PYQTPATH, "pyrcc4.exe") else: self.PYUIC = "pyuic4" self.PYRCC = "pyrcc4"
def add_gstreamer_packages(): import os import sys from distutils.sysconfig import get_python_lib dest_dir = get_python_lib() packages = ['gobject', 'glib', 'pygst', 'pygst.pyc', 'pygst.pth', 'gst-0.10', 'pygtk.pth', 'pygtk.py', 'pygtk.pyc'] python_version = sys.version[:3] global_path = os.path.join('/usr/lib', 'python' + python_version) global_sitepackages = [os.path.join(global_path, 'dist-packages'), # for Debian-based os.path.join(global_path, 'site-packages')] # for others for package in packages: for pack_dir in global_sitepackages: src = os.path.join(pack_dir, package) dest = os.path.join(dest_dir, package) if not os.path.exists(dest) and os.path.exists(src): os.symlink(src, dest)
def __init__(self): """ Class constructor. """ python_lib=get_python_lib() cham_dir = "%s/.pg_ninja" % os.path.expanduser('~') local_config = "%s/config/" % cham_dir local_logs = "%s/logs/" % cham_dir local_pid = "%s/pid/" % cham_dir self.global_config_example = '%s/pg_ninja/config/config-example.yaml' % python_lib self.local_config_example = '%s/config-example.yaml' % local_config self.global_obfuscation_example = '%s/pg_ninja/config/obfuscation-example.yaml' % python_lib self.local_obfuscation_example = '%s/obfuscation-example.yaml' % local_config self.conf_dirs=[ cham_dir, local_config, local_logs, local_pid, ]
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_path(name): if name not in ('platlib', 'purelib'): raise ValueError("Name must be purelib or platlib") return get_python_lib(name=='platlib')
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)
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