本文整理匯總了Python中pip.py方法的典型用法代碼示例。如果您正苦於以下問題:Python pip.py方法的具體用法?Python pip.py怎麽用?Python pip.py使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pip
的用法示例。
在下文中一共展示了pip.py方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setup
# 需要導入模塊: import pip [as 別名]
# 或者: from pip import py [as 別名]
def setup(self, data):
if not data:
# It's safe to use ensurepip.
print("Installing pip...")
try:
import ensurepip
ensurepip.bootstrap()
except PermissionError:
# panic and try and sudo it
sudo_check_call("python3.5 -m ensurepip")
return
# Instead, we have to run get-pip.py.
print("Installing pip...")
try:
sudo_check_call(["python3.5", "{}".format(data)])
except FileNotFoundError:
subprocess.check_call(["python3.5", "{}".format(data)])
示例2: apply_vagrant_workaround
# 需要導入模塊: import pip [as 別名]
# 或者: from pip import py [as 別名]
def apply_vagrant_workaround():
"""
Function which detects if the script is being executed inside vagrant and if it is, it deletes
"os.link" attribute.
Note: Without this workaround, setup.py sdist will fail when running inside a shared directory
(nfs / virtualbox shared folders).
"""
if os.environ.get('USER', None) == 'vagrant':
del os.link
示例3: pip_main
# 需要導入模塊: import pip [as 別名]
# 或者: from pip import py [as 別名]
def pip_main(argv):
# Extract the certificates from the PAR following the example of get-pip.py
# https://github.com/pypa/get-pip/blob/430ba37776ae2ad89/template.py#L164-L168
cert_tmpdir = tempfile.mkdtemp()
cert_path = os.path.join(cert_tmpdir, "cacert.pem")
atexit.register(lambda: shutil.rmtree(cert_tmpdir, ignore_errors=True))
with open(cert_path, "wb") as cert:
cert.write(pkgutil.get_data("pip._vendor.requests", "cacert.pem"))
argv = ["--isolated", "--disable-pip-version-check", "--cert", cert_path] + argv
return pip.main(argv)
示例4: download
# 需要導入模塊: import pip [as 別名]
# 或者: from pip import py [as 別名]
def download(self):
# Try and use ensurepip.
try:
import ensurepip
return False
except ImportError:
# Download `get-pip.py`.
# We hope we have urllib.request, otherwise we're sort of fucked.
f = tempfile.NamedTemporaryFile(delete=False)
f.close() # we only want the name
print("Downloading pip...")
urlretrieve(GET_PIP, f.name)
return f.name