0

I am looking at a package (which can be installed using pip) code which requires a file from internet.

Pip provides an option to mention proxy details as shown below

pip install --proxy="http://user:pass@proxyserver:port" package_name

But the same proxy details are not identified by the setup.py script of the package. When I modified the setup.py file using the following lines, it works fine.

proxy_url = 'http://user:pass@proxy:port/'
proxy_url_https = 'http://user:pass@proxy:port/'
proxy_handler = urllib2.ProxyHandler({'http': proxy_url, 'https': proxy_url_https})
opener = urllib2.build_opener(proxy_handler, urllib2.HTTPHandler)
urllib2.install_opener(opener)

But how can the setup.py file be modified to check if the proxy is provided and take the necessary steps?

Naks
  • 361
  • 3
  • 10
  • 1
    Set up environment variable `http_proxy` / `https_proxy`. More details: http://stackoverflow.com/questions/17247981/how-to-tell-python-to-automatically-use-the-proxy-setting-in-windows-xp-like-rs – Rikka Feb 18 '16 at 04:58
  • but, what if the user who is installing using pip doesn't set environment variable and provide proxy settings to pip. – Naks Feb 18 '16 at 05:05

0 Answers0