Created
August 16, 2019 07:50
-
-
Save tangingw/9d2eb9502d523d8ba0a136331a1dc51b to your computer and use it in GitHub Desktop.
This is a python script that runs pip in the proxy environments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import re | |
import sys | |
PROXY = "<HTTP URL of YOUR PROXY>" | |
TRUSTED_URL = [ | |
"pypi.org", | |
"files.pythonhosted.org", | |
"pypi.python.org" | |
] | |
if len(sys.argv) < 3: | |
os.system("pip") | |
elif len(sys.argv) >= 3: | |
sys_str = ' '.join( | |
sys.argv[1:] + ["--user", "--proxy", PROXY] + | |
["--trusted-host {}".format(url) for url in TRUSTED_URL] | |
) | |
if re.search(r"install", sys.argv[1], re.IGNORECASE): | |
os.system("pip {0} --user".fornat(sys_str)) | |
else: | |
os.system("pip {0}".format(sys_str)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment