Skip to content

Instantly share code, notes, and snippets.

@tangingw
Created August 16, 2019 07:50
Show Gist options
  • Save tangingw/9d2eb9502d523d8ba0a136331a1dc51b to your computer and use it in GitHub Desktop.
Save tangingw/9d2eb9502d523d8ba0a136331a1dc51b to your computer and use it in GitHub Desktop.
This is a python script that runs pip in the proxy environments
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