Created
December 14, 2012 15:57
-
-
Save anonymous/4286446 to your computer and use it in GitHub Desktop.
Installing pip with one click on windows
This file contains hidden or 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
""" | |
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