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"
python类get_python_lib()的实例源码
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_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 _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_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_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))