Skip to content

Instantly share code, notes, and snippets.

@nomelif
Last active November 30, 2016 16:34
Show Gist options
  • Save nomelif/c92e4011bd84bd33a210939d380f87f6 to your computer and use it in GitHub Desktop.
Save nomelif/c92e4011bd84bd33a210939d380f87f6 to your computer and use it in GitHub Desktop.
# Setup parameters to work in userspace
import sys
import os
import tempfile
import urllib.request
get_pip = urllib.request.urlopen("https://bootstrap.pypa.io/get-pip.py").read()
sys.argv.append("--user")
# Install pip
try:
exec(get_pip)
except SystemExit:
pass
# Install pygame
try:
import pip
# Create a directory to the temporary directory for pip to download its stuff. We don't know the final file name but we will check it later
os.mkdir(tempfile.gettempdir()+"/piptemp")
pip.main(['download', '--dest='+tempfile.gettempdir()+"/piptemp", '--trusted-host=pypi.python.org', '--index-url=http://pypi.python.org/simple/', 'pygame'])
# Dig up the name of the file
wheelfile = tempfile.gettempdir()+"/piptemp/" + os.listdir(tempfile.gettempdir()+"/piptemp")[0]
pip.main(['install', 'wheel', wheelfile, '--user'])
except SystemExit:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment