Skip to content

Instantly share code, notes, and snippets.

Created December 14, 2012 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/4286446 to your computer and use it in GitHub Desktop.
Save anonymous/4286446 to your computer and use it in GitHub Desktop.
Installing pip with one click on windows
"""
This gist installs distribute if needed and a
"""
import subprocess
import urllib
import os
import tarfile
distribute_url = 'http://pypi.python.org/packages/source/d/distribute/distribute-0.6.32.tar.gz'
get_pip_url = 'https://raw.github.com/pypa/pip/master/contrib/get-pip.py'
def download(url):
print 'downloading %s' % url
fname = os.path.basename(url)
with open(fname, 'wb') as f:
data = urllib.urlopen(url).read()
f.write(data)
return fname
def run(line):
subprocess.check_call(line.split())
def main():
try:
import distribute
except ImportError:
# install distribute
fname = download(distribute_url)
with tarfile.open(fname) as tar:
dirname = tar.getnames()[0]
tar.extractall()
#print tar.list()
run('python %s/setup.py install' % dirname)
pipf = download(get_pip_url)
run('python %s' % pipf)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment