Compare commits

...

65 Commits
v9 ... v11

Author SHA1 Message Date
Kenneth Reitz 46ba98a4ee no LEGACY_VIRTUALENV default 2012-12-06 12:48:37 -05:00
Kenneth Reitz 958de9441a not for legacy apps yet 2012-12-06 12:43:07 -05:00
Kenneth Reitz 74312f5487 injection warning 2012-12-03 16:17:01 +01:00
Kenneth Reitz ecf5278679 extract utils 2012-12-03 16:00:23 +01:00
Kenneth Reitz 863abfb00e cleanups 2012-12-03 15:01:05 +01:00
Kenneth Reitz f782693537 patched pip version 2012-12-03 12:39:16 +01:00
Kenneth Reitz a2c2411109 test 2012-12-03 12:29:21 +01:00
Kenneth Reitz 712f02e359 v1.8.4 2012-12-03 12:29:13 +01:00
Kenneth Reitz 61477e515a Merge remote-tracking branch 'origin/master' 2012-12-03 12:27:26 +01:00
Kenneth Reitz be9343534a virtualenv 1.8.4 2012-12-03 12:26:27 +01:00
Kenneth Reitz 2b4e9be4ad Merge pull request #61 from gulopine/already-satisfied
Clean up output of virtualenv setup
2012-12-03 03:23:54 -08:00
Kenneth Reitz 382dff7e3b update scripts 2012-11-18 02:27:31 +01:00
Kenneth Reitz 6f2012c1c9 updated vendored pip 2012-11-18 02:27:25 +01:00
Kenneth Reitz c71fe81f8d new virtualenv 2012-11-18 02:26:41 +01:00
Kenneth Reitz 91586d6690 Merge pull request #62 from gulopine/ellipses
Collapse ellipses when setting up virtualenv
2012-11-15 07:07:42 -08:00
Marty Alchin 046726b864 Collapse ellipses when setting up virtualenv 2012-11-14 20:37:44 -08:00
Marty Alchin ddf353cff5 Clean up output of virtualenv setup 2012-11-14 20:35:37 -08:00
Kenneth Reitz 160497cb64 Merge pull request #55 from dcrosta/patch-1
Set `$VIRTUALENV_DIRS` for `$CLEAN_VIRTUALENV`
2012-09-23 03:56:33 -07:00
Dan Crosta 6194f94aa7 Set $VIRTUALENV_DIRS for $CLEAN_VIRTUALENV
I had to do this to wipe out my virtualenv -- there may be a more appropriate solution.
2012-09-22 17:30:58 -03:00
Kenneth Reitz e288332f0e .profile.d
🍰 /cc @ddollar
2012-07-16 18:24:42 -04:00
Kenneth Reitz e4979f33e3 profile.d
:(
2012-07-16 18:03:13 -04:00
Kenneth Reitz 03c3aebca8 fix set-default-env escaping 2012-07-16 17:35:01 -04:00
Kenneth Reitz 487a5ffb95 don't clobber envsssssssss 2012-07-16 17:11:17 -04:00
Kenneth Reitz 01d15d4d0e fix links 2012-07-02 00:07:30 -04:00
Kenneth Reitz 6655794b4d distribute 2012-07-01 23:57:42 -04:00
Kenneth Reitz 4beb57a5a0 ch ch changes 2012-07-01 23:33:33 -04:00
Kenneth Reitz bac517e755 patched pip v1.1 2012-07-01 23:31:07 -04:00
Kenneth Reitz 62b68cfcd9 pip v1.1 2012-07-01 23:28:10 -04:00
Kenneth Reitz 481e800a7c virtualenv v1.7.2 2012-07-01 23:21:27 -04:00
Kenneth Reitz 9a7c6c339d changelog 2012-07-01 17:02:19 -04:00
Kenneth Reitz 23340bcfee default path confict 2012-07-01 16:57:34 -04:00
Kenneth Reitz 102979e985 changelog 2012-06-27 14:27:08 -07:00
Kenneth Reitz ab9a4fbe5f typo 2012-06-27 14:16:31 -07:00
Kenneth Reitz aad72f8e81 legacy 2012-06-27 14:13:35 -07:00
Kenneth Reitz 72295bf186 Disable injection for fresh apps 2012-06-27 14:11:53 -07:00
Kenneth Reitz c45a2c14b2 FRESH_APP 2012-06-27 13:35:42 -07:00
Kenneth Reitz ee177b28ff spaces 2012-06-27 12:11:01 -07:00
Kenneth Reitz 2e0f2f59a0 fresh app 2012-06-27 12:08:22 -07:00
Kenneth Reitz 9856efa7c4 remove deprecation warning 2012-06-27 11:42:38 -07:00
Kenneth Reitz 34878b9638 explicit profile path 2012-06-25 13:30:13 -04:00
Kenneth Reitz 27abdfe7d7 Revert "no more release config vars"
This reverts commit 1bd317cd50.
2012-06-25 13:24:42 -04:00
Kenneth Reitz 3b0bdba799 $HOME & $PATH 2012-06-25 13:23:46 -04:00
Kenneth Reitz b547d8c30c cleanup 2012-06-25 13:16:57 -04:00
Kenneth Reitz 1bd317cd50 no more release config vars 2012-06-25 13:14:43 -04:00
Kenneth Reitz 60b57fd368 profile env vars 2012-06-25 13:13:54 -04:00
Kenneth Reitz 27a22e8ccb .profile.d/python 2012-06-25 13:11:17 -04:00
Kenneth Reitz 0378bbb491 profile.d 2012-06-14 16:40:37 -04:00
Kenneth Reitz bccec5cee9 Merge pull request #47 from ojno/master
Option to purge and recreate virtualenv
2012-06-01 13:20:14 -07:00
Jonathan French d6fbb29977 add CLEAN_VIRTUALENV option to purge and recreate virtualenv 2012-06-01 20:59:34 +01:00
Kenneth Reitz 9d0bf98a52 v13 2012-05-31 20:30:38 -04:00
Kenneth Reitz 795272d625 only talk about static files when configured 2012-05-31 20:29:14 -04:00
Kenneth Reitz c3866f80b6 fix pip quoting 2012-05-31 20:24:35 -04:00
Kenneth Reitz 580a662f36 v12 2012-05-31 15:45:51 -04:00
Kenneth Reitz 5767e0df04 more careful database setting 2012-05-31 15:40:31 -04:00
Kenneth Reitz eeb63f215a v11 2012-05-31 02:45:43 -04:00
Kenneth Reitz 5a6e4e49b4 cleanup collectstatic output 2012-05-31 02:44:56 -04:00
Kenneth Reitz b6eada4e67 exclude overly verbose 'copying' lines 2012-05-31 02:35:33 -04:00
Kenneth Reitz bbe0acf001 whitespace 2012-05-31 02:02:11 -04:00
Kenneth Reitz 05e65801fa always show django deprecation warning 2012-05-31 01:59:37 -04:00
Kenneth Reitz 08338a4a26 Do everything except modify the filesystem. 2012-05-31 01:59:07 -04:00
Kenneth Reitz bf913e0016 collectstatic not a warning 2012-05-31 01:52:38 -04:00
Kenneth Reitz 774ceb3367 v10 2012-05-31 01:51:21 -04:00
Kenneth Reitz 335a14c714 better comments 2012-05-31 01:50:20 -04:00
Kenneth Reitz 4dea56d4a0 better collectstatic pre-check 2012-05-31 01:49:13 -04:00
Kenneth Reitz c9916dd2e3 disable collectstatic file for user-env-compile
hesitance
2012-05-30 18:51:32 -04:00
65 changed files with 6052 additions and 2718 deletions
+40
View File
@@ -1,3 +1,43 @@
## v14
Features:
* Full removal of Django settings injection for new apps.
* Support for profile.d
* Fresh app detection.
* Update to Virtualenv v1.7.2
* Updated to Pip v1.1 (patched)
Bugfixes:
* Default pip path exists action.
## v13
Bugfixes:
* Fix pip quoting error.
* Only talk about collectstatic in buildpack output when it's configured.
## v12
Bugfixes:
* Catch database setting corner case.
## v11
Bugfixes:
* Cleanup collectstatic output.
## v10
Bugfixes:
* Check for collectstatic validity with --dry-run instead of --help for Django 1.4.
## v9 ## v9
Bugfixes: Bugfixes:
+2 -2
View File
@@ -14,8 +14,8 @@ site: docs
pip: pip:
git clone git@github.com:kennethreitz/pip.git --branch heroku --depth 1 git clone git@github.com:kennethreitz/pip.git --branch heroku --depth 1
rm -fr vendor/virtualenv-1.7/virtualenv_support/pip-1.0.2.tar.gz rm -fr vendor/virtualenv-1.8.4/virtualenv_support/pip-1.2.1.tar.gz
rm -fr pip/.git rm -fr pip/.git
tar -pczf vendor/virtualenv-1.7/virtualenv_support/pip-1.0.2.tar.gz pip tar -pczf vendor/virtualenv-1.8.4/virtualenv_support/pip-1.2.1.tar.gz pip
rm -fr pip rm -fr pip
+2 -2
View File
@@ -14,7 +14,7 @@ Example usage:
$ ls $ ls
Procfile requirements.txt web.py Procfile requirements.txt web.py
$ heroku create --stack cedar --buildpack git@github.com:heroku/heroku-buildpack-python.git $ heroku create --stack cedar --buildpack git://github.com/heroku/heroku-buildpack-python.git
$ git push heroku master $ git push heroku master
... ...
@@ -35,7 +35,7 @@ Example usage:
You can also add it to upcoming builds of an existing application: You can also add it to upcoming builds of an existing application:
$ heroku config:add BUILDPACK_URL=git@github.com:heroku/heroku-buildpack-python.git $ heroku config:add BUILDPACK_URL=git://github.com/heroku/heroku-buildpack-python.git
The buildpack will detect your app as Python if it has the file `requirements.txt` in the root. It will detect your app as Python/Django if there is an additional `settings.py` in a project subdirectory. The buildpack will detect your app as Python if it has the file `requirements.txt` in the root. It will detect your app as Python/Django if there is an additional `settings.py` in a project subdirectory.
+32 -32
View File
@@ -53,6 +53,7 @@ LEGACY_VIRTUALENV_LOC="."
MODERN_VIRTUALENV_LOC=".heroku/venv" MODERN_VIRTUALENV_LOC=".heroku/venv"
LEGACY_VIRTUALENV_DIRS="bin include lib" LEGACY_VIRTUALENV_DIRS="bin include lib"
LEGACY_VIRTUALENV_TRIGGER="lib/python2.7" LEGACY_VIRTUALENV_TRIGGER="lib/python2.7"
PROFILE_PATH="$1/.profile.d/python.sh"
# Python version. This will be used in the future to specify custom Pythons. # Python version. This will be used in the future to specify custom Pythons.
@@ -60,30 +61,12 @@ PYTHON_VERSION="2.7.2"
PYTHON_EXE="python2.7" PYTHON_EXE="python2.7"
# Sanitizing environment variables. # Sanitizing environment variables.
unset GIT_DIR unset GIT_DIR PYTHONHOME PYTHONPATH LD_LIBRARY_PATH LIBRARY_PATH
unset PYTHONHOME
unset PYTHONPATH
# We'll need to send these statics to other scripts we `source`. # We'll need to send these statics to other scripts we `source`.
export PIP_DOWNLOAD_CACHE BUILD_DIR CACHE_DIR BIN_DIR export PIP_DOWNLOAD_CACHE BUILD_DIR CACHE_DIR BIN_DIR PROFILE_PATH
# Syntax sugar. source $BIN_DIR/utils
indent() {
RE="s/^/ /"
[ $(uname) == "Darwin" ] && sed -l "$RE" || sed -u "$RE"
}
function virtualenv (){
python "$ROOT_DIR/vendor/virtualenv-1.7/virtualenv.py" "$@"
}
function puts-step (){
echo "-----> $@"
}
function puts-warn (){
echo " ! $@"
}
# ## Build Time # ## Build Time
# #
@@ -106,16 +89,18 @@ fi
# ### The Cache # ### The Cache
mkdir -p $CACHE_DIR mkdir -p $CACHE_DIR
[ ! "$(ls -A $CACHE_DIR)" ] && export FRESH_APP=1
# Nice defaults. # Nice defaults.
LEGACY_VIRTUALENV=false
VIRTUALENV_LOC=$MODERN_VIRTUALENV_LOC VIRTUALENV_LOC=$MODERN_VIRTUALENV_LOC
VIRTUALENV_DIRS=$MODERN_VIRTUALENV_LOC
# Support "old-style" virtualenvs. # Support "old-style" virtualenvs.
if [ -d $CACHE_DIR/$LEGACY_VIRTUALENV_TRIGGER ]; then if [ -d $CACHE_DIR/$LEGACY_VIRTUALENV_TRIGGER ]; then
LEGACY_VIRTUALENV=true LEGACY_VIRTUALENV=true
VIRTUALENV_LOC=$LEGACY_VIRTUALENV_LOC VIRTUALENV_LOC=$LEGACY_VIRTUALENV_LOC
VIRTUALENV_DIRS=$LEGACY_VIRTUALENV_DIRS
CACHED_DIRS=$LEGACY_VIRTUALENV_DIRS CACHED_DIRS=$LEGACY_VIRTUALENV_DIRS
# Warn for a checked-in virtualenv. # Warn for a checked-in virtualenv.
@@ -142,10 +127,12 @@ HEROKU_DIR_STATUS=$?
# TODO: This is a new app, disable injection. # TODO: This is a new app, disable injection.
# [ $HEROKU_DIR_STATUS -eq 0 ] && { # [ $HEROKU_DIR_STATUS -eq 0 ] && {
#TODO: touch .heroku/injection_disabled # TODO: touch .heroku/injection_disabled
# } # }
set -e set -e
# Buildpack profile init script
mkdir -p $(dirname $PROFILE_PATH)
# ### Virtualenv Setup # ### Virtualenv Setup
# #
@@ -155,20 +142,22 @@ set -e
set +e set +e
puts-step "Preparing Python interpreter ($PYTHON_VERSION)" puts-step "Preparing Python interpreter ($PYTHON_VERSION)"
puts-step "Creating Virtualenv version $(virtualenv --version)" puts-step "Creating Virtualenv ($(virtualenv --version))"
# Try to create the virtualenv. # Try to create the virtualenv.
OUT=$(virtualenv --python $PYTHON_EXE --distribute --never-download --prompt='(venv) ' $VIRTUALENV_LOC 2>&1) OUT=$(virtualenv --python $PYTHON_EXE --distribute --never-download --prompt='(venv) ' $VIRTUALENV_LOC 2>&1)
# If there's an error, purge and recreate. [ $? -ne 0 -o -n "$CLEAN_VIRTUALENV" ] && {
[ $? -ne 0 ] && { if [ -n "$CLEAN_VIRTUALENV" ]
puts-warn "Virtualenv corrupt, rebuilding." then echo " ! CLEAN_VIRTUALENV set, rebuilding virtualenv."
else echo " ! Virtualenv corrupt, rebuilding."
fi
for dir in $VIRTUALENV_DIRS; do for dir in $VIRTUALENV_DIRS; do
rm -fr $dir &> /dev/null || true rm -fr $dir &> /dev/null || true
done done
OUT=$(virtualenv --python $PYTHON_EXE --distribute --never-download --prompt='(venv) ' $VIRTUALENV_LOC ) OUT=$(virtualenv --python $PYTHON_EXE --distribute --never-download --prompt='(venv) ' $VIRTUALENV_LOC )
} }
echo "$OUT" | indent echo "$OUT" | cleanup | indent
set -e set -e
@@ -177,17 +166,16 @@ set -e
source $BIN_DIR/steps/pylibmc source $BIN_DIR/steps/pylibmc
# Activate the Virtualenv. # Activate the Virtualenv.
puts-step "Activating virtualenv"
source $VIRTUALENV_LOC/bin/activate source $VIRTUALENV_LOC/bin/activate
# Install Mercurial if it appears to be required. # Install Mercurial if it appears to be required.
if (grep -Fiq "hg+" requirements.txt) then if (grep -Fiq "hg+" requirements.txt) then
pip install --use-mirrors mercurial | indent pip install --use-mirrors mercurial | cleanup | indent
fi fi
# Install dependencies with Pip. # Install dependencies with Pip.
puts-step "Installing dependencies using pip version $(pip --version | awk '{print $2}')" puts-step "Installing dependencies using pip ($(pip --version | awk '{print $2}'))"
pip install --use-mirrors -r requirements.txt --src ./.heroku/src | indent pip install --use-mirrors -r requirements.txt --exists-action=w --src=./.heroku/src | cleanup | indent
# Do additional application hackery if applications appears to be a Django app. # Do additional application hackery if applications appears to be a Django app.
# Optionally, disable all Django-specific changes with `DISABLE_INJECTION` env. # Optionally, disable all Django-specific changes with `DISABLE_INJECTION` env.
@@ -217,6 +205,18 @@ for dir in $CACHED_DIRS; do
cp -R $dir $CACHE_DIR/ cp -R $dir $CACHE_DIR/
done done
# Set context environment variables.
if [ ! -n "$LEGACY_VIRTUALENV" ]; then
set-env PATH '$HOME/.heroku/venv/bin:$PATH'
set-default-env PYTHONUNBUFFERED true
set-default-env LIBRARY_PATH /app/.heroku/vendor/lib
set-default-env LD_LIBRARY_PATH /app/.heroku/vendor/lib
set-default-env LANG en_US.UTF-8
set-default-env PYTHONHASHSEED random
set-default-env PYTHONHOME /app/.heroku/venv/
set-default-env PYTHONPATH /app/
fi
# ### Fin. # ### Fin.
# Experimental post_compile hook. # Experimental post_compile hook.
+6 -13
View File
@@ -9,27 +9,20 @@ indent() {
} }
# Check if collectstatic is configured. # Check if collectstatic is configured properly.
python $MANAGE_FILE collectstatic --help &> /dev/null && RUN_COLLECTSTATIC=true python $MANAGE_FILE collectstatic --dry-run --noinput &> /dev/null && RUN_COLLECTSTATIC=true
# Don't raise errors if SILENCE_COLLECTSTATIC is set.
echo "-----> Collecting static files"
set -e
# Compile assets if collectstatic appears to be kosher. # Compile assets if collectstatic appears to be kosher.
if [ "$RUN_COLLECTSTATIC" ]; then if [ "$RUN_COLLECTSTATIC" ]; then
python $MANAGE_FILE collectstatic --noinput | indent
echo "-----> Collecting static files"
python $MANAGE_FILE collectstatic --noinput 2>&1 | sed '/^Copying/d;/^$/d;/^ /d' | indent
[ $? -ne 0 ] && { [ $? -ne 0 ] && {
echo " ! Error running manage.py collectstatic. More info:" echo " ! Error running manage.py collectstatic. More info:"
echo " http://devcenter.heroku.com/articles/django-assets" echo " http://devcenter.heroku.com/articles/django-assets"
# exit 1
} }
else
echo " ! Django collecstatic is not configured. Learn more:"
echo " http://devcenter.heroku.com/articles/django-assets"
fi fi
echo echo
+10 -5
View File
@@ -5,22 +5,27 @@ PROJECT=$(dirname $SETTINGS_FILE)
MANAGE_FILE=$(find . -maxdepth 3 -type f -name 'manage.py' | head -1) MANAGE_FILE=$(find . -maxdepth 3 -type f -name 'manage.py' | head -1)
MANAGE_FILE=${MANAGE_FILE:2} MANAGE_FILE=${MANAGE_FILE:2}
if [ "$FRESH_APP" ]; then
# Legacy Django injection for existing applications.
touch .heroku/injection_disabled
fi
# Disable injection for new applications. # Disable injection for new applications.
if [ -f .heroku/injection_disabled ]; then if [ -f .heroku/injection_disabled ]; then
DISABLE_INJECTION=1 DISABLE_INJECTION=1
fi fi
if [ -f .heroku/collectstatic_disabled ]; then
DISABLE_COLLECTSTATIC=1
fi
export SETTINGS_FILE MANAGE_FILE PROJECT DISABLE_INJECTION export SETTINGS_FILE MANAGE_FILE PROJECT DISABLE_INJECTION
if [ ! "$DISABLE_INJECTION" ]; then if [ ! "$DISABLE_INJECTION" ]; then
# Legacy Django injection for existing applications.
source $BIN_DIR/steps/django/injection source $BIN_DIR/steps/django/injection
echo " ! Notice: settings injection will be deprecated for all new Django "
echo " ! apps starting on July 1, 2012. Learn more:"
echo " ! https://devcenter.heroku.com/articles/django-injection"
fi fi
if [ ! "$DISABLE_COLLECTSTATIC" ]; then if [ ! "$DISABLE_COLLECTSTATIC" ]; then
source $BIN_DIR/steps/django/collectstatic source $BIN_DIR/steps/django/collectstatic
fi fi
+14 -4
View File
@@ -18,10 +18,13 @@ indent() {
[ $(uname) == "Darwin" ] && sed -l "$RE" || sed -u "$RE" [ $(uname) == "Darwin" ] && sed -l "$RE" || sed -u "$RE"
} }
echo "-----> Installing dj-database-url..." echo "-----> Injecting legacy Django settings..."
pip install --use-mirrors dj-database-url>=0.2.0 | indent echo " ! WARNING: Settings injection will be fully deprecated on January 1, 2013. More info:"
echo " ! https://devcenter.heroku.com/articles/django-injection "
echo "-----> Injecting Django settings..."
echo "-----> Installing dj-database-url..."
pip install --use-mirrors 'dj-database-url>=0.2.0' | indent
SETTINGS_FILE=$(find . -maxdepth 2 -type f -name 'settings.py' | head -1) SETTINGS_FILE=$(find . -maxdepth 2 -type f -name 'settings.py' | head -1)
PROJECT=$(dirname $SETTINGS_FILE) PROJECT=$(dirname $SETTINGS_FILE)
@@ -32,6 +35,13 @@ cat >>$SETTINGS_FILE <<EOF
import dj_database_url import dj_database_url
DATABASES = {'default': dj_database_url.config(default='postgres://')} if 'DATABASES' not in locals():
DATABASES = {}
if not 'default' in DATABASES:
DATABASES['default'] = {}
DATABASES['default'].update(dj_database_url.config(default='postgres://'))
EOF EOF
Executable
+35
View File
@@ -0,0 +1,35 @@
# Syntax sugar.
indent() {
RE="s/^/ /"
[ $(uname) == "Darwin" ] && sed -l "$RE" || sed -u "$RE"
}
# Clean up pip output
cleanup() {
sed -e 's/\.\.\.\+/.../g' | sed -e '/already satisfied/Id' | sed -e '/Overwriting/Id' | sed -e '/python executable/Id' | sed -e '/no previously-included files/Id'
}
# Virtualenv wrapper.
function virtualenv (){
python "$ROOT_DIR/vendor/virtualenv-1.8.4/virtualenv.py" "$@"
}
# Buildpack Steps.
function puts-step (){
echo "-----> $@"
}
# Buildpack Warnings.
function puts-warn (){
echo " ! $@"
}
# Usage: $ set-env key value
function set-env (){
echo "export $1=$2" >> $PROFILE_PATH
}
# Usage: $ set-default-env key value
function set-default-env (){
echo "export $1=\${$1:-$2}" >> $PROFILE_PATH
}
-16
View File
@@ -1,16 +0,0 @@
virtualenv
==========
See docs/index.txt for user documentation.
Contributor notes
-----------------
* virtualenv is designed to work on python 2 and 3 with a single code base.
Use Python 3 print-function syntax, and always use sys.exc_info()[1]
inside the `except` block to get at exception objects.
* virtualenv uses git-flow_ to `coordinate development`_.
.. _git-flow: https://github.com/nvie/gitflow
.. _coordinate development: http://nvie.com/posts/a-successful-git-branching-model/
-9
View File
@@ -1,9 +0,0 @@
recursive-include docs *.txt
recursive-include scripts *
recursive-include virtualenv_support *.egg *.tar.gz
recursive-exclude virtualenv_support *.py
recursive-exclude docs/_templates *.*
include virtualenv_support/__init__.py
include *.py
include AUTHORS.txt
include LICENSE.txt
-58
View File
@@ -1,58 +0,0 @@
import sys, os
try:
from setuptools import setup
kw = {'entry_points':
"""[console_scripts]\nvirtualenv = virtualenv:main\n""",
'zip_safe': False}
except ImportError:
from distutils.core import setup
if sys.platform == 'win32':
print('Note: without Setuptools installed you will have to use "python -m virtualenv ENV"')
kw = {}
else:
kw = {'scripts': ['scripts/virtualenv']}
here = os.path.dirname(os.path.abspath(__file__))
## Get long_description from index.txt:
f = open(os.path.join(here, 'docs', 'index.txt'))
long_description = f.read().strip()
long_description = long_description.split('split here', 1)[1]
f.close()
f = open(os.path.join(here, 'docs', 'news.txt'))
long_description += "\n\n" + f.read()
f.close()
setup(name='virtualenv',
# If you change the version here, change it in virtualenv.py and
# docs/conf.py as well
version="1.7",
description="Virtual Python Environment builder",
long_description=long_description,
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.4',
'Programming Language :: Python :: 2.5',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.1',
'Programming Language :: Python :: 3.2',
],
keywords='setuptools deployment installation distutils',
author='Ian Bicking',
author_email='ianb@colorstudy.com',
maintainer='Jannis Leidel, Carl Meyer and Brian Rosner',
maintainer_email='python-virtualenv@groups.google.com',
url='http://www.virtualenv.org',
license='MIT',
py_modules=['virtualenv'],
packages=['virtualenv_support'],
package_data={'virtualenv_support': ['*-py%s.egg' % sys.version[:3], '*.tar.gz']},
test_suite='nose.collector',
tests_require=['nose', 'Mock'],
**kw
)
-50
View File
@@ -1,50 +0,0 @@
import virtualenv
from mock import patch, Mock
def test_version():
"""Should have a version string"""
assert virtualenv.virtualenv_version == "1.7", "Should have version"
@patch('os.path.exists')
def test_resolve_interpreter_with_absolute_path(mock_exists):
"""Should return absolute path if given and exists"""
mock_exists.return_value = True
virtualenv.is_executable = Mock(return_value=True)
exe = virtualenv.resolve_interpreter("/usr/bin/python42")
assert exe == "/usr/bin/python42", "Absolute path should return as is"
mock_exists.assert_called_with("/usr/bin/python42")
virtualenv.is_executable.assert_called_with("/usr/bin/python42")
@patch('os.path.exists')
def test_resolve_intepreter_with_nonexistant_interpreter(mock_exists):
"""Should exit when with absolute path if not exists"""
mock_exists.return_value = False
try:
virtualenv.resolve_interpreter("/usr/bin/python42")
assert False, "Should raise exception"
except SystemExit:
pass
mock_exists.assert_called_with("/usr/bin/python42")
@patch('os.path.exists')
def test_resolve_intepreter_with_invalid_interpreter(mock_exists):
"""Should exit when with absolute path if not exists"""
mock_exists.return_value = True
virtualenv.is_executable = Mock(return_value=False)
try:
virtualenv.resolve_interpreter("/usr/bin/python42")
assert False, "Should raise exception"
except SystemExit:
pass
mock_exists.assert_called_with("/usr/bin/python42")
virtualenv.is_executable.assert_called_with("/usr/bin/python42")
File diff suppressed because it is too large Load Diff
-31
View File
@@ -1,31 +0,0 @@
@echo off
set VIRTUAL_ENV=__VIRTUAL_ENV__
if not defined PROMPT (
set PROMPT=$P$G
)
if defined _OLD_VIRTUAL_PROMPT (
set PROMPT=%_OLD_VIRTUAL_PROMPT%
)
if defined _OLD_VIRTUAL_PYTHONHOME (
set PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%
)
set _OLD_VIRTUAL_PROMPT=%PROMPT%
set PROMPT=__VIRTUAL_WINPROMPT__ %PROMPT%
if defined PYTHONHOME (
set _OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%
set PYTHONHOME=
)
if defined _OLD_VIRTUAL_PATH set PATH=%_OLD_VIRTUAL_PATH%; goto SKIPPATH
set _OLD_VIRTUAL_PATH=%PATH%
:SKIPPATH
set PATH=%VIRTUAL_ENV%\__BIN_NAME__;%PATH%
:END
-79
View File
@@ -1,79 +0,0 @@
# This file must be used with ". bin/activate.fish" *from fish* (http://fishshell.org)
# you cannot run it directly
function deactivate -d "Exit virtualenv and return to normal shell environment"
# reset old environment variables
if test -n "$_OLD_VIRTUAL_PATH"
set -gx PATH $_OLD_VIRTUAL_PATH
set -e _OLD_VIRTUAL_PATH
end
if test -n "$_OLD_VIRTUAL_PYTHONHOME"
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
set -e _OLD_VIRTUAL_PYTHONHOME
end
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
functions -e fish_prompt
set -e _OLD_FISH_PROMPT_OVERRIDE
end
set -e VIRTUAL_ENV
if test "$argv[1]" != "nondestructive"
# Self destruct!
functions -e deactivate
end
end
# unset irrelavent variables
deactivate nondestructive
set -gx VIRTUAL_ENV "__VIRTUAL_ENV__"
set -gx _OLD_VIRTUAL_PATH $PATH
set -gx PATH "$VIRTUAL_ENV/__BIN_NAME__" $PATH
# unset PYTHONHOME if set
if set -q PYTHONHOME
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
set -e PYTHONHOME
end
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
# fish shell uses a function, instead of env vars,
# to produce the prompt. Overriding the existing function is easy.
# However, adding to the current prompt, instead of clobbering it,
# is a little more work.
set -l oldpromptfile (tempfile)
if test $status
# save the current fish_prompt function...
echo "function _old_fish_prompt" >> $oldpromptfile
echo -n \# >> $oldpromptfile
functions fish_prompt >> $oldpromptfile
# we've made the "_old_fish_prompt" file, source it.
. $oldpromptfile
rm -f $oldpromptfile
if test -n "__VIRTUAL_PROMPT__"
# We've been given us a prompt override.
#
# FIXME: Unsure how to handle this *safely*. We could just eval()
# whatever is given, but the risk is a bit much.
echo "activate.fish: Alternative prompt prefix is not supported under fish-shell." 1>&2
echo "activate.fish: Alter the fish_prompt in this file as needed." 1>&2
end
# with the original prompt function renamed, we can override with our own.
function fish_prompt
set -l _checkbase (basename "$VIRTUAL_ENV")
if test $_checkbase = "__"
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
printf "%s[%s]%s %s" (set_color -b blue white) (basename (dirname "$VIRTUAL_ENV")) (set_color normal) (_old_fish_prompt)
else
printf "%s(%s)%s%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal) (_old_fish_prompt)
end
end
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
end
end
-17
View File
@@ -1,17 +0,0 @@
@echo off
if defined _OLD_VIRTUAL_PROMPT (
set PROMPT=%_OLD_VIRTUAL_PROMPT%
)
set _OLD_VIRTUAL_PROMPT=
if defined _OLD_VIRTUAL_PYTHONHOME (
set PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%
set _OLD_VIRTUAL_PYTHONHOME=
)
if defined _OLD_VIRTUAL_PATH set PATH=%_OLD_VIRTUAL_PATH%
set _OLD_VIRTUAL_PATH=
:END
Binary file not shown.
Binary file not shown.
@@ -9,25 +9,50 @@ Maintainers
Brian Rosner Brian Rosner
Carl Meyer Carl Meyer
Jannis Leidel Jannis Leidel
Paul Nasrat
Contributors Contributors
------------ ------------
Alex Grönholm Alex Grönholm
Anatoly Techtonik
Antonio Cuni Antonio Cuni
Armin Ronacher Armin Ronacher
Benjamin Root
Bradley Ayers
Branden Rolston
Cap Petschulat
CBWhiz
Chris McDonough Chris McDonough
Christian Stefanescu Christian Stefanescu
Christopher Nilsson Christopher Nilsson
Cliff Xuan
Curt Micol Curt Micol
Damien Nozay
David Schoonover
Doug Hellmann
Doug Napoleone
Douglas Creager Douglas Creager
Ethan Jucovy
Gabriel de Perthuis
Gunnlaugur Thor Briem Gunnlaugur Thor Briem
Greg Haskins
Jason R. Coombs
Jeff Hammel Jeff Hammel
Jeremy Orem
Jonathan Griffin
Jorge Vargas Jorge Vargas
Josh Bronson Josh Bronson
Konstantin Zemlyak
Kumar McMillan Kumar McMillan
Lars Francke Lars Francke
Marc Abramowitz
Mike Hommey
Miki Tebeka
Paul Moore
Philip Jenvey Philip Jenvey
Raul Leal
Ronny Pfannschmidt Ronny Pfannschmidt
Stefano Rivera
Tarek Ziadé Tarek Ziadé
Vinay Sajip Vinay Sajip
@@ -1,6 +1,6 @@
Copyright (c) 2007 Ian Bicking and Contributors Copyright (c) 2007 Ian Bicking and Contributors
Copyright (c) 2009 Ian Bicking, The Open Planning Project Copyright (c) 2009 Ian Bicking, The Open Planning Project
Copyright (c) 2011 The virtualenv developers Copyright (c) 2011-2012 The virtualenv developers
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
+11
View File
@@ -0,0 +1,11 @@
recursive-include bin *
recursive-include docs *
recursive-include scripts *
recursive-include virtualenv_support *.egg *.tar.gz
recursive-include virtualenv_embedded *
recursive-exclude docs/_templates *
recursive-exclude docs/_build *
include virtualenv_support/__init__.py
include *.py
include AUTHORS.txt
include LICENSE.txt
@@ -1,6 +1,6 @@
Metadata-Version: 1.0 Metadata-Version: 1.1
Name: virtualenv Name: virtualenv
Version: 1.7 Version: 1.8.4
Summary: Virtual Python Environment builder Summary: Virtual Python Environment builder
Home-page: http://www.virtualenv.org Home-page: http://www.virtualenv.org
Author: Jannis Leidel, Carl Meyer and Brian Rosner Author: Jannis Leidel, Carl Meyer and Brian Rosner
@@ -8,23 +8,12 @@ Author-email: python-virtualenv@groups.google.com
License: MIT License: MIT
Description: Description:
Status and License Installation
------------------ ------------
``virtualenv`` is a successor to `workingenv You can install virtualenv with ``pip install virtualenv``, or the `latest
<http://cheeseshop.python.org/pypi/workingenv.py>`_, and an extension development version <https://github.com/pypa/virtualenv/tarball/develop>`_
of `virtual-python with ``pip install https://github.com/pypa/virtualenv/tarball/develop``.
<http://peak.telecommunity.com/DevCenter/EasyInstall#creating-a-virtual-python>`_.
It was written by Ian Bicking, sponsored by the `Open Planning
Project <http://openplans.org>`_ and is now maintained by a
`group of developers <https://github.com/pypa/virtualenv/raw/master/AUTHORS.txt>`_.
It is licensed under an
`MIT-style permissive license <https://github.com/pypa/virtualenv/raw/master/LICENSE.txt>`_.
You can install it with ``pip install virtualenv``, or the `latest
development version <https://github.com/pypa/virtualenv/tarball/develop#egg=virtualenv-dev>`_
with ``pip install virtualenv==dev``.
You can also use ``easy_install``, or if you have no Python package manager You can also use ``easy_install``, or if you have no Python package manager
available at all, you can just grab the single file `virtualenv.py`_ and run available at all, you can just grab the single file `virtualenv.py`_ and run
@@ -32,7 +21,6 @@ Description:
.. _virtualenv.py: https://raw.github.com/pypa/virtualenv/master/virtualenv.py .. _virtualenv.py: https://raw.github.com/pypa/virtualenv/master/virtualenv.py
What It Does What It Does
------------ ------------
@@ -59,6 +47,9 @@ Description:
share libraries with other virtualenv environments (and optionally share libraries with other virtualenv environments (and optionally
doesn't access the globally installed libraries either). doesn't access the globally installed libraries either).
Usage
-----
The basic usage is:: The basic usage is::
$ python virtualenv.py ENV $ python virtualenv.py ENV
@@ -78,12 +69,116 @@ Description:
$ python virtualenv.py --distribute ENV $ python virtualenv.py --distribute ENV
You can also set the environment variable VIRTUALENV_USE_DISTRIBUTE. You can also set the environment variable VIRTUALENV_DISTRIBUTE.
A new virtualenv also includes the `pip <http://pypy.python.org/pypi/pip>`_ A new virtualenv also includes the `pip <http://pypi.python.org/pypi/pip>`_
installer, so you can use ``ENV/bin/pip`` to install additional packages into installer, so you can use ``ENV/bin/pip`` to install additional packages into
the environment. the environment.
activate script
~~~~~~~~~~~~~~~
In a newly created virtualenv there will be a ``bin/activate`` shell
script. For Windows systems, activation scripts are provided for CMD.exe
and Powershell.
On Posix systems you can do::
$ source bin/activate
This will change your ``$PATH`` so its first entry is the virtualenv's
``bin/`` directory. (You have to use ``source`` because it changes your
shell environment in-place.) This is all it does; it's purely a
convenience. If you directly run a script or the python interpreter
from the virtualenv's ``bin/`` directory (e.g. ``path/to/env/bin/pip``
or ``/path/to/env/bin/python script.py``) there's no need for
activation.
After activating an environment you can use the function ``deactivate`` to
undo the changes to your ``$PATH``.
The ``activate`` script will also modify your shell prompt to indicate
which environment is currently active. You can disable this behavior,
which can be useful if you have your own custom prompt that already
displays the active environment name. To do so, set the
``VIRTUAL_ENV_DISABLE_PROMPT`` environment variable to any non-empty
value before running the ``activate`` script.
On Windows you just do::
> \path\to\env\Scripts\activate
And type `deactivate` to undo the changes.
Based on your active shell (CMD.exe or Powershell.exe), Windows will use
either activate.bat or activate.ps1 (as appropriate) to activate the
virtual environment. If using Powershell, see the notes about code signing
below.
.. note::
If using Powershell, the ``activate`` script is subject to the
`execution policies`_ on the system. By default on Windows 7, the system's
excution policy is set to ``Restricted``, meaning no scripts like the
``activate`` script are allowed to be executed. But that can't stop us
from changing that slightly to allow it to be executed.
In order to use the script, you have to relax your system's execution
policy to ``AllSigned``, meaning all scripts on the system must be
digitally signed to be executed. Since the virtualenv activation
script is signed by one of the authors (Jannis Leidel) this level of
the execution policy suffices. As an administrator run::
PS C:\> Set-ExecutionPolicy AllSigned
Then you'll be asked to trust the signer, when executing the script.
You will be prompted with the following::
PS C:\> virtualenv .\foo
New python executable in C:\foo\Scripts\python.exe
Installing setuptools................done.
Installing pip...................done.
PS C:\> .\foo\scripts\activate
Do you want to run software from this untrusted publisher?
File C:\foo\scripts\activate.ps1 is published by E=jannis@leidel.info,
CN=Jannis Leidel, L=Berlin, S=Berlin, C=DE, Description=581796-Gh7xfJxkxQSIO4E0
and is not trusted on your system. Only run scripts from trusted publishers.
[V] Never run [D] Do not run [R] Run once [A] Always run [?] Help
(default is "D"):A
(foo) PS C:\>
If you select ``[A] Always Run``, the certificate will be added to the
Trusted Publishers of your user account, and will be trusted in this
user's context henceforth. If you select ``[R] Run Once``, the script will
be run, but you will be prometed on a subsequent invocation. Advanced users
can add the signer's certificate to the Trusted Publishers of the Computer
account to apply to all users (though this technique is out of scope of this
document).
Alternatively, you may relax the system execution policy to allow running
of local scripts without verifying the code signature using the following::
PS C:\> Set-ExecutionPolicy RemoteSigned
Since the ``activate.ps1`` script is generated locally for each virtualenv,
it is not considered a remote script and can then be executed.
.. _`execution policies`: http://technet.microsoft.com/en-us/library/dd347641.aspx
The ``--system-site-packages`` Option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you build with ``virtualenv --system-site-packages ENV``, your virtual
environment will inherit packages from ``/usr/lib/python2.7/site-packages``
(or wherever your global site-packages directory is).
This can be used if you have control over the global site-packages directory,
and you want to depend on the packages there. If you want isolation from the
global system, do not use this flag.
Environment variables and configuration files Environment variables and configuration files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -100,7 +195,7 @@ Description:
For example, to automatically install Distribute instead of setuptools For example, to automatically install Distribute instead of setuptools
you can also set an environment variable:: you can also set an environment variable::
$ export VIRTUALENV_USE_DISTRIBUTE=true $ export VIRTUALENV_DISTRIBUTE=true
$ python virtualenv.py ENV $ python virtualenv.py ENV
It's the same as passing the option to virtualenv directly:: It's the same as passing the option to virtualenv directly::
@@ -121,7 +216,7 @@ Description:
virtualenv also looks for a standard ini config file. On Unix and Mac OS X virtualenv also looks for a standard ini config file. On Unix and Mac OS X
that's ``$HOME/.virtualenv/virtualenv.ini`` and on Windows, it's that's ``$HOME/.virtualenv/virtualenv.ini`` and on Windows, it's
``%HOME%\\virtualenv\\virtualenv.ini``. ``%APPDATA%\virtualenv\virtualenv.ini``.
The names of the settings are derived from the long command line option, The names of the settings are derived from the long command line option,
e.g. the option ``--distribute`` would look like this:: e.g. the option ``--distribute`` would look like this::
@@ -232,52 +327,9 @@ Description:
Another example is available `here Another example is available `here
<https://github.com/socialplanning/fassembler/blob/master/fassembler/create-venv-script.py>`_. <https://github.com/socialplanning/fassembler/blob/master/fassembler/create-venv-script.py>`_.
activate script
~~~~~~~~~~~~~~~
In a newly created virtualenv there will be a ``bin/activate`` shell
script, or a ``Scripts/activate.bat`` batch file on Windows.
On Posix systems you can do::
$ source bin/activate
This will change your ``$PATH`` to point to the virtualenv's ``bin/``
directory. (You have to use ``source`` because it changes your shell
environment in-place.) This is all it does; it's purely a convenience. If
you directly run a script or the python interpreter from the virtualenv's
``bin/`` directory (e.g. ``path/to/env/bin/pip`` or
``/path/to/env/bin/python script.py``) there's no need for activation.
After activating an environment you can use the function ``deactivate`` to
undo the changes to your ``$PATH``.
The ``activate`` script will also modify your shell prompt to indicate
which environment is currently active. You can disable this behavior,
which can be useful if you have your own custom prompt that already
displays the active environment name. To do so, set the
``VIRTUAL_ENV_DISABLE_PROMPT`` environment variable to any non-empty
value before running the ``activate`` script.
On Windows you just do::
> \path\to\env\Scripts\activate.bat
And use ``deactivate.bat`` to undo the changes.
The ``--system-site-packages`` Option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you build with ``virtualenv --system-site-packages ENV``, your virtual
environment will inherit packages from ``/usr/lib/python2.7/site-packages``
(or wherever your global site-packages directory is).
This can be used if you have control over the global site-packages directory,
and you want to depend on the packages there. If you want isolation from the
global system, do not use this flag.
Using Virtualenv without ``bin/python`` Using Virtualenv without ``bin/python``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ---------------------------------------
Sometimes you can't or don't want to use the Python interpreter Sometimes you can't or don't want to use the Python interpreter
created by the virtualenv. For instance, in a `mod_python created by the virtualenv. For instance, in a `mod_python
@@ -303,7 +355,7 @@ Description:
do it again in that process. do it again in that process.
Making Environments Relocatable Making Environments Relocatable
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -------------------------------
Note: this option is somewhat experimental, and there are probably Note: this option is somewhat experimental, and there are probably
caveats that have not yet been identified. Also this does not caveats that have not yet been identified. Also this does not
@@ -340,16 +392,16 @@ Description:
If you use this flag to create an environment, currently, the If you use this flag to create an environment, currently, the
``--system-site-packages`` option will be implied. ``--system-site-packages`` option will be implied.
The ``--extra-search-dir`` Option The ``--extra-search-dir`` option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ---------------------------------
When it creates a new environment, virtualenv installs either When it creates a new environment, virtualenv installs either setuptools
setuptools or distribute, and pip. In normal operation, the latest or distribute, and pip. In normal operation when virtualenv is
installed, the bundled version of these packages included in the
``virtualenv_support`` directory is used. When ``virtualenv.py`` is run
standalone and ``virtualenv_support`` is not available, the latest
releases of these packages are fetched from the `Python Package Index releases of these packages are fetched from the `Python Package Index
<http://pypi.python.org>`_ (PyPI). In some circumstances, this <http://pypi.python.org>`_ (PyPI).
behavior may not be wanted, for example if you are using virtualenv
during a deployment and do not want to depend on Internet access and
PyPI availability.
As an alternative, you can provide your own versions of setuptools, As an alternative, you can provide your own versions of setuptools,
distribute and/or pip on the filesystem, and tell virtualenv to use distribute and/or pip on the filesystem, and tell virtualenv to use
@@ -361,8 +413,9 @@ Description:
The ``/path/to/distributions`` path should point to a directory that The ``/path/to/distributions`` path should point to a directory that
contains setuptools, distribute and/or pip distributions. Setuptools contains setuptools, distribute and/or pip distributions. Setuptools
distributions must be ``.egg`` files; distribute and pip distributions distributions must be ``.egg`` files; pip distributions should be
should be `.tar.gz` source distributions. `.tar.gz` source distributions, and distribute distributions may be
either (if found an egg will be used preferentially).
Virtualenv will still download these packages if no satisfactory local Virtualenv will still download these packages if no satisfactory local
distributions are found. distributions are found.
@@ -376,7 +429,17 @@ Description:
If this option is provided, virtualenv will never try to download If this option is provided, virtualenv will never try to download
setuptools/distribute or pip. Instead, it will exit with status code 1 setuptools/distribute or pip. Instead, it will exit with status code 1
if it fails to find local distributions for any of these required if it fails to find local distributions for any of these required
packages. packages. The local distribution lookup is done in the following
locations, with the most recent version found used:
#. The current directory.
#. The directory where virtualenv.py is located.
#. A ``virtualenv_support`` directory relative to the directory where
virtualenv.py is located.
#. If the file being executed is not named virtualenv.py (i.e. is a boot
script), a ``virtualenv_support`` directory relative to wherever
virtualenv.py is actually installed.
Compare & Contrast with Alternatives Compare & Contrast with Alternatives
------------------------------------ ------------------------------------
@@ -420,13 +483,22 @@ Description:
------------ ------------
Refer to the `contributing to pip`_ documentation - it applies equally to Refer to the `contributing to pip`_ documentation - it applies equally to
virtualenv. virtualenv, except that virtualenv issues should filed on the `virtualenv
repo`_ at GitHub.
Virtualenv's release schedule is tied to pip's -- each time there's a new pip Virtualenv's release schedule is tied to pip's -- each time there's a new pip
release, there will be a new virtualenv release that bundles the new version of release, there will be a new virtualenv release that bundles the new version of
pip. pip.
.. _contributing to pip: http://www.pip-installer.org/en/latest/how-to-contribute.html Files in the `virtualenv_embedded/` subdirectory are embedded into
`virtualenv.py` itself as base64-encoded strings (in order to support
single-file use of `virtualenv.py` without installing it). If your patch
changes any file in `virtualenv_embedded/`, run `bin/rebuild-script.py` to
update the embedded version of that file in `virtualenv.py`; commit that and
submit it as part of your patch / pull request.
.. _contributing to pip: http://www.pip-installer.org/en/latest/contributing.html
.. _virtualenv repo: https://github.com/pypa/virtualenv/
Running the tests Running the tests
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
@@ -478,16 +550,213 @@ Description:
<http://code.google.com/p/modwsgi/wiki/VirtualEnvironments>`_. <http://code.google.com/p/modwsgi/wiki/VirtualEnvironments>`_.
* `virtualenv commands * `virtualenv commands
<http://thisismedium.com/tech/extending-virtualenv/>`_ for some more <https://github.com/thisismedium/virtualenv-commands>`_ for some more
workflow-related tools around virtualenv. workflow-related tools around virtualenv.
Status and License
------------------
``virtualenv`` is a successor to `workingenv
<http://cheeseshop.python.org/pypi/workingenv.py>`_, and an extension
of `virtual-python
<http://peak.telecommunity.com/DevCenter/EasyInstall#creating-a-virtual-python>`_.
It was written by Ian Bicking, sponsored by the `Open Planning
Project <http://openplans.org>`_ and is now maintained by a
`group of developers <https://github.com/pypa/virtualenv/raw/master/AUTHORS.txt>`_.
It is licensed under an
`MIT-style permissive license <https://github.com/pypa/virtualenv/raw/master/LICENSE.txt>`_.
Changes & News Changes & News
-------------- --------------
.. warning::
Python bugfix releases 2.6.8, 2.7.3, 3.1.5 and 3.2.3 include a change that
will cause "import random" to fail with "cannot import name urandom" on any
virtualenv created on a Unix host with an earlier release of Python
2.6/2.7/3.1/3.2, if the underlying system Python is upgraded. This is due to
the fact that a virtualenv uses the system Python's standard library but
contains its own copy of the Python interpreter, so an upgrade to the system
Python results in a mismatch between the version of the Python interpreter
and the version of the standard library. It can be fixed by removing
``$ENV/bin/python`` and re-running virtualenv on the same target directory
with the upgraded Python.
1.8.4 (2012-11-25)
~~~~~~~~~~~~~~~~~~
* Updated distribute to 0.6.31. This fixes #359 (numpy install regression) on
UTF-8 platforms, and provides a workaround on other platforms:
``PYTHONIOENCODING=utf8 pip install numpy``.
* When installing virtualenv via curl, don't forget to filter out arguments
the distribute setup script won't understand. Fixes #358.
* Added some more integration tests.
1.8.3 (2012-11-21)
~~~~~~~~~~~~~~~~~~
* Fixed readline on OS X. Thanks minrk
* Updated distribute to 0.6.30 (improves our error reporting, plus new
distribute features and fixes). Thanks Gabriel (g2p)
* Added compatibility with multiarch Python (Python 3.3 for example). Added an
integration test. Thanks Gabriel (g2p)
* Added ability to install distribute from a user-provided egg, rather than the
bundled sdist, for better speed. Thanks Paul Moore.
* Make the creation of lib64 symlink smarter about already-existing symlink,
and more explicit about full paths. Fixes #334 and #330. Thanks Jeremy Orem.
* Give lib64 site-dir preference over lib on 64-bit systems, to avoid wrong
32-bit compiles in the venv. Fixes #328. Thanks Damien Nozay.
* Fix a bug with prompt-handling in ``activate.csh`` in non-interactive csh
shells. Fixes #332. Thanks Benjamin Root for report and patch.
* Make it possible to create a virtualenv from within a Python
3.3. pyvenv. Thanks Chris McDonough for the report.
* Add optional --setuptools option to be able to switch to it in case
distribute is the default (like in Debian).
1.8.2 (2012-09-06)
~~~~~~~~~~~~~~~~~~
* Updated the included pip version to 1.2.1 to fix regressions introduced
there in 1.2.
1.8.1 (2012-09-03)
~~~~~~~~~~~~~~~~~~
* Fixed distribute version used with `--never-download`. Thanks michr for
report and patch.
* Fix creating Python 3.3 based virtualenvs by unsetting the
``__PYVENV_LAUNCHER__`` environment variable in subprocesses.
1.8 (2012-09-01)
~~~~~~~~~~~~~~~~
* **Dropped support for Python 2.4** The minimum supported Python version is
now Python 2.5.
* Fix `--relocatable` on systems that use lib64. Fixes #78. Thanks Branden
Rolston.
* Symlink some additional modules under Python 3. Fixes #194. Thanks Vinay
Sajip, Ian Clelland, and Stefan Holek for the report.
* Fix ``--relocatable`` when a script uses ``__future__`` imports. Thanks
Branden Rolston.
* Fix a bug in the config option parser that prevented setting negative
options with environemnt variables. Thanks Ralf Schmitt.
* Allow setting ``--no-site-packages`` from the config file.
* Use ``/usr/bin/multiarch-platform`` if available to figure out the include
directory. Thanks for the patch, Mika Laitio.
* Fix ``install_name_tool`` replacement to work on Python 3.X.
* Handle paths of users' site-packages on Mac OS X correctly when changing
the prefix.
* Updated the embedded version of distribute to 0.6.28 and pip to 1.2.
1.7.2 (2012-06-22)
~~~~~~~~~~~~~~~~~~
* Updated to distribute 0.6.27.
* Fix activate.fish on OS X. Fixes #8. Thanks David Schoonover.
* Create a virtualenv-x.x script with the Python version when installing, so
virtualenv for multiple Python versions can be installed to the same
script location. Thanks Miki Tebeka.
* Restored ability to create a virtualenv with a path longer than 78
characters, without breaking creation of virtualenvs with non-ASCII paths.
Thanks, Bradley Ayers.
* Added ability to create virtualenvs without having installed Apple's
developers tools (using an own implementation of ``install_name_tool``).
Thanks Mike Hommey.
* Fixed PyPy and Jython support on Windows. Thanks Konstantin Zemlyak.
* Added pydoc script to ease use. Thanks Marc Abramowitz. Fixes #149.
* Fixed creating a bootstrap script on Python 3. Thanks Raul Leal. Fixes #280.
* Fixed inconsistency when having set the ``PYTHONDONTWRITEBYTECODE`` env var
with the --distribute option or the ``VIRTUALENV_USE_DISTRIBUTE`` env var.
``VIRTUALENV_USE_DISTRIBUTE`` is now considered again as a legacy alias.
1.7.1.2 (2012-02-17)
~~~~~~~~~~~~~~~~~~~~
* Fixed minor issue in `--relocatable`. Thanks, Cap Petschulat.
1.7.1.1 (2012-02-16)
~~~~~~~~~~~~~~~~~~~~
* Bumped the version string in ``virtualenv.py`` up, too.
* Fixed rST rendering bug of long description.
1.7.1 (2012-02-16)
~~~~~~~~~~~~~~~~~~
* Update embedded pip to version 1.1.
* Fix `--relocatable` under Python 3. Thanks Doug Hellmann.
* Added environ PATH modification to activate_this.py. Thanks Doug
Napoleone. Fixes #14.
* Support creating virtualenvs directly from a Python build directory on
Windows. Thanks CBWhiz. Fixes #139.
* Use non-recursive symlinks to fix things up for posix_local install
scheme. Thanks michr.
* Made activate script available for use with msys and cygwin on Windows.
Thanks Greg Haskins, Cliff Xuan, Jonathan Griffin and Doug Napoleone.
Fixes #176.
* Fixed creation of virtualenvs on Windows when Python is not installed for
all users. Thanks Anatoly Techtonik for report and patch and Doug
Napoleone for testing and confirmation. Fixes #87.
* Fixed creation of virtualenvs using -p in installs where some modules
that ought to be in the standard library (e.g. `readline`) are actually
installed in `site-packages` next to `virtualenv.py`. Thanks Greg Haskins
for report and fix. Fixes #167.
* Added activation script for Powershell (signed by Jannis Leidel). Many
thanks to Jason R. Coombs.
1.7 (2011-11-30) 1.7 (2011-11-30)
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
* Updated embedded Distribute release to 0.6.24. Thanks Alex Grönholm. * Gave user-provided ``--extra-search-dir`` priority over default dirs for
finding setuptools/distribute (it already had priority for finding pip).
Thanks Ethan Jucovy.
* Updated embedded Distribute release to 0.6.24. Thanks Alex Gronholm.
* Made ``--no-site-packages`` behavior the default behavior. The * Made ``--no-site-packages`` behavior the default behavior. The
``--no-site-packages`` flag is still permitted, but displays a warning when ``--no-site-packages`` flag is still permitted, but displays a warning when
@@ -503,16 +772,19 @@ Description:
* Made ``virtualenv.py`` script executable. * Made ``virtualenv.py`` script executable.
1.6.4 (2011-07-21) 1.6.4 (2011-07-21)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
* Restored ability to run on Python 2.4, too. * Restored ability to run on Python 2.4, too.
1.6.3 (2011-07-16) 1.6.3 (2011-07-16)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
* Restored ability to run on Python < 2.7. * Restored ability to run on Python < 2.7.
1.6.2 (2011-07-16) 1.6.2 (2011-07-16)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
@@ -547,6 +819,7 @@ Description:
* Added --never-download and --search-dir options. Thanks Ethan Jucovy. * Added --never-download and --search-dir options. Thanks Ethan Jucovy.
1.6 1.6
~~~ ~~~
@@ -557,6 +830,7 @@ Description:
* Updated bundled pip to 1.0. * Updated bundled pip to 1.0.
1.5.2 1.5.2
~~~~~ ~~~~~
@@ -572,6 +846,7 @@ Description:
* Moved virtualenv to Github at https://github.com/pypa/virtualenv * Moved virtualenv to Github at https://github.com/pypa/virtualenv
1.5.1 1.5.1
~~~~~ ~~~~~
@@ -579,6 +854,7 @@ Description:
* Fixed Windows regression in 1.5 * Fixed Windows regression in 1.5
1.5 1.5
~~~ ~~~
@@ -596,11 +872,13 @@ Description:
* Add fish and csh activate scripts. * Add fish and csh activate scripts.
1.4.9 1.4.9
~~~~~ ~~~~~
* Include pip 0.7.2 * Include pip 0.7.2
1.4.8 1.4.8
~~~~~ ~~~~~
@@ -615,17 +893,20 @@ Description:
* Include pip 0.7.1 * Include pip 0.7.1
1.4.7 1.4.7
~~~~~ ~~~~~
* Include pip 0.7 * Include pip 0.7
1.4.6 1.4.6
~~~~~ ~~~~~
* Allow ``activate.sh`` to skip updating the prompt (by setting * Allow ``activate.sh`` to skip updating the prompt (by setting
``$VIRTUAL_ENV_DISABLE_PROMPT``). ``$VIRTUAL_ENV_DISABLE_PROMPT``).
1.4.5 1.4.5
~~~~~ ~~~~~
@@ -634,6 +915,7 @@ Description:
* Fix ``activate.bat`` and ``deactivate.bat`` under Windows when * Fix ``activate.bat`` and ``deactivate.bat`` under Windows when
``PATH`` contained a parenthesis ``PATH`` contained a parenthesis
1.4.4 1.4.4
~~~~~ ~~~~~
@@ -645,15 +927,17 @@ Description:
* Fix problem with ``virtualenv --relocate`` when ``bin/`` has * Fix problem with ``virtualenv --relocate`` when ``bin/`` has
subdirectories (e.g., ``bin/.svn/``); from Alan Franzoni. subdirectories (e.g., ``bin/.svn/``); from Alan Franzoni.
* If you set ``$VIRTUALENV_USE_DISTRIBUTE`` then virtualenv will use * If you set ``$VIRTUALENV_DISTRIBUTE`` then virtualenv will use
Distribute by default (so you don't have to remember to use Distribute by default (so you don't have to remember to use
``--distribute``). ``--distribute``).
1.4.3 1.4.3
~~~~~ ~~~~~
* Include pip 0.6.1 * Include pip 0.6.1
1.4.2 1.4.2
~~~~~ ~~~~~
@@ -664,11 +948,13 @@ Description:
* Exclude ~/.local (user site-packages) from environments when using * Exclude ~/.local (user site-packages) from environments when using
``--no-site-packages`` ``--no-site-packages``
1.4.1 1.4.1
~~~~~ ~~~~~
* Include pip 0.6 * Include pip 0.6
1.4 1.4
~~~ ~~~
@@ -678,6 +964,7 @@ Description:
* Fixed packaging problem of support-files * Fixed packaging problem of support-files
1.3.4 1.3.4
~~~~~ ~~~~~
@@ -707,6 +994,7 @@ Description:
* Fixes for ``--python``: make it work with ``--relocatable`` and the * Fixes for ``--python``: make it work with ``--relocatable`` and the
symlink created to the exact Python version. symlink created to the exact Python version.
1.3.3 1.3.3
~~~~~ ~~~~~
@@ -729,6 +1017,7 @@ Description:
<https://bugs.launchpad.net/virtualenv/+bug/340050>`_ picking up <https://bugs.launchpad.net/virtualenv/+bug/340050>`_ picking up
some ``.so`` libraries in ``/usr/local``. some ``.so`` libraries in ``/usr/local``.
1.3.2 1.3.2
~~~~~ ~~~~~
@@ -736,11 +1025,12 @@ Description:
``distutils.cfg`` -- this has been causing problems for a lot of ``distutils.cfg`` -- this has been causing problems for a lot of
people, in rather obscure ways. people, in rather obscure ways.
* If you use a `boot script <./index.html#boot-script>`_ it will attempt to import ``virtualenv`` * If you use a boot script it will attempt to import ``virtualenv``
and find a pre-downloaded Setuptools egg using that. and find a pre-downloaded Setuptools egg using that.
* Added platform-specific paths, like ``/usr/lib/pythonX.Y/plat-linux2`` * Added platform-specific paths, like ``/usr/lib/pythonX.Y/plat-linux2``
1.3.1 1.3.1
~~~~~ ~~~~~
@@ -763,6 +1053,7 @@ Description:
* Fixed handling of Jython environments that use a * Fixed handling of Jython environments that use a
jython-complete.jar. jython-complete.jar.
1.3 1.3
~~~ ~~~
@@ -789,6 +1080,7 @@ Description:
* Fixed the ``__classpath__`` entry in Jython's ``sys.path`` taking * Fixed the ``__classpath__`` entry in Jython's ``sys.path`` taking
precedent over virtualenv's libs. precedent over virtualenv's libs.
1.2 1.2
~~~ ~~~
@@ -797,11 +1089,13 @@ Description:
* Add ``sets`` to the module copied over for Python 2.3 (though Python * Add ``sets`` to the module copied over for Python 2.3 (though Python
2.3 still probably doesn't work). 2.3 still probably doesn't work).
1.1.1 1.1.1
~~~~~ ~~~~~
* Added support for Jython 2.5. * Added support for Jython 2.5.
1.1 1.1
~~~ ~~~
@@ -816,6 +1110,7 @@ Description:
* Copy or symlink over the ``include`` directory so that packages will * Copy or symlink over the ``include`` directory so that packages will
more consistently compile. more consistently compile.
1.0 1.0
~~~ ~~~
@@ -825,6 +1120,7 @@ Description:
* Fixed typos in ``deactivate.bat``. * Fixed typos in ``deactivate.bat``.
* Preserve ``$PYTHONPATH`` when calling subprocesses. * Preserve ``$PYTHONPATH`` when calling subprocesses.
0.9.2 0.9.2
~~~~~ ~~~~~
@@ -839,6 +1135,7 @@ Description:
* Fixed an issue with Mac Framework Python builds, and absolute paths * Fixed an issue with Mac Framework Python builds, and absolute paths
(from Ronald Oussoren). (from Ronald Oussoren).
0.9.1 0.9.1
~~~~~ ~~~~~
@@ -846,6 +1143,7 @@ Description:
* Fix a little bug in ``bin/activate``. * Fix a little bug in ``bin/activate``.
* Actually get ``distutils.cfg`` to work reliably. * Actually get ``distutils.cfg`` to work reliably.
0.9 0.9
~~~ ~~~
@@ -861,6 +1159,7 @@ Description:
* Should work on MacOSX Framework builds (the default Python * Should work on MacOSX Framework builds (the default Python
installations on Mac). Thanks to Ronald Oussoren. installations on Mac). Thanks to Ronald Oussoren.
0.8.4 0.8.4
~~~~~ ~~~~~
@@ -868,11 +1167,13 @@ Description:
were inaccurate. were inaccurate.
* Slightly prettier output. * Slightly prettier output.
0.8.3 0.8.3
~~~~~ ~~~~~
* Added support for Windows. * Added support for Windows.
0.8.2 0.8.2
~~~~~ ~~~~~
@@ -881,11 +1182,13 @@ Description:
* Give error about running while inside a workingenv. * Give error about running while inside a workingenv.
* Give better error message about Python 2.3. * Give better error message about Python 2.3.
0.8.1 0.8.1
~~~~~ ~~~~~
Fixed packaging of the library. Fixed packaging of the library.
0.8 0.8
~~~ ~~~
@@ -897,7 +1200,6 @@ Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.4
Classifier: Programming Language :: Python :: 2.5 Classifier: Programming Language :: Python :: 2.5
Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 2.7
+7
View File
@@ -0,0 +1,7 @@
virtualenv
==========
.. image:: https://secure.travis-ci.org/pypa/virtualenv.png?branch=develop
:target: http://travis-ci.org/pypa/virtualenv
For documentation, see http://www.virtualenv.org/
@@ -29,7 +29,8 @@ def rebuild():
varname = match.group(2) varname = match.group(2)
data = match.group(3) data = match.group(3)
print('Found reference to file %s' % filename) print('Found reference to file %s' % filename)
f = open(os.path.join(here, '..', 'virtualenv_support', filename), 'rb') pathname = os.path.join(here, '..', 'virtualenv_embedded', filename)
f = open(pathname, 'rb')
c = f.read() c = f.read()
f.close() f.close()
new_data = c.encode('zlib').encode('base64') new_data = c.encode('zlib').encode('base64')
@@ -11,19 +11,23 @@ except ImportError:
import sys import sys
here = os.path.dirname(__file__) here = os.path.dirname(__file__)
support_files = os.path.join(here, '..', 'virtualenv_support') support_location = os.path.join(here, '..', 'virtualenv_support')
embedded_location = os.path.join(here, '..', 'virtualenv_embedded')
files = [ embedded_files = [
('http://peak.telecommunity.com/dist/ez_setup.py', 'ez_setup.py'), ('http://peak.telecommunity.com/dist/ez_setup.py', 'ez_setup.py'),
('http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg', 'setuptools-0.6c11-py2.6.egg'),
('http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c11-py2.5.egg', 'setuptools-0.6c11-py2.5.egg'),
('http://pypi.python.org/packages/2.4/s/setuptools/setuptools-0.6c11-py2.4.egg', 'setuptools-0.6c11-py2.4.egg'),
('http://python-distribute.org/distribute_setup.py', 'distribute_setup.py'), ('http://python-distribute.org/distribute_setup.py', 'distribute_setup.py'),
('http://pypi.python.org/packages/source/d/distribute/distribute-0.6.24.tar.gz', 'distribute-0.6.24.tar.gz'),
('http://pypi.python.org/packages/source/p/pip/pip-1.0.2.tar.gz', 'pip-1.0.2.tar.gz'),
] ]
def main(): support_files = [
('http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg', 'setuptools-0.6c11-py2.6.egg'),
('http://pypi.python.org/packages/2.5/s/setuptools/setuptools-0.6c11-py2.5.egg', 'setuptools-0.6c11-py2.5.egg'),
('http://pypi.python.org/packages/source/d/distribute/distribute-0.6.31.tar.gz', 'distribute-0.6.31.tar.gz'),
('http://pypi.python.org/packages/source/p/pip/pip-1.2.1.tar.gz', 'pip-1.2.1.tar.gz'),
]
def refresh_files(files, location):
for url, filename in files: for url, filename in files:
sys.stdout.write('fetching %s ... ' % url) sys.stdout.write('fetching %s ... ' % url)
sys.stdout.flush() sys.stdout.flush()
@@ -31,7 +35,7 @@ def main():
content = f.read() content = f.read()
f.close() f.close()
print('done.') print('done.')
filename = os.path.join(support_files, filename) filename = os.path.join(location, filename)
if os.path.exists(filename): if os.path.exists(filename):
f = open(filename, 'rb') f = open(filename, 'rb')
cur_content = f.read() cur_content = f.read()
@@ -46,7 +50,10 @@ def main():
f.write(content) f.write(content)
f.close() f.close()
def main():
refresh_files(embedded_files, embedded_location)
refresh_files(support_files, support_location)
if __name__ == '__main__': if __name__ == '__main__':
main() main()
@@ -35,15 +35,18 @@ master_doc = 'index'
# General substitutions. # General substitutions.
project = 'virtualenv' project = 'virtualenv'
copyright = '2007-2011, Ian Bicking, The Open Planning Project, The virtualenv developers' copyright = '2007-2012, Ian Bicking, The Open Planning Project, The virtualenv developers'
# The default replacements for |version| and |release|, also used in various # The default replacements for |version| and |release|, also used in various
# other places throughout the built documents. # other places throughout the built documents.
# try:
# The short X.Y version. from virtualenv import __version__
# The short X.Y version.
release = "1.7" version = '.'.join(__version__.split('.')[:2])
version = ".".join(release.split(".")[:2]) # The full version, including alpha/beta/rc tags.
release = __version__
except ImportError:
version = release = 'dev'
# There are two options for replacing |today|: either, you set today to some # There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used: # non-false value, then it is used:
@@ -83,7 +86,7 @@ html_theme_path = ['_theme']
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css". # so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static'] # html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format. # using the given strftime format.
@@ -13,23 +13,12 @@ virtualenv
.. comment: split here .. comment: split here
Status and License Installation
------------------ ------------
``virtualenv`` is a successor to `workingenv You can install virtualenv with ``pip install virtualenv``, or the `latest
<http://cheeseshop.python.org/pypi/workingenv.py>`_, and an extension development version <https://github.com/pypa/virtualenv/tarball/develop>`_
of `virtual-python with ``pip install https://github.com/pypa/virtualenv/tarball/develop``.
<http://peak.telecommunity.com/DevCenter/EasyInstall#creating-a-virtual-python>`_.
It was written by Ian Bicking, sponsored by the `Open Planning
Project <http://openplans.org>`_ and is now maintained by a
`group of developers <https://github.com/pypa/virtualenv/raw/master/AUTHORS.txt>`_.
It is licensed under an
`MIT-style permissive license <https://github.com/pypa/virtualenv/raw/master/LICENSE.txt>`_.
You can install it with ``pip install virtualenv``, or the `latest
development version <https://github.com/pypa/virtualenv/tarball/develop#egg=virtualenv-dev>`_
with ``pip install virtualenv==dev``.
You can also use ``easy_install``, or if you have no Python package manager You can also use ``easy_install``, or if you have no Python package manager
available at all, you can just grab the single file `virtualenv.py`_ and run available at all, you can just grab the single file `virtualenv.py`_ and run
@@ -37,7 +26,6 @@ it with ``python virtualenv.py``.
.. _virtualenv.py: https://raw.github.com/pypa/virtualenv/master/virtualenv.py .. _virtualenv.py: https://raw.github.com/pypa/virtualenv/master/virtualenv.py
What It Does What It Does
------------ ------------
@@ -64,6 +52,9 @@ environment that has its own installation directories, that doesn't
share libraries with other virtualenv environments (and optionally share libraries with other virtualenv environments (and optionally
doesn't access the globally installed libraries either). doesn't access the globally installed libraries either).
Usage
-----
The basic usage is:: The basic usage is::
$ python virtualenv.py ENV $ python virtualenv.py ENV
@@ -83,12 +74,116 @@ Distribute instead of setuptools, just call virtualenv like this::
$ python virtualenv.py --distribute ENV $ python virtualenv.py --distribute ENV
You can also set the environment variable VIRTUALENV_USE_DISTRIBUTE. You can also set the environment variable VIRTUALENV_DISTRIBUTE.
A new virtualenv also includes the `pip <http://pypy.python.org/pypi/pip>`_ A new virtualenv also includes the `pip <http://pypi.python.org/pypi/pip>`_
installer, so you can use ``ENV/bin/pip`` to install additional packages into installer, so you can use ``ENV/bin/pip`` to install additional packages into
the environment. the environment.
activate script
~~~~~~~~~~~~~~~
In a newly created virtualenv there will be a ``bin/activate`` shell
script. For Windows systems, activation scripts are provided for CMD.exe
and Powershell.
On Posix systems you can do::
$ source bin/activate
This will change your ``$PATH`` so its first entry is the virtualenv's
``bin/`` directory. (You have to use ``source`` because it changes your
shell environment in-place.) This is all it does; it's purely a
convenience. If you directly run a script or the python interpreter
from the virtualenv's ``bin/`` directory (e.g. ``path/to/env/bin/pip``
or ``/path/to/env/bin/python script.py``) there's no need for
activation.
After activating an environment you can use the function ``deactivate`` to
undo the changes to your ``$PATH``.
The ``activate`` script will also modify your shell prompt to indicate
which environment is currently active. You can disable this behavior,
which can be useful if you have your own custom prompt that already
displays the active environment name. To do so, set the
``VIRTUAL_ENV_DISABLE_PROMPT`` environment variable to any non-empty
value before running the ``activate`` script.
On Windows you just do::
> \path\to\env\Scripts\activate
And type `deactivate` to undo the changes.
Based on your active shell (CMD.exe or Powershell.exe), Windows will use
either activate.bat or activate.ps1 (as appropriate) to activate the
virtual environment. If using Powershell, see the notes about code signing
below.
.. note::
If using Powershell, the ``activate`` script is subject to the
`execution policies`_ on the system. By default on Windows 7, the system's
excution policy is set to ``Restricted``, meaning no scripts like the
``activate`` script are allowed to be executed. But that can't stop us
from changing that slightly to allow it to be executed.
In order to use the script, you have to relax your system's execution
policy to ``AllSigned``, meaning all scripts on the system must be
digitally signed to be executed. Since the virtualenv activation
script is signed by one of the authors (Jannis Leidel) this level of
the execution policy suffices. As an administrator run::
PS C:\> Set-ExecutionPolicy AllSigned
Then you'll be asked to trust the signer, when executing the script.
You will be prompted with the following::
PS C:\> virtualenv .\foo
New python executable in C:\foo\Scripts\python.exe
Installing setuptools................done.
Installing pip...................done.
PS C:\> .\foo\scripts\activate
Do you want to run software from this untrusted publisher?
File C:\foo\scripts\activate.ps1 is published by E=jannis@leidel.info,
CN=Jannis Leidel, L=Berlin, S=Berlin, C=DE, Description=581796-Gh7xfJxkxQSIO4E0
and is not trusted on your system. Only run scripts from trusted publishers.
[V] Never run [D] Do not run [R] Run once [A] Always run [?] Help
(default is "D"):A
(foo) PS C:\>
If you select ``[A] Always Run``, the certificate will be added to the
Trusted Publishers of your user account, and will be trusted in this
user's context henceforth. If you select ``[R] Run Once``, the script will
be run, but you will be prometed on a subsequent invocation. Advanced users
can add the signer's certificate to the Trusted Publishers of the Computer
account to apply to all users (though this technique is out of scope of this
document).
Alternatively, you may relax the system execution policy to allow running
of local scripts without verifying the code signature using the following::
PS C:\> Set-ExecutionPolicy RemoteSigned
Since the ``activate.ps1`` script is generated locally for each virtualenv,
it is not considered a remote script and can then be executed.
.. _`execution policies`: http://technet.microsoft.com/en-us/library/dd347641.aspx
The ``--system-site-packages`` Option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you build with ``virtualenv --system-site-packages ENV``, your virtual
environment will inherit packages from ``/usr/lib/python2.7/site-packages``
(or wherever your global site-packages directory is).
This can be used if you have control over the global site-packages directory,
and you want to depend on the packages there. If you want isolation from the
global system, do not use this flag.
Environment variables and configuration files Environment variables and configuration files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -105,7 +200,7 @@ virtualenv can not only be configured by passing command line options such as
For example, to automatically install Distribute instead of setuptools For example, to automatically install Distribute instead of setuptools
you can also set an environment variable:: you can also set an environment variable::
$ export VIRTUALENV_USE_DISTRIBUTE=true $ export VIRTUALENV_DISTRIBUTE=true
$ python virtualenv.py ENV $ python virtualenv.py ENV
It's the same as passing the option to virtualenv directly:: It's the same as passing the option to virtualenv directly::
@@ -126,7 +221,7 @@ virtualenv can not only be configured by passing command line options such as
virtualenv also looks for a standard ini config file. On Unix and Mac OS X virtualenv also looks for a standard ini config file. On Unix and Mac OS X
that's ``$HOME/.virtualenv/virtualenv.ini`` and on Windows, it's that's ``$HOME/.virtualenv/virtualenv.ini`` and on Windows, it's
``%HOME%\\virtualenv\\virtualenv.ini``. ``%APPDATA%\virtualenv\virtualenv.ini``.
The names of the settings are derived from the long command line option, The names of the settings are derived from the long command line option,
e.g. the option ``--distribute`` would look like this:: e.g. the option ``--distribute`` would look like this::
@@ -237,52 +332,9 @@ Here's a more concrete example of how you could use this::
Another example is available `here Another example is available `here
<https://github.com/socialplanning/fassembler/blob/master/fassembler/create-venv-script.py>`_. <https://github.com/socialplanning/fassembler/blob/master/fassembler/create-venv-script.py>`_.
activate script
~~~~~~~~~~~~~~~
In a newly created virtualenv there will be a ``bin/activate`` shell
script, or a ``Scripts/activate.bat`` batch file on Windows.
On Posix systems you can do::
$ source bin/activate
This will change your ``$PATH`` to point to the virtualenv's ``bin/``
directory. (You have to use ``source`` because it changes your shell
environment in-place.) This is all it does; it's purely a convenience. If
you directly run a script or the python interpreter from the virtualenv's
``bin/`` directory (e.g. ``path/to/env/bin/pip`` or
``/path/to/env/bin/python script.py``) there's no need for activation.
After activating an environment you can use the function ``deactivate`` to
undo the changes to your ``$PATH``.
The ``activate`` script will also modify your shell prompt to indicate
which environment is currently active. You can disable this behavior,
which can be useful if you have your own custom prompt that already
displays the active environment name. To do so, set the
``VIRTUAL_ENV_DISABLE_PROMPT`` environment variable to any non-empty
value before running the ``activate`` script.
On Windows you just do::
> \path\to\env\Scripts\activate.bat
And use ``deactivate.bat`` to undo the changes.
The ``--system-site-packages`` Option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you build with ``virtualenv --system-site-packages ENV``, your virtual
environment will inherit packages from ``/usr/lib/python2.7/site-packages``
(or wherever your global site-packages directory is).
This can be used if you have control over the global site-packages directory,
and you want to depend on the packages there. If you want isolation from the
global system, do not use this flag.
Using Virtualenv without ``bin/python`` Using Virtualenv without ``bin/python``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ---------------------------------------
Sometimes you can't or don't want to use the Python interpreter Sometimes you can't or don't want to use the Python interpreter
created by the virtualenv. For instance, in a `mod_python created by the virtualenv. For instance, in a `mod_python
@@ -308,7 +360,7 @@ request; you should activate *one* environment as early as possible, and not
do it again in that process. do it again in that process.
Making Environments Relocatable Making Environments Relocatable
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -------------------------------
Note: this option is somewhat experimental, and there are probably Note: this option is somewhat experimental, and there are probably
caveats that have not yet been identified. Also this does not caveats that have not yet been identified. Also this does not
@@ -345,16 +397,16 @@ layout).
If you use this flag to create an environment, currently, the If you use this flag to create an environment, currently, the
``--system-site-packages`` option will be implied. ``--system-site-packages`` option will be implied.
The ``--extra-search-dir`` Option The ``--extra-search-dir`` option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ---------------------------------
When it creates a new environment, virtualenv installs either When it creates a new environment, virtualenv installs either setuptools
setuptools or distribute, and pip. In normal operation, the latest or distribute, and pip. In normal operation when virtualenv is
installed, the bundled version of these packages included in the
``virtualenv_support`` directory is used. When ``virtualenv.py`` is run
standalone and ``virtualenv_support`` is not available, the latest
releases of these packages are fetched from the `Python Package Index releases of these packages are fetched from the `Python Package Index
<http://pypi.python.org>`_ (PyPI). In some circumstances, this <http://pypi.python.org>`_ (PyPI).
behavior may not be wanted, for example if you are using virtualenv
during a deployment and do not want to depend on Internet access and
PyPI availability.
As an alternative, you can provide your own versions of setuptools, As an alternative, you can provide your own versions of setuptools,
distribute and/or pip on the filesystem, and tell virtualenv to use distribute and/or pip on the filesystem, and tell virtualenv to use
@@ -366,8 +418,9 @@ virtualenv like this::
The ``/path/to/distributions`` path should point to a directory that The ``/path/to/distributions`` path should point to a directory that
contains setuptools, distribute and/or pip distributions. Setuptools contains setuptools, distribute and/or pip distributions. Setuptools
distributions must be ``.egg`` files; distribute and pip distributions distributions must be ``.egg`` files; pip distributions should be
should be `.tar.gz` source distributions. `.tar.gz` source distributions, and distribute distributions may be
either (if found an egg will be used preferentially).
Virtualenv will still download these packages if no satisfactory local Virtualenv will still download these packages if no satisfactory local
distributions are found. distributions are found.
@@ -381,7 +434,17 @@ provide an option ``--never-download`` like so::
If this option is provided, virtualenv will never try to download If this option is provided, virtualenv will never try to download
setuptools/distribute or pip. Instead, it will exit with status code 1 setuptools/distribute or pip. Instead, it will exit with status code 1
if it fails to find local distributions for any of these required if it fails to find local distributions for any of these required
packages. packages. The local distribution lookup is done in the following
locations, with the most recent version found used:
#. The current directory.
#. The directory where virtualenv.py is located.
#. A ``virtualenv_support`` directory relative to the directory where
virtualenv.py is located.
#. If the file being executed is not named virtualenv.py (i.e. is a boot
script), a ``virtualenv_support`` directory relative to wherever
virtualenv.py is actually installed.
Compare & Contrast with Alternatives Compare & Contrast with Alternatives
------------------------------------ ------------------------------------
@@ -425,13 +488,22 @@ Contributing
------------ ------------
Refer to the `contributing to pip`_ documentation - it applies equally to Refer to the `contributing to pip`_ documentation - it applies equally to
virtualenv. virtualenv, except that virtualenv issues should filed on the `virtualenv
repo`_ at GitHub.
Virtualenv's release schedule is tied to pip's -- each time there's a new pip Virtualenv's release schedule is tied to pip's -- each time there's a new pip
release, there will be a new virtualenv release that bundles the new version of release, there will be a new virtualenv release that bundles the new version of
pip. pip.
.. _contributing to pip: http://www.pip-installer.org/en/latest/how-to-contribute.html Files in the `virtualenv_embedded/` subdirectory are embedded into
`virtualenv.py` itself as base64-encoded strings (in order to support
single-file use of `virtualenv.py` without installing it). If your patch
changes any file in `virtualenv_embedded/`, run `bin/rebuild-script.py` to
update the embedded version of that file in `virtualenv.py`; commit that and
submit it as part of your patch / pull request.
.. _contributing to pip: http://www.pip-installer.org/en/latest/contributing.html
.. _virtualenv repo: https://github.com/pypa/virtualenv/
Running the tests Running the tests
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
@@ -483,5 +555,19 @@ Other Documentation and Links
<http://code.google.com/p/modwsgi/wiki/VirtualEnvironments>`_. <http://code.google.com/p/modwsgi/wiki/VirtualEnvironments>`_.
* `virtualenv commands * `virtualenv commands
<http://thisismedium.com/tech/extending-virtualenv/>`_ for some more <https://github.com/thisismedium/virtualenv-commands>`_ for some more
workflow-related tools around virtualenv. workflow-related tools around virtualenv.
Status and License
------------------
``virtualenv`` is a successor to `workingenv
<http://cheeseshop.python.org/pypi/workingenv.py>`_, and an extension
of `virtual-python
<http://peak.telecommunity.com/DevCenter/EasyInstall#creating-a-virtual-python>`_.
It was written by Ian Bicking, sponsored by the `Open Planning
Project <http://openplans.org>`_ and is now maintained by a
`group of developers <https://github.com/pypa/virtualenv/raw/master/AUTHORS.txt>`_.
It is licensed under an
`MIT-style permissive license <https://github.com/pypa/virtualenv/raw/master/LICENSE.txt>`_.
@@ -1,10 +1,193 @@
Changes & News Changes & News
-------------- --------------
.. warning::
Python bugfix releases 2.6.8, 2.7.3, 3.1.5 and 3.2.3 include a change that
will cause "import random" to fail with "cannot import name urandom" on any
virtualenv created on a Unix host with an earlier release of Python
2.6/2.7/3.1/3.2, if the underlying system Python is upgraded. This is due to
the fact that a virtualenv uses the system Python's standard library but
contains its own copy of the Python interpreter, so an upgrade to the system
Python results in a mismatch between the version of the Python interpreter
and the version of the standard library. It can be fixed by removing
``$ENV/bin/python`` and re-running virtualenv on the same target directory
with the upgraded Python.
1.8.4 (2012-11-25)
~~~~~~~~~~~~~~~~~~
* Updated distribute to 0.6.31. This fixes #359 (numpy install regression) on
UTF-8 platforms, and provides a workaround on other platforms:
``PYTHONIOENCODING=utf8 pip install numpy``.
* When installing virtualenv via curl, don't forget to filter out arguments
the distribute setup script won't understand. Fixes #358.
* Added some more integration tests.
1.8.3 (2012-11-21)
~~~~~~~~~~~~~~~~~~
* Fixed readline on OS X. Thanks minrk
* Updated distribute to 0.6.30 (improves our error reporting, plus new
distribute features and fixes). Thanks Gabriel (g2p)
* Added compatibility with multiarch Python (Python 3.3 for example). Added an
integration test. Thanks Gabriel (g2p)
* Added ability to install distribute from a user-provided egg, rather than the
bundled sdist, for better speed. Thanks Paul Moore.
* Make the creation of lib64 symlink smarter about already-existing symlink,
and more explicit about full paths. Fixes #334 and #330. Thanks Jeremy Orem.
* Give lib64 site-dir preference over lib on 64-bit systems, to avoid wrong
32-bit compiles in the venv. Fixes #328. Thanks Damien Nozay.
* Fix a bug with prompt-handling in ``activate.csh`` in non-interactive csh
shells. Fixes #332. Thanks Benjamin Root for report and patch.
* Make it possible to create a virtualenv from within a Python
3.3. pyvenv. Thanks Chris McDonough for the report.
* Add optional --setuptools option to be able to switch to it in case
distribute is the default (like in Debian).
1.8.2 (2012-09-06)
~~~~~~~~~~~~~~~~~~
* Updated the included pip version to 1.2.1 to fix regressions introduced
there in 1.2.
1.8.1 (2012-09-03)
~~~~~~~~~~~~~~~~~~
* Fixed distribute version used with `--never-download`. Thanks michr for
report and patch.
* Fix creating Python 3.3 based virtualenvs by unsetting the
``__PYVENV_LAUNCHER__`` environment variable in subprocesses.
1.8 (2012-09-01)
~~~~~~~~~~~~~~~~
* **Dropped support for Python 2.4** The minimum supported Python version is
now Python 2.5.
* Fix `--relocatable` on systems that use lib64. Fixes #78. Thanks Branden
Rolston.
* Symlink some additional modules under Python 3. Fixes #194. Thanks Vinay
Sajip, Ian Clelland, and Stefan Holek for the report.
* Fix ``--relocatable`` when a script uses ``__future__`` imports. Thanks
Branden Rolston.
* Fix a bug in the config option parser that prevented setting negative
options with environemnt variables. Thanks Ralf Schmitt.
* Allow setting ``--no-site-packages`` from the config file.
* Use ``/usr/bin/multiarch-platform`` if available to figure out the include
directory. Thanks for the patch, Mika Laitio.
* Fix ``install_name_tool`` replacement to work on Python 3.X.
* Handle paths of users' site-packages on Mac OS X correctly when changing
the prefix.
* Updated the embedded version of distribute to 0.6.28 and pip to 1.2.
1.7.2 (2012-06-22)
~~~~~~~~~~~~~~~~~~
* Updated to distribute 0.6.27.
* Fix activate.fish on OS X. Fixes #8. Thanks David Schoonover.
* Create a virtualenv-x.x script with the Python version when installing, so
virtualenv for multiple Python versions can be installed to the same
script location. Thanks Miki Tebeka.
* Restored ability to create a virtualenv with a path longer than 78
characters, without breaking creation of virtualenvs with non-ASCII paths.
Thanks, Bradley Ayers.
* Added ability to create virtualenvs without having installed Apple's
developers tools (using an own implementation of ``install_name_tool``).
Thanks Mike Hommey.
* Fixed PyPy and Jython support on Windows. Thanks Konstantin Zemlyak.
* Added pydoc script to ease use. Thanks Marc Abramowitz. Fixes #149.
* Fixed creating a bootstrap script on Python 3. Thanks Raul Leal. Fixes #280.
* Fixed inconsistency when having set the ``PYTHONDONTWRITEBYTECODE`` env var
with the --distribute option or the ``VIRTUALENV_USE_DISTRIBUTE`` env var.
``VIRTUALENV_USE_DISTRIBUTE`` is now considered again as a legacy alias.
1.7.1.2 (2012-02-17)
~~~~~~~~~~~~~~~~~~~~
* Fixed minor issue in `--relocatable`. Thanks, Cap Petschulat.
1.7.1.1 (2012-02-16)
~~~~~~~~~~~~~~~~~~~~
* Bumped the version string in ``virtualenv.py`` up, too.
* Fixed rST rendering bug of long description.
1.7.1 (2012-02-16)
~~~~~~~~~~~~~~~~~~
* Update embedded pip to version 1.1.
* Fix `--relocatable` under Python 3. Thanks Doug Hellmann.
* Added environ PATH modification to activate_this.py. Thanks Doug
Napoleone. Fixes #14.
* Support creating virtualenvs directly from a Python build directory on
Windows. Thanks CBWhiz. Fixes #139.
* Use non-recursive symlinks to fix things up for posix_local install
scheme. Thanks michr.
* Made activate script available for use with msys and cygwin on Windows.
Thanks Greg Haskins, Cliff Xuan, Jonathan Griffin and Doug Napoleone.
Fixes #176.
* Fixed creation of virtualenvs on Windows when Python is not installed for
all users. Thanks Anatoly Techtonik for report and patch and Doug
Napoleone for testing and confirmation. Fixes #87.
* Fixed creation of virtualenvs using -p in installs where some modules
that ought to be in the standard library (e.g. `readline`) are actually
installed in `site-packages` next to `virtualenv.py`. Thanks Greg Haskins
for report and fix. Fixes #167.
* Added activation script for Powershell (signed by Jannis Leidel). Many
thanks to Jason R. Coombs.
1.7 (2011-11-30) 1.7 (2011-11-30)
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
* Updated embedded Distribute release to 0.6.24. Thanks Alex Grönholm. * Gave user-provided ``--extra-search-dir`` priority over default dirs for
finding setuptools/distribute (it already had priority for finding pip).
Thanks Ethan Jucovy.
* Updated embedded Distribute release to 0.6.24. Thanks Alex Gronholm.
* Made ``--no-site-packages`` behavior the default behavior. The * Made ``--no-site-packages`` behavior the default behavior. The
``--no-site-packages`` flag is still permitted, but displays a warning when ``--no-site-packages`` flag is still permitted, but displays a warning when
@@ -20,16 +203,19 @@ Changes & News
* Made ``virtualenv.py`` script executable. * Made ``virtualenv.py`` script executable.
1.6.4 (2011-07-21) 1.6.4 (2011-07-21)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
* Restored ability to run on Python 2.4, too. * Restored ability to run on Python 2.4, too.
1.6.3 (2011-07-16) 1.6.3 (2011-07-16)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
* Restored ability to run on Python < 2.7. * Restored ability to run on Python < 2.7.
1.6.2 (2011-07-16) 1.6.2 (2011-07-16)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
@@ -64,6 +250,7 @@ Changes & News
* Added --never-download and --search-dir options. Thanks Ethan Jucovy. * Added --never-download and --search-dir options. Thanks Ethan Jucovy.
1.6 1.6
~~~ ~~~
@@ -74,6 +261,7 @@ Changes & News
* Updated bundled pip to 1.0. * Updated bundled pip to 1.0.
1.5.2 1.5.2
~~~~~ ~~~~~
@@ -89,6 +277,7 @@ Changes & News
* Moved virtualenv to Github at https://github.com/pypa/virtualenv * Moved virtualenv to Github at https://github.com/pypa/virtualenv
1.5.1 1.5.1
~~~~~ ~~~~~
@@ -96,6 +285,7 @@ Changes & News
* Fixed Windows regression in 1.5 * Fixed Windows regression in 1.5
1.5 1.5
~~~ ~~~
@@ -113,11 +303,13 @@ Changes & News
* Add fish and csh activate scripts. * Add fish and csh activate scripts.
1.4.9 1.4.9
~~~~~ ~~~~~
* Include pip 0.7.2 * Include pip 0.7.2
1.4.8 1.4.8
~~~~~ ~~~~~
@@ -132,17 +324,20 @@ Changes & News
* Include pip 0.7.1 * Include pip 0.7.1
1.4.7 1.4.7
~~~~~ ~~~~~
* Include pip 0.7 * Include pip 0.7
1.4.6 1.4.6
~~~~~ ~~~~~
* Allow ``activate.sh`` to skip updating the prompt (by setting * Allow ``activate.sh`` to skip updating the prompt (by setting
``$VIRTUAL_ENV_DISABLE_PROMPT``). ``$VIRTUAL_ENV_DISABLE_PROMPT``).
1.4.5 1.4.5
~~~~~ ~~~~~
@@ -151,6 +346,7 @@ Changes & News
* Fix ``activate.bat`` and ``deactivate.bat`` under Windows when * Fix ``activate.bat`` and ``deactivate.bat`` under Windows when
``PATH`` contained a parenthesis ``PATH`` contained a parenthesis
1.4.4 1.4.4
~~~~~ ~~~~~
@@ -162,15 +358,17 @@ Changes & News
* Fix problem with ``virtualenv --relocate`` when ``bin/`` has * Fix problem with ``virtualenv --relocate`` when ``bin/`` has
subdirectories (e.g., ``bin/.svn/``); from Alan Franzoni. subdirectories (e.g., ``bin/.svn/``); from Alan Franzoni.
* If you set ``$VIRTUALENV_USE_DISTRIBUTE`` then virtualenv will use * If you set ``$VIRTUALENV_DISTRIBUTE`` then virtualenv will use
Distribute by default (so you don't have to remember to use Distribute by default (so you don't have to remember to use
``--distribute``). ``--distribute``).
1.4.3 1.4.3
~~~~~ ~~~~~
* Include pip 0.6.1 * Include pip 0.6.1
1.4.2 1.4.2
~~~~~ ~~~~~
@@ -181,11 +379,13 @@ Changes & News
* Exclude ~/.local (user site-packages) from environments when using * Exclude ~/.local (user site-packages) from environments when using
``--no-site-packages`` ``--no-site-packages``
1.4.1 1.4.1
~~~~~ ~~~~~
* Include pip 0.6 * Include pip 0.6
1.4 1.4
~~~ ~~~
@@ -195,6 +395,7 @@ Changes & News
* Fixed packaging problem of support-files * Fixed packaging problem of support-files
1.3.4 1.3.4
~~~~~ ~~~~~
@@ -224,6 +425,7 @@ Changes & News
* Fixes for ``--python``: make it work with ``--relocatable`` and the * Fixes for ``--python``: make it work with ``--relocatable`` and the
symlink created to the exact Python version. symlink created to the exact Python version.
1.3.3 1.3.3
~~~~~ ~~~~~
@@ -246,6 +448,7 @@ Changes & News
<https://bugs.launchpad.net/virtualenv/+bug/340050>`_ picking up <https://bugs.launchpad.net/virtualenv/+bug/340050>`_ picking up
some ``.so`` libraries in ``/usr/local``. some ``.so`` libraries in ``/usr/local``.
1.3.2 1.3.2
~~~~~ ~~~~~
@@ -253,11 +456,12 @@ Changes & News
``distutils.cfg`` -- this has been causing problems for a lot of ``distutils.cfg`` -- this has been causing problems for a lot of
people, in rather obscure ways. people, in rather obscure ways.
* If you use a `boot script <./index.html#boot-script>`_ it will attempt to import ``virtualenv`` * If you use a boot script it will attempt to import ``virtualenv``
and find a pre-downloaded Setuptools egg using that. and find a pre-downloaded Setuptools egg using that.
* Added platform-specific paths, like ``/usr/lib/pythonX.Y/plat-linux2`` * Added platform-specific paths, like ``/usr/lib/pythonX.Y/plat-linux2``
1.3.1 1.3.1
~~~~~ ~~~~~
@@ -280,6 +484,7 @@ Changes & News
* Fixed handling of Jython environments that use a * Fixed handling of Jython environments that use a
jython-complete.jar. jython-complete.jar.
1.3 1.3
~~~ ~~~
@@ -306,6 +511,7 @@ Changes & News
* Fixed the ``__classpath__`` entry in Jython's ``sys.path`` taking * Fixed the ``__classpath__`` entry in Jython's ``sys.path`` taking
precedent over virtualenv's libs. precedent over virtualenv's libs.
1.2 1.2
~~~ ~~~
@@ -314,11 +520,13 @@ Changes & News
* Add ``sets`` to the module copied over for Python 2.3 (though Python * Add ``sets`` to the module copied over for Python 2.3 (though Python
2.3 still probably doesn't work). 2.3 still probably doesn't work).
1.1.1 1.1.1
~~~~~ ~~~~~
* Added support for Jython 2.5. * Added support for Jython 2.5.
1.1 1.1
~~~ ~~~
@@ -333,6 +541,7 @@ Changes & News
* Copy or symlink over the ``include`` directory so that packages will * Copy or symlink over the ``include`` directory so that packages will
more consistently compile. more consistently compile.
1.0 1.0
~~~ ~~~
@@ -342,6 +551,7 @@ Changes & News
* Fixed typos in ``deactivate.bat``. * Fixed typos in ``deactivate.bat``.
* Preserve ``$PYTHONPATH`` when calling subprocesses. * Preserve ``$PYTHONPATH`` when calling subprocesses.
0.9.2 0.9.2
~~~~~ ~~~~~
@@ -356,6 +566,7 @@ Changes & News
* Fixed an issue with Mac Framework Python builds, and absolute paths * Fixed an issue with Mac Framework Python builds, and absolute paths
(from Ronald Oussoren). (from Ronald Oussoren).
0.9.1 0.9.1
~~~~~ ~~~~~
@@ -363,6 +574,7 @@ Changes & News
* Fix a little bug in ``bin/activate``. * Fix a little bug in ``bin/activate``.
* Actually get ``distutils.cfg`` to work reliably. * Actually get ``distutils.cfg`` to work reliably.
0.9 0.9
~~~ ~~~
@@ -378,6 +590,7 @@ Changes & News
* Should work on MacOSX Framework builds (the default Python * Should work on MacOSX Framework builds (the default Python
installations on Mac). Thanks to Ronald Oussoren. installations on Mac). Thanks to Ronald Oussoren.
0.8.4 0.8.4
~~~~~ ~~~~~
@@ -385,11 +598,13 @@ Changes & News
were inaccurate. were inaccurate.
* Slightly prettier output. * Slightly prettier output.
0.8.3 0.8.3
~~~~~ ~~~~~
* Added support for Windows. * Added support for Windows.
0.8.2 0.8.2
~~~~~ ~~~~~
@@ -398,11 +613,13 @@ Changes & News
* Give error about running while inside a workingenv. * Give error about running while inside a workingenv.
* Give better error message about Python 2.3. * Give better error message about Python 2.3.
0.8.1 0.8.1
~~~~~ ~~~~~
Fixed packaging of the library. Fixed packaging of the library.
0.8 0.8
~~~ ~~~
+91
View File
@@ -0,0 +1,91 @@
import os
import re
import shutil
import sys
try:
from setuptools import setup
setup_params = {
'entry_points': {
'console_scripts': [
'virtualenv=virtualenv:main',
'virtualenv-%s.%s=virtualenv:main' % sys.version_info[:2]
],
},
'zip_safe': False,
'test_suite': 'nose.collector',
'tests_require': ['nose', 'Mock'],
}
except ImportError:
from distutils.core import setup
if sys.platform == 'win32':
print('Note: without Setuptools installed you will have to use "python -m virtualenv ENV"')
setup_params = {}
else:
script = 'scripts/virtualenv'
script_ver = script + '-%s.%s' % sys.version_info[:2]
shutil.copy(script, script_ver)
setup_params = {'scripts': [script, script_ver]}
here = os.path.dirname(os.path.abspath(__file__))
## Get long_description from index.txt:
f = open(os.path.join(here, 'docs', 'index.txt'))
long_description = f.read().strip()
long_description = long_description.split('split here', 1)[1]
f.close()
f = open(os.path.join(here, 'docs', 'news.txt'))
long_description += "\n\n" + f.read()
f.close()
def get_version():
f = open(os.path.join(here, 'virtualenv.py'))
version_file = f.read()
f.close()
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")
# Hack to prevent stupid TypeError: 'NoneType' object is not callable error on
# exit of python setup.py test # in multiprocessing/util.py _exit_function when
# running python setup.py test (see
# http://www.eby-sarna.com/pipermail/peak/2010-May/003357.html)
try:
import multiprocessing
except ImportError:
pass
setup(
name='virtualenv',
# If you change the version here, change it in virtualenv.py and
# docs/conf.py as well
version=get_version(),
description="Virtual Python Environment builder",
long_description=long_description,
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.5',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.1',
'Programming Language :: Python :: 3.2',
],
keywords='setuptools deployment installation distutils',
author='Ian Bicking',
author_email='ianb@colorstudy.com',
maintainer='Jannis Leidel, Carl Meyer and Brian Rosner',
maintainer_email='python-virtualenv@groups.google.com',
url='http://www.virtualenv.org',
license='MIT',
py_modules=['virtualenv'],
packages=['virtualenv_support'],
package_data={'virtualenv_support': ['*-py%s.egg' % sys.version[:3], '*.tar.gz']},
**setup_params)
@@ -1,6 +1,6 @@
Metadata-Version: 1.0 Metadata-Version: 1.1
Name: virtualenv Name: virtualenv
Version: 1.7 Version: 1.8.4
Summary: Virtual Python Environment builder Summary: Virtual Python Environment builder
Home-page: http://www.virtualenv.org Home-page: http://www.virtualenv.org
Author: Jannis Leidel, Carl Meyer and Brian Rosner Author: Jannis Leidel, Carl Meyer and Brian Rosner
@@ -8,23 +8,12 @@ Author-email: python-virtualenv@groups.google.com
License: MIT License: MIT
Description: Description:
Status and License Installation
------------------ ------------
``virtualenv`` is a successor to `workingenv You can install virtualenv with ``pip install virtualenv``, or the `latest
<http://cheeseshop.python.org/pypi/workingenv.py>`_, and an extension development version <https://github.com/pypa/virtualenv/tarball/develop>`_
of `virtual-python with ``pip install https://github.com/pypa/virtualenv/tarball/develop``.
<http://peak.telecommunity.com/DevCenter/EasyInstall#creating-a-virtual-python>`_.
It was written by Ian Bicking, sponsored by the `Open Planning
Project <http://openplans.org>`_ and is now maintained by a
`group of developers <https://github.com/pypa/virtualenv/raw/master/AUTHORS.txt>`_.
It is licensed under an
`MIT-style permissive license <https://github.com/pypa/virtualenv/raw/master/LICENSE.txt>`_.
You can install it with ``pip install virtualenv``, or the `latest
development version <https://github.com/pypa/virtualenv/tarball/develop#egg=virtualenv-dev>`_
with ``pip install virtualenv==dev``.
You can also use ``easy_install``, or if you have no Python package manager You can also use ``easy_install``, or if you have no Python package manager
available at all, you can just grab the single file `virtualenv.py`_ and run available at all, you can just grab the single file `virtualenv.py`_ and run
@@ -32,7 +21,6 @@ Description:
.. _virtualenv.py: https://raw.github.com/pypa/virtualenv/master/virtualenv.py .. _virtualenv.py: https://raw.github.com/pypa/virtualenv/master/virtualenv.py
What It Does What It Does
------------ ------------
@@ -59,6 +47,9 @@ Description:
share libraries with other virtualenv environments (and optionally share libraries with other virtualenv environments (and optionally
doesn't access the globally installed libraries either). doesn't access the globally installed libraries either).
Usage
-----
The basic usage is:: The basic usage is::
$ python virtualenv.py ENV $ python virtualenv.py ENV
@@ -78,12 +69,116 @@ Description:
$ python virtualenv.py --distribute ENV $ python virtualenv.py --distribute ENV
You can also set the environment variable VIRTUALENV_USE_DISTRIBUTE. You can also set the environment variable VIRTUALENV_DISTRIBUTE.
A new virtualenv also includes the `pip <http://pypy.python.org/pypi/pip>`_ A new virtualenv also includes the `pip <http://pypi.python.org/pypi/pip>`_
installer, so you can use ``ENV/bin/pip`` to install additional packages into installer, so you can use ``ENV/bin/pip`` to install additional packages into
the environment. the environment.
activate script
~~~~~~~~~~~~~~~
In a newly created virtualenv there will be a ``bin/activate`` shell
script. For Windows systems, activation scripts are provided for CMD.exe
and Powershell.
On Posix systems you can do::
$ source bin/activate
This will change your ``$PATH`` so its first entry is the virtualenv's
``bin/`` directory. (You have to use ``source`` because it changes your
shell environment in-place.) This is all it does; it's purely a
convenience. If you directly run a script or the python interpreter
from the virtualenv's ``bin/`` directory (e.g. ``path/to/env/bin/pip``
or ``/path/to/env/bin/python script.py``) there's no need for
activation.
After activating an environment you can use the function ``deactivate`` to
undo the changes to your ``$PATH``.
The ``activate`` script will also modify your shell prompt to indicate
which environment is currently active. You can disable this behavior,
which can be useful if you have your own custom prompt that already
displays the active environment name. To do so, set the
``VIRTUAL_ENV_DISABLE_PROMPT`` environment variable to any non-empty
value before running the ``activate`` script.
On Windows you just do::
> \path\to\env\Scripts\activate
And type `deactivate` to undo the changes.
Based on your active shell (CMD.exe or Powershell.exe), Windows will use
either activate.bat or activate.ps1 (as appropriate) to activate the
virtual environment. If using Powershell, see the notes about code signing
below.
.. note::
If using Powershell, the ``activate`` script is subject to the
`execution policies`_ on the system. By default on Windows 7, the system's
excution policy is set to ``Restricted``, meaning no scripts like the
``activate`` script are allowed to be executed. But that can't stop us
from changing that slightly to allow it to be executed.
In order to use the script, you have to relax your system's execution
policy to ``AllSigned``, meaning all scripts on the system must be
digitally signed to be executed. Since the virtualenv activation
script is signed by one of the authors (Jannis Leidel) this level of
the execution policy suffices. As an administrator run::
PS C:\> Set-ExecutionPolicy AllSigned
Then you'll be asked to trust the signer, when executing the script.
You will be prompted with the following::
PS C:\> virtualenv .\foo
New python executable in C:\foo\Scripts\python.exe
Installing setuptools................done.
Installing pip...................done.
PS C:\> .\foo\scripts\activate
Do you want to run software from this untrusted publisher?
File C:\foo\scripts\activate.ps1 is published by E=jannis@leidel.info,
CN=Jannis Leidel, L=Berlin, S=Berlin, C=DE, Description=581796-Gh7xfJxkxQSIO4E0
and is not trusted on your system. Only run scripts from trusted publishers.
[V] Never run [D] Do not run [R] Run once [A] Always run [?] Help
(default is "D"):A
(foo) PS C:\>
If you select ``[A] Always Run``, the certificate will be added to the
Trusted Publishers of your user account, and will be trusted in this
user's context henceforth. If you select ``[R] Run Once``, the script will
be run, but you will be prometed on a subsequent invocation. Advanced users
can add the signer's certificate to the Trusted Publishers of the Computer
account to apply to all users (though this technique is out of scope of this
document).
Alternatively, you may relax the system execution policy to allow running
of local scripts without verifying the code signature using the following::
PS C:\> Set-ExecutionPolicy RemoteSigned
Since the ``activate.ps1`` script is generated locally for each virtualenv,
it is not considered a remote script and can then be executed.
.. _`execution policies`: http://technet.microsoft.com/en-us/library/dd347641.aspx
The ``--system-site-packages`` Option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you build with ``virtualenv --system-site-packages ENV``, your virtual
environment will inherit packages from ``/usr/lib/python2.7/site-packages``
(or wherever your global site-packages directory is).
This can be used if you have control over the global site-packages directory,
and you want to depend on the packages there. If you want isolation from the
global system, do not use this flag.
Environment variables and configuration files Environment variables and configuration files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -100,7 +195,7 @@ Description:
For example, to automatically install Distribute instead of setuptools For example, to automatically install Distribute instead of setuptools
you can also set an environment variable:: you can also set an environment variable::
$ export VIRTUALENV_USE_DISTRIBUTE=true $ export VIRTUALENV_DISTRIBUTE=true
$ python virtualenv.py ENV $ python virtualenv.py ENV
It's the same as passing the option to virtualenv directly:: It's the same as passing the option to virtualenv directly::
@@ -121,7 +216,7 @@ Description:
virtualenv also looks for a standard ini config file. On Unix and Mac OS X virtualenv also looks for a standard ini config file. On Unix and Mac OS X
that's ``$HOME/.virtualenv/virtualenv.ini`` and on Windows, it's that's ``$HOME/.virtualenv/virtualenv.ini`` and on Windows, it's
``%HOME%\\virtualenv\\virtualenv.ini``. ``%APPDATA%\virtualenv\virtualenv.ini``.
The names of the settings are derived from the long command line option, The names of the settings are derived from the long command line option,
e.g. the option ``--distribute`` would look like this:: e.g. the option ``--distribute`` would look like this::
@@ -232,52 +327,9 @@ Description:
Another example is available `here Another example is available `here
<https://github.com/socialplanning/fassembler/blob/master/fassembler/create-venv-script.py>`_. <https://github.com/socialplanning/fassembler/blob/master/fassembler/create-venv-script.py>`_.
activate script
~~~~~~~~~~~~~~~
In a newly created virtualenv there will be a ``bin/activate`` shell
script, or a ``Scripts/activate.bat`` batch file on Windows.
On Posix systems you can do::
$ source bin/activate
This will change your ``$PATH`` to point to the virtualenv's ``bin/``
directory. (You have to use ``source`` because it changes your shell
environment in-place.) This is all it does; it's purely a convenience. If
you directly run a script or the python interpreter from the virtualenv's
``bin/`` directory (e.g. ``path/to/env/bin/pip`` or
``/path/to/env/bin/python script.py``) there's no need for activation.
After activating an environment you can use the function ``deactivate`` to
undo the changes to your ``$PATH``.
The ``activate`` script will also modify your shell prompt to indicate
which environment is currently active. You can disable this behavior,
which can be useful if you have your own custom prompt that already
displays the active environment name. To do so, set the
``VIRTUAL_ENV_DISABLE_PROMPT`` environment variable to any non-empty
value before running the ``activate`` script.
On Windows you just do::
> \path\to\env\Scripts\activate.bat
And use ``deactivate.bat`` to undo the changes.
The ``--system-site-packages`` Option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you build with ``virtualenv --system-site-packages ENV``, your virtual
environment will inherit packages from ``/usr/lib/python2.7/site-packages``
(or wherever your global site-packages directory is).
This can be used if you have control over the global site-packages directory,
and you want to depend on the packages there. If you want isolation from the
global system, do not use this flag.
Using Virtualenv without ``bin/python`` Using Virtualenv without ``bin/python``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ---------------------------------------
Sometimes you can't or don't want to use the Python interpreter Sometimes you can't or don't want to use the Python interpreter
created by the virtualenv. For instance, in a `mod_python created by the virtualenv. For instance, in a `mod_python
@@ -303,7 +355,7 @@ Description:
do it again in that process. do it again in that process.
Making Environments Relocatable Making Environments Relocatable
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -------------------------------
Note: this option is somewhat experimental, and there are probably Note: this option is somewhat experimental, and there are probably
caveats that have not yet been identified. Also this does not caveats that have not yet been identified. Also this does not
@@ -340,16 +392,16 @@ Description:
If you use this flag to create an environment, currently, the If you use this flag to create an environment, currently, the
``--system-site-packages`` option will be implied. ``--system-site-packages`` option will be implied.
The ``--extra-search-dir`` Option The ``--extra-search-dir`` option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ---------------------------------
When it creates a new environment, virtualenv installs either When it creates a new environment, virtualenv installs either setuptools
setuptools or distribute, and pip. In normal operation, the latest or distribute, and pip. In normal operation when virtualenv is
installed, the bundled version of these packages included in the
``virtualenv_support`` directory is used. When ``virtualenv.py`` is run
standalone and ``virtualenv_support`` is not available, the latest
releases of these packages are fetched from the `Python Package Index releases of these packages are fetched from the `Python Package Index
<http://pypi.python.org>`_ (PyPI). In some circumstances, this <http://pypi.python.org>`_ (PyPI).
behavior may not be wanted, for example if you are using virtualenv
during a deployment and do not want to depend on Internet access and
PyPI availability.
As an alternative, you can provide your own versions of setuptools, As an alternative, you can provide your own versions of setuptools,
distribute and/or pip on the filesystem, and tell virtualenv to use distribute and/or pip on the filesystem, and tell virtualenv to use
@@ -361,8 +413,9 @@ Description:
The ``/path/to/distributions`` path should point to a directory that The ``/path/to/distributions`` path should point to a directory that
contains setuptools, distribute and/or pip distributions. Setuptools contains setuptools, distribute and/or pip distributions. Setuptools
distributions must be ``.egg`` files; distribute and pip distributions distributions must be ``.egg`` files; pip distributions should be
should be `.tar.gz` source distributions. `.tar.gz` source distributions, and distribute distributions may be
either (if found an egg will be used preferentially).
Virtualenv will still download these packages if no satisfactory local Virtualenv will still download these packages if no satisfactory local
distributions are found. distributions are found.
@@ -376,7 +429,17 @@ Description:
If this option is provided, virtualenv will never try to download If this option is provided, virtualenv will never try to download
setuptools/distribute or pip. Instead, it will exit with status code 1 setuptools/distribute or pip. Instead, it will exit with status code 1
if it fails to find local distributions for any of these required if it fails to find local distributions for any of these required
packages. packages. The local distribution lookup is done in the following
locations, with the most recent version found used:
#. The current directory.
#. The directory where virtualenv.py is located.
#. A ``virtualenv_support`` directory relative to the directory where
virtualenv.py is located.
#. If the file being executed is not named virtualenv.py (i.e. is a boot
script), a ``virtualenv_support`` directory relative to wherever
virtualenv.py is actually installed.
Compare & Contrast with Alternatives Compare & Contrast with Alternatives
------------------------------------ ------------------------------------
@@ -420,13 +483,22 @@ Description:
------------ ------------
Refer to the `contributing to pip`_ documentation - it applies equally to Refer to the `contributing to pip`_ documentation - it applies equally to
virtualenv. virtualenv, except that virtualenv issues should filed on the `virtualenv
repo`_ at GitHub.
Virtualenv's release schedule is tied to pip's -- each time there's a new pip Virtualenv's release schedule is tied to pip's -- each time there's a new pip
release, there will be a new virtualenv release that bundles the new version of release, there will be a new virtualenv release that bundles the new version of
pip. pip.
.. _contributing to pip: http://www.pip-installer.org/en/latest/how-to-contribute.html Files in the `virtualenv_embedded/` subdirectory are embedded into
`virtualenv.py` itself as base64-encoded strings (in order to support
single-file use of `virtualenv.py` without installing it). If your patch
changes any file in `virtualenv_embedded/`, run `bin/rebuild-script.py` to
update the embedded version of that file in `virtualenv.py`; commit that and
submit it as part of your patch / pull request.
.. _contributing to pip: http://www.pip-installer.org/en/latest/contributing.html
.. _virtualenv repo: https://github.com/pypa/virtualenv/
Running the tests Running the tests
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
@@ -478,16 +550,213 @@ Description:
<http://code.google.com/p/modwsgi/wiki/VirtualEnvironments>`_. <http://code.google.com/p/modwsgi/wiki/VirtualEnvironments>`_.
* `virtualenv commands * `virtualenv commands
<http://thisismedium.com/tech/extending-virtualenv/>`_ for some more <https://github.com/thisismedium/virtualenv-commands>`_ for some more
workflow-related tools around virtualenv. workflow-related tools around virtualenv.
Status and License
------------------
``virtualenv`` is a successor to `workingenv
<http://cheeseshop.python.org/pypi/workingenv.py>`_, and an extension
of `virtual-python
<http://peak.telecommunity.com/DevCenter/EasyInstall#creating-a-virtual-python>`_.
It was written by Ian Bicking, sponsored by the `Open Planning
Project <http://openplans.org>`_ and is now maintained by a
`group of developers <https://github.com/pypa/virtualenv/raw/master/AUTHORS.txt>`_.
It is licensed under an
`MIT-style permissive license <https://github.com/pypa/virtualenv/raw/master/LICENSE.txt>`_.
Changes & News Changes & News
-------------- --------------
.. warning::
Python bugfix releases 2.6.8, 2.7.3, 3.1.5 and 3.2.3 include a change that
will cause "import random" to fail with "cannot import name urandom" on any
virtualenv created on a Unix host with an earlier release of Python
2.6/2.7/3.1/3.2, if the underlying system Python is upgraded. This is due to
the fact that a virtualenv uses the system Python's standard library but
contains its own copy of the Python interpreter, so an upgrade to the system
Python results in a mismatch between the version of the Python interpreter
and the version of the standard library. It can be fixed by removing
``$ENV/bin/python`` and re-running virtualenv on the same target directory
with the upgraded Python.
1.8.4 (2012-11-25)
~~~~~~~~~~~~~~~~~~
* Updated distribute to 0.6.31. This fixes #359 (numpy install regression) on
UTF-8 platforms, and provides a workaround on other platforms:
``PYTHONIOENCODING=utf8 pip install numpy``.
* When installing virtualenv via curl, don't forget to filter out arguments
the distribute setup script won't understand. Fixes #358.
* Added some more integration tests.
1.8.3 (2012-11-21)
~~~~~~~~~~~~~~~~~~
* Fixed readline on OS X. Thanks minrk
* Updated distribute to 0.6.30 (improves our error reporting, plus new
distribute features and fixes). Thanks Gabriel (g2p)
* Added compatibility with multiarch Python (Python 3.3 for example). Added an
integration test. Thanks Gabriel (g2p)
* Added ability to install distribute from a user-provided egg, rather than the
bundled sdist, for better speed. Thanks Paul Moore.
* Make the creation of lib64 symlink smarter about already-existing symlink,
and more explicit about full paths. Fixes #334 and #330. Thanks Jeremy Orem.
* Give lib64 site-dir preference over lib on 64-bit systems, to avoid wrong
32-bit compiles in the venv. Fixes #328. Thanks Damien Nozay.
* Fix a bug with prompt-handling in ``activate.csh`` in non-interactive csh
shells. Fixes #332. Thanks Benjamin Root for report and patch.
* Make it possible to create a virtualenv from within a Python
3.3. pyvenv. Thanks Chris McDonough for the report.
* Add optional --setuptools option to be able to switch to it in case
distribute is the default (like in Debian).
1.8.2 (2012-09-06)
~~~~~~~~~~~~~~~~~~
* Updated the included pip version to 1.2.1 to fix regressions introduced
there in 1.2.
1.8.1 (2012-09-03)
~~~~~~~~~~~~~~~~~~
* Fixed distribute version used with `--never-download`. Thanks michr for
report and patch.
* Fix creating Python 3.3 based virtualenvs by unsetting the
``__PYVENV_LAUNCHER__`` environment variable in subprocesses.
1.8 (2012-09-01)
~~~~~~~~~~~~~~~~
* **Dropped support for Python 2.4** The minimum supported Python version is
now Python 2.5.
* Fix `--relocatable` on systems that use lib64. Fixes #78. Thanks Branden
Rolston.
* Symlink some additional modules under Python 3. Fixes #194. Thanks Vinay
Sajip, Ian Clelland, and Stefan Holek for the report.
* Fix ``--relocatable`` when a script uses ``__future__`` imports. Thanks
Branden Rolston.
* Fix a bug in the config option parser that prevented setting negative
options with environemnt variables. Thanks Ralf Schmitt.
* Allow setting ``--no-site-packages`` from the config file.
* Use ``/usr/bin/multiarch-platform`` if available to figure out the include
directory. Thanks for the patch, Mika Laitio.
* Fix ``install_name_tool`` replacement to work on Python 3.X.
* Handle paths of users' site-packages on Mac OS X correctly when changing
the prefix.
* Updated the embedded version of distribute to 0.6.28 and pip to 1.2.
1.7.2 (2012-06-22)
~~~~~~~~~~~~~~~~~~
* Updated to distribute 0.6.27.
* Fix activate.fish on OS X. Fixes #8. Thanks David Schoonover.
* Create a virtualenv-x.x script with the Python version when installing, so
virtualenv for multiple Python versions can be installed to the same
script location. Thanks Miki Tebeka.
* Restored ability to create a virtualenv with a path longer than 78
characters, without breaking creation of virtualenvs with non-ASCII paths.
Thanks, Bradley Ayers.
* Added ability to create virtualenvs without having installed Apple's
developers tools (using an own implementation of ``install_name_tool``).
Thanks Mike Hommey.
* Fixed PyPy and Jython support on Windows. Thanks Konstantin Zemlyak.
* Added pydoc script to ease use. Thanks Marc Abramowitz. Fixes #149.
* Fixed creating a bootstrap script on Python 3. Thanks Raul Leal. Fixes #280.
* Fixed inconsistency when having set the ``PYTHONDONTWRITEBYTECODE`` env var
with the --distribute option or the ``VIRTUALENV_USE_DISTRIBUTE`` env var.
``VIRTUALENV_USE_DISTRIBUTE`` is now considered again as a legacy alias.
1.7.1.2 (2012-02-17)
~~~~~~~~~~~~~~~~~~~~
* Fixed minor issue in `--relocatable`. Thanks, Cap Petschulat.
1.7.1.1 (2012-02-16)
~~~~~~~~~~~~~~~~~~~~
* Bumped the version string in ``virtualenv.py`` up, too.
* Fixed rST rendering bug of long description.
1.7.1 (2012-02-16)
~~~~~~~~~~~~~~~~~~
* Update embedded pip to version 1.1.
* Fix `--relocatable` under Python 3. Thanks Doug Hellmann.
* Added environ PATH modification to activate_this.py. Thanks Doug
Napoleone. Fixes #14.
* Support creating virtualenvs directly from a Python build directory on
Windows. Thanks CBWhiz. Fixes #139.
* Use non-recursive symlinks to fix things up for posix_local install
scheme. Thanks michr.
* Made activate script available for use with msys and cygwin on Windows.
Thanks Greg Haskins, Cliff Xuan, Jonathan Griffin and Doug Napoleone.
Fixes #176.
* Fixed creation of virtualenvs on Windows when Python is not installed for
all users. Thanks Anatoly Techtonik for report and patch and Doug
Napoleone for testing and confirmation. Fixes #87.
* Fixed creation of virtualenvs using -p in installs where some modules
that ought to be in the standard library (e.g. `readline`) are actually
installed in `site-packages` next to `virtualenv.py`. Thanks Greg Haskins
for report and fix. Fixes #167.
* Added activation script for Powershell (signed by Jannis Leidel). Many
thanks to Jason R. Coombs.
1.7 (2011-11-30) 1.7 (2011-11-30)
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
* Updated embedded Distribute release to 0.6.24. Thanks Alex Grönholm. * Gave user-provided ``--extra-search-dir`` priority over default dirs for
finding setuptools/distribute (it already had priority for finding pip).
Thanks Ethan Jucovy.
* Updated embedded Distribute release to 0.6.24. Thanks Alex Gronholm.
* Made ``--no-site-packages`` behavior the default behavior. The * Made ``--no-site-packages`` behavior the default behavior. The
``--no-site-packages`` flag is still permitted, but displays a warning when ``--no-site-packages`` flag is still permitted, but displays a warning when
@@ -503,16 +772,19 @@ Description:
* Made ``virtualenv.py`` script executable. * Made ``virtualenv.py`` script executable.
1.6.4 (2011-07-21) 1.6.4 (2011-07-21)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
* Restored ability to run on Python 2.4, too. * Restored ability to run on Python 2.4, too.
1.6.3 (2011-07-16) 1.6.3 (2011-07-16)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
* Restored ability to run on Python < 2.7. * Restored ability to run on Python < 2.7.
1.6.2 (2011-07-16) 1.6.2 (2011-07-16)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
@@ -547,6 +819,7 @@ Description:
* Added --never-download and --search-dir options. Thanks Ethan Jucovy. * Added --never-download and --search-dir options. Thanks Ethan Jucovy.
1.6 1.6
~~~ ~~~
@@ -557,6 +830,7 @@ Description:
* Updated bundled pip to 1.0. * Updated bundled pip to 1.0.
1.5.2 1.5.2
~~~~~ ~~~~~
@@ -572,6 +846,7 @@ Description:
* Moved virtualenv to Github at https://github.com/pypa/virtualenv * Moved virtualenv to Github at https://github.com/pypa/virtualenv
1.5.1 1.5.1
~~~~~ ~~~~~
@@ -579,6 +854,7 @@ Description:
* Fixed Windows regression in 1.5 * Fixed Windows regression in 1.5
1.5 1.5
~~~ ~~~
@@ -596,11 +872,13 @@ Description:
* Add fish and csh activate scripts. * Add fish and csh activate scripts.
1.4.9 1.4.9
~~~~~ ~~~~~
* Include pip 0.7.2 * Include pip 0.7.2
1.4.8 1.4.8
~~~~~ ~~~~~
@@ -615,17 +893,20 @@ Description:
* Include pip 0.7.1 * Include pip 0.7.1
1.4.7 1.4.7
~~~~~ ~~~~~
* Include pip 0.7 * Include pip 0.7
1.4.6 1.4.6
~~~~~ ~~~~~
* Allow ``activate.sh`` to skip updating the prompt (by setting * Allow ``activate.sh`` to skip updating the prompt (by setting
``$VIRTUAL_ENV_DISABLE_PROMPT``). ``$VIRTUAL_ENV_DISABLE_PROMPT``).
1.4.5 1.4.5
~~~~~ ~~~~~
@@ -634,6 +915,7 @@ Description:
* Fix ``activate.bat`` and ``deactivate.bat`` under Windows when * Fix ``activate.bat`` and ``deactivate.bat`` under Windows when
``PATH`` contained a parenthesis ``PATH`` contained a parenthesis
1.4.4 1.4.4
~~~~~ ~~~~~
@@ -645,15 +927,17 @@ Description:
* Fix problem with ``virtualenv --relocate`` when ``bin/`` has * Fix problem with ``virtualenv --relocate`` when ``bin/`` has
subdirectories (e.g., ``bin/.svn/``); from Alan Franzoni. subdirectories (e.g., ``bin/.svn/``); from Alan Franzoni.
* If you set ``$VIRTUALENV_USE_DISTRIBUTE`` then virtualenv will use * If you set ``$VIRTUALENV_DISTRIBUTE`` then virtualenv will use
Distribute by default (so you don't have to remember to use Distribute by default (so you don't have to remember to use
``--distribute``). ``--distribute``).
1.4.3 1.4.3
~~~~~ ~~~~~
* Include pip 0.6.1 * Include pip 0.6.1
1.4.2 1.4.2
~~~~~ ~~~~~
@@ -664,11 +948,13 @@ Description:
* Exclude ~/.local (user site-packages) from environments when using * Exclude ~/.local (user site-packages) from environments when using
``--no-site-packages`` ``--no-site-packages``
1.4.1 1.4.1
~~~~~ ~~~~~
* Include pip 0.6 * Include pip 0.6
1.4 1.4
~~~ ~~~
@@ -678,6 +964,7 @@ Description:
* Fixed packaging problem of support-files * Fixed packaging problem of support-files
1.3.4 1.3.4
~~~~~ ~~~~~
@@ -707,6 +994,7 @@ Description:
* Fixes for ``--python``: make it work with ``--relocatable`` and the * Fixes for ``--python``: make it work with ``--relocatable`` and the
symlink created to the exact Python version. symlink created to the exact Python version.
1.3.3 1.3.3
~~~~~ ~~~~~
@@ -729,6 +1017,7 @@ Description:
<https://bugs.launchpad.net/virtualenv/+bug/340050>`_ picking up <https://bugs.launchpad.net/virtualenv/+bug/340050>`_ picking up
some ``.so`` libraries in ``/usr/local``. some ``.so`` libraries in ``/usr/local``.
1.3.2 1.3.2
~~~~~ ~~~~~
@@ -736,11 +1025,12 @@ Description:
``distutils.cfg`` -- this has been causing problems for a lot of ``distutils.cfg`` -- this has been causing problems for a lot of
people, in rather obscure ways. people, in rather obscure ways.
* If you use a `boot script <./index.html#boot-script>`_ it will attempt to import ``virtualenv`` * If you use a boot script it will attempt to import ``virtualenv``
and find a pre-downloaded Setuptools egg using that. and find a pre-downloaded Setuptools egg using that.
* Added platform-specific paths, like ``/usr/lib/pythonX.Y/plat-linux2`` * Added platform-specific paths, like ``/usr/lib/pythonX.Y/plat-linux2``
1.3.1 1.3.1
~~~~~ ~~~~~
@@ -763,6 +1053,7 @@ Description:
* Fixed handling of Jython environments that use a * Fixed handling of Jython environments that use a
jython-complete.jar. jython-complete.jar.
1.3 1.3
~~~ ~~~
@@ -789,6 +1080,7 @@ Description:
* Fixed the ``__classpath__`` entry in Jython's ``sys.path`` taking * Fixed the ``__classpath__`` entry in Jython's ``sys.path`` taking
precedent over virtualenv's libs. precedent over virtualenv's libs.
1.2 1.2
~~~ ~~~
@@ -797,11 +1089,13 @@ Description:
* Add ``sets`` to the module copied over for Python 2.3 (though Python * Add ``sets`` to the module copied over for Python 2.3 (though Python
2.3 still probably doesn't work). 2.3 still probably doesn't work).
1.1.1 1.1.1
~~~~~ ~~~~~
* Added support for Jython 2.5. * Added support for Jython 2.5.
1.1 1.1
~~~ ~~~
@@ -816,6 +1110,7 @@ Description:
* Copy or symlink over the ``include`` directory so that packages will * Copy or symlink over the ``include`` directory so that packages will
more consistently compile. more consistently compile.
1.0 1.0
~~~ ~~~
@@ -825,6 +1120,7 @@ Description:
* Fixed typos in ``deactivate.bat``. * Fixed typos in ``deactivate.bat``.
* Preserve ``$PYTHONPATH`` when calling subprocesses. * Preserve ``$PYTHONPATH`` when calling subprocesses.
0.9.2 0.9.2
~~~~~ ~~~~~
@@ -839,6 +1135,7 @@ Description:
* Fixed an issue with Mac Framework Python builds, and absolute paths * Fixed an issue with Mac Framework Python builds, and absolute paths
(from Ronald Oussoren). (from Ronald Oussoren).
0.9.1 0.9.1
~~~~~ ~~~~~
@@ -846,6 +1143,7 @@ Description:
* Fix a little bug in ``bin/activate``. * Fix a little bug in ``bin/activate``.
* Actually get ``distutils.cfg`` to work reliably. * Actually get ``distutils.cfg`` to work reliably.
0.9 0.9
~~~ ~~~
@@ -861,6 +1159,7 @@ Description:
* Should work on MacOSX Framework builds (the default Python * Should work on MacOSX Framework builds (the default Python
installations on Mac). Thanks to Ronald Oussoren. installations on Mac). Thanks to Ronald Oussoren.
0.8.4 0.8.4
~~~~~ ~~~~~
@@ -868,11 +1167,13 @@ Description:
were inaccurate. were inaccurate.
* Slightly prettier output. * Slightly prettier output.
0.8.3 0.8.3
~~~~~ ~~~~~
* Added support for Windows. * Added support for Windows.
0.8.2 0.8.2
~~~~~ ~~~~~
@@ -881,11 +1182,13 @@ Description:
* Give error about running while inside a workingenv. * Give error about running while inside a workingenv.
* Give better error message about Python 2.3. * Give better error message about Python 2.3.
0.8.1 0.8.1
~~~~~ ~~~~~
Fixed packaging of the library. Fixed packaging of the library.
0.8 0.8
~~~ ~~~
@@ -897,7 +1200,6 @@ Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.4
Classifier: Programming Language :: Python :: 2.5 Classifier: Programming Language :: Python :: 2.5
Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 2.7
@@ -1,7 +1,7 @@
AUTHORS.txt AUTHORS.txt
HACKING
LICENSE.txt LICENSE.txt
MANIFEST.in MANIFEST.in
README.rst
setup.py setup.py
virtualenv.py virtualenv.py
bin/rebuild-script.py bin/rebuild-script.py
@@ -15,24 +15,28 @@ docs/_theme/nature/theme.conf
docs/_theme/nature/static/nature.css_t docs/_theme/nature/static/nature.css_t
docs/_theme/nature/static/pygments.css docs/_theme/nature/static/pygments.css
scripts/virtualenv scripts/virtualenv
tests/__init__.py
tests/test_virtualenv.py
virtualenv.egg-info/PKG-INFO virtualenv.egg-info/PKG-INFO
virtualenv.egg-info/SOURCES.txt virtualenv.egg-info/SOURCES.txt
virtualenv.egg-info/dependency_links.txt virtualenv.egg-info/dependency_links.txt
virtualenv.egg-info/entry_points.txt virtualenv.egg-info/entry_points.txt
virtualenv.egg-info/not-zip-safe virtualenv.egg-info/not-zip-safe
virtualenv.egg-info/top_level.txt virtualenv.egg-info/top_level.txt
virtualenv_embedded/activate.bat
virtualenv_embedded/activate.csh
virtualenv_embedded/activate.fish
virtualenv_embedded/activate.ps1
virtualenv_embedded/activate.sh
virtualenv_embedded/activate_this.py
virtualenv_embedded/deactivate.bat
virtualenv_embedded/distribute_from_egg.py
virtualenv_embedded/distribute_setup.py
virtualenv_embedded/distutils-init.py
virtualenv_embedded/distutils.cfg
virtualenv_embedded/ez_setup.py
virtualenv_embedded/site.py
virtualenv_support/__init__.py virtualenv_support/__init__.py
virtualenv_support/activate.bat virtualenv_support/distribute-0.6.31.tar.gz
virtualenv_support/activate.csh virtualenv_support/pip-1.2.1.tar.gz
virtualenv_support/activate.fish
virtualenv_support/activate.sh
virtualenv_support/deactivate.bat
virtualenv_support/distribute-0.6.24.tar.gz
virtualenv_support/distutils.cfg
virtualenv_support/pip-1.0.2.tar.gz
virtualenv_support/setuptools-0.6c11-py2.4.egg
virtualenv_support/setuptools-0.6c11-py2.5.egg virtualenv_support/setuptools-0.6c11-py2.5.egg
virtualenv_support/setuptools-0.6c11-py2.6.egg virtualenv_support/setuptools-0.6c11-py2.6.egg
virtualenv_support/setuptools-0.6c11-py2.7.egg virtualenv_support/setuptools-0.6c11-py2.7.egg
@@ -1,2 +1,4 @@
[console_scripts] [console_scripts]
virtualenv = virtualenv:main virtualenv = virtualenv:main
virtualenv-2.7 = virtualenv:main
+2564
View File
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,26 @@
@echo off
set "VIRTUAL_ENV=__VIRTUAL_ENV__"
if defined _OLD_VIRTUAL_PROMPT (
set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
) else (
if not defined PROMPT (
set "PROMPT=$P$G"
)
set "_OLD_VIRTUAL_PROMPT=%PROMPT%"
)
set "PROMPT=__VIRTUAL_WINPROMPT__ %PROMPT%"
if not defined _OLD_VIRTUAL_PYTHONHOME (
set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%"
)
set PYTHONHOME=
if defined _OLD_VIRTUAL_PATH (
set "PATH=%_OLD_VIRTUAL_PATH%"
) else (
set "_OLD_VIRTUAL_PATH=%PATH%"
)
set "PATH=%VIRTUAL_ENV%\__BIN_NAME__;%PATH%"
:END
@@ -2,9 +2,9 @@
# You cannot run it directly. # You cannot run it directly.
# Created by Davide Di Blasi <davidedb@gmail.com>. # Created by Davide Di Blasi <davidedb@gmail.com>.
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate' alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc'
# Unset irrelavent variables. # Unset irrelevant variables.
deactivate nondestructive deactivate nondestructive
setenv VIRTUAL_ENV "__VIRTUAL_ENV__" setenv VIRTUAL_ENV "__VIRTUAL_ENV__"
@@ -12,7 +12,7 @@ setenv VIRTUAL_ENV "__VIRTUAL_ENV__"
set _OLD_VIRTUAL_PATH="$PATH" set _OLD_VIRTUAL_PATH="$PATH"
setenv PATH "$VIRTUAL_ENV/__BIN_NAME__:$PATH" setenv PATH "$VIRTUAL_ENV/__BIN_NAME__:$PATH"
set _OLD_VIRTUAL_PROMPT="$prompt"
if ("__VIRTUAL_PROMPT__" != "") then if ("__VIRTUAL_PROMPT__" != "") then
set env_name = "__VIRTUAL_PROMPT__" set env_name = "__VIRTUAL_PROMPT__"
@@ -25,8 +25,18 @@ else
set env_name = `basename "$VIRTUAL_ENV"` set env_name = `basename "$VIRTUAL_ENV"`
endif endif
endif endif
set prompt = "[$env_name] $prompt"
# Could be in a non-interactive environment,
# in which case, $prompt is undefined and we wouldn't
# care about the prompt anyway.
if ( $?prompt ) then
set _OLD_VIRTUAL_PROMPT="$prompt"
set prompt = "[$env_name] $prompt"
endif
unset env_name unset env_name
alias pydoc python -m pydoc
rehash rehash
@@ -0,0 +1,74 @@
# This file must be used with ". bin/activate.fish" *from fish* (http://fishshell.org)
# you cannot run it directly
function deactivate -d "Exit virtualenv and return to normal shell environment"
# reset old environment variables
if test -n "$_OLD_VIRTUAL_PATH"
set -gx PATH $_OLD_VIRTUAL_PATH
set -e _OLD_VIRTUAL_PATH
end
if test -n "$_OLD_VIRTUAL_PYTHONHOME"
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
set -e _OLD_VIRTUAL_PYTHONHOME
end
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
functions -e fish_prompt
set -e _OLD_FISH_PROMPT_OVERRIDE
. ( begin
printf "function fish_prompt\n\t#"
functions _old_fish_prompt
end | psub )
functions -e _old_fish_prompt
end
set -e VIRTUAL_ENV
if test "$argv[1]" != "nondestructive"
# Self destruct!
functions -e deactivate
end
end
# unset irrelevant variables
deactivate nondestructive
set -gx VIRTUAL_ENV "__VIRTUAL_ENV__"
set -gx _OLD_VIRTUAL_PATH $PATH
set -gx PATH "$VIRTUAL_ENV/__BIN_NAME__" $PATH
# unset PYTHONHOME if set
if set -q PYTHONHOME
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
set -e PYTHONHOME
end
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
# fish uses a function instead of an env var to generate the prompt.
# save the current fish_prompt function as the function _old_fish_prompt
. ( begin
printf "function _old_fish_prompt\n\t#"
functions fish_prompt
end | psub )
# with the original prompt function renamed, we can override with our own.
function fish_prompt
# Prompt override?
if test -n "__VIRTUAL_PROMPT__"
printf "%s%s%s" "__VIRTUAL_PROMPT__" (set_color normal) (_old_fish_prompt)
return
end
# ...Otherwise, prepend env
set -l _checkbase (basename "$VIRTUAL_ENV")
if test $_checkbase = "__"
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
printf "%s[%s]%s %s" (set_color -b blue white) (basename (dirname "$VIRTUAL_ENV")) (set_color normal) (_old_fish_prompt)
else
printf "%s(%s)%s%s" (set_color -b blue white) (basename "$VIRTUAL_ENV") (set_color normal) (_old_fish_prompt)
end
end
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
end
+148
View File
@@ -0,0 +1,148 @@
# This file must be dot sourced from PoSh; you cannot run it
# directly. Do this: . ./activate.ps1
# FIXME: clean up unused vars.
$script:THIS_PATH = $myinvocation.mycommand.path
$script:BASE_DIR = split-path (resolve-path "$THIS_PATH/..") -Parent
$script:DIR_NAME = split-path $BASE_DIR -Leaf
function global:deactivate ( [switch] $NonDestructive ){
if ( test-path variable:_OLD_VIRTUAL_PATH ) {
$env:PATH = $variable:_OLD_VIRTUAL_PATH
remove-variable "_OLD_VIRTUAL_PATH" -scope global
}
if ( test-path function:_old_virtual_prompt ) {
$function:prompt = $function:_old_virtual_prompt
remove-item function:\_old_virtual_prompt
}
if ($env:VIRTUAL_ENV) {
$old_env = split-path $env:VIRTUAL_ENV -leaf
remove-item env:VIRTUAL_ENV -erroraction silentlycontinue
}
if ( !$NonDestructive ) {
# Self destruct!
remove-item function:deactivate
}
}
# unset irrelevant variables
deactivate -nondestructive
$VIRTUAL_ENV = $BASE_DIR
$env:VIRTUAL_ENV = $VIRTUAL_ENV
$global:_OLD_VIRTUAL_PATH = $env:PATH
$env:PATH = "$env:VIRTUAL_ENV/Scripts;" + $env:PATH
function global:_old_virtual_prompt { "" }
$function:_old_virtual_prompt = $function:prompt
function global:prompt {
# Add a prefix to the current prompt, but don't discard it.
write-host "($(split-path $env:VIRTUAL_ENV -leaf)) " -nonewline
& $function:_old_virtual_prompt
}
# SIG # Begin signature block
# MIISeAYJKoZIhvcNAQcCoIISaTCCEmUCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUS5reBwSg3zOUwhXf2jPChZzf
# yPmggg6tMIIGcDCCBFigAwIBAgIBJDANBgkqhkiG9w0BAQUFADB9MQswCQYDVQQG
# EwJJTDEWMBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMiU2VjdXJlIERp
# Z2l0YWwgQ2VydGlmaWNhdGUgU2lnbmluZzEpMCcGA1UEAxMgU3RhcnRDb20gQ2Vy
# dGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDcxMDI0MjIwMTQ2WhcNMTcxMDI0MjIw
# MTQ2WjCBjDELMAkGA1UEBhMCSUwxFjAUBgNVBAoTDVN0YXJ0Q29tIEx0ZC4xKzAp
# BgNVBAsTIlNlY3VyZSBEaWdpdGFsIENlcnRpZmljYXRlIFNpZ25pbmcxODA2BgNV
# BAMTL1N0YXJ0Q29tIENsYXNzIDIgUHJpbWFyeSBJbnRlcm1lZGlhdGUgT2JqZWN0
# IENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyiOLIjUemqAbPJ1J
# 0D8MlzgWKbr4fYlbRVjvhHDtfhFN6RQxq0PjTQxRgWzwFQNKJCdU5ftKoM5N4YSj
# Id6ZNavcSa6/McVnhDAQm+8H3HWoD030NVOxbjgD/Ih3HaV3/z9159nnvyxQEckR
# ZfpJB2Kfk6aHqW3JnSvRe+XVZSufDVCe/vtxGSEwKCaNrsLc9pboUoYIC3oyzWoU
# TZ65+c0H4paR8c8eK/mC914mBo6N0dQ512/bkSdaeY9YaQpGtW/h/W/FkbQRT3sC
# pttLVlIjnkuY4r9+zvqhToPjxcfDYEf+XD8VGkAqle8Aa8hQ+M1qGdQjAye8OzbV
# uUOw7wIDAQABo4IB6TCCAeUwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
# AQYwHQYDVR0OBBYEFNBOD0CZbLhLGW87KLjg44gHNKq3MB8GA1UdIwQYMBaAFE4L
# 7xqkQFulF2mHMMo0aEPQQa7yMD0GCCsGAQUFBwEBBDEwLzAtBggrBgEFBQcwAoYh
# aHR0cDovL3d3dy5zdGFydHNzbC5jb20vc2ZzY2EuY3J0MFsGA1UdHwRUMFIwJ6Al
# oCOGIWh0dHA6Ly93d3cuc3RhcnRzc2wuY29tL3Nmc2NhLmNybDAnoCWgI4YhaHR0
# cDovL2NybC5zdGFydHNzbC5jb20vc2ZzY2EuY3JsMIGABgNVHSAEeTB3MHUGCysG
# AQQBgbU3AQIBMGYwLgYIKwYBBQUHAgEWImh0dHA6Ly93d3cuc3RhcnRzc2wuY29t
# L3BvbGljeS5wZGYwNAYIKwYBBQUHAgEWKGh0dHA6Ly93d3cuc3RhcnRzc2wuY29t
# L2ludGVybWVkaWF0ZS5wZGYwEQYJYIZIAYb4QgEBBAQDAgABMFAGCWCGSAGG+EIB
# DQRDFkFTdGFydENvbSBDbGFzcyAyIFByaW1hcnkgSW50ZXJtZWRpYXRlIE9iamVj
# dCBTaWduaW5nIENlcnRpZmljYXRlczANBgkqhkiG9w0BAQUFAAOCAgEAcnMLA3Va
# N4OIE9l4QT5OEtZy5PByBit3oHiqQpgVEQo7DHRsjXD5H/IyTivpMikaaeRxIv95
# baRd4hoUcMwDj4JIjC3WA9FoNFV31SMljEZa66G8RQECdMSSufgfDYu1XQ+cUKxh
# D3EtLGGcFGjjML7EQv2Iol741rEsycXwIXcryxeiMbU2TPi7X3elbwQMc4JFlJ4B
# y9FhBzuZB1DV2sN2irGVbC3G/1+S2doPDjL1CaElwRa/T0qkq2vvPxUgryAoCppU
# FKViw5yoGYC+z1GaesWWiP1eFKAL0wI7IgSvLzU3y1Vp7vsYaxOVBqZtebFTWRHt
# XjCsFrrQBngt0d33QbQRI5mwgzEp7XJ9xu5d6RVWM4TPRUsd+DDZpBHm9mszvi9g
# VFb2ZG7qRRXCSqys4+u/NLBPbXi/m/lU00cODQTlC/euwjk9HQtRrXQ/zqsBJS6U
# J+eLGw1qOfj+HVBl/ZQpfoLk7IoWlRQvRL1s7oirEaqPZUIWY/grXq9r6jDKAp3L
# ZdKQpPOnnogtqlU4f7/kLjEJhrrc98mrOWmVMK/BuFRAfQ5oDUMnVmCzAzLMjKfG
# cVW/iMew41yfhgKbwpfzm3LBr1Zv+pEBgcgW6onRLSAn3XHM0eNtz+AkxH6rRf6B
# 2mYhLEEGLapH8R1AMAo4BbVFOZR5kXcMCwowggg1MIIHHaADAgECAgIEuDANBgkq
# hkiG9w0BAQUFADCBjDELMAkGA1UEBhMCSUwxFjAUBgNVBAoTDVN0YXJ0Q29tIEx0
# ZC4xKzApBgNVBAsTIlNlY3VyZSBEaWdpdGFsIENlcnRpZmljYXRlIFNpZ25pbmcx
# ODA2BgNVBAMTL1N0YXJ0Q29tIENsYXNzIDIgUHJpbWFyeSBJbnRlcm1lZGlhdGUg
# T2JqZWN0IENBMB4XDTExMTIwMzE1MzQxOVoXDTEzMTIwMzE0NTgwN1owgYwxIDAe
# BgNVBA0TFzU4MTc5Ni1HaDd4Zkp4a3hRU0lPNEUwMQswCQYDVQQGEwJERTEPMA0G
# A1UECBMGQmVybGluMQ8wDQYDVQQHEwZCZXJsaW4xFjAUBgNVBAMTDUphbm5pcyBM
# ZWlkZWwxITAfBgkqhkiG9w0BCQEWEmphbm5pc0BsZWlkZWwuaW5mbzCCAiIwDQYJ
# KoZIhvcNAQEBBQADggIPADCCAgoCggIBAMcPeABYdN7nPq/AkZ/EkyUBGx/l2Yui
# Lfm8ZdLG0ulMb/kQL3fRY7sUjYPyn9S6PhqqlFnNoGHJvbbReCdUC9SIQYmOEjEA
# raHfb7MZU10NjO4U2DdGucj2zuO5tYxKizizOJF0e4yRQZVxpUGdvkW/+GLjCNK5
# L7mIv3Z1dagxDKHYZT74HXiS4VFUwHF1k36CwfM2vsetdm46bdgSwV+BCMmZICYT
# IJAS9UQHD7kP4rik3bFWjUx08NtYYFAVOd/HwBnemUmJe4j3IhZHr0k1+eDG8hDH
# KVvPgLJIoEjC4iMFk5GWsg5z2ngk0LLu3JZMtckHsnnmBPHQK8a3opUNd8hdMNJx
# gOwKjQt2JZSGUdIEFCKVDqj0FmdnDMPfwy+FNRtpBMl1sz78dUFhSrnM0D8NXrqa
# 4rG+2FoOXlmm1rb6AFtpjAKksHRpYcPk2DPGWp/1sWB+dUQkS3gOmwFzyqeTuXpT
# 0juqd3iAxOGx1VRFQ1VHLLf3AzV4wljBau26I+tu7iXxesVucSdsdQu293jwc2kN
# xK2JyHCoZH+RyytrwS0qw8t7rMOukU9gwP8mn3X6mgWlVUODMcHTULjSiCEtvyZ/
# aafcwjUbt4ReEcnmuZtWIha86MTCX7U7e+cnpWG4sIHPnvVTaz9rm8RyBkIxtFCB
# nQ3FnoQgyxeJAgMBAAGjggOdMIIDmTAJBgNVHRMEAjAAMA4GA1UdDwEB/wQEAwIH
# gDAuBgNVHSUBAf8EJDAiBggrBgEFBQcDAwYKKwYBBAGCNwIBFQYKKwYBBAGCNwoD
# DTAdBgNVHQ4EFgQUWyCgrIWo8Ifvvm1/YTQIeMU9nc8wHwYDVR0jBBgwFoAU0E4P
# QJlsuEsZbzsouODjiAc0qrcwggIhBgNVHSAEggIYMIICFDCCAhAGCysGAQQBgbU3
# AQICMIIB/zAuBggrBgEFBQcCARYiaHR0cDovL3d3dy5zdGFydHNzbC5jb20vcG9s
# aWN5LnBkZjA0BggrBgEFBQcCARYoaHR0cDovL3d3dy5zdGFydHNzbC5jb20vaW50
# ZXJtZWRpYXRlLnBkZjCB9wYIKwYBBQUHAgIwgeowJxYgU3RhcnRDb20gQ2VydGlm
# aWNhdGlvbiBBdXRob3JpdHkwAwIBARqBvlRoaXMgY2VydGlmaWNhdGUgd2FzIGlz
# c3VlZCBhY2NvcmRpbmcgdG8gdGhlIENsYXNzIDIgVmFsaWRhdGlvbiByZXF1aXJl
# bWVudHMgb2YgdGhlIFN0YXJ0Q29tIENBIHBvbGljeSwgcmVsaWFuY2Ugb25seSBm
# b3IgdGhlIGludGVuZGVkIHB1cnBvc2UgaW4gY29tcGxpYW5jZSBvZiB0aGUgcmVs
# eWluZyBwYXJ0eSBvYmxpZ2F0aW9ucy4wgZwGCCsGAQUFBwICMIGPMCcWIFN0YXJ0
# Q29tIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MAMCAQIaZExpYWJpbGl0eSBhbmQg
# d2FycmFudGllcyBhcmUgbGltaXRlZCEgU2VlIHNlY3Rpb24gIkxlZ2FsIGFuZCBM
# aW1pdGF0aW9ucyIgb2YgdGhlIFN0YXJ0Q29tIENBIHBvbGljeS4wNgYDVR0fBC8w
# LTAroCmgJ4YlaHR0cDovL2NybC5zdGFydHNzbC5jb20vY3J0YzItY3JsLmNybDCB
# iQYIKwYBBQUHAQEEfTB7MDcGCCsGAQUFBzABhitodHRwOi8vb2NzcC5zdGFydHNz
# bC5jb20vc3ViL2NsYXNzMi9jb2RlL2NhMEAGCCsGAQUFBzAChjRodHRwOi8vYWlh
# LnN0YXJ0c3NsLmNvbS9jZXJ0cy9zdWIuY2xhc3MyLmNvZGUuY2EuY3J0MCMGA1Ud
# EgQcMBqGGGh0dHA6Ly93d3cuc3RhcnRzc2wuY29tLzANBgkqhkiG9w0BAQUFAAOC
# AQEAhrzEV6zwoEtKjnFRhCsjwiPykVpo5Eiye77Ve801rQDiRKgSCCiW6g3HqedL
# OtaSs65Sj2pm3Viea4KR0TECLcbCTgsdaHqw2x1yXwWBQWZEaV6EB05lIwfr94P1
# SFpV43zkuc+bbmA3+CRK45LOcCNH5Tqq7VGTCAK5iM7tvHwFlbQRl+I6VEL2mjpF
# NsuRjDOVrv/9qw/a22YJ9R7Y1D0vUSs3IqZx2KMUaYDP7H2mSRxJO2nADQZBtriF
# gTyfD3lYV12MlIi5CQwe3QC6DrrfSMP33i5Wa/OFJiQ27WPxmScYVhiqozpImFT4
# PU9goiBv9RKXdgTmZE1PN0NQ5jGCAzUwggMxAgEBMIGTMIGMMQswCQYDVQQGEwJJ
# TDEWMBQGA1UEChMNU3RhcnRDb20gTHRkLjErMCkGA1UECxMiU2VjdXJlIERpZ2l0
# YWwgQ2VydGlmaWNhdGUgU2lnbmluZzE4MDYGA1UEAxMvU3RhcnRDb20gQ2xhc3Mg
# MiBQcmltYXJ5IEludGVybWVkaWF0ZSBPYmplY3QgQ0ECAgS4MAkGBSsOAwIaBQCg
# eDAYBgorBgEEAYI3AgEMMQowCKACgAChAoAAMBkGCSqGSIb3DQEJAzEMBgorBgEE
# AYI3AgEEMBwGCisGAQQBgjcCAQsxDjAMBgorBgEEAYI3AgEVMCMGCSqGSIb3DQEJ
# BDEWBBRVGw0FDSiaIi38dWteRUAg/9Pr6DANBgkqhkiG9w0BAQEFAASCAgCInvOZ
# FdaNFzbf6trmFDZKMojyx3UjKMCqNjHVBbuKY0qXwFC/ElYDV1ShJ2CBZbdurydO
# OQ6cIQ0KREOCwmX/xB49IlLHHUxNhEkVv7HGU3EKAFf9IBt9Yr7jikiR9cjIsfHK
# 4cjkoKJL7g28yEpLLkHt1eo37f1Ga9lDWEa5Zq3U5yX+IwXhrUBm1h8Xr033FhTR
# VEpuSz6LHtbrL/zgJnCzJ2ahjtJoYevdcWiNXffosJHFaSfYDDbiNsPRDH/1avmb
# 5j/7BhP8BcBaR6Fp8tFbNGIcWHHGcjqLMnTc4w13b7b4pDhypqElBa4+lCmwdvv9
# GydYtRgPz8GHeoBoKj30YBlMzRIfFYaIFGIC4Ai3UEXkuH9TxYohVbGm/W0Kl4Lb
# RJ1FwiVcLcTOJdgNId2vQvKc+jtNrjcg5SP9h2v/C4aTx8tyc6tE3TOPh2f9b8DL
# S+SbVArJpuJqrPTxDDoO1QNjTgLcdVYeZDE+r/NjaGZ6cMSd8db3EaG3ijD/0bud
# SItbm/OlNVbQOFRR76D+ZNgPcU5iNZ3bmvQQIg6aSB9MHUpIE/SeCkNl9YeVk1/1
# GFULgNMRmIYP4KLvu9ylh5Gu3hvD5VNhH6+FlXANwFy07uXks5uF8mfZVxVCnodG
# xkNCx+6PsrA5Z7WP4pXcmYnMn97npP/Q9EHJWw==
# SIG # End signature block
@@ -2,6 +2,8 @@
# you cannot run it directly # you cannot run it directly
deactivate () { deactivate () {
unset pydoc
# reset old environment variables # reset old environment variables
if [ -n "$_OLD_VIRTUAL_PATH" ] ; then if [ -n "$_OLD_VIRTUAL_PATH" ] ; then
PATH="$_OLD_VIRTUAL_PATH" PATH="$_OLD_VIRTUAL_PATH"
@@ -18,7 +20,7 @@ deactivate () {
# be called to get it to forget past commands. Without forgetting # be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected # past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
hash -r hash -r 2>/dev/null
fi fi
if [ -n "$_OLD_VIRTUAL_PS1" ] ; then if [ -n "$_OLD_VIRTUAL_PS1" ] ; then
@@ -34,7 +36,7 @@ deactivate () {
fi fi
} }
# unset irrelavent variables # unset irrelevant variables
deactivate nondestructive deactivate nondestructive
VIRTUAL_ENV="__VIRTUAL_ENV__" VIRTUAL_ENV="__VIRTUAL_ENV__"
@@ -55,7 +57,7 @@ fi
if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then
_OLD_VIRTUAL_PS1="$PS1" _OLD_VIRTUAL_PS1="$PS1"
if [ "x__VIRTUAL_PROMPT__" != x ] ; then if [ "x__VIRTUAL_PROMPT__" != x ] ; then
PS1="__VIRTUAL_PROMPT__$PS1" PS1="__VIRTUAL_PROMPT__$PS1"
else else
if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
# special case for Aspen magic directories # special case for Aspen magic directories
@@ -68,9 +70,11 @@ if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then
export PS1 export PS1
fi fi
alias pydoc="python -m pydoc"
# This should detect bash and zsh, which have a hash command that must # This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting # be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected # past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
hash -r hash -r 2>/dev/null
fi fi
@@ -0,0 +1,34 @@
"""By using execfile(this_file, dict(__file__=this_file)) you will
activate this virtualenv environment.
This can be used when you must use an existing Python interpreter, not
the virtualenv bin/python
"""
try:
__file__
except NameError:
raise AssertionError(
"You must run this like execfile('path/to/activate_this.py', dict(__file__='path/to/activate_this.py'))")
import sys
import os
old_os_path = os.environ['PATH']
os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + os.pathsep + old_os_path
base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if sys.platform == 'win32':
site_packages = os.path.join(base, 'Lib', 'site-packages')
else:
site_packages = os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'site-packages')
prev_sys_path = list(sys.path)
import site
site.addsitedir(site_packages)
sys.real_prefix = sys.prefix
sys.prefix = base
# Move the added items to the front of the path:
new_sys_path = []
for item in list(sys.path):
if item not in prev_sys_path:
new_sys_path.append(item)
sys.path.remove(item)
sys.path[:0] = new_sys_path
@@ -0,0 +1,18 @@
@echo off
if defined _OLD_VIRTUAL_PROMPT (
set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
set _OLD_VIRTUAL_PROMPT=
)
if defined _OLD_VIRTUAL_PYTHONHOME (
set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%"
set _OLD_VIRTUAL_PYTHONHOME=
)
if defined _OLD_VIRTUAL_PATH (
set "PATH=%_OLD_VIRTUAL_PATH%"
set _OLD_VIRTUAL_PATH=
)
:END
@@ -0,0 +1,8 @@
# Called from virtualenv with parameters:
# [--always-unzip] [-v] egg_name
# So, the distribute egg is always the last argument.
import sys
eggname = sys.argv[-1]
sys.path.insert(0, eggname)
from setuptools.command.easy_install import main
main(sys.argv[1:])
@@ -0,0 +1,541 @@
#!python
"""Bootstrap distribute installation
If you want to use setuptools in your package's setup.py, just include this
file in the same directory with it, and add this to the top of your setup.py::
from distribute_setup import use_setuptools
use_setuptools()
If you want to require a specific version of setuptools, set a download
mirror, or use an alternate download directory, you can do so by supplying
the appropriate options to ``use_setuptools()``.
This file can also be run as a script to install or upgrade setuptools.
"""
import os
import shutil
import sys
import time
import fnmatch
import tempfile
import tarfile
import optparse
from distutils import log
try:
from site import USER_SITE
except ImportError:
USER_SITE = None
try:
import subprocess
def _python_cmd(*args):
args = (sys.executable,) + args
return subprocess.call(args) == 0
except ImportError:
# will be used for python 2.3
def _python_cmd(*args):
args = (sys.executable,) + args
# quoting arguments if windows
if sys.platform == 'win32':
def quote(arg):
if ' ' in arg:
return '"%s"' % arg
return arg
args = [quote(arg) for arg in args]
return os.spawnl(os.P_WAIT, sys.executable, *args) == 0
DEFAULT_VERSION = "0.6.31"
DEFAULT_URL = "http://pypi.python.org/packages/source/d/distribute/"
SETUPTOOLS_FAKED_VERSION = "0.6c11"
SETUPTOOLS_PKG_INFO = """\
Metadata-Version: 1.0
Name: setuptools
Version: %s
Summary: xxxx
Home-page: xxx
Author: xxx
Author-email: xxx
License: xxx
Description: xxx
""" % SETUPTOOLS_FAKED_VERSION
def _install(tarball, install_args=()):
# extracting the tarball
tmpdir = tempfile.mkdtemp()
log.warn('Extracting in %s', tmpdir)
old_wd = os.getcwd()
try:
os.chdir(tmpdir)
tar = tarfile.open(tarball)
_extractall(tar)
tar.close()
# going in the directory
subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
os.chdir(subdir)
log.warn('Now working in %s', subdir)
# installing
log.warn('Installing Distribute')
if not _python_cmd('setup.py', 'install', *install_args):
log.warn('Something went wrong during the installation.')
log.warn('See the error message above.')
# exitcode will be 2
return 2
finally:
os.chdir(old_wd)
shutil.rmtree(tmpdir)
def _build_egg(egg, tarball, to_dir):
# extracting the tarball
tmpdir = tempfile.mkdtemp()
log.warn('Extracting in %s', tmpdir)
old_wd = os.getcwd()
try:
os.chdir(tmpdir)
tar = tarfile.open(tarball)
_extractall(tar)
tar.close()
# going in the directory
subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
os.chdir(subdir)
log.warn('Now working in %s', subdir)
# building an egg
log.warn('Building a Distribute egg in %s', to_dir)
_python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir)
finally:
os.chdir(old_wd)
shutil.rmtree(tmpdir)
# returning the result
log.warn(egg)
if not os.path.exists(egg):
raise IOError('Could not build the egg.')
def _do_download(version, download_base, to_dir, download_delay):
egg = os.path.join(to_dir, 'distribute-%s-py%d.%d.egg'
% (version, sys.version_info[0], sys.version_info[1]))
if not os.path.exists(egg):
tarball = download_setuptools(version, download_base,
to_dir, download_delay)
_build_egg(egg, tarball, to_dir)
sys.path.insert(0, egg)
import setuptools
setuptools.bootstrap_install_from = egg
def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
to_dir=os.curdir, download_delay=15, no_fake=True):
# making sure we use the absolute path
to_dir = os.path.abspath(to_dir)
was_imported = 'pkg_resources' in sys.modules or \
'setuptools' in sys.modules
try:
try:
import pkg_resources
if not hasattr(pkg_resources, '_distribute'):
if not no_fake:
_fake_setuptools()
raise ImportError
except ImportError:
return _do_download(version, download_base, to_dir, download_delay)
try:
pkg_resources.require("distribute>=" + version)
return
except pkg_resources.VersionConflict:
e = sys.exc_info()[1]
if was_imported:
sys.stderr.write(
"The required version of distribute (>=%s) is not available,\n"
"and can't be installed while this script is running. Please\n"
"install a more recent version first, using\n"
"'easy_install -U distribute'."
"\n\n(Currently using %r)\n" % (version, e.args[0]))
sys.exit(2)
else:
del pkg_resources, sys.modules['pkg_resources'] # reload ok
return _do_download(version, download_base, to_dir,
download_delay)
except pkg_resources.DistributionNotFound:
return _do_download(version, download_base, to_dir,
download_delay)
finally:
if not no_fake:
_create_fake_setuptools_pkg_info(to_dir)
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
to_dir=os.curdir, delay=15):
"""Download distribute from a specified location and return its filename
`version` should be a valid distribute version number that is available
as an egg for download under the `download_base` URL (which should end
with a '/'). `to_dir` is the directory where the egg will be downloaded.
`delay` is the number of seconds to pause before an actual download
attempt.
"""
# making sure we use the absolute path
to_dir = os.path.abspath(to_dir)
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
tgz_name = "distribute-%s.tar.gz" % version
url = download_base + tgz_name
saveto = os.path.join(to_dir, tgz_name)
src = dst = None
if not os.path.exists(saveto): # Avoid repeated downloads
try:
log.warn("Downloading %s", url)
src = urlopen(url)
# Read/write all in one block, so we don't create a corrupt file
# if the download is interrupted.
data = src.read()
dst = open(saveto, "wb")
dst.write(data)
finally:
if src:
src.close()
if dst:
dst.close()
return os.path.realpath(saveto)
def _no_sandbox(function):
def __no_sandbox(*args, **kw):
try:
from setuptools.sandbox import DirectorySandbox
if not hasattr(DirectorySandbox, '_old'):
def violation(*args):
pass
DirectorySandbox._old = DirectorySandbox._violation
DirectorySandbox._violation = violation
patched = True
else:
patched = False
except ImportError:
patched = False
try:
return function(*args, **kw)
finally:
if patched:
DirectorySandbox._violation = DirectorySandbox._old
del DirectorySandbox._old
return __no_sandbox
def _patch_file(path, content):
"""Will backup the file then patch it"""
existing_content = open(path).read()
if existing_content == content:
# already patched
log.warn('Already patched.')
return False
log.warn('Patching...')
_rename_path(path)
f = open(path, 'w')
try:
f.write(content)
finally:
f.close()
return True
_patch_file = _no_sandbox(_patch_file)
def _same_content(path, content):
return open(path).read() == content
def _rename_path(path):
new_name = path + '.OLD.%s' % time.time()
log.warn('Renaming %s to %s', path, new_name)
os.rename(path, new_name)
return new_name
def _remove_flat_installation(placeholder):
if not os.path.isdir(placeholder):
log.warn('Unkown installation at %s', placeholder)
return False
found = False
for file in os.listdir(placeholder):
if fnmatch.fnmatch(file, 'setuptools*.egg-info'):
found = True
break
if not found:
log.warn('Could not locate setuptools*.egg-info')
return
log.warn('Moving elements out of the way...')
pkg_info = os.path.join(placeholder, file)
if os.path.isdir(pkg_info):
patched = _patch_egg_dir(pkg_info)
else:
patched = _patch_file(pkg_info, SETUPTOOLS_PKG_INFO)
if not patched:
log.warn('%s already patched.', pkg_info)
return False
# now let's move the files out of the way
for element in ('setuptools', 'pkg_resources.py', 'site.py'):
element = os.path.join(placeholder, element)
if os.path.exists(element):
_rename_path(element)
else:
log.warn('Could not find the %s element of the '
'Setuptools distribution', element)
return True
_remove_flat_installation = _no_sandbox(_remove_flat_installation)
def _after_install(dist):
log.warn('After install bootstrap.')
placeholder = dist.get_command_obj('install').install_purelib
_create_fake_setuptools_pkg_info(placeholder)
def _create_fake_setuptools_pkg_info(placeholder):
if not placeholder or not os.path.exists(placeholder):
log.warn('Could not find the install location')
return
pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1])
setuptools_file = 'setuptools-%s-py%s.egg-info' % \
(SETUPTOOLS_FAKED_VERSION, pyver)
pkg_info = os.path.join(placeholder, setuptools_file)
if os.path.exists(pkg_info):
log.warn('%s already exists', pkg_info)
return
log.warn('Creating %s', pkg_info)
try:
f = open(pkg_info, 'w')
except EnvironmentError:
log.warn("Don't have permissions to write %s, skipping", pkg_info)
return
try:
f.write(SETUPTOOLS_PKG_INFO)
finally:
f.close()
pth_file = os.path.join(placeholder, 'setuptools.pth')
log.warn('Creating %s', pth_file)
f = open(pth_file, 'w')
try:
f.write(os.path.join(os.curdir, setuptools_file))
finally:
f.close()
_create_fake_setuptools_pkg_info = _no_sandbox(
_create_fake_setuptools_pkg_info
)
def _patch_egg_dir(path):
# let's check if it's already patched
pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO')
if os.path.exists(pkg_info):
if _same_content(pkg_info, SETUPTOOLS_PKG_INFO):
log.warn('%s already patched.', pkg_info)
return False
_rename_path(path)
os.mkdir(path)
os.mkdir(os.path.join(path, 'EGG-INFO'))
pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO')
f = open(pkg_info, 'w')
try:
f.write(SETUPTOOLS_PKG_INFO)
finally:
f.close()
return True
_patch_egg_dir = _no_sandbox(_patch_egg_dir)
def _before_install():
log.warn('Before install bootstrap.')
_fake_setuptools()
def _under_prefix(location):
if 'install' not in sys.argv:
return True
args = sys.argv[sys.argv.index('install') + 1:]
for index, arg in enumerate(args):
for option in ('--root', '--prefix'):
if arg.startswith('%s=' % option):
top_dir = arg.split('root=')[-1]
return location.startswith(top_dir)
elif arg == option:
if len(args) > index:
top_dir = args[index + 1]
return location.startswith(top_dir)
if arg == '--user' and USER_SITE is not None:
return location.startswith(USER_SITE)
return True
def _fake_setuptools():
log.warn('Scanning installed packages')
try:
import pkg_resources
except ImportError:
# we're cool
log.warn('Setuptools or Distribute does not seem to be installed.')
return
ws = pkg_resources.working_set
try:
setuptools_dist = ws.find(
pkg_resources.Requirement.parse('setuptools', replacement=False)
)
except TypeError:
# old distribute API
setuptools_dist = ws.find(
pkg_resources.Requirement.parse('setuptools')
)
if setuptools_dist is None:
log.warn('No setuptools distribution found')
return
# detecting if it was already faked
setuptools_location = setuptools_dist.location
log.warn('Setuptools installation detected at %s', setuptools_location)
# if --root or --preix was provided, and if
# setuptools is not located in them, we don't patch it
if not _under_prefix(setuptools_location):
log.warn('Not patching, --root or --prefix is installing Distribute'
' in another location')
return
# let's see if its an egg
if not setuptools_location.endswith('.egg'):
log.warn('Non-egg installation')
res = _remove_flat_installation(setuptools_location)
if not res:
return
else:
log.warn('Egg installation')
pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO')
if (os.path.exists(pkg_info) and
_same_content(pkg_info, SETUPTOOLS_PKG_INFO)):
log.warn('Already patched.')
return
log.warn('Patching...')
# let's create a fake egg replacing setuptools one
res = _patch_egg_dir(setuptools_location)
if not res:
return
log.warn('Patching complete.')
_relaunch()
def _relaunch():
log.warn('Relaunching...')
# we have to relaunch the process
# pip marker to avoid a relaunch bug
_cmd1 = ['-c', 'install', '--single-version-externally-managed']
_cmd2 = ['-c', 'install', '--record']
if sys.argv[:3] == _cmd1 or sys.argv[:3] == _cmd2:
sys.argv[0] = 'setup.py'
args = [sys.executable] + sys.argv
sys.exit(subprocess.call(args))
def _extractall(self, path=".", members=None):
"""Extract all members from the archive to the current working
directory and set owner, modification time and permissions on
directories afterwards. `path' specifies a different directory
to extract to. `members' is optional and must be a subset of the
list returned by getmembers().
"""
import copy
import operator
from tarfile import ExtractError
directories = []
if members is None:
members = self
for tarinfo in members:
if tarinfo.isdir():
# Extract directories with a safe mode.
directories.append(tarinfo)
tarinfo = copy.copy(tarinfo)
tarinfo.mode = 448 # decimal for oct 0700
self.extract(tarinfo, path)
# Reverse sort directories.
if sys.version_info < (2, 4):
def sorter(dir1, dir2):
return cmp(dir1.name, dir2.name)
directories.sort(sorter)
directories.reverse()
else:
directories.sort(key=operator.attrgetter('name'), reverse=True)
# Set correct owner, mtime and filemode on directories.
for tarinfo in directories:
dirpath = os.path.join(path, tarinfo.name)
try:
self.chown(tarinfo, dirpath)
self.utime(tarinfo, dirpath)
self.chmod(tarinfo, dirpath)
except ExtractError:
e = sys.exc_info()[1]
if self.errorlevel > 1:
raise
else:
self._dbg(1, "tarfile: %s" % e)
def _build_install_args(options):
"""
Build the arguments to 'python setup.py install' on the distribute package
"""
install_args = []
if options.user_install:
if sys.version_info < (2, 6):
log.warn("--user requires Python 2.6 or later")
raise SystemExit(1)
install_args.append('--user')
return install_args
def _parse_args():
"""
Parse the command line for options
"""
parser = optparse.OptionParser()
parser.add_option(
'--user', dest='user_install', action='store_true', default=False,
help='install in user site package (requires Python 2.6 or later)')
parser.add_option(
'--download-base', dest='download_base', metavar="URL",
default=DEFAULT_URL,
help='alternative URL from where to download the distribute package')
options, args = parser.parse_args()
# positional arguments are ignored
return options
def main(version=DEFAULT_VERSION):
"""Install or upgrade setuptools and EasyInstall"""
options = _parse_args()
tarball = download_setuptools(download_base=options.download_base)
return _install(tarball, _build_install_args(options))
if __name__ == '__main__':
sys.exit(main())
@@ -0,0 +1,101 @@
import os
import sys
import warnings
import imp
import opcode # opcode is not a virtualenv module, so we can use it to find the stdlib
# Important! To work on pypy, this must be a module that resides in the
# lib-python/modified-x.y.z directory
dirname = os.path.dirname
distutils_path = os.path.join(os.path.dirname(opcode.__file__), 'distutils')
if os.path.normpath(distutils_path) == os.path.dirname(os.path.normpath(__file__)):
warnings.warn(
"The virtualenv distutils package at %s appears to be in the same location as the system distutils?")
else:
__path__.insert(0, distutils_path)
real_distutils = imp.load_module("_virtualenv_distutils", None, distutils_path, ('', '', imp.PKG_DIRECTORY))
# Copy the relevant attributes
try:
__revision__ = real_distutils.__revision__
except AttributeError:
pass
__version__ = real_distutils.__version__
from distutils import dist, sysconfig
try:
basestring
except NameError:
basestring = str
## patch build_ext (distutils doesn't know how to get the libs directory
## path on windows - it hardcodes the paths around the patched sys.prefix)
if sys.platform == 'win32':
from distutils.command.build_ext import build_ext as old_build_ext
class build_ext(old_build_ext):
def finalize_options (self):
if self.library_dirs is None:
self.library_dirs = []
elif isinstance(self.library_dirs, basestring):
self.library_dirs = self.library_dirs.split(os.pathsep)
self.library_dirs.insert(0, os.path.join(sys.real_prefix, "Libs"))
old_build_ext.finalize_options(self)
from distutils.command import build_ext as build_ext_module
build_ext_module.build_ext = build_ext
## distutils.dist patches:
old_find_config_files = dist.Distribution.find_config_files
def find_config_files(self):
found = old_find_config_files(self)
system_distutils = os.path.join(distutils_path, 'distutils.cfg')
#if os.path.exists(system_distutils):
# found.insert(0, system_distutils)
# What to call the per-user config file
if os.name == 'posix':
user_filename = ".pydistutils.cfg"
else:
user_filename = "pydistutils.cfg"
user_filename = os.path.join(sys.prefix, user_filename)
if os.path.isfile(user_filename):
for item in list(found):
if item.endswith('pydistutils.cfg'):
found.remove(item)
found.append(user_filename)
return found
dist.Distribution.find_config_files = find_config_files
## distutils.sysconfig patches:
old_get_python_inc = sysconfig.get_python_inc
def sysconfig_get_python_inc(plat_specific=0, prefix=None):
if prefix is None:
prefix = sys.real_prefix
return old_get_python_inc(plat_specific, prefix)
sysconfig_get_python_inc.__doc__ = old_get_python_inc.__doc__
sysconfig.get_python_inc = sysconfig_get_python_inc
old_get_python_lib = sysconfig.get_python_lib
def sysconfig_get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
if standard_lib and prefix is None:
prefix = sys.real_prefix
return old_get_python_lib(plat_specific, standard_lib, prefix)
sysconfig_get_python_lib.__doc__ = old_get_python_lib.__doc__
sysconfig.get_python_lib = sysconfig_get_python_lib
old_get_config_vars = sysconfig.get_config_vars
def sysconfig_get_config_vars(*args):
real_vars = old_get_config_vars(*args)
if sys.platform == 'win32':
lib_dir = os.path.join(sys.real_prefix, "libs")
if isinstance(real_vars, dict) and 'LIBDIR' not in real_vars:
real_vars['LIBDIR'] = lib_dir # asked for all
elif isinstance(real_vars, list) and 'LIBDIR' in args:
real_vars = real_vars + [lib_dir] # asked for list
return real_vars
sysconfig_get_config_vars.__doc__ = old_get_config_vars.__doc__
sysconfig.get_config_vars = sysconfig_get_config_vars
+284
View File
@@ -0,0 +1,284 @@
#!python
"""Bootstrap setuptools installation
If you want to use setuptools in your package's setup.py, just include this
file in the same directory with it, and add this to the top of your setup.py::
from ez_setup import use_setuptools
use_setuptools()
If you want to require a specific version of setuptools, set a download
mirror, or use an alternate download directory, you can do so by supplying
the appropriate options to ``use_setuptools()``.
This file can also be run as a script to install or upgrade setuptools.
"""
import sys
DEFAULT_VERSION = "0.6c11"
DEFAULT_URL = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3]
md5_data = {
'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca',
'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb',
'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b',
'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a',
'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618',
'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac',
'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5',
'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4',
'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c',
'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b',
'setuptools-0.6c10-py2.3.egg': 'ce1e2ab5d3a0256456d9fc13800a7090',
'setuptools-0.6c10-py2.4.egg': '57d6d9d6e9b80772c59a53a8433a5dd4',
'setuptools-0.6c10-py2.5.egg': 'de46ac8b1c97c895572e5e8596aeb8c7',
'setuptools-0.6c10-py2.6.egg': '58ea40aef06da02ce641495523a0b7f5',
'setuptools-0.6c11-py2.3.egg': '2baeac6e13d414a9d28e7ba5b5a596de',
'setuptools-0.6c11-py2.4.egg': 'bd639f9b0eac4c42497034dec2ec0c2b',
'setuptools-0.6c11-py2.5.egg': '64c94f3bf7a72a13ec83e0b24f2749b2',
'setuptools-0.6c11-py2.6.egg': 'bfa92100bd772d5a213eedd356d64086',
'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27',
'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277',
'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa',
'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e',
'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e',
'setuptools-0.6c4-py2.3.egg': 'b0b9131acab32022bfac7f44c5d7971f',
'setuptools-0.6c4-py2.4.egg': '2a1f9656d4fbf3c97bf946c0a124e6e2',
'setuptools-0.6c4-py2.5.egg': '8f5a052e32cdb9c72bcf4b5526f28afc',
'setuptools-0.6c5-py2.3.egg': 'ee9fd80965da04f2f3e6b3576e9d8167',
'setuptools-0.6c5-py2.4.egg': 'afe2adf1c01701ee841761f5bcd8aa64',
'setuptools-0.6c5-py2.5.egg': 'a8d3f61494ccaa8714dfed37bccd3d5d',
'setuptools-0.6c6-py2.3.egg': '35686b78116a668847237b69d549ec20',
'setuptools-0.6c6-py2.4.egg': '3c56af57be3225019260a644430065ab',
'setuptools-0.6c6-py2.5.egg': 'b2f8a7520709a5b34f80946de5f02f53',
'setuptools-0.6c7-py2.3.egg': '209fdf9adc3a615e5115b725658e13e2',
'setuptools-0.6c7-py2.4.egg': '5a8f954807d46a0fb67cf1f26c55a82e',
'setuptools-0.6c7-py2.5.egg': '45d2ad28f9750e7434111fde831e8372',
'setuptools-0.6c8-py2.3.egg': '50759d29b349db8cfd807ba8303f1902',
'setuptools-0.6c8-py2.4.egg': 'cba38d74f7d483c06e9daa6070cce6de',
'setuptools-0.6c8-py2.5.egg': '1721747ee329dc150590a58b3e1ac95b',
'setuptools-0.6c9-py2.3.egg': 'a83c4020414807b496e4cfbe08507c03',
'setuptools-0.6c9-py2.4.egg': '260a2be2e5388d66bdaee06abec6342a',
'setuptools-0.6c9-py2.5.egg': 'fe67c3e5a17b12c0e7c541b7ea43a8e6',
'setuptools-0.6c9-py2.6.egg': 'ca37b1ff16fa2ede6e19383e7b59245a',
}
import sys, os
try: from hashlib import md5
except ImportError: from md5 import md5
def _validate_md5(egg_name, data):
if egg_name in md5_data:
digest = md5(data).hexdigest()
if digest != md5_data[egg_name]:
print >>sys.stderr, (
"md5 validation of %s failed! (Possible download problem?)"
% egg_name
)
sys.exit(2)
return data
def use_setuptools(
version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
download_delay=15
):
"""Automatically find/download setuptools and make it available on sys.path
`version` should be a valid setuptools version number that is available
as an egg for download under the `download_base` URL (which should end with
a '/'). `to_dir` is the directory where setuptools will be downloaded, if
it is not already available. If `download_delay` is specified, it should
be the number of seconds that will be paused before initiating a download,
should one be required. If an older version of setuptools is installed,
this routine will print a message to ``sys.stderr`` and raise SystemExit in
an attempt to abort the calling script.
"""
was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules
def do_download():
egg = download_setuptools(version, download_base, to_dir, download_delay)
sys.path.insert(0, egg)
import setuptools; setuptools.bootstrap_install_from = egg
try:
import pkg_resources
except ImportError:
return do_download()
try:
pkg_resources.require("setuptools>="+version); return
except pkg_resources.VersionConflict, e:
if was_imported:
print >>sys.stderr, (
"The required version of setuptools (>=%s) is not available, and\n"
"can't be installed while this script is running. Please install\n"
" a more recent version first, using 'easy_install -U setuptools'."
"\n\n(Currently using %r)"
) % (version, e.args[0])
sys.exit(2)
except pkg_resources.DistributionNotFound:
pass
del pkg_resources, sys.modules['pkg_resources'] # reload ok
return do_download()
def download_setuptools(
version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
delay = 15
):
"""Download setuptools from a specified location and return its filename
`version` should be a valid setuptools version number that is available
as an egg for download under the `download_base` URL (which should end
with a '/'). `to_dir` is the directory where the egg will be downloaded.
`delay` is the number of seconds to pause before an actual download attempt.
"""
import urllib2, shutil
egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3])
url = download_base + egg_name
saveto = os.path.join(to_dir, egg_name)
src = dst = None
if not os.path.exists(saveto): # Avoid repeated downloads
try:
from distutils import log
if delay:
log.warn("""
---------------------------------------------------------------------------
This script requires setuptools version %s to run (even to display
help). I will attempt to download it for you (from
%s), but
you may need to enable firewall access for this script first.
I will start the download in %d seconds.
(Note: if this machine does not have network access, please obtain the file
%s
and place it in this directory before rerunning this script.)
---------------------------------------------------------------------------""",
version, download_base, delay, url
); from time import sleep; sleep(delay)
log.warn("Downloading %s", url)
src = urllib2.urlopen(url)
# Read/write all in one block, so we don't create a corrupt file
# if the download is interrupted.
data = _validate_md5(egg_name, src.read())
dst = open(saveto,"wb"); dst.write(data)
finally:
if src: src.close()
if dst: dst.close()
return os.path.realpath(saveto)
def main(argv, version=DEFAULT_VERSION):
"""Install or upgrade setuptools and EasyInstall"""
try:
import setuptools
except ImportError:
egg = None
try:
egg = download_setuptools(version, delay=0)
sys.path.insert(0,egg)
from setuptools.command.easy_install import main
return main(list(argv)+[egg]) # we're done here
finally:
if egg and os.path.exists(egg):
os.unlink(egg)
else:
if setuptools.__version__ == '0.0.1':
print >>sys.stderr, (
"You have an obsolete version of setuptools installed. Please\n"
"remove it from your system entirely before rerunning this script."
)
sys.exit(2)
req = "setuptools>="+version
import pkg_resources
try:
pkg_resources.require(req)
except pkg_resources.VersionConflict:
try:
from setuptools.command.easy_install import main
except ImportError:
from easy_install import main
main(list(argv)+[download_setuptools(delay=0)])
sys.exit(0) # try to force an exit
else:
if argv:
from setuptools.command.easy_install import main
main(argv)
else:
print "Setuptools version",version,"or greater has been installed."
print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'
def update_md5(filenames):
"""Update our built-in md5 registry"""
import re
for name in filenames:
base = os.path.basename(name)
f = open(name,'rb')
md5_data[base] = md5(f.read()).hexdigest()
f.close()
data = [" %r: %r,\n" % it for it in md5_data.items()]
data.sort()
repl = "".join(data)
import inspect
srcfile = inspect.getsourcefile(sys.modules[__name__])
f = open(srcfile, 'rb'); src = f.read(); f.close()
match = re.search("\nmd5_data = {\n([^}]+)}", src)
if not match:
print >>sys.stderr, "Internal error!"
sys.exit(2)
src = src[:match.start(1)] + repl + src[match.end(1):]
f = open(srcfile,'w')
f.write(src)
f.close()
if __name__=='__main__':
if len(sys.argv)>2 and sys.argv[1]=='--md5update':
update_md5(sys.argv[2:])
else:
main(sys.argv[1:])
+743
View File
@@ -0,0 +1,743 @@
"""Append module search paths for third-party packages to sys.path.
****************************************************************
* This module is automatically imported during initialization. *
****************************************************************
In earlier versions of Python (up to 1.5a3), scripts or modules that
needed to use site-specific modules would place ``import site''
somewhere near the top of their code. Because of the automatic
import, this is no longer necessary (but code that does it still
works).
This will append site-specific paths to the module search path. On
Unix, it starts with sys.prefix and sys.exec_prefix (if different) and
appends lib/python<version>/site-packages as well as lib/site-python.
It also supports the Debian convention of
lib/python<version>/dist-packages. On other platforms (mainly Mac and
Windows), it uses just sys.prefix (and sys.exec_prefix, if different,
but this is unlikely). The resulting directories, if they exist, are
appended to sys.path, and also inspected for path configuration files.
FOR DEBIAN, this sys.path is augmented with directories in /usr/local.
Local addons go into /usr/local/lib/python<version>/site-packages
(resp. /usr/local/lib/site-python), Debian addons install into
/usr/{lib,share}/python<version>/dist-packages.
A path configuration file is a file whose name has the form
<package>.pth; its contents are additional directories (one per line)
to be added to sys.path. Non-existing directories (or
non-directories) are never added to sys.path; no directory is added to
sys.path more than once. Blank lines and lines beginning with
'#' are skipped. Lines starting with 'import' are executed.
For example, suppose sys.prefix and sys.exec_prefix are set to
/usr/local and there is a directory /usr/local/lib/python2.X/site-packages
with three subdirectories, foo, bar and spam, and two path
configuration files, foo.pth and bar.pth. Assume foo.pth contains the
following:
# foo package configuration
foo
bar
bletch
and bar.pth contains:
# bar package configuration
bar
Then the following directories are added to sys.path, in this order:
/usr/local/lib/python2.X/site-packages/bar
/usr/local/lib/python2.X/site-packages/foo
Note that bletch is omitted because it doesn't exist; bar precedes foo
because bar.pth comes alphabetically before foo.pth; and spam is
omitted because it is not mentioned in either path configuration file.
After these path manipulations, an attempt is made to import a module
named sitecustomize, which can perform arbitrary additional
site-specific customizations. If this import fails with an
ImportError exception, it is silently ignored.
"""
import sys
import os
try:
import __builtin__ as builtins
except ImportError:
import builtins
try:
set
except NameError:
from sets import Set as set
# Prefixes for site-packages; add additional prefixes like /usr/local here
PREFIXES = [sys.prefix, sys.exec_prefix]
# Enable per user site-packages directory
# set it to False to disable the feature or True to force the feature
ENABLE_USER_SITE = None
# for distutils.commands.install
USER_SITE = None
USER_BASE = None
_is_pypy = hasattr(sys, 'pypy_version_info')
_is_jython = sys.platform[:4] == 'java'
if _is_jython:
ModuleType = type(os)
def makepath(*paths):
dir = os.path.join(*paths)
if _is_jython and (dir == '__classpath__' or
dir.startswith('__pyclasspath__')):
return dir, dir
dir = os.path.abspath(dir)
return dir, os.path.normcase(dir)
def abs__file__():
"""Set all module' __file__ attribute to an absolute path"""
for m in sys.modules.values():
if ((_is_jython and not isinstance(m, ModuleType)) or
hasattr(m, '__loader__')):
# only modules need the abspath in Jython. and don't mess
# with a PEP 302-supplied __file__
continue
f = getattr(m, '__file__', None)
if f is None:
continue
m.__file__ = os.path.abspath(f)
def removeduppaths():
""" Remove duplicate entries from sys.path along with making them
absolute"""
# This ensures that the initial path provided by the interpreter contains
# only absolute pathnames, even if we're running from the build directory.
L = []
known_paths = set()
for dir in sys.path:
# Filter out duplicate paths (on case-insensitive file systems also
# if they only differ in case); turn relative paths into absolute
# paths.
dir, dircase = makepath(dir)
if not dircase in known_paths:
L.append(dir)
known_paths.add(dircase)
sys.path[:] = L
return known_paths
# XXX This should not be part of site.py, since it is needed even when
# using the -S option for Python. See http://www.python.org/sf/586680
def addbuilddir():
"""Append ./build/lib.<platform> in case we're running in the build dir
(especially for Guido :-)"""
from distutils.util import get_platform
s = "build/lib.%s-%.3s" % (get_platform(), sys.version)
if hasattr(sys, 'gettotalrefcount'):
s += '-pydebug'
s = os.path.join(os.path.dirname(sys.path[-1]), s)
sys.path.append(s)
def _init_pathinfo():
"""Return a set containing all existing directory entries from sys.path"""
d = set()
for dir in sys.path:
try:
if os.path.isdir(dir):
dir, dircase = makepath(dir)
d.add(dircase)
except TypeError:
continue
return d
def addpackage(sitedir, name, known_paths):
"""Add a new path to known_paths by combining sitedir and 'name' or execute
sitedir if it starts with 'import'"""
if known_paths is None:
_init_pathinfo()
reset = 1
else:
reset = 0
fullname = os.path.join(sitedir, name)
try:
f = open(fullname, "rU")
except IOError:
return
try:
for line in f:
if line.startswith("#"):
continue
if line.startswith("import"):
exec(line)
continue
line = line.rstrip()
dir, dircase = makepath(sitedir, line)
if not dircase in known_paths and os.path.exists(dir):
sys.path.append(dir)
known_paths.add(dircase)
finally:
f.close()
if reset:
known_paths = None
return known_paths
def addsitedir(sitedir, known_paths=None):
"""Add 'sitedir' argument to sys.path if missing and handle .pth files in
'sitedir'"""
if known_paths is None:
known_paths = _init_pathinfo()
reset = 1
else:
reset = 0
sitedir, sitedircase = makepath(sitedir)
if not sitedircase in known_paths:
sys.path.append(sitedir) # Add path component
try:
names = os.listdir(sitedir)
except os.error:
return
names.sort()
for name in names:
if name.endswith(os.extsep + "pth"):
addpackage(sitedir, name, known_paths)
if reset:
known_paths = None
return known_paths
def addsitepackages(known_paths, sys_prefix=sys.prefix, exec_prefix=sys.exec_prefix):
"""Add site-packages (and possibly site-python) to sys.path"""
prefixes = [os.path.join(sys_prefix, "local"), sys_prefix]
if exec_prefix != sys_prefix:
prefixes.append(os.path.join(exec_prefix, "local"))
for prefix in prefixes:
if prefix:
if sys.platform in ('os2emx', 'riscos') or _is_jython:
sitedirs = [os.path.join(prefix, "Lib", "site-packages")]
elif _is_pypy:
sitedirs = [os.path.join(prefix, 'site-packages')]
elif sys.platform == 'darwin' and prefix == sys_prefix:
if prefix.startswith("/System/Library/Frameworks/"): # Apple's Python
sitedirs = [os.path.join("/Library/Python", sys.version[:3], "site-packages"),
os.path.join(prefix, "Extras", "lib", "python")]
else: # any other Python distros on OSX work this way
sitedirs = [os.path.join(prefix, "lib",
"python" + sys.version[:3], "site-packages")]
elif os.sep == '/':
sitedirs = [os.path.join(prefix,
"lib",
"python" + sys.version[:3],
"site-packages"),
os.path.join(prefix, "lib", "site-python"),
os.path.join(prefix, "python" + sys.version[:3], "lib-dynload")]
lib64_dir = os.path.join(prefix, "lib64", "python" + sys.version[:3], "site-packages")
if (os.path.exists(lib64_dir) and
os.path.realpath(lib64_dir) not in [os.path.realpath(p) for p in sitedirs]):
if sys.maxsize > 2**32:
sitedirs.insert(0, lib64_dir)
else:
sitedirs.append(lib64_dir)
try:
# sys.getobjects only available in --with-pydebug build
sys.getobjects
sitedirs.insert(0, os.path.join(sitedirs[0], 'debug'))
except AttributeError:
pass
# Debian-specific dist-packages directories:
if sys.version[0] == '2':
sitedirs.append(os.path.join(prefix, "lib",
"python" + sys.version[:3],
"dist-packages"))
else:
sitedirs.append(os.path.join(prefix, "lib",
"python" + sys.version[0],
"dist-packages"))
sitedirs.append(os.path.join(prefix, "local/lib",
"python" + sys.version[:3],
"dist-packages"))
sitedirs.append(os.path.join(prefix, "lib", "dist-python"))
else:
sitedirs = [prefix, os.path.join(prefix, "lib", "site-packages")]
if sys.platform == 'darwin':
# for framework builds *only* we add the standard Apple
# locations. Currently only per-user, but /Library and
# /Network/Library could be added too
if 'Python.framework' in prefix:
home = os.environ.get('HOME')
if home:
sitedirs.append(
os.path.join(home,
'Library',
'Python',
sys.version[:3],
'site-packages'))
for sitedir in sitedirs:
if os.path.isdir(sitedir):
addsitedir(sitedir, known_paths)
return None
def check_enableusersite():
"""Check if user site directory is safe for inclusion
The function tests for the command line flag (including environment var),
process uid/gid equal to effective uid/gid.
None: Disabled for security reasons
False: Disabled by user (command line option)
True: Safe and enabled
"""
if hasattr(sys, 'flags') and getattr(sys.flags, 'no_user_site', False):
return False
if hasattr(os, "getuid") and hasattr(os, "geteuid"):
# check process uid == effective uid
if os.geteuid() != os.getuid():
return None
if hasattr(os, "getgid") and hasattr(os, "getegid"):
# check process gid == effective gid
if os.getegid() != os.getgid():
return None
return True
def addusersitepackages(known_paths):
"""Add a per user site-package to sys.path
Each user has its own python directory with site-packages in the
home directory.
USER_BASE is the root directory for all Python versions
USER_SITE is the user specific site-packages directory
USER_SITE/.. can be used for data.
"""
global USER_BASE, USER_SITE, ENABLE_USER_SITE
env_base = os.environ.get("PYTHONUSERBASE", None)
def joinuser(*args):
return os.path.expanduser(os.path.join(*args))
#if sys.platform in ('os2emx', 'riscos'):
# # Don't know what to put here
# USER_BASE = ''
# USER_SITE = ''
if os.name == "nt":
base = os.environ.get("APPDATA") or "~"
if env_base:
USER_BASE = env_base
else:
USER_BASE = joinuser(base, "Python")
USER_SITE = os.path.join(USER_BASE,
"Python" + sys.version[0] + sys.version[2],
"site-packages")
else:
if env_base:
USER_BASE = env_base
else:
USER_BASE = joinuser("~", ".local")
USER_SITE = os.path.join(USER_BASE, "lib",
"python" + sys.version[:3],
"site-packages")
if ENABLE_USER_SITE and os.path.isdir(USER_SITE):
addsitedir(USER_SITE, known_paths)
if ENABLE_USER_SITE:
for dist_libdir in ("lib", "local/lib"):
user_site = os.path.join(USER_BASE, dist_libdir,
"python" + sys.version[:3],
"dist-packages")
if os.path.isdir(user_site):
addsitedir(user_site, known_paths)
return known_paths
def setBEGINLIBPATH():
"""The OS/2 EMX port has optional extension modules that do double duty
as DLLs (and must use the .DLL file extension) for other extensions.
The library search path needs to be amended so these will be found
during module import. Use BEGINLIBPATH so that these are at the start
of the library search path.
"""
dllpath = os.path.join(sys.prefix, "Lib", "lib-dynload")
libpath = os.environ['BEGINLIBPATH'].split(';')
if libpath[-1]:
libpath.append(dllpath)
else:
libpath[-1] = dllpath
os.environ['BEGINLIBPATH'] = ';'.join(libpath)
def setquit():
"""Define new built-ins 'quit' and 'exit'.
These are simply strings that display a hint on how to exit.
"""
if os.sep == ':':
eof = 'Cmd-Q'
elif os.sep == '\\':
eof = 'Ctrl-Z plus Return'
else:
eof = 'Ctrl-D (i.e. EOF)'
class Quitter(object):
def __init__(self, name):
self.name = name
def __repr__(self):
return 'Use %s() or %s to exit' % (self.name, eof)
def __call__(self, code=None):
# Shells like IDLE catch the SystemExit, but listen when their
# stdin wrapper is closed.
try:
sys.stdin.close()
except:
pass
raise SystemExit(code)
builtins.quit = Quitter('quit')
builtins.exit = Quitter('exit')
class _Printer(object):
"""interactive prompt objects for printing the license text, a list of
contributors and the copyright notice."""
MAXLINES = 23
def __init__(self, name, data, files=(), dirs=()):
self.__name = name
self.__data = data
self.__files = files
self.__dirs = dirs
self.__lines = None
def __setup(self):
if self.__lines:
return
data = None
for dir in self.__dirs:
for filename in self.__files:
filename = os.path.join(dir, filename)
try:
fp = open(filename, "rU")
data = fp.read()
fp.close()
break
except IOError:
pass
if data:
break
if not data:
data = self.__data
self.__lines = data.split('\n')
self.__linecnt = len(self.__lines)
def __repr__(self):
self.__setup()
if len(self.__lines) <= self.MAXLINES:
return "\n".join(self.__lines)
else:
return "Type %s() to see the full %s text" % ((self.__name,)*2)
def __call__(self):
self.__setup()
prompt = 'Hit Return for more, or q (and Return) to quit: '
lineno = 0
while 1:
try:
for i in range(lineno, lineno + self.MAXLINES):
print(self.__lines[i])
except IndexError:
break
else:
lineno += self.MAXLINES
key = None
while key is None:
try:
key = raw_input(prompt)
except NameError:
key = input(prompt)
if key not in ('', 'q'):
key = None
if key == 'q':
break
def setcopyright():
"""Set 'copyright' and 'credits' in __builtin__"""
builtins.copyright = _Printer("copyright", sys.copyright)
if _is_jython:
builtins.credits = _Printer(
"credits",
"Jython is maintained by the Jython developers (www.jython.org).")
elif _is_pypy:
builtins.credits = _Printer(
"credits",
"PyPy is maintained by the PyPy developers: http://codespeak.net/pypy")
else:
builtins.credits = _Printer("credits", """\
Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
for supporting Python development. See www.python.org for more information.""")
here = os.path.dirname(os.__file__)
builtins.license = _Printer(
"license", "See http://www.python.org/%.3s/license.html" % sys.version,
["LICENSE.txt", "LICENSE"],
[os.path.join(here, os.pardir), here, os.curdir])
class _Helper(object):
"""Define the built-in 'help'.
This is a wrapper around pydoc.help (with a twist).
"""
def __repr__(self):
return "Type help() for interactive help, " \
"or help(object) for help about object."
def __call__(self, *args, **kwds):
import pydoc
return pydoc.help(*args, **kwds)
def sethelper():
builtins.help = _Helper()
def aliasmbcs():
"""On Windows, some default encodings are not provided by Python,
while they are always available as "mbcs" in each locale. Make
them usable by aliasing to "mbcs" in such a case."""
if sys.platform == 'win32':
import locale, codecs
enc = locale.getdefaultlocale()[1]
if enc.startswith('cp'): # "cp***" ?
try:
codecs.lookup(enc)
except LookupError:
import encodings
encodings._cache[enc] = encodings._unknown
encodings.aliases.aliases[enc] = 'mbcs'
def setencoding():
"""Set the string encoding used by the Unicode implementation. The
default is 'ascii', but if you're willing to experiment, you can
change this."""
encoding = "ascii" # Default value set by _PyUnicode_Init()
if 0:
# Enable to support locale aware default string encodings.
import locale
loc = locale.getdefaultlocale()
if loc[1]:
encoding = loc[1]
if 0:
# Enable to switch off string to Unicode coercion and implicit
# Unicode to string conversion.
encoding = "undefined"
if encoding != "ascii":
# On Non-Unicode builds this will raise an AttributeError...
sys.setdefaultencoding(encoding) # Needs Python Unicode build !
def execsitecustomize():
"""Run custom site specific code, if available."""
try:
import sitecustomize
except ImportError:
pass
def virtual_install_main_packages():
f = open(os.path.join(os.path.dirname(__file__), 'orig-prefix.txt'))
sys.real_prefix = f.read().strip()
f.close()
pos = 2
hardcoded_relative_dirs = []
if sys.path[0] == '':
pos += 1
if _is_jython:
paths = [os.path.join(sys.real_prefix, 'Lib')]
elif _is_pypy:
if sys.pypy_version_info >= (1, 5):
cpyver = '%d.%d' % sys.version_info[:2]
else:
cpyver = '%d.%d.%d' % sys.version_info[:3]
paths = [os.path.join(sys.real_prefix, 'lib_pypy'),
os.path.join(sys.real_prefix, 'lib-python', 'modified-%s' % cpyver),
os.path.join(sys.real_prefix, 'lib-python', cpyver)]
hardcoded_relative_dirs = paths[:] # for the special 'darwin' case below
#
# This is hardcoded in the Python executable, but relative to sys.prefix:
for path in paths[:]:
plat_path = os.path.join(path, 'plat-%s' % sys.platform)
if os.path.exists(plat_path):
paths.append(plat_path)
elif sys.platform == 'win32':
paths = [os.path.join(sys.real_prefix, 'Lib'), os.path.join(sys.real_prefix, 'DLLs')]
else:
paths = [os.path.join(sys.real_prefix, 'lib', 'python'+sys.version[:3])]
hardcoded_relative_dirs = paths[:] # for the special 'darwin' case below
lib64_path = os.path.join(sys.real_prefix, 'lib64', 'python'+sys.version[:3])
if os.path.exists(lib64_path):
if sys.maxsize > 2**32:
paths.insert(0, lib64_path)
else:
paths.append(lib64_path)
# This is hardcoded in the Python executable, but relative to sys.prefix:
plat_path = os.path.join(sys.real_prefix, 'lib', 'python'+sys.version[:3],
'plat-%s' % sys.platform)
if os.path.exists(plat_path):
paths.append(plat_path)
# This is hardcoded in the Python executable, but
# relative to sys.prefix, so we have to fix up:
for path in list(paths):
tk_dir = os.path.join(path, 'lib-tk')
if os.path.exists(tk_dir):
paths.append(tk_dir)
# These are hardcoded in the Apple's Python executable,
# but relative to sys.prefix, so we have to fix them up:
if sys.platform == 'darwin':
hardcoded_paths = [os.path.join(relative_dir, module)
for relative_dir in hardcoded_relative_dirs
for module in ('plat-darwin', 'plat-mac', 'plat-mac/lib-scriptpackages')]
for path in hardcoded_paths:
if os.path.exists(path):
paths.append(path)
sys.path.extend(paths)
def force_global_eggs_after_local_site_packages():
"""
Force easy_installed eggs in the global environment to get placed
in sys.path after all packages inside the virtualenv. This
maintains the "least surprise" result that packages in the
virtualenv always mask global packages, never the other way
around.
"""
egginsert = getattr(sys, '__egginsert', 0)
for i, path in enumerate(sys.path):
if i > egginsert and path.startswith(sys.prefix):
egginsert = i
sys.__egginsert = egginsert + 1
def virtual_addsitepackages(known_paths):
force_global_eggs_after_local_site_packages()
return addsitepackages(known_paths, sys_prefix=sys.real_prefix)
def fixclasspath():
"""Adjust the special classpath sys.path entries for Jython. These
entries should follow the base virtualenv lib directories.
"""
paths = []
classpaths = []
for path in sys.path:
if path == '__classpath__' or path.startswith('__pyclasspath__'):
classpaths.append(path)
else:
paths.append(path)
sys.path = paths
sys.path.extend(classpaths)
def execusercustomize():
"""Run custom user specific code, if available."""
try:
import usercustomize
except ImportError:
pass
def main():
global ENABLE_USER_SITE
virtual_install_main_packages()
abs__file__()
paths_in_sys = removeduppaths()
if (os.name == "posix" and sys.path and
os.path.basename(sys.path[-1]) == "Modules"):
addbuilddir()
if _is_jython:
fixclasspath()
GLOBAL_SITE_PACKAGES = not os.path.exists(os.path.join(os.path.dirname(__file__), 'no-global-site-packages.txt'))
if not GLOBAL_SITE_PACKAGES:
ENABLE_USER_SITE = False
if ENABLE_USER_SITE is None:
ENABLE_USER_SITE = check_enableusersite()
paths_in_sys = addsitepackages(paths_in_sys)
paths_in_sys = addusersitepackages(paths_in_sys)
if GLOBAL_SITE_PACKAGES:
paths_in_sys = virtual_addsitepackages(paths_in_sys)
if sys.platform == 'os2emx':
setBEGINLIBPATH()
setquit()
setcopyright()
sethelper()
aliasmbcs()
setencoding()
execsitecustomize()
if ENABLE_USER_SITE:
execusercustomize()
# Remove sys.setdefaultencoding() so that users cannot change the
# encoding after initialization. The test for presence is needed when
# this module is run as a script, because this code is executed twice.
if hasattr(sys, "setdefaultencoding"):
del sys.setdefaultencoding
main()
def _script():
help = """\
%s [--user-base] [--user-site]
Without arguments print some useful information
With arguments print the value of USER_BASE and/or USER_SITE separated
by '%s'.
Exit codes with --user-base or --user-site:
0 - user site directory is enabled
1 - user site directory is disabled by user
2 - uses site directory is disabled by super user
or for security reasons
>2 - unknown error
"""
args = sys.argv[1:]
if not args:
print("sys.path = [")
for dir in sys.path:
print(" %r," % (dir,))
print("]")
def exists(path):
if os.path.isdir(path):
return "exists"
else:
return "doesn't exist"
print("USER_BASE: %r (%s)" % (USER_BASE, exists(USER_BASE)))
print("USER_SITE: %r (%s)" % (USER_SITE, exists(USER_BASE)))
print("ENABLE_USER_SITE: %r" % ENABLE_USER_SITE)
sys.exit(0)
buffer = []
if '--user-base' in args:
buffer.append(USER_BASE)
if '--user-site' in args:
buffer.append(USER_SITE)
if buffer:
print(os.pathsep.join(buffer))
if ENABLE_USER_SITE:
sys.exit(0)
elif ENABLE_USER_SITE is False:
sys.exit(1)
elif ENABLE_USER_SITE is None:
sys.exit(2)
else:
sys.exit(3)
else:
import textwrap
print(textwrap.dedent(help % (sys.argv[0], os.pathsep)))
sys.exit(10)
if __name__ == '__main__':
_script()
Binary file not shown.