Skip to content

Instantly share code, notes, and snippets.

@michaelxor
Last active January 10, 2017 10:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelxor/8136225 to your computer and use it in GitHub Desktop.
Save michaelxor/8136225 to your computer and use it in GitHub Desktop.
A clean virtualenv with pip and setuptools (formerly distribute). Only requirement is a local python install. Adapted from http://stackoverflow.com/a/5177027
# Name your first "bootstrap" environment:
INITIAL_ENV=pymordial
# Options for your first environment:
ENV_OPTS=''
# Set to whatever python interpreter you want for your first environment:
PYTHON=$(type -P python)
# Latest virtualenv from pypa
URL_BASE=https://github.com/pypa/virtualenv/tarball/master
# Name on local fs
TAR_NAME=virtualenv-tmp.tar.gz
# --- Real work starts here ---
curl -Lo $TAR_NAME $URL_BASE
tar xzf $TAR_NAME
# Discover the name of the untarred directory
UNTARRED_NAME=$(tar tzf $TAR_NAME | sed -e 's,/.*,,' | uniq)
# Create the first "bootstrap" environment & install virtualenv
$PYTHON $UNTARRED_NAME/virtualenv.py $ENV_OPTS $INITIAL_ENV
$INITIAL_ENV/bin/pip install $TAR_NAME
# Don't need these anymore.
rm -rf $UNTARRED_NAME
rm -f $TAR_NAME
# Create a second environment from the first:
#$INITIAL_ENV/bin/virtualenv py-env1
# Create more:
#$INITIAL_ENV/bin/virtualenv py-env2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment