summaryrefslogtreecommitdiff
path: root/virtualenv_embedded
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2012-06-22 18:39:45 +0200
committerJannis Leidel <jannis@leidel.info>2012-06-22 18:39:45 +0200
commitc80ab42b6d3a345d71c39c8bdab197015ad3ed4b (patch)
treeb36a71b525bcabb5bd46e6c5696ecfd2b93b3aa8 /virtualenv_embedded
parent1a3a9c099163126e9be49114ca57937d71777597 (diff)
parent5bc16dff8c78723273d41849635343e102421ac9 (diff)
downloadvirtualenv-1.7.2.tar.gz
Merge branch 'release/1.7.2'1.7.2
Diffstat (limited to 'virtualenv_embedded')
-rw-r--r--virtualenv_embedded/activate.csh4
-rw-r--r--virtualenv_embedded/activate.fish71
-rw-r--r--virtualenv_embedded/activate.sh8
-rw-r--r--virtualenv_embedded/distribute_setup.py23
-rw-r--r--virtualenv_embedded/distutils-init.py7
-rw-r--r--virtualenv_embedded/site.py8
6 files changed, 67 insertions, 54 deletions
diff --git a/virtualenv_embedded/activate.csh b/virtualenv_embedded/activate.csh
index 20fe95d..4c5abc1 100644
--- a/virtualenv_embedded/activate.csh
+++ b/virtualenv_embedded/activate.csh
@@ -2,7 +2,7 @@
# You cannot run it directly.
# 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.
deactivate nondestructive
@@ -28,5 +28,7 @@ endif
set prompt = "[$env_name] $prompt"
unset env_name
+alias pydoc python -m pydoc
+
rehash
diff --git a/virtualenv_embedded/activate.fish b/virtualenv_embedded/activate.fish
index fcb31d8..119399b 100644
--- a/virtualenv_embedded/activate.fish
+++ b/virtualenv_embedded/activate.fish
@@ -11,12 +11,17 @@ function deactivate -d "Exit virtualenv and return to normal shell environment"
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!
@@ -39,41 +44,31 @@ if set -q 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
-
+ # 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__"
- # 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
+ 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
-
diff --git a/virtualenv_embedded/activate.sh b/virtualenv_embedded/activate.sh
index 975d7e7..b25efa6 100644
--- a/virtualenv_embedded/activate.sh
+++ b/virtualenv_embedded/activate.sh
@@ -2,6 +2,8 @@
# you cannot run it directly
deactivate () {
+ unset pydoc
+
# reset old environment variables
if [ -n "$_OLD_VIRTUAL_PATH" ] ; then
PATH="$_OLD_VIRTUAL_PATH"
@@ -18,7 +20,7 @@ deactivate () {
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
- hash -r
+ hash -r 2>/dev/null
fi
if [ -n "$_OLD_VIRTUAL_PS1" ] ; then
@@ -68,9 +70,11 @@ if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then
export PS1
fi
+alias pydoc="python -m pydoc"
+
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
- hash -r
+ hash -r 2>/dev/null
fi
diff --git a/virtualenv_embedded/distribute_setup.py b/virtualenv_embedded/distribute_setup.py
index b204902..86272cc 100644
--- a/virtualenv_embedded/distribute_setup.py
+++ b/virtualenv_embedded/distribute_setup.py
@@ -14,6 +14,7 @@ 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
@@ -46,7 +47,7 @@ except ImportError:
args = [quote(arg) for arg in args]
return os.spawnl(os.P_WAIT, sys.executable, *args) == 0
-DEFAULT_VERSION = "0.6.24"
+DEFAULT_VERSION = "0.6.27"
DEFAULT_URL = "http://pypi.python.org/packages/source/d/distribute/"
SETUPTOOLS_FAKED_VERSION = "0.6c11"
@@ -63,7 +64,7 @@ Description: xxx
""" % SETUPTOOLS_FAKED_VERSION
-def _install(tarball):
+def _install(tarball, install_args=()):
# extracting the tarball
tmpdir = tempfile.mkdtemp()
log.warn('Extracting in %s', tmpdir)
@@ -81,11 +82,12 @@ def _install(tarball):
# installing
log.warn('Installing Distribute')
- if not _python_cmd('setup.py', 'install'):
+ if not _python_cmd('setup.py', 'install', *install_args):
log.warn('Something went wrong during the installation.')
log.warn('See the error message above.')
finally:
os.chdir(old_wd)
+ shutil.rmtree(tmpdir)
def _build_egg(egg, tarball, to_dir):
@@ -110,6 +112,7 @@ def _build_egg(egg, tarball, to_dir):
finally:
os.chdir(old_wd)
+ shutil.rmtree(tmpdir)
# returning the result
log.warn(egg)
if not os.path.exists(egg):
@@ -306,6 +309,9 @@ def _create_fake_setuptools_pkg_info(placeholder):
log.warn('%s already exists', pkg_info)
return
+ if not os.access(pkg_info, os.W_OK):
+ log.warn("Don't have permissions to write %s, skipping", pkg_info)
+
log.warn('Creating %s', pkg_info)
f = open(pkg_info, 'w')
try:
@@ -474,11 +480,20 @@ def _extractall(self, path=".", members=None):
else:
self._dbg(1, "tarfile: %s" % e)
+def _build_install_args(argv):
+ install_args = []
+ user_install = '--user' in argv
+ if user_install and sys.version_info < (2,6):
+ log.warn("--user requires Python 2.6 or later")
+ raise SystemExit(1)
+ if user_install:
+ install_args.append('--user')
+ return install_args
def main(argv, version=DEFAULT_VERSION):
"""Install or upgrade setuptools and EasyInstall"""
tarball = download_setuptools()
- _install(tarball)
+ _install(tarball, _build_install_args(argv))
if __name__ == '__main__':
diff --git a/virtualenv_embedded/distutils-init.py b/virtualenv_embedded/distutils-init.py
index 7eea9ef..e272d1e 100644
--- a/virtualenv_embedded/distutils-init.py
+++ b/virtualenv_embedded/distutils-init.py
@@ -15,11 +15,8 @@ else:
__path__.insert(0, distutils_path)
exec(open(os.path.join(distutils_path, '__init__.py')).read())
-try:
- import dist
- import sysconfig
-except ImportError:
- from distutils import dist, sysconfig
+from distutils import dist, sysconfig
+
try:
basestring
except NameError:
diff --git a/virtualenv_embedded/site.py b/virtualenv_embedded/site.py
index 935808b..1faaa11 100644
--- a/virtualenv_embedded/site.py
+++ b/virtualenv_embedded/site.py
@@ -422,7 +422,7 @@ class _Printer(object):
for filename in self.__files:
filename = os.path.join(dir, filename)
try:
- fp = file(filename, "rU")
+ fp = open(filename, "rU")
data = fp.read()
fp.close()
break
@@ -553,9 +553,7 @@ def virtual_install_main_packages():
hardcoded_relative_dirs = []
if sys.path[0] == '':
pos += 1
- if sys.platform == 'win32':
- paths = [os.path.join(sys.real_prefix, 'Lib'), os.path.join(sys.real_prefix, 'DLLs')]
- elif _is_jython:
+ if _is_jython:
paths = [os.path.join(sys.real_prefix, 'Lib')]
elif _is_pypy:
if sys.pypy_version_info >= (1, 5):
@@ -572,6 +570,8 @@ def virtual_install_main_packages():
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