From db9bbdb4db7b5ec67dafed52e1d6760d6980fbbd Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Oct 2008 14:01:38 +0000 Subject: [PATCH 001/947] fix the download url --HG-- extra : convert_revision : svn%3A98f53aa3-d424-0410-b225-a548b0275c4d/Projects/virtualenvwrapper/trunk%401726 --- setup.py.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py.in b/setup.py.in index 992f50d..c944cce 100644 --- a/setup.py.in +++ b/setup.py.in @@ -57,7 +57,7 @@ setup ( author_email = 'doug.hellmann@gmail.com', url = 'http://www.doughellmann.com/projects/virtualenvwrapper/', - download_url = 'http://www.doughellmann.com/downloads/Proctor-VERSION.tar.gz', + download_url = 'http://www.doughellmann.com/downloads/virtualenvwrapper-VERSION.tar.gz', classifiers = [ 'Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: BSD License', From 01146a71f2a6d470a1bcea657338acdfa072d161 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 13 Oct 2008 12:27:07 +0000 Subject: [PATCH 002/947] Add tab completion based on Arthur Koziel's version at http://arthurkoziel.com/2008/10/11/virtualenvwrapper-bash-completion/ --HG-- extra : convert_revision : svn%3A98f53aa3-d424-0410-b225-a548b0275c4d/Projects/virtualenvwrapper/trunk%401736 --- virtualenvwrapper_bashrc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 904a560..4cac57e 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -114,4 +114,17 @@ function workon () { source "$VIRTUAL_ENV/bin/postactivate" fi return 0 -} \ No newline at end of file +} + +# +# Set up tab completion. (Adapted from Arthur Koziel's version at +# http://arthurkoziel.com/2008/10/11/virtualenvwrapper-bash-completion/) +# +_virtualenvs () +{ + local cur="${COMP_WORDS[COMP_CWORD]}" + COMPREPLY=( $(compgen -W "`show_workon_options`" -- ${cur}) ) +} + +complete -o default -o nospace -F _virtualenvs workon +complete -o default -o nospace -F _virtualenvs rmvirtualenv From 9cc29ed328f86ec9a625dfd73c262c77771d76d3 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 8 Nov 2008 12:37:21 +0000 Subject: [PATCH 003/947] bug fix from John Shimek --HG-- extra : convert_revision : svn%3A98f53aa3-d424-0410-b225-a548b0275c4d/Projects/virtualenvwrapper/trunk%401756 --- virtualenvwrapper_bashrc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 4cac57e..64cb970 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -65,6 +65,11 @@ function mkvirtualenv () { function rmvirtualenv () { typeset env_name="$1" verify_workon_home + if ["$env_name" == "" ] + then + echo "Please specifiy an enviroment." + return 1 + fi env_dir="$WORKON_HOME/$env_name" if [ "$VIRTUAL_ENV" == "$env_dir" ] then From 1cb54d90da7c0d65f39df256de0bda64ef189118 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 8 Nov 2008 15:38:37 +0000 Subject: [PATCH 004/947] fix spelling mistake --HG-- extra : convert_revision : svn%3A98f53aa3-d424-0410-b225-a548b0275c4d/Projects/virtualenvwrapper/trunk%401759 --- virtualenvwrapper_bashrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 64cb970..2ec70fc 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -67,7 +67,7 @@ function rmvirtualenv () { verify_workon_home if ["$env_name" == "" ] then - echo "Please specifiy an enviroment." + echo "Please specify an enviroment." return 1 fi env_dir="$WORKON_HOME/$env_name" From d7f357c73953262eda01a892384131e33e7034bd Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 8 Nov 2008 15:48:34 +0000 Subject: [PATCH 005/947] fix another typo, TEST, then add another useful message when the user tries to remove an active environment --HG-- extra : convert_revision : svn%3A98f53aa3-d424-0410-b225-a548b0275c4d/Projects/virtualenvwrapper/trunk%401761 --- virtualenvwrapper_bashrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 2ec70fc..37b65c3 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -65,7 +65,7 @@ function mkvirtualenv () { function rmvirtualenv () { typeset env_name="$1" verify_workon_home - if ["$env_name" == "" ] + if [ "$env_name" == "" ] then echo "Please specify an enviroment." return 1 @@ -74,6 +74,7 @@ function rmvirtualenv () { if [ "$VIRTUAL_ENV" == "$env_dir" ] then echo "ERROR: You cannot remove the active environment ('$env_name')." + echo "Either switch to another environment, or run 'deactivate'." return 1 fi rm -rf "$env_dir" From c24fc8256969de8744a8d5ff02012cd5f1c8c65f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 11 Nov 2008 12:53:51 +0000 Subject: [PATCH 006/947] add path management feature contributed by James Bennett --HG-- extra : convert_revision : svn%3A98f53aa3-d424-0410-b225-a548b0275c4d/Projects/virtualenvwrapper/trunk%401767 --- virtualenvwrapper_bashrc | 60 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 37b65c3..5331371 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -41,8 +41,8 @@ function verify_workon_home () { # Verify that the requested environment exists function verify_workon_environment () { - typeset env_name="$1" - if [ ! -d "$WORKON_HOME/$env_name" ] + typeset env_name="$1" + if [ ! -d "$WORKON_HOME/$env_name" ] then echo "ERROR: Environment '$env_name' does not exist. Create it with 'mkvirtualenv $env_name'." return 1 @@ -50,6 +50,16 @@ function verify_workon_environment () { return 0 } +# Verify that the active environment exists +function verify_active_environment () { + if [ ! -n "${VIRTUAL_ENV}" ] || [ ! -d ${VIRTUAL_ENV} ] + then + echo "ERROR: no virtualenv active, or active virtualenv is missing" + return 1 + fi + return 0 +} + # Create a new environment, in the WORKON_HOME. # # Usage: mkvirtualenv [options] ENVNAME @@ -134,3 +144,49 @@ _virtualenvs () complete -o default -o nospace -F _virtualenvs workon complete -o default -o nospace -F _virtualenvs rmvirtualenv + +# Path management for packages outside of the virtual env. +# Based on a contribution from James Bennett. +# +# add2virtualenv directory1 directory2 ... +# +# Adds the specified directories to the Python path for the +# currently-active virtualenv. This will be done by placing the +# directory names in a path file named +# "virtualenv_path_extensions.pth" inside the virtualenv's +# site-packages directory; if this file does not exist, it will be +# created first. +# +function add2virtualenv () { + + verify_active_environment || return 1 + + site_packages=$VIRTUAL_ENV/lib/python`python -c "import sys; print sys.version[:3]"`/site-packages + + if [ ! -d "${site_packages}" ] + then + echo "ERROR: currently-active virtualenv does not appear to have a site-packages directory" + return 1 + fi + + path_file=$site_packages/virtualenv_path_extensions.pth + + if [ "$*" = "" ] + then + echo "Usage: add2virtualenv dir [dir ...]" + if [ -f "$path_file" ] + then + echo + echo "Existing paths:" + cat "$path_file" + fi + return 1 + fi + + touch $path_file + for pydir in "$@" + do + echo $pydir >> "$path_file" + done + return 0 +} From 4938a5d6d3a7bc37cbbdc7bf7cea89657bf32db0 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 11 Nov 2008 13:02:09 +0000 Subject: [PATCH 007/947] remove premature release --HG-- extra : convert_revision : svn%3A98f53aa3-d424-0410-b225-a548b0275c4d/Projects/virtualenvwrapper/trunk%401769 --- README | 17 ++++++++++++++--- virtualenvwrapper_bashrc | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README b/README index 2ed0784..834e562 100644 --- a/README +++ b/README @@ -13,9 +13,20 @@ Quick Setup 5. A list of environments, empty, is printed. 6. Run: ``mkvirtualenv temp`` 7. Run: ``workon`` -8. This time, the ``temp`` environment is included. -9. Run: ``workon temp`` -10. The virtual environment is activated. +8. A new environment, ``temp`` is created and activated. +9. This time, the ``temp`` environment is included. + + +=============== +Path Management +=============== + +Sometimes it is desirable to share installed packages that are not in the system ``site-pacakges`` directory and which you do not want to install in each virtualenv. In this case, you *could* symlink the source into the environment ``site-packages`` directory, but it is also easy to add extra directories to the PYTHONPATH by including them in a .pth file inside ``site-packages`` using ``add2virtualenv``. + +1. Check out the source for a big project, such as Django. +2. Run: ``add2virtualenv path_to_source``. +3. Run: ``add2virtualenv``. +4. A usage message and list of current "extra" paths is printed. ========== References diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 5331371..985ec62 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -146,7 +146,7 @@ complete -o default -o nospace -F _virtualenvs workon complete -o default -o nospace -F _virtualenvs rmvirtualenv # Path management for packages outside of the virtual env. -# Based on a contribution from James Bennett. +# Based on a contribution from James Bennett and Jannis Leidel. # # add2virtualenv directory1 directory2 ... # From f663a8141f7e5542f5bad305b143638c1d2e3268 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 18 Nov 2008 12:44:57 +0000 Subject: [PATCH 008/947] add docs; fix space issues --HG-- extra : convert_revision : svn%3A98f53aa3-d424-0410-b225-a548b0275c4d/Projects/virtualenvwrapper/trunk%401774 --- README | 52 +++++++++++++++++++++++++++++++++++++++- virtualenvwrapper_bashrc | 25 +++++++++++++------ 2 files changed, 69 insertions(+), 8 deletions(-) diff --git a/README b/README index 834e562..23936c4 100644 --- a/README +++ b/README @@ -28,8 +28,58 @@ Sometimes it is desirable to share installed packages that are not in the system 3. Run: ``add2virtualenv``. 4. A usage message and list of current "extra" paths is printed. +================== +Activation Scripts +================== + +virtualenvwrapper adds two separate hook scripts you can use to change your settings when moving between environments. They are *sourced* by ``workon`` at the appropriate trigger time, allowing them to modify your shell environment. + +Both scripts are bash shell scripts and need to be saved in ``$VIRTUAL_ENV/bin/``. + +postactivate +============ + +The ``postactivate`` script is run after the new environment is enabled. ``$VIRTUAL_ENV`` refers to the new environment at the time the script runs. + +This example script for the PyMOTW environment changes the current working directory and the PATH variable to refer to the source tree containing the PyMOTW source. + +:: + + pymotw_root=/Users/dhellmann/Documents/PyMOTW + cd $pymotw_root + PATH=$pymotw_root/bin:$PATH + +predeactivate +============= + +The ``predeactivate`` script is run before the current environment is deactivated, and can be used to disable or clear settings in your environment. ``$VIRTUAL_ENV`` refers to the old environment at the time the script runs. + +=============== +Path Management +=============== + +The function ``add2virtualenv`` adds the specified directories to the Python path for the active virtualenv. The directory names passed as argument are added to a path file named ``virtualenv_path_extensions.pth`` inside the virtualenv's site-packages directory. If this file does not exist, it will be created first. + ========== References ========== -For more details, refer to the column I wrote for the May 2008 issue of Python Magazine: `virtualenvwrapper | And Now For Something Completely Different `_. \ No newline at end of file +For more details, refer to the column I wrote for the May 2008 issue of Python Magazine: `virtualenvwrapper | And Now For Something Completely Different `_. + +======= +Updates +======= + +1.5 + + - Fix some issues with spaces in directory or env names. They still don't really work with virtualenv, though. + - Added documentation for the postactivate and predeactivate scripts. + +1.4 + + - Includes a new .pth management function based on work contributed by James Bennett and Jannis Leidel. + +1.3.x + + - Includes a fix for a nasty bug in rmvirtualenv identified by John Shimek. + diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 985ec62..ac6c1b0 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -52,7 +52,7 @@ function verify_workon_environment () { # Verify that the active environment exists function verify_active_environment () { - if [ ! -n "${VIRTUAL_ENV}" ] || [ ! -d ${VIRTUAL_ENV} ] + if [ ! -n "${VIRTUAL_ENV}" ] || [ ! -d "${VIRTUAL_ENV}" ] then echo "ERROR: no virtualenv active, or active virtualenv is missing" return 1 @@ -60,6 +60,16 @@ function verify_active_environment () { return 0 } +# Print the last argument given to us. +# There has to be a smarter way to do this! +function _lastarg () { + local a + for a in "$@" + do + echo $a + done | tail -1 +} + # Create a new environment, in the WORKON_HOME. # # Usage: mkvirtualenv [options] ENVNAME @@ -67,8 +77,8 @@ function verify_active_environment () { # function mkvirtualenv () { verify_workon_home - (cd "$WORKON_HOME"; virtualenv $*) - workon "${@:-1}" + (cd "$WORKON_HOME"; virtualenv "$@") + workon $(_lastarg "$@") } # Remove an environment, in the WORKON_HOME. @@ -161,7 +171,8 @@ function add2virtualenv () { verify_active_environment || return 1 - site_packages=$VIRTUAL_ENV/lib/python`python -c "import sys; print sys.version[:3]"`/site-packages + pyvers="`python -c 'import sys; print sys.version[:3]'`" + site_packages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" if [ ! -d "${site_packages}" ] then @@ -169,7 +180,7 @@ function add2virtualenv () { return 1 fi - path_file=$site_packages/virtualenv_path_extensions.pth + path_file="$site_packages/virtualenv_path_extensions.pth" if [ "$*" = "" ] then @@ -183,10 +194,10 @@ function add2virtualenv () { return 1 fi - touch $path_file + touch "$path_file" for pydir in "$@" do - echo $pydir >> "$path_file" + echo "$pydir" >> "$path_file" done return 0 } From 75eb54c064a649d62a40ee676fdaa627757aa634 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 17 Dec 2008 14:19:46 +0000 Subject: [PATCH 009/947] add zsh completion support, courtesy of Ted Leung --HG-- extra : convert_revision : svn%3A98f53aa3-d424-0410-b225-a548b0275c4d/Projects/virtualenvwrapper/trunk%401850 --- virtualenvwrapper_bashrc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index ac6c1b0..f231e72 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -146,14 +146,19 @@ function workon () { # Set up tab completion. (Adapted from Arthur Koziel's version at # http://arthurkoziel.com/2008/10/11/virtualenvwrapper-bash-completion/) # -_virtualenvs () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - COMPREPLY=( $(compgen -W "`show_workon_options`" -- ${cur}) ) -} -complete -o default -o nospace -F _virtualenvs workon -complete -o default -o nospace -F _virtualenvs rmvirtualenv +if [ -n "$BASH" ] ; then + _virtualenvs () + { + local cur="${COMP_WORDS[COMP_CWORD]}" + COMPREPLY=( $(compgen -W "`show_workon_options`" -- ${cur}) ) + } + + complete -o default -o nospace -F _virtualenvs workon + complete -o default -o nospace -F _virtualenvs rmvirtualenv +elif [ -n "$ZSH_VERSION" ] ; then + compctl -g "`show_workon_options`" workon rmvirtualenv +fi # Path management for packages outside of the virtual env. # Based on a contribution from James Bennett and Jannis Leidel. From df9dc5dfb7954f7ab306a5428c64d79bb4b7eed9 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 17 Dec 2008 14:21:39 +0000 Subject: [PATCH 010/947] add note about zsh completion support --HG-- extra : convert_revision : svn%3A98f53aa3-d424-0410-b225-a548b0275c4d/Projects/virtualenvwrapper/trunk%401851 --- README | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README b/README index 23936c4..60c0371 100644 --- a/README +++ b/README @@ -70,6 +70,10 @@ For more details, refer to the column I wrote for the May 2008 issue of Python M Updates ======= +1.6 + + - Add completion support for zsh, courtesy of Ted Leung. + 1.5 - Fix some issues with spaces in directory or env names. They still don't really work with virtualenv, though. From 747aecb44d49f3d90913631823789e12d2490728 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 18 Dec 2008 13:06:32 +0000 Subject: [PATCH 011/947] patches to rmvirtualenv to make it work with zsh from Byron Clark --HG-- extra : convert_revision : svn%3A98f53aa3-d424-0410-b225-a548b0275c4d/Projects/virtualenvwrapper/trunk%401853 --- README | 4 ++++ virtualenvwrapper_bashrc | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README b/README index 60c0371..b864d29 100644 --- a/README +++ b/README @@ -70,6 +70,10 @@ For more details, refer to the column I wrote for the May 2008 issue of Python M Updates ======= +1.6.1 + + - More zsh support (fixes to rmvirtualenv) from Byron Clark. + 1.6 - Add completion support for zsh, courtesy of Ted Leung. diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index f231e72..ea0aff0 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -85,13 +85,13 @@ function mkvirtualenv () { function rmvirtualenv () { typeset env_name="$1" verify_workon_home - if [ "$env_name" == "" ] + if [ "$env_name" = "" ] then echo "Please specify an enviroment." return 1 fi env_dir="$WORKON_HOME/$env_name" - if [ "$VIRTUAL_ENV" == "$env_dir" ] + if [ "$VIRTUAL_ENV" = "$env_dir" ] then echo "ERROR: You cannot remove the active environment ('$env_name')." echo "Either switch to another environment, or run 'deactivate'." From fbe11d4715dc049cd192c27a0396751957046f1f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 28 Feb 2009 14:18:50 +0000 Subject: [PATCH 012/947] convert from make to paver 1.0 --HG-- extra : convert_revision : svn%3A98f53aa3-d424-0410-b225-a548b0275c4d/Projects/virtualenvwrapper/trunk%401984 --- MANIFEST.in | 3 ++ Makefile | 41 ----------------- pavement.py | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++++ setup.py.in | 81 ---------------------------------- 4 files changed, 128 insertions(+), 122 deletions(-) delete mode 100644 Makefile create mode 100644 pavement.py delete mode 100644 setup.py.in diff --git a/MANIFEST.in b/MANIFEST.in index 54a1c81..a394811 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,4 @@ include README.html +include setup.py +include paver-minilib.zip +include pavement.py \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index 22e4cc7..0000000 --- a/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -# -# $Id$ -# - -SVNHOME=$(shell svn info | grep "^URL" | cut -f2- -d:) -PROJECT=virtualenvwrapper -VERSION=$(shell basename $(SVNHOME)) -RELEASE=$(PROJECT)-$(VERSION) - -info: - SVNHOME=$(SVNHOME) - PROJECT=$(PROJECT) - VERSION=$(VERSION) - RELEASE=$(RELEASE) - -package: - rm -f setup.py - $(MAKE) setup.py README.html - python setup.py sdist --force-manifest - mv dist/*.gz ~/Desktop/ - -register: setup.py - python setup.py register - -README.html: README - rst2html.py $< $@ - -%: %.in - cat $< | sed 's/VERSION/$(VERSION)/g' > $@ - chmod -w $@ - - -dist: - mkdir -p dist - -# -# Dump a version that does not include .svn directories. -# -export: - rm -rf dist/$(RELEASE) - (cd dist; svn export $(SVNHOME) $(RELEASE); rm -f $(RELEASE)/Makefile) diff --git a/pavement.py b/pavement.py new file mode 100644 index 0000000..65a1609 --- /dev/null +++ b/pavement.py @@ -0,0 +1,125 @@ +#!/usr/bin/env python +# encoding: utf-8 +# +# Copyright (c) 2008 Doug Hellmann All rights reserved. +# +""" +TODO + + - make sure all of the files from the manifests are included + +""" + +__version__ = "$Id$" + +# Standard library +import copy +import os + +# Third-party + +# Set up Paver +import paver +import paver.misctasks +from paver.path import path +from paver.easy import * +import paver.setuputils +paver.setuputils.install_distutils_tasks() + +# What project are we building? +PROJECT = 'virtualenvwrapper' + +# What version is this? (take from path in svn tree) +VERSION = path(os.getcwd()).name +os.environ['VERSION'] = VERSION + +# Read the long description to give to setup +README = path('README').text() + +# Scan the input for package information +# to grab any data files (text, images, etc.) +# associated with sub-packages. +# PACKAGE_DATA = paver.setuputils.find_package_data(PROJECT, +# package=PROJECT, +# only_in_packages=True, +# ) + +options( + setup=Bunch( + name = PROJECT, + version = VERSION, + + description = 'Enhancements to virtualenv', + long_description = README, + + author = 'Doug Hellmann', + author_email = 'doug.hellmann@gmail.com', + + url = 'http://www.doughellmann.com/projects/virtualenvwrapper/', + download_url = 'http://www.doughellmann.com/downloads/%s-%s.tar.gz' % \ + (PROJECT, VERSION), + + classifiers = [ 'Development Status :: 5 - Production/Stable', + 'License :: OSI Approved :: BSD License', + 'Programming Language :: Python', + 'Intended Audience :: Developers', + 'Environment :: Console', + ], + + platforms = ('Any',), + + scripts = ['virtualenvwrapper_bashrc', + ], + + provides=['virtualenvwrapper', + ], + requires=['virtualenv'], + + data_files=[('docs', ['README.html']), + ], + + # It seems wrong to have to list recursive packages explicitly. + # packages = sorted(PACKAGE_DATA.keys()), + # package_data=PACKAGE_DATA, + + zip_safe=False, + + ), + + packaging = Bunch( + outdir='~/Desktop', + ), + +) + +def remake_directories(*dirnames): + """Remove the directories and recreate them. + """ + for d in dirnames: + d = path(d) + if d.exists(): + d.rmtree() + d.mkdir() + return + +@task +@needs(['html', 'generate_setup', 'minilib', + 'setuptools.command.sdist' + ]) +def sdist(): + """Create a source distribution. + """ + # Move the output file to the desktop + dist_files = path('dist').glob('*.tar.gz') + dest_dir = path(options.packaging.outdir).expanduser() + for f in dist_files: + f.move(dest_dir) + return + +@task +def html(): + # FIXME - Switch to sphinx? + outfile = path('README.html') + outfile.unlink() + sh('rst2html.py README README.html') + return diff --git a/setup.py.in b/setup.py.in deleted file mode 100644 index c944cce..0000000 --- a/setup.py.in +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env python -# -# $Id: setup.py 120 2003-04-23 12:18:54Z doughellmann $ -# -# Time-stamp: <06/12/31 12:03:26 dhellmann> -# -# Copyright 2001 Doug Hellmann. -# -# -# All Rights Reserved -# -# Permission to use, copy, modify, and distribute this software and -# its documentation for any purpose and without fee is hereby -# granted, provided that the above copyright notice appear in all -# copies and that both that copyright notice and this permission -# notice appear in supporting documentation, and that the name of Doug -# Hellmann not be used in advertising or publicity pertaining to -# distribution of the software without specific, written prior -# permission. -# -# DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN -# NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR -# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS -# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, -# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# -"""Distutils setup file for Proctor - -""" - -# -# Import system modules -# -from distutils.core import setup -import os - -# -# Import Local modules -# - -# -# Module -# - -long_description = open('README', 'rt').read() - -setup ( - name = 'virtualenvwrapper', - version = 'VERSION', - - description = 'Enhancements to virtualenv', - long_description = long_description, - - author = 'Doug Hellmann', - author_email = 'doug.hellmann@gmail.com', - - url = 'http://www.doughellmann.com/projects/virtualenvwrapper/', - download_url = 'http://www.doughellmann.com/downloads/virtualenvwrapper-VERSION.tar.gz', - - classifiers = [ 'Development Status :: 5 - Production/Stable', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: Python', - 'Intended Audience :: Developers', - 'Environment :: Console', - ], - - platforms = ('Any',), - - scripts = ['virtualenvwrapper_bashrc', - ], - - provides=['virtualenvwrapper', - ], - requires=['virtualenv'], - - data_files=[('docs', ['README.html']), - ], - ) - From f24284f5555a5d2dae9ccc26074a2647651e4f3f Mon Sep 17 00:00:00 2001 From: convert-repo Date: Thu, 5 Mar 2009 05:48:01 +0000 Subject: [PATCH 013/947] update tags --- .hgtags | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .hgtags diff --git a/.hgtags b/.hgtags new file mode 100644 index 0000000..d6571a5 --- /dev/null +++ b/.hgtags @@ -0,0 +1,10 @@ +6172dee8bf6a2babf689f01288d843ab21dc6284 1.0 +8c46828abec08903275727ac4cae20e3dfa5c0c2 1.3.1 +8c46828abec08903275727ac4cae20e3dfa5c0c2 1.3.2 +8c46828abec08903275727ac4cae20e3dfa5c0c2 1.4 +8c46828abec08903275727ac4cae20e3dfa5c0c2 1.5 +8c46828abec08903275727ac4cae20e3dfa5c0c2 1.6 +8c46828abec08903275727ac4cae20e3dfa5c0c2 1.6.1 +b39eeb3dd437ec6c4ab29ed9b020061a639032fe 1.1 +b39eeb3dd437ec6c4ab29ed9b020061a639032fe 1.2 +b39eeb3dd437ec6c4ab29ed9b020061a639032fe 1.3 From f0abb5abba0f9364311fa99c8a84580068c65a45 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 5 Mar 2009 08:38:51 -0500 Subject: [PATCH 014/947] Ignore files generated by paver and the build process. Use a fixed version string in the pavement.py file. --- .hgignore | 4 ++++ pavement.py | 10 ++++------ 2 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 .hgignore diff --git a/.hgignore b/.hgignore new file mode 100644 index 0000000..fe2f22a --- /dev/null +++ b/.hgignore @@ -0,0 +1,4 @@ +README.html +virtualenvwrapper.egg-info +paver-minilib.zip +setup.py diff --git a/pavement.py b/pavement.py index 65a1609..fb61442 100644 --- a/pavement.py +++ b/pavement.py @@ -28,13 +28,11 @@ # What project are we building? PROJECT = 'virtualenvwrapper' - -# What version is this? (take from path in svn tree) -VERSION = path(os.getcwd()).name -os.environ['VERSION'] = VERSION +VERSION = '1.7' # Read the long description to give to setup -README = path('README').text() +README_FILE = 'README' +README = path(README_FILE).text() # Scan the input for package information # to grab any data files (text, images, etc.) @@ -121,5 +119,5 @@ def html(): # FIXME - Switch to sphinx? outfile = path('README.html') outfile.unlink() - sh('rst2html.py README README.html') + sh('rst2html.py %s README.html' % README_FILE) return From b773315896bef45b128f99cb43a5724e46432301 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 5 Mar 2009 08:38:58 -0500 Subject: [PATCH 015/947] Added tag 1.7 for changeset 54aa96a1c09f --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index d6571a5..5183b10 100644 --- a/.hgtags +++ b/.hgtags @@ -8,3 +8,4 @@ b39eeb3dd437ec6c4ab29ed9b020061a639032fe 1.1 b39eeb3dd437ec6c4ab29ed9b020061a639032fe 1.2 b39eeb3dd437ec6c4ab29ed9b020061a639032fe 1.3 +54aa96a1c09f4e6474dcbee8f6fbbf811c97987d 1.7 From 55c7935cc6e480259e758e0c33dad829bf7cef42 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 5 Mar 2009 09:16:34 -0500 Subject: [PATCH 016/947] Clean up TODO list and svn keywords. Add license section to README. --- README | 27 +++++++++++++++++++++++++++ TODO | 7 +++++-- pavement.py | 8 +------- virtualenvwrapper_bashrc | 2 -- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/README b/README index b864d29..0298a57 100644 --- a/README +++ b/README @@ -70,6 +70,11 @@ For more details, refer to the column I wrote for the May 2008 issue of Python M Updates ======= +1.7 + - Move to bitbucket.org for hosting + - clean up TODO list and svn keywords + - add license section below + 1.6.1 - More zsh support (fixes to rmvirtualenv) from Byron Clark. @@ -91,3 +96,25 @@ Updates - Includes a fix for a nasty bug in rmvirtualenv identified by John Shimek. +======= +License +======= + +Copyright Doug Hellmann, All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that copyright notice and this permission +notice appear in supporting documentation, and that the name of Doug +Hellmann not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN +NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/TODO b/TODO index e34a424..fbbc52d 100644 --- a/TODO +++ b/TODO @@ -1,2 +1,5 @@ -o register on pypi -o setup.py for easy_install? +######### +TODO List +######### + + - figure out if there's a way to host tarballs on bitbucket.org diff --git a/pavement.py b/pavement.py index fb61442..6710795 100644 --- a/pavement.py +++ b/pavement.py @@ -1,17 +1,11 @@ #!/usr/bin/env python # encoding: utf-8 # -# Copyright (c) 2008 Doug Hellmann All rights reserved. +# Copyright (c) 2009 Doug Hellmann All rights reserved. # """ -TODO - - - make sure all of the files from the manifests are included - """ -__version__ = "$Id$" - # Standard library import copy import os diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index ea0aff0..3c68d1d 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -1,6 +1,4 @@ # -# $Id$ -# # Shell functions to act as wrapper for Ian Bicking's virtualenv # (http://pypi.python.org/pypi/virtualenv) # From e2594dc0ac1931aff9951fb347e89f7acdd6250a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 5 Mar 2009 09:16:49 -0500 Subject: [PATCH 017/947] Added tag 1.7 for changeset 32f2a081d649 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 5183b10..6cf96b8 100644 --- a/.hgtags +++ b/.hgtags @@ -9,3 +9,4 @@ b39eeb3dd437ec6c4ab29ed9b020061a639032fe 1.1 b39eeb3dd437ec6c4ab29ed9b020061a639032fe 1.2 b39eeb3dd437ec6c4ab29ed9b020061a639032fe 1.3 54aa96a1c09f4e6474dcbee8f6fbbf811c97987d 1.7 +32f2a081d64997ec7bd863132978043a43b7f64a 1.7 From 44e0741ba407f6da36f9630c43eeae6840c93970 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 6 Mar 2009 08:13:54 -0500 Subject: [PATCH 018/947] Fix for processing the argument list in mkvirtualenv from jorgevargas (#1) --- README | 2 ++ pavement.py | 2 +- virtualenvwrapper_bashrc | 12 +----------- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/README b/README index 0298a57..38d9fae 100644 --- a/README +++ b/README @@ -69,6 +69,8 @@ For more details, refer to the column I wrote for the May 2008 issue of Python M ======= Updates ======= +1.8 + - Fix for processing the argument list in mkvirtualenv from jorgevargas (BitBucket issue #1) 1.7 - Move to bitbucket.org for hosting diff --git a/pavement.py b/pavement.py index 6710795..dace793 100644 --- a/pavement.py +++ b/pavement.py @@ -22,7 +22,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.7' +VERSION = '1.8' # Read the long description to give to setup README_FILE = 'README' diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 3c68d1d..4095691 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -58,16 +58,6 @@ function verify_active_environment () { return 0 } -# Print the last argument given to us. -# There has to be a smarter way to do this! -function _lastarg () { - local a - for a in "$@" - do - echo $a - done | tail -1 -} - # Create a new environment, in the WORKON_HOME. # # Usage: mkvirtualenv [options] ENVNAME @@ -76,7 +66,7 @@ function _lastarg () { function mkvirtualenv () { verify_workon_home (cd "$WORKON_HOME"; virtualenv "$@") - workon $(_lastarg "$@") + workon "$_" } # Remove an environment, in the WORKON_HOME. From 9cc0a3cda9628338a5bfb02b043a897fb99a5601 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 6 Mar 2009 08:14:05 -0500 Subject: [PATCH 019/947] Added tag 1.8 for changeset ea5f27af83bb --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 6cf96b8..c364a15 100644 --- a/.hgtags +++ b/.hgtags @@ -10,3 +10,4 @@ b39eeb3dd437ec6c4ab29ed9b020061a639032fe 1.2 b39eeb3dd437ec6c4ab29ed9b020061a639032fe 1.3 54aa96a1c09f4e6474dcbee8f6fbbf811c97987d 1.7 32f2a081d64997ec7bd863132978043a43b7f64a 1.7 +ea5f27af83bb54128e7fa8752c61de074efec2ca 1.8 From 4428140811342069aad1ea4064fbda689f37b722 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 6 Mar 2009 12:37:48 -0500 Subject: [PATCH 020/947] fix argument processing in mkvirtualenv --- README | 4 ++++ virtualenvwrapper_bashrc | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README b/README index 38d9fae..b16bbbb 100644 --- a/README +++ b/README @@ -69,6 +69,10 @@ For more details, refer to the column I wrote for the May 2008 issue of Python M ======= Updates ======= + +1.8.1 + - Corrected a problem with change to mkvirtualenv that lead to release 1.8 by using an alternate fix proposed by James in comments on release 1.4. + 1.8 - Fix for processing the argument list in mkvirtualenv from jorgevargas (BitBucket issue #1) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 4095691..4cbad1f 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -64,9 +64,10 @@ function verify_active_environment () { # (where the options are passed directly to virtualenv) # function mkvirtualenv () { + eval "envname=\$$#" verify_workon_home - (cd "$WORKON_HOME"; virtualenv "$@") - workon "$_" + (cd "$WORKON_HOME"; virtualenv "$@") + workon "$envname" } # Remove an environment, in the WORKON_HOME. From 01eaf91ac510a0534513131d41d077e66eea5c44 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 6 Mar 2009 12:38:06 -0500 Subject: [PATCH 021/947] Added tag 1.8.1 for changeset dca76424222e --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index c364a15..0643215 100644 --- a/.hgtags +++ b/.hgtags @@ -11,3 +11,4 @@ b39eeb3dd437ec6c4ab29ed9b020061a639032fe 1.3 54aa96a1c09f4e6474dcbee8f6fbbf811c97987d 1.7 32f2a081d64997ec7bd863132978043a43b7f64a 1.7 ea5f27af83bb54128e7fa8752c61de074efec2ca 1.8 +dca76424222e4f5184aab2c64129029bebd3b378 1.8.1 From 4e59cf468fdcd67a4b2770d142812cff0f10a0a4 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 6 Mar 2009 12:38:23 -0500 Subject: [PATCH 022/947] bump version number --- pavement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pavement.py b/pavement.py index dace793..70c8c93 100644 --- a/pavement.py +++ b/pavement.py @@ -22,7 +22,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.8' +VERSION = '1.8.1' # Read the long description to give to setup README_FILE = 'README' From 9b64b67977b303ea9c537f8993f9792b9e67e979 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 6 Mar 2009 12:38:30 -0500 Subject: [PATCH 023/947] Added tag 1.8.1 for changeset 8417344df8ff --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 0643215..0324f19 100644 --- a/.hgtags +++ b/.hgtags @@ -12,3 +12,4 @@ b39eeb3dd437ec6c4ab29ed9b020061a639032fe 1.3 32f2a081d64997ec7bd863132978043a43b7f64a 1.7 ea5f27af83bb54128e7fa8752c61de074efec2ca 1.8 dca76424222e4f5184aab2c64129029bebd3b378 1.8.1 +8417344df8ff4ea1ddfe563956e7e36cddfd732d 1.8.1 From 488d794715f15e8ac47829780215a11b1ce7af83 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 14 Mar 2009 12:49:21 -0400 Subject: [PATCH 024/947] add more hooks based on suggestion from Chris Hasenpflug; add documentation --- .hgignore | 1 + README | 63 ++++++++++++++++++++++++++++++---------- pavement.py | 2 +- test.sh | 54 ++++++++++++++++++++++++++++++++++ virtualenvwrapper_bashrc | 63 +++++++++++++++++++++++++--------------- 5 files changed, 143 insertions(+), 40 deletions(-) create mode 100755 test.sh diff --git a/.hgignore b/.hgignore index fe2f22a..fd9f147 100644 --- a/.hgignore +++ b/.hgignore @@ -2,3 +2,4 @@ README.html virtualenvwrapper.egg-info paver-minilib.zip setup.py +trace.txt diff --git a/README b/README index b16bbbb..515dc8c 100644 --- a/README +++ b/README @@ -28,31 +28,59 @@ Sometimes it is desirable to share installed packages that are not in the system 3. Run: ``add2virtualenv``. 4. A usage message and list of current "extra" paths is printed. -================== -Activation Scripts -================== - -virtualenvwrapper adds two separate hook scripts you can use to change your settings when moving between environments. They are *sourced* by ``workon`` at the appropriate trigger time, allowing them to modify your shell environment. +============ +Hook Scripts +============ -Both scripts are bash shell scripts and need to be saved in ``$VIRTUAL_ENV/bin/``. +virtualenvwrapper adds several hook points you can use to change your settings when creating, +deleting, or moving between environments. They are either *sourced* (allowing them to modify +your shell environment) or run as an external program at the appropriate trigger time. -postactivate -============ +$VIRTUAL_ENV/bin/postactivate +============================= -The ``postactivate`` script is run after the new environment is enabled. ``$VIRTUAL_ENV`` refers to the new environment at the time the script runs. +The ``postactivate`` script is sourced after the new environment is enabled. ``$VIRTUAL_ENV`` +refers to the new environment at the time the script runs. -This example script for the PyMOTW environment changes the current working directory and the PATH variable to refer to the source tree containing the PyMOTW source. +This example script for the PyMOTW environment changes the current working directory and the +PATH variable to refer to the source tree containing the PyMOTW source. :: - pymotw_root=/Users/dhellmann/Documents/PyMOTW - cd $pymotw_root - PATH=$pymotw_root/bin:$PATH + pymotw_root=/Users/dhellmann/Documents/PyMOTW + cd $pymotw_root + PATH=$pymotw_root/bin:$PATH + +$VIRTUAL_ENV/bin/predeactivate +============================== + +The ``predeactivate`` script is source before the current environment is deactivated, and can +be used to disable or clear settings in your environment. ``$VIRTUAL_ENV`` refers to the old +environment at the time the script runs. + +$WORKON_HOME/premkvirtualenv +============================= -predeactivate -============= +The ``premkvirtualenv`` script is run as an external program after the virtual environment is +created but before the current environment is switched to point to the new env. The current +working directory for the script is ``$WORKON_HOME`` and the name of the new environment is +passed as an argument to the script. -The ``predeactivate`` script is run before the current environment is deactivated, and can be used to disable or clear settings in your environment. ``$VIRTUAL_ENV`` refers to the old environment at the time the script runs. +$WORKON_HOME/postmkvirtualenv +============================= + +The ``postmkvirtualenv`` script is sourced after the new environment is created and +activated. + +$WORKON_HOME/prermvirtualenv +============================ + +The ``prermvirtualenv`` script is run as an external program before the environment is removed. The full path to the environment directory is passed as an argument to the script. + +$WORKON_HOME/postrmvirtualenv +============================= + +The ``postrmvirtualenv`` script is run as an external program after the environment is removed. The full path to the environment directory is passed as an argument to the script. =============== Path Management @@ -70,6 +98,9 @@ For more details, refer to the column I wrote for the May 2008 issue of Python M Updates ======= +1.9 + - Add more hooks for operations to run before and after creating or deleting environments based on changes from Chris Hasenpflug. + 1.8.1 - Corrected a problem with change to mkvirtualenv that lead to release 1.8 by using an alternate fix proposed by James in comments on release 1.4. diff --git a/pavement.py b/pavement.py index 70c8c93..e499cde 100644 --- a/pavement.py +++ b/pavement.py @@ -22,7 +22,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.8.1' +VERSION = '1.9' # Read the long description to give to setup README_FILE = 'README' diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..df7c9e8 --- /dev/null +++ b/test.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +#set -x + +export WORKON_HOME="./WORKON_HOME" +mkdir -p $WORKON_HOME + +function mk_test_hook () { + hookname="$1" + echo "echo \"$hookname\" \$@" > $WORKON_HOME/$hookname + chmod +x $WORKON_HOME/$hookname +} + +mk_test_hook premkvirtualenv +mk_test_hook postmkvirtualenv +mk_test_hook prermvirtualenv +mk_test_hook postrmvirtualenv + +echo +echo "HOOKS:" +ls -l $WORKON_HOME + +bindir=$(dirname $0) +source "$bindir/virtualenvwrapper_bashrc" + +echo +echo "CREATING AND ACTIVATING" +mkvirtualenv "env1" +echo "Current environment: $VIRTUAL_ENV" + +echo +echo "CREATING AND SWITCHING" +mkvirtualenv "env2" +echo "Current environment: $VIRTUAL_ENV" + +echo +echo "POSTACTIVATE HOOK" +echo "echo postactivate" > $WORKON_HOME/env1/bin/postactivate +workon env1 + +echo +echo "DEACTIVATING" +deactivate + +echo +echo "LISTING ENVIRONMENTS" +workon + +echo +echo "REMOVING ENVIRONMENTS" +rmvirtualenv "env1" +rmvirtualenv "env2" + +rm -rf $WORKON_HOME diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 4cbad1f..8da40ce 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -28,7 +28,7 @@ then fi # Verify that the WORKON_HOME directory exists -function verify_workon_home () { +function virtualenvwrapper_verify_workon_home () { if [ ! -d "$WORKON_HOME" ] then echo "ERROR: Virtual environments directory '$WORKON_HOME' does not exist." @@ -38,7 +38,7 @@ function verify_workon_home () { } # Verify that the requested environment exists -function verify_workon_environment () { +function virtualenvwrapper_verify_workon_environment () { typeset env_name="$1" if [ ! -d "$WORKON_HOME/$env_name" ] then @@ -49,7 +49,7 @@ function verify_workon_environment () { } # Verify that the active environment exists -function verify_active_environment () { +function virtualenvwrapper_verify_active_environment () { if [ ! -n "${VIRTUAL_ENV}" ] || [ ! -d "${VIRTUAL_ENV}" ] then echo "ERROR: no virtualenv active, or active virtualenv is missing" @@ -58,6 +58,23 @@ function verify_active_environment () { return 0 } +function virtualenvwrapper_source_hook () { + scriptname="$1" + if [ -f "$scriptname" ] + then + source "$scriptname" + fi +} + +function virtualenvwrapper_run_hook () { + scriptname="$1" + shift + if [ -x "$scriptname" ] + then + "$scriptname" "$@" + fi +} + # Create a new environment, in the WORKON_HOME. # # Usage: mkvirtualenv [options] ENVNAME @@ -65,15 +82,19 @@ function verify_active_environment () { # function mkvirtualenv () { eval "envname=\$$#" - verify_workon_home - (cd "$WORKON_HOME"; virtualenv "$@") + virtualenvwrapper_verify_workon_home + (cd "$WORKON_HOME"; + virtualenv "$@"; + virtualenvwrapper_run_hook "./premkvirtualenv" "$envname" + ) workon "$envname" + virtualenvwrapper_source_hook "$WORKON_HOME/postmkvirtualenv" } # Remove an environment, in the WORKON_HOME. function rmvirtualenv () { typeset env_name="$1" - verify_workon_home + virtualenvwrapper_verify_workon_home if [ "$env_name" = "" ] then echo "Please specify an enviroment." @@ -86,13 +107,15 @@ function rmvirtualenv () { echo "Either switch to another environment, or run 'deactivate'." return 1 fi + virtualenvwrapper_run_hook "$WORKON_HOME/prermvirtualenv" "$env_dir" rm -rf "$env_dir" + virtualenvwrapper_run_hook "$WORKON_HOME/postrmvirtualenv" "$env_dir" } # List the available environments. -function show_workon_options () { - verify_workon_home - ls "$WORKON_HOME" | egrep -v '*.egg' | sort +function virtualenvwrapper_show_workon_options () { + virtualenvwrapper_verify_workon_home + ls "$WORKON_HOME" | egrep -v '*.egg' | egrep -v '(pre|post)(rm|mk)virtualenv' | sort } # List or change working virtual environments @@ -103,12 +126,12 @@ function workon () { typeset env_name="$1" if [ "$env_name" = "" ] then - show_workon_options + virtualenvwrapper_show_workon_options return 1 fi - verify_workon_home || return 1 - verify_workon_environment $env_name || return 1 + virtualenvwrapper_verify_workon_home || return 1 + virtualenvwrapper_verify_workon_environment $env_name || return 1 activate="$WORKON_HOME/$env_name/bin/activate" if [ ! -f "$activate" ] @@ -117,17 +140,11 @@ function workon () { return 1 fi - if [ -f "$VIRTUAL_ENV/bin/predeactivate" ] - then - source "$VIRTUAL_ENV/bin/predeactivate" - fi + virtualenvwrapper_source_hook "$VIRTUAL_ENV/bin/predeactivate" source "$activate" - if [ -f "$VIRTUAL_ENV/bin/postactivate" ] - then - source "$VIRTUAL_ENV/bin/postactivate" - fi + virtualenvwrapper_source_hook "$VIRTUAL_ENV/bin/postactivate" return 0 } @@ -140,13 +157,13 @@ if [ -n "$BASH" ] ; then _virtualenvs () { local cur="${COMP_WORDS[COMP_CWORD]}" - COMPREPLY=( $(compgen -W "`show_workon_options`" -- ${cur}) ) + COMPREPLY=( $(compgen -W "`virtualenvwrapper_show_workon_options`" -- ${cur}) ) } complete -o default -o nospace -F _virtualenvs workon complete -o default -o nospace -F _virtualenvs rmvirtualenv elif [ -n "$ZSH_VERSION" ] ; then - compctl -g "`show_workon_options`" workon rmvirtualenv + compctl -g "`virtualenvwrapper_show_workon_options`" workon rmvirtualenv fi # Path management for packages outside of the virtual env. @@ -163,7 +180,7 @@ fi # function add2virtualenv () { - verify_active_environment || return 1 + virtualenvwrapper_verify_active_environment || return 1 pyvers="`python -c 'import sys; print sys.version[:3]'`" site_packages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" From 3ca29566d27bbcc2bbcce889f3863f6b52423844 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 14 Mar 2009 12:49:47 -0400 Subject: [PATCH 025/947] Added tag 1.9 for changeset d8112e52eadc --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 0324f19..fe5f0fd 100644 --- a/.hgtags +++ b/.hgtags @@ -13,3 +13,4 @@ b39eeb3dd437ec6c4ab29ed9b020061a639032fe 1.3 ea5f27af83bb54128e7fa8752c61de074efec2ca 1.8 dca76424222e4f5184aab2c64129029bebd3b378 1.8.1 8417344df8ff4ea1ddfe563956e7e36cddfd732d 1.8.1 +d8112e52eadcb83bc72d76a421ceab325711a369 1.9 From 31c1253f1388fd01a89e53a3afe1fe76676b4953 Mon Sep 17 00:00:00 2001 From: jforcier Date: Wed, 18 Mar 2009 16:03:02 -0400 Subject: [PATCH 026/947] Updated 'workon' to use find, to avoid problems with colorized 'ls' output. --- virtualenvwrapper_bashrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 8da40ce..0f46dfc 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -115,7 +115,7 @@ function rmvirtualenv () { # List the available environments. function virtualenvwrapper_show_workon_options () { virtualenvwrapper_verify_workon_home - ls "$WORKON_HOME" | egrep -v '*.egg' | egrep -v '(pre|post)(rm|mk)virtualenv' | sort + find "$WORKON_HOME" -maxdepth 1 -mindepth 1 -type d -exec basename '{}' \; | egrep -v '*.egg' | egrep -v '(pre|post)(rm|mk)virtualenv' | sort } # List or change working virtual environments From 795d3d8f06f9afc18461acdb284a815b92688146 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 18 Mar 2009 16:59:02 -0400 Subject: [PATCH 027/947] update change history --- README | 3 +++ pavement.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README b/README index 515dc8c..bb149e6 100644 --- a/README +++ b/README @@ -98,6 +98,9 @@ For more details, refer to the column I wrote for the May 2008 issue of Python M Updates ======= +1.10 + - Pull in fix for colorized ls from Jeff Forcier (b42a25f7b74a). + 1.9 - Add more hooks for operations to run before and after creating or deleting environments based on changes from Chris Hasenpflug. diff --git a/pavement.py b/pavement.py index e499cde..b474ee6 100644 --- a/pavement.py +++ b/pavement.py @@ -22,7 +22,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.9' +VERSION = '1.10' # Read the long description to give to setup README_FILE = 'README' From 3f3aee7f4b9be7ee5b3b1f4640928a0c02eaf639 Mon Sep 17 00:00:00 2001 From: ChrisHas35 Date: Wed, 18 Mar 2009 20:45:23 -0500 Subject: [PATCH 028/947] remove unnecssary egrep calls on show_workon_options. fixes #4 --- virtualenvwrapper_bashrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 0f46dfc..418d700 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -115,7 +115,7 @@ function rmvirtualenv () { # List the available environments. function virtualenvwrapper_show_workon_options () { virtualenvwrapper_verify_workon_home - find "$WORKON_HOME" -maxdepth 1 -mindepth 1 -type d -exec basename '{}' \; | egrep -v '*.egg' | egrep -v '(pre|post)(rm|mk)virtualenv' | sort + find "$WORKON_HOME" -maxdepth 1 -mindepth 1 -type d -exec basename '{}' \; | sort } # List or change working virtual environments From 1cc216f17963619cf6fc3ff22daeec8fe11a0e4c Mon Sep 17 00:00:00 2001 From: ChrisHas35 Date: Wed, 18 Mar 2009 21:04:10 -0500 Subject: [PATCH 029/947] add global postactivate hook. related to #3 --- README | 15 +++++++++++++++ test.sh | 1 + virtualenvwrapper_bashrc | 3 +++ 3 files changed, 19 insertions(+) diff --git a/README b/README index bb149e6..4210617 100644 --- a/README +++ b/README @@ -58,6 +58,20 @@ The ``predeactivate`` script is source before the current environment is deactiv be used to disable or clear settings in your environment. ``$VIRTUAL_ENV`` refers to the old environment at the time the script runs. +$WORKON_HOME/postactivate +============================= + +The global ``postactivate`` script is sourced after the new environment is enabled and the new +environment's postactivate is sourced (if it exists). ``$VIRTUAL_ENV`` refers to the new +environment at the time the script runs. + +This example script adds a space between the virtual environment name and your old PS1 by making +use of ``_OLD_VIRTUAL_PS1``. + +:: + + PS1="(`basename \"$VIRTUAL_ENV\"`) $_OLD_VIRTUAL_PS1" + $WORKON_HOME/premkvirtualenv ============================= @@ -100,6 +114,7 @@ Updates 1.10 - Pull in fix for colorized ls from Jeff Forcier (b42a25f7b74a). + - Add global postactivate hook. 1.9 - Add more hooks for operations to run before and after creating or deleting environments based on changes from Chris Hasenpflug. diff --git a/test.sh b/test.sh index df7c9e8..1c8b301 100755 --- a/test.sh +++ b/test.sh @@ -15,6 +15,7 @@ mk_test_hook premkvirtualenv mk_test_hook postmkvirtualenv mk_test_hook prermvirtualenv mk_test_hook postrmvirtualenv +mk_test_hook postactivate echo echo "HOOKS:" diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 418d700..82513dd 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -145,6 +145,9 @@ function workon () { source "$activate" virtualenvwrapper_source_hook "$VIRTUAL_ENV/bin/postactivate" + + virtualenvwrapper_source_hook "$WORKON_HOME/postactivate" + return 0 } From b264d3592e4e67f2ac425c805d8a9550ff8ce42f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 19 Mar 2009 07:37:45 -0400 Subject: [PATCH 030/947] Added tag 1.10 for changeset 274d4576d606 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index fe5f0fd..4ecb35b 100644 --- a/.hgtags +++ b/.hgtags @@ -14,3 +14,4 @@ ea5f27af83bb54128e7fa8752c61de074efec2ca 1.8 dca76424222e4f5184aab2c64129029bebd3b378 1.8.1 8417344df8ff4ea1ddfe563956e7e36cddfd732d 1.8.1 d8112e52eadcb83bc72d76a421ceab325711a369 1.9 +274d4576d606596a2c9f27b69fd4bc454614c299 1.10 From 46f4ea77fd767fc8a8f6b4f27990686e1cc6d026 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 19 Mar 2009 07:38:54 -0400 Subject: [PATCH 031/947] start 1.11 with optimization suggestion from ChrisHas35 --- README | 4 ++++ pavement.py | 2 +- virtualenvwrapper_bashrc | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README b/README index bb149e6..08c20b8 100644 --- a/README +++ b/README @@ -98,6 +98,10 @@ For more details, refer to the column I wrote for the May 2008 issue of Python M Updates ======= +1.11 + - Optimize virtualenvwrapper_show_workon_options. + - + 1.10 - Pull in fix for colorized ls from Jeff Forcier (b42a25f7b74a). diff --git a/pavement.py b/pavement.py index b474ee6..8ba8227 100644 --- a/pavement.py +++ b/pavement.py @@ -22,7 +22,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.10' +VERSION = '1.11' # Read the long description to give to setup README_FILE = 'README' diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 0f46dfc..418d700 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -115,7 +115,7 @@ function rmvirtualenv () { # List the available environments. function virtualenvwrapper_show_workon_options () { virtualenvwrapper_verify_workon_home - find "$WORKON_HOME" -maxdepth 1 -mindepth 1 -type d -exec basename '{}' \; | egrep -v '*.egg' | egrep -v '(pre|post)(rm|mk)virtualenv' | sort + find "$WORKON_HOME" -maxdepth 1 -mindepth 1 -type d -exec basename '{}' \; | sort } # List or change working virtual environments From 3ea7c9943189f1f85c03df1d28abe8066de00945 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 19 Mar 2009 07:53:51 -0400 Subject: [PATCH 032/947] run global postactivatehook before local; move release not to the correct version --- README | 3 +-- virtualenvwrapper_bashrc | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README b/README index 1b3d4c7..1c0330d 100644 --- a/README +++ b/README @@ -114,11 +114,10 @@ Updates 1.11 - Optimize virtualenvwrapper_show_workon_options. - - + - Add global postactivate hook. 1.10 - Pull in fix for colorized ls from Jeff Forcier (b42a25f7b74a). - - Add global postactivate hook. 1.9 - Add more hooks for operations to run before and after creating or deleting environments based on changes from Chris Hasenpflug. diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 82513dd..47899fc 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -144,9 +144,9 @@ function workon () { source "$activate" - virtualenvwrapper_source_hook "$VIRTUAL_ENV/bin/postactivate" - virtualenvwrapper_source_hook "$WORKON_HOME/postactivate" + + virtualenvwrapper_source_hook "$VIRTUAL_ENV/bin/postactivate" return 0 } From 8289bee78ef34547bc2db9814f569c0031a7bdc2 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 19 Mar 2009 07:54:37 -0400 Subject: [PATCH 033/947] Added tag 1.11 for changeset 511994f15d58 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 4ecb35b..06a6a4c 100644 --- a/.hgtags +++ b/.hgtags @@ -15,3 +15,4 @@ dca76424222e4f5184aab2c64129029bebd3b378 1.8.1 8417344df8ff4ea1ddfe563956e7e36cddfd732d 1.8.1 d8112e52eadcb83bc72d76a421ceab325711a369 1.9 274d4576d606596a2c9f27b69fd4bc454614c299 1.10 +511994f15d58deb14deeee969677ca132aae83e2 1.11 From 6924e8e9b709290f4c04dc9c7123fc2532852c85 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 21 Mar 2009 12:42:26 -0400 Subject: [PATCH 034/947] Update quick setup instructions to make them a little easier to follow and to fix a mistake in the order of some of the steps. --- README | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/README b/README index 1c0330d..e50e4e0 100644 --- a/README +++ b/README @@ -6,15 +6,18 @@ virtualenvwrapper Quick Setup =========== -1. Add a line like ``export WORKON_HOME=$HOME/.virtualenvs`` to your .bashrc. -2. Add a line like ``source /path/to/this/file/virtualenvwrapper_bashrc`` to your .bashrc. -3. Run: ``source ~/.bashrc`` -4. Run: ``workon`` -5. A list of environments, empty, is printed. -6. Run: ``mkvirtualenv temp`` +1. Add two lines to your .bashrc to set the location where the virtual environments should live and the location of the script installed with this package:: + + export WORKON_HOME=$HOME/.virtualenvs + source /usr/local/bin/virtualenvwrapper_bashrc + +2. Run: ``source ~/.bashrc`` +3. Run: ``workon`` +4. A list of environments, empty, is printed. +5. Run: ``mkvirtualenv temp`` +6. A new environment, ``temp`` is created and activated. 7. Run: ``workon`` -8. A new environment, ``temp`` is created and activated. -9. This time, the ``temp`` environment is included. +8. This time, the ``temp`` environment is included. =============== From a97ad3b425e1597bc2aeafe74938fe6ad7cdeb36 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 21 Mar 2009 12:50:54 -0400 Subject: [PATCH 035/947] check return code from virtualenvwrapper_verify_workon_home everywhere and return an error code if validation fails --- test.sh | 14 +++++++++++++- virtualenvwrapper_bashrc | 6 +++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/test.sh b/test.sh index 1c8b301..6776367 100755 --- a/test.sh +++ b/test.sh @@ -45,7 +45,13 @@ deactivate echo echo "LISTING ENVIRONMENTS" -workon +envs=`workon | tr '\n' ' '` +if [ "$envs" = "env1 env2 " ] +then + echo "PASS" +else + echo "FAIL: \""$envs\""" +fi echo echo "REMOVING ENVIRONMENTS" @@ -53,3 +59,9 @@ rmvirtualenv "env1" rmvirtualenv "env2" rm -rf $WORKON_HOME + +echo +echo "MISSING WORKON_HOME" +workon && echo "Failed to detect missing dir" || echo "PASS" +mkvirtualenv foo && echo "Failed to detect missing dir" || echo "PASS" +rmvirtualenv foo && echo "Failed to detect missing dir" || echo "PASS" diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 47899fc..8bbfd7c 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -82,7 +82,7 @@ function virtualenvwrapper_run_hook () { # function mkvirtualenv () { eval "envname=\$$#" - virtualenvwrapper_verify_workon_home + virtualenvwrapper_verify_workon_home || return 1 (cd "$WORKON_HOME"; virtualenv "$@"; virtualenvwrapper_run_hook "./premkvirtualenv" "$envname" @@ -94,7 +94,7 @@ function mkvirtualenv () { # Remove an environment, in the WORKON_HOME. function rmvirtualenv () { typeset env_name="$1" - virtualenvwrapper_verify_workon_home + virtualenvwrapper_verify_workon_home || return 1 if [ "$env_name" = "" ] then echo "Please specify an enviroment." @@ -114,7 +114,7 @@ function rmvirtualenv () { # List the available environments. function virtualenvwrapper_show_workon_options () { - virtualenvwrapper_verify_workon_home + virtualenvwrapper_verify_workon_home || return 1 find "$WORKON_HOME" -maxdepth 1 -mindepth 1 -type d -exec basename '{}' \; | sort } From a98d925e721cad8ca1b98e8941e7e91584b4458e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 21 Mar 2009 12:54:22 -0400 Subject: [PATCH 036/947] add attribution --- README | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README b/README index e50e4e0..75d3a6d 100644 --- a/README +++ b/README @@ -115,6 +115,11 @@ For more details, refer to the column I wrote for the May 2008 issue of Python M Updates ======= +1.12 + - Check return value of virtualenvwrapper_verify_workon_home everywhere, thanks to + Jeff Forcier for pointing out the errors. + - Fix instructions at top of README, pointed out by Matthew Scott. + 1.11 - Optimize virtualenvwrapper_show_workon_options. - Add global postactivate hook. From a139f21f8182ba0f2527f64b98422309272e724a Mon Sep 17 00:00:00 2001 From: James Bennett Date: Tue, 24 Mar 2009 02:03:51 -0500 Subject: [PATCH 037/947] Add a couple of quick-navigation helper functions --- README | 6 ++++++ virtualenvwrapper_bashrc | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/README b/README index 75d3a6d..4cbe0c2 100644 --- a/README +++ b/README @@ -105,6 +105,12 @@ Path Management The function ``add2virtualenv`` adds the specified directories to the Python path for the active virtualenv. The directory names passed as argument are added to a path file named ``virtualenv_path_extensions.pth`` inside the virtualenv's site-packages directory. If this file does not exist, it will be created first. +================================== +Quickly Navigating to a virtualenv +================================== + +The functions ``cdsitepackages`` and ``cdvirtualenv`` provide quick shortcuts to quickly ``cd`` into the ``site-packages`` directory of the currently-active virtualenv, and to the root of the currently-active virtualenv, respectively. + ========== References ========== diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 8bbfd7c..4987198 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -215,3 +215,28 @@ function add2virtualenv () { done return 0 } + +# +# cdsitepackages +# +# Does a ``cd`` to the site-packages directory of the currently-active +# virtualenv. +# + +function cdsitepackages () { + verify_active_environment || return 1 + pyvers="`python -c 'import sys; print sys.version[:3]'`" + site_packages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" + cd $site_packages +} + +# +# cdvirtualenv +# +# Does a ``cd`` to the root of the currently-active virtualenv. +# + +function cdvirtualenv () { + verify_active_environment || return 1 + cd $VIRTUAL_ENV +} From e175d9a5616ed60236ab7e1a389c2388106ee114 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 24 Mar 2009 08:06:09 -0400 Subject: [PATCH 038/947] fix verification in navigation functions and add tests --- README | 21 ++++++++++++++++----- pavement.py | 2 +- test.sh | 22 ++++++++++++++++++++++ virtualenvwrapper_bashrc | 4 ++-- 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/README b/README index 4cbe0c2..3ebf7f3 100644 --- a/README +++ b/README @@ -92,30 +92,39 @@ activated. $WORKON_HOME/prermvirtualenv ============================ -The ``prermvirtualenv`` script is run as an external program before the environment is removed. The full path to the environment directory is passed as an argument to the script. +The ``prermvirtualenv`` script is run as an external program before the environment is +removed. The full path to the environment directory is passed as an argument to the script. $WORKON_HOME/postrmvirtualenv ============================= -The ``postrmvirtualenv`` script is run as an external program after the environment is removed. The full path to the environment directory is passed as an argument to the script. +The ``postrmvirtualenv`` script is run as an external program after the environment is +removed. The full path to the environment directory is passed as an argument to the script. =============== Path Management =============== -The function ``add2virtualenv`` adds the specified directories to the Python path for the active virtualenv. The directory names passed as argument are added to a path file named ``virtualenv_path_extensions.pth`` inside the virtualenv's site-packages directory. If this file does not exist, it will be created first. +The function ``add2virtualenv`` adds the specified directories to the Python path for the +active virtualenv. The directory names passed as argument are added to a path file named +``virtualenv_path_extensions.pth`` inside the virtualenv's site-packages directory. If this +file does not exist, it will be created first. ================================== Quickly Navigating to a virtualenv ================================== -The functions ``cdsitepackages`` and ``cdvirtualenv`` provide quick shortcuts to quickly ``cd`` into the ``site-packages`` directory of the currently-active virtualenv, and to the root of the currently-active virtualenv, respectively. +The functions ``cdsitepackages`` and ``cdvirtualenv`` provide quick shortcuts to quickly +``cd`` into the ``site-packages`` directory of the currently-active virtualenv, and to the +root of the currently-active virtualenv, respectively. ========== References ========== -For more details, refer to the column I wrote for the May 2008 issue of Python Magazine: `virtualenvwrapper | And Now For Something Completely Different `_. +For more details, refer to the column published in the May 2008 issue of Python Magazine: +`virtualenvwrapper | And Now For Something Completely Different +`_. ======= Updates @@ -125,6 +134,8 @@ Updates - Check return value of virtualenvwrapper_verify_workon_home everywhere, thanks to Jeff Forcier for pointing out the errors. - Fix instructions at top of README, pointed out by Matthew Scott. + - Add cdvirtualenv and cdsitepackages, contributed by James Bennett. + - Enhance test.sh. 1.11 - Optimize virtualenvwrapper_show_workon_options. diff --git a/pavement.py b/pavement.py index 8ba8227..ad28c6c 100644 --- a/pavement.py +++ b/pavement.py @@ -22,7 +22,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.11' +VERSION = '1.12' # Read the long description to give to setup README_FILE = 'README' diff --git a/test.sh b/test.sh index 6776367..ad1d301 100755 --- a/test.sh +++ b/test.sh @@ -29,23 +29,42 @@ echo "CREATING AND ACTIVATING" mkvirtualenv "env1" echo "Current environment: $VIRTUAL_ENV" +echo +echo "NAVIGATION" +echo -n "remember where we start " +pushd `pwd` +cdvirtualenv +echo "cdvirtualenv: `pwd`" +cdsitepackages +echo "cdsitepackages: `pwd`" +echo -n "back to where we started " +popd + echo echo "CREATING AND SWITCHING" mkvirtualenv "env2" echo "Current environment: $VIRTUAL_ENV" +echo -n "virtualenvwrapper_verify_active_environment: " +virtualenvwrapper_verify_active_environment && echo "PASS" || echo "FAIL" echo echo "POSTACTIVATE HOOK" echo "echo postactivate" > $WORKON_HOME/env1/bin/postactivate workon env1 +echo -n "virtualenvwrapper_verify_active_environment: " +virtualenvwrapper_verify_active_environment && echo "PASS" || echo "FAIL" echo echo "DEACTIVATING" deactivate +echo "VIRTUAL_ENV: $VIRTUAL_ENV" +echo "virtualenvwrapper_verify_active_environment: " +virtualenvwrapper_verify_active_environment && echo "FAIL" || echo "PASS" echo echo "LISTING ENVIRONMENTS" envs=`workon | tr '\n' ' '` +echo "Found environments: $envs" if [ "$envs" = "env1 env2 " ] then echo "PASS" @@ -62,6 +81,9 @@ rm -rf $WORKON_HOME echo echo "MISSING WORKON_HOME" +echo -n "workon: " workon && echo "Failed to detect missing dir" || echo "PASS" +echo -n "mkvirtualenv: " mkvirtualenv foo && echo "Failed to detect missing dir" || echo "PASS" +echo -n "rmvirtualenv: " rmvirtualenv foo && echo "Failed to detect missing dir" || echo "PASS" diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 4987198..f2d3bd6 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -224,7 +224,7 @@ function add2virtualenv () { # function cdsitepackages () { - verify_active_environment || return 1 + virtualenvwrapper_verify_active_environment || return 1 pyvers="`python -c 'import sys; print sys.version[:3]'`" site_packages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" cd $site_packages @@ -237,6 +237,6 @@ function cdsitepackages () { # function cdvirtualenv () { - verify_active_environment || return 1 + virtualenvwrapper_verify_active_environment || return 1 cd $VIRTUAL_ENV } From 6521e8ef9e6e859354fdcdd9e97a18204995aa45 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 24 Mar 2009 08:06:15 -0400 Subject: [PATCH 039/947] Added tag 1.12 for changeset dda0e4d36a91 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 06a6a4c..38640e7 100644 --- a/.hgtags +++ b/.hgtags @@ -16,3 +16,4 @@ dca76424222e4f5184aab2c64129029bebd3b378 1.8.1 d8112e52eadcb83bc72d76a421ceab325711a369 1.9 274d4576d606596a2c9f27b69fd4bc454614c299 1.10 511994f15d58deb14deeee969677ca132aae83e2 1.11 +dda0e4d36a9150968ea6d2d7778d58dbfaf34ba4 1.12 From 5cdf8caa6c145aee14ff0f5c13f7d7ebffac3a84 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 27 Mar 2009 08:31:47 -0400 Subject: [PATCH 040/947] fix for issue #5 --- README | 4 ++++ pavement.py | 2 +- test.sh | 6 +++++- virtualenvwrapper_bashrc | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README b/README index 3ebf7f3..808cf91 100644 --- a/README +++ b/README @@ -130,6 +130,10 @@ For more details, refer to the column published in the May 2008 issue of Python Updates ======= +1.13 + - Fix issue #5 by correctly handling symlinks and limiting the list of envs to things + that look like they can be activated. + 1.12 - Check return value of virtualenvwrapper_verify_workon_home everywhere, thanks to Jeff Forcier for pointing out the errors. diff --git a/pavement.py b/pavement.py index ad28c6c..6832b25 100644 --- a/pavement.py +++ b/pavement.py @@ -22,7 +22,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.12' +VERSION = '1.13' # Read the long description to give to setup README_FILE = 'README' diff --git a/test.sh b/test.sh index ad1d301..3f23a0d 100755 --- a/test.sh +++ b/test.sh @@ -63,13 +63,17 @@ virtualenvwrapper_verify_active_environment && echo "FAIL" || echo "PASS" echo echo "LISTING ENVIRONMENTS" +mkdir -p "$WORKON_HOME/extra/bin" +touch "$WORKON_HOME/extra/bin/activate" +(cd "$WORKON_HOME"; ln -s extra link) envs=`workon | tr '\n' ' '` echo "Found environments: $envs" -if [ "$envs" = "env1 env2 " ] +if [ "$envs" = "env1 env2 extra link " ] then echo "PASS" else echo "FAIL: \""$envs\""" + ls -l "$WORKON_HOME" fi echo diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index f2d3bd6..6819925 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -115,7 +115,7 @@ function rmvirtualenv () { # List the available environments. function virtualenvwrapper_show_workon_options () { virtualenvwrapper_verify_workon_home || return 1 - find "$WORKON_HOME" -maxdepth 1 -mindepth 1 -type d -exec basename '{}' \; | sort + (cd "$WORKON_HOME"; ls */bin/activate) | sed 's|/bin/activate||' | sort } # List or change working virtual environments From 5cdf4fd78e8fd40eabf72afec462ede9c7d212b1 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 2 Apr 2009 07:11:07 -0400 Subject: [PATCH 041/947] Added tag 1.13 for changeset 8e73805a97e1 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 38640e7..5f0527b 100644 --- a/.hgtags +++ b/.hgtags @@ -17,3 +17,4 @@ d8112e52eadcb83bc72d76a421ceab325711a369 1.9 274d4576d606596a2c9f27b69fd4bc454614c299 1.10 511994f15d58deb14deeee969677ca132aae83e2 1.11 dda0e4d36a9150968ea6d2d7778d58dbfaf34ba4 1.12 +8e73805a97e118524b77da40f25cc42d1ad03e6c 1.13 From 05d61afc694288717a22b98bb331a3f063accb33 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 2 Apr 2009 07:12:24 -0400 Subject: [PATCH 042/947] add test.sh to manifest --- MANIFEST.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index a394811..6ecbcd5 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,5 @@ include README.html include setup.py include paver-minilib.zip -include pavement.py \ No newline at end of file +include pavement.py +include test.sh From 98d22ca8da54f993b3854b94fcddb12cf600fd92 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 2 Apr 2009 07:12:29 -0400 Subject: [PATCH 043/947] Added tag 1.13 for changeset 7c40caf6ce6f --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 5f0527b..886508a 100644 --- a/.hgtags +++ b/.hgtags @@ -18,3 +18,4 @@ d8112e52eadcb83bc72d76a421ceab325711a369 1.9 511994f15d58deb14deeee969677ca132aae83e2 1.11 dda0e4d36a9150968ea6d2d7778d58dbfaf34ba4 1.12 8e73805a97e118524b77da40f25cc42d1ad03e6c 1.13 +7c40caf6ce6f9e5bffe4ec35969ba2f19d308f00 1.13 From 4f964c72de8437bdaeca1ce82c9626ca5d8204c9 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 2 Apr 2009 08:26:06 -0400 Subject: [PATCH 044/947] experimental version of deactivate wrapper --- README | 4 ++++ test.sh | 18 ++++++++++++++--- virtualenvwrapper_bashrc | 43 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 61 insertions(+), 4 deletions(-) diff --git a/README b/README index 808cf91..ef72a87 100644 --- a/README +++ b/README @@ -130,6 +130,10 @@ For more details, refer to the column published in the May 2008 issue of Python Updates ======= +Upcoming + - Wrap the virtualenv version of deactivate() with one that lets us invoke + the predeactivate hooks. + 1.13 - Fix issue #5 by correctly handling symlinks and limiting the list of envs to things that look like they can be activated. diff --git a/test.sh b/test.sh index 3f23a0d..da242ff 100755 --- a/test.sh +++ b/test.sh @@ -7,16 +7,21 @@ mkdir -p $WORKON_HOME function mk_test_hook () { hookname="$1" - echo "echo \"$hookname\" \$@" > $WORKON_HOME/$hookname + echo "echo GLOBAL \"$hookname\" \$@" > $WORKON_HOME/$hookname chmod +x $WORKON_HOME/$hookname } mk_test_hook premkvirtualenv mk_test_hook postmkvirtualenv + mk_test_hook prermvirtualenv mk_test_hook postrmvirtualenv + mk_test_hook postactivate +mk_test_hook predeactivate +mk_test_hook postdeactivate + echo echo "HOOKS:" ls -l $WORKON_HOME @@ -49,15 +54,18 @@ virtualenvwrapper_verify_active_environment && echo "PASS" || echo "FAIL" echo echo "POSTACTIVATE HOOK" -echo "echo postactivate" > $WORKON_HOME/env1/bin/postactivate +echo "echo ENV postactivate" > "$WORKON_HOME/env1/bin/postactivate" workon env1 echo -n "virtualenvwrapper_verify_active_environment: " virtualenvwrapper_verify_active_environment && echo "PASS" || echo "FAIL" echo echo "DEACTIVATING" +echo "before VIRTUAL_ENV: $VIRTUAL_ENV" +echo "echo ENV predeactivate \$@" > "$WORKON_HOME/env1/bin/predeactivate" +echo "echo ENV postdeactivate \$@" > "$WORKON_HOME/env1/bin/postdeactivate" deactivate -echo "VIRTUAL_ENV: $VIRTUAL_ENV" +echo "after VIRTUAL_ENV: $VIRTUAL_ENV" echo "virtualenvwrapper_verify_active_environment: " virtualenvwrapper_verify_active_environment && echo "FAIL" || echo "PASS" @@ -81,6 +89,10 @@ echo "REMOVING ENVIRONMENTS" rmvirtualenv "env1" rmvirtualenv "env2" +echo +echo "REMOVING MISSING ENVIRONMENT" +rmvirtualenv "env1" + rm -rf $WORKON_HOME echo diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 6819925..69d5052 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -27,6 +27,17 @@ then export WORKON_HOME="$HOME/.virtualenvs" fi +# Normalize the directory name in case it includes +# relative path components. +WORKON_HOME=$(cd "$WORKON_HOME"; pwd) +export WORKON_HOME + +VIRTUALENV_WRAPPER_BIN=$(dirname "$0") +if [ "$VIRTUALENV_WRAPPER_BIN" = "." ] +then + VIRTUALENV_WRAPPER_BIN=$(pwd) +fi + # Verify that the WORKON_HOME directory exists function virtualenvwrapper_verify_workon_home () { if [ ! -d "$WORKON_HOME" ] @@ -140,10 +151,39 @@ function workon () { return 1 fi - virtualenvwrapper_source_hook "$VIRTUAL_ENV/bin/predeactivate" + # Deactivate any current environment "destructively" + # before switching so we use our override function, + # if it exists. + type deactivate >/dev/null 2>&1 + if [ $? -eq 0 ] + then + deactivate + fi source "$activate" + # Save the deactivate function from virtualenv + virtualenvwrapper_saved_deactivate=$(typeset -f deactivate) + + # Replace the deactivate() function with a wrapper. + eval 'function deactivate () { + # Call the local hook before the global so we can undo + # any settings made by the local postactivate first. + virtualenvwrapper_source_hook "$VIRTUAL_ENV/bin/predeactivate" + virtualenvwrapper_source_hook "$WORKON_HOME/predeactivate" + + env_postdeactivate_hook="$VIRTUAL_ENV/bin/postdeactivate" + + # Restore the original definition of deactivate + eval "$virtualenvwrapper_saved_deactivate" + + # Instead of recursing, this calls the now restored original function. + deactivate + + virtualenvwrapper_source_hook "$env_postdeactivate_hook" + virtualenvwrapper_source_hook "$WORKON_HOME/postdeactivate" + }' + virtualenvwrapper_source_hook "$WORKON_HOME/postactivate" virtualenvwrapper_source_hook "$VIRTUAL_ENV/bin/postactivate" @@ -151,6 +191,7 @@ function workon () { return 0 } + # # Set up tab completion. (Adapted from Arthur Koziel's version at # http://arthurkoziel.com/2008/10/11/virtualenvwrapper-bash-completion/) From d7d6b07d81a013322a0aad1950fb60ec94b2a803 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 4 Apr 2009 12:16:16 -0400 Subject: [PATCH 045/947] rewrite tests using shutil2 --HG-- rename : test.sh => tests/test.sh --- pavement.py | 4 + test.sh | 105 ----- tests/shunit2 | 1116 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/test.sh | 131 ++++++ 4 files changed, 1251 insertions(+), 105 deletions(-) delete mode 100755 test.sh create mode 100644 tests/shunit2 create mode 100755 tests/test.sh diff --git a/pavement.py b/pavement.py index 6832b25..77e298a 100644 --- a/pavement.py +++ b/pavement.py @@ -115,3 +115,7 @@ def html(): outfile.unlink() sh('rst2html.py %s README.html' % README_FILE) return + +@task +def test(): + sh('./tests/test.sh') diff --git a/test.sh b/test.sh deleted file mode 100755 index da242ff..0000000 --- a/test.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/sh - -#set -x - -export WORKON_HOME="./WORKON_HOME" -mkdir -p $WORKON_HOME - -function mk_test_hook () { - hookname="$1" - echo "echo GLOBAL \"$hookname\" \$@" > $WORKON_HOME/$hookname - chmod +x $WORKON_HOME/$hookname -} - -mk_test_hook premkvirtualenv -mk_test_hook postmkvirtualenv - -mk_test_hook prermvirtualenv -mk_test_hook postrmvirtualenv - -mk_test_hook postactivate - -mk_test_hook predeactivate -mk_test_hook postdeactivate - -echo -echo "HOOKS:" -ls -l $WORKON_HOME - -bindir=$(dirname $0) -source "$bindir/virtualenvwrapper_bashrc" - -echo -echo "CREATING AND ACTIVATING" -mkvirtualenv "env1" -echo "Current environment: $VIRTUAL_ENV" - -echo -echo "NAVIGATION" -echo -n "remember where we start " -pushd `pwd` -cdvirtualenv -echo "cdvirtualenv: `pwd`" -cdsitepackages -echo "cdsitepackages: `pwd`" -echo -n "back to where we started " -popd - -echo -echo "CREATING AND SWITCHING" -mkvirtualenv "env2" -echo "Current environment: $VIRTUAL_ENV" -echo -n "virtualenvwrapper_verify_active_environment: " -virtualenvwrapper_verify_active_environment && echo "PASS" || echo "FAIL" - -echo -echo "POSTACTIVATE HOOK" -echo "echo ENV postactivate" > "$WORKON_HOME/env1/bin/postactivate" -workon env1 -echo -n "virtualenvwrapper_verify_active_environment: " -virtualenvwrapper_verify_active_environment && echo "PASS" || echo "FAIL" - -echo -echo "DEACTIVATING" -echo "before VIRTUAL_ENV: $VIRTUAL_ENV" -echo "echo ENV predeactivate \$@" > "$WORKON_HOME/env1/bin/predeactivate" -echo "echo ENV postdeactivate \$@" > "$WORKON_HOME/env1/bin/postdeactivate" -deactivate -echo "after VIRTUAL_ENV: $VIRTUAL_ENV" -echo "virtualenvwrapper_verify_active_environment: " -virtualenvwrapper_verify_active_environment && echo "FAIL" || echo "PASS" - -echo -echo "LISTING ENVIRONMENTS" -mkdir -p "$WORKON_HOME/extra/bin" -touch "$WORKON_HOME/extra/bin/activate" -(cd "$WORKON_HOME"; ln -s extra link) -envs=`workon | tr '\n' ' '` -echo "Found environments: $envs" -if [ "$envs" = "env1 env2 extra link " ] -then - echo "PASS" -else - echo "FAIL: \""$envs\""" - ls -l "$WORKON_HOME" -fi - -echo -echo "REMOVING ENVIRONMENTS" -rmvirtualenv "env1" -rmvirtualenv "env2" - -echo -echo "REMOVING MISSING ENVIRONMENT" -rmvirtualenv "env1" - -rm -rf $WORKON_HOME - -echo -echo "MISSING WORKON_HOME" -echo -n "workon: " -workon && echo "Failed to detect missing dir" || echo "PASS" -echo -n "mkvirtualenv: " -mkvirtualenv foo && echo "Failed to detect missing dir" || echo "PASS" -echo -n "rmvirtualenv: " -rmvirtualenv foo && echo "Failed to detect missing dir" || echo "PASS" diff --git a/tests/shunit2 b/tests/shunit2 new file mode 100644 index 0000000..d900a70 --- /dev/null +++ b/tests/shunit2 @@ -0,0 +1,1116 @@ +# $Id: shunit2 277 2008-10-29 21:20:22Z kate.ward@forestent.com $ +# vim:et:ft=sh:sts=2:sw=2 +# vim:foldmethod=marker:foldmarker=/**,*/ +# +#/** +# +# +# +# shUnit 2.1.5 +# Shell Unit Test Framework +# +# http://shunit2.googlecode.com/ +# +# written by Kate Ward <kate.ward@forestent.com> +# released under the LGPL +# +# This module implements a xUnit based unit test framework similar to JUnit. +# +#*/ + +SHUNIT_VERSION='2.1.5' + +SHUNIT_TRUE=0 +SHUNIT_FALSE=1 +SHUNIT_ERROR=2 + +_shunit_warn() { echo "shunit2:WARN $@" >&2; } +_shunit_error() { echo "shunit2:ERROR $@" >&2; } +_shunit_fatal() { echo "shunit2:FATAL $@" >&2; } + +# specific shell checks +if [ -n "${ZSH_VERSION:-}" ]; then + setopt |grep "^shwordsplit$" >/dev/null + if [ $? -ne ${SHUNIT_TRUE} ]; then + _shunit_fatal 'zsh shwordsplit option is required for proper operation' + exit ${SHUNIT_ERROR} + fi + if [ -z "${SHUNIT_PARENT:-}" ]; then + _shunit_fatal "zsh does not pass \$0 through properly. please declare \ +\"SHUNIT_PARENT=\$0\" before calling shUnit2" + exit ${SHUNIT_ERROR} + fi +fi + +# +# constants +# + +__SHUNIT_ASSERT_MSG_PREFIX='ASSERT:' +__SHUNIT_PARENT=${SHUNIT_PARENT:-$0} + +# set the constants readonly +shunit_constants_=`set |grep '^__SHUNIT_' |cut -d= -f1` +echo "${shunit_constants_}" |grep '^Binary file' >/dev/null \ + && shunit_constants_=`set |grep -a '^__SHUNIT_' |cut -d= -f1` +for shunit_constant_ in ${shunit_constants_}; do + shunit_ro_opts_='' + case ${ZSH_VERSION:-} in + '') ;; # this isn't zsh + [123].*) ;; # early versions (1.x, 2.x, 3.x) + *) shunit_ro_opts_='-g' ;; # all later versions. declare readonly globally + esac + readonly ${shunit_ro_opts_} ${shunit_constant_} +done +unset shunit_constant_ shunit_constants_ shunit_ro_opts_ + +# variables +__shunit_skip=${SHUNIT_FALSE} +__shunit_suite='' + +# counts of tests +__shunit_testSuccess=${SHUNIT_TRUE} +__shunit_testsTotal=0 +__shunit_testsPassed=0 +__shunit_testsFailed=0 + +# counts of asserts +__shunit_assertsTotal=0 +__shunit_assertsPassed=0 +__shunit_assertsFailed=0 +__shunit_assertsSkipped=0 + +__shunit_lineno='' +__shunit_reportGenerated=${SHUNIT_FALSE} + +# macros +_SHUNIT_LINENO_='eval __shunit_lineno=""; if [ "${1:-}" = "--lineno" ]; then [ -n "$2" ] && __shunit_lineno="[$2] "; shift 2; fi' + +#----------------------------------------------------------------------------- +# assert functions +# + +#/** +# +# +# void +# +# +# +# +# assertEquals +# string [message] +# string expected +# string actual +# +# +# Asserts that expected and +# actual are equal to one another. The message is +# optional. +# +# +#*/ +assertEquals() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "assertEquals() requires two or three arguments; $# given" + _shunit_error "1: ${1:+$1} 2: ${2:+$2} 3: ${3:+$3}" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + shunit_expected_=$1 + shunit_actual_=$2 + + shunit_return=${SHUNIT_TRUE} + if [ "${shunit_expected_}" = "${shunit_actual_}" ]; then + _shunit_assertPass + else + failNotEquals "${shunit_message_}" "${shunit_expected_}" "${shunit_actual_}" + shunit_return=${SHUNIT_FALSE} + fi + + unset shunit_message_ shunit_expected_ shunit_actual_ + return ${shunit_return} +} +_ASSERT_EQUALS_='eval assertEquals --lineno "${LINENO:-}"' + +#/** +# +# +# void +# +# +# +# +# assertNotEquals +# string [message] +# string unexpected +# string actual +# +# +# Asserts that unexpected and +# actual are not +# equal to one another. The message is optional. +# +# +#*/ +assertNotEquals() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "assertNotEquals() requires two or three arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + shunit_unexpected_=$1 + shunit_actual_=$2 + + shunit_return=${SHUNIT_TRUE} + if [ "${shunit_unexpected_}" != "${shunit_actual_}" ]; then + _shunit_assertPass + else + failSame "${shunit_message_}" "$@" + shunit_return=${SHUNIT_FALSE} + fi + + unset shunit_message_ shunit_unexpected_ shunit_actual_ + return ${shunit_return} +} +_ASSERT_NOT_EQUALS_='eval assertNotEquals --lineno "${LINENO:-}"' + +#/** +# +# +# void +# +# +# +# +# assertNull +# string [message] +# string value +# +# +# Asserts that value is null, +# or in shell terms a zero-length string. The message is optional. +# +# +#*/ +assertNull() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 1 -o $# -gt 2 ]; then + _shunit_error "assertNull() requires one or two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 2 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + assertTrue "${shunit_message_}" "[ -z '$1' ]" + shunit_return=$? + + unset shunit_message_ + return ${shunit_return} +} +_ASSERT_NULL_='eval assertNull --lineno "${LINENO:-}"' + +#/** +# +# +# void +# +# +# +# +# assertNotNull +# string [message] +# string value +# +# +# Asserts that value is not null, or in shell terms not +# a zero-length string. The message is optional. +# +# +#*/ +assertNotNull() +{ + ${_SHUNIT_LINENO_} + if [ $# -gt 2 ]; then # allowing 0 arguments as $1 might actually be null + _shunit_error "assertNotNull() requires one or two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 2 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + assertTrue "${shunit_message_}" "[ -n '${1:-}' ]" + shunit_return=$? + + unset shunit_message_ + return ${shunit_return} +} +_ASSERT_NOT_NULL_='eval assertNotNull --lineno "${LINENO:-}"' + +#/** +# +# +# void +# +# +# +# +# assertSame +# string [message] +# string expected +# string actual +# +# +# This function is functionally equivalent to +# assertEquals. +# +# +#*/ +assertSame() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "assertSame() requires one or two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + assertEquals "${shunit_message_}" "$1" "$2" + shunit_return=$? + + unset shunit_message_ + return ${shunit_return} +} +_ASSERT_SAME_='eval assertSame --lineno "${LINENO:-}"' + +#/** +# +# +# void +# +# +# +# +# assertNotSame +# string [message] +# string unexpected +# string actual +# +# +# Asserts that unexpected and +# actual are not +# equal to one another. The message is optional. +# +# +#*/ +assertNotSame() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "assertNotSame() requires two or three arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_:-}$1" + shift + fi + assertNotEquals "${shunit_message_}" "$1" "$2" + shunit_return=$? + + unset shunit_message_ + return ${shunit_return} +} +_ASSERT_NOT_SAME_='eval assertNotSame --lineno "${LINENO:-}"' + +#/** +# +# +# void +# +# +# +# +# assertTrue +# string [message] +# string condition +# +# +# Asserts that a given shell test condition is true. The message is +# optional. +# Testing whether something is true or false is easy enough by using +# the assertEquals/assertNotSame functions. Shell supports much more +# complicated tests though, and a means to support them was needed. As such, +# this function tests that conditions are true or false through evaluation +# rather than just looking for a true or false. +# +# The following test will succeed: assertTrue "[ 34 -gt 23 ]" +# The folloing test will fail with a message: assertTrue "test failed" "[ -r '/non/existant/file' ]" +# +# +# +#*/ +assertTrue() +{ + ${_SHUNIT_LINENO_} + if [ $# -gt 2 ]; then + _shunit_error "assertTrue() takes one two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 2 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + shunit_condition_=$1 + + # see if condition is an integer, i.e. a return value + shunit_match_=`expr "${shunit_condition_}" : '\([0-9]*\)'` + shunit_return=${SHUNIT_TRUE} + if [ -z "${shunit_condition_}" ]; then + # null condition + shunit_return=${SHUNIT_FALSE} + elif [ "${shunit_condition_}" = "${shunit_match_}" ]; then + # possible return value. treating 0 as true, and non-zero as false. + [ ${shunit_condition_} -ne 0 ] && shunit_return=${SHUNIT_FALSE} + else + # (hopefully) a condition + ( eval ${shunit_condition_} ) >/dev/null 2>&1 + [ $? -ne 0 ] && shunit_return=${SHUNIT_FALSE} + fi + + # record the test + if [ ${shunit_return} -eq ${SHUNIT_TRUE} ]; then + _shunit_assertPass + else + _shunit_assertFail "${shunit_message_}" + fi + + unset shunit_message_ shunit_condition_ shunit_match_ + return ${shunit_return} +} +_ASSERT_TRUE_='eval assertTrue --lineno "${LINENO:-}"' + +#/** +# +# +# void +# +# +# +# +# assertFalse +# string [message] +# string condition +# +# +# Asserts that a given shell test condition is false. The message is +# optional. +# Testing whether something is true or false is easy enough by using +# the assertEquals/assertNotSame functions. Shell supports much more +# complicated tests though, and a means to support them was needed. As such, +# this function tests that conditions are true or false through evaluation +# rather than just looking for a true or false. +# +# The following test will succeed: assertFalse "[ 'apples' = 'oranges' ]" +# The folloing test will fail with a message: assertFalse "test failed" "[ 1 -eq 1 -a 2 -eq 2 ]" +# +# +# +#*/ +assertFalse() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 1 -o $# -gt 2 ]; then + _shunit_error "assertFalse() quires one or two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 2 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + shunit_condition_=$1 + + # see if condition is an integer, i.e. a return value + shunit_match_=`expr "${shunit_condition_}" : '\([0-9]*\)'` + shunit_return=${SHUNIT_TRUE} + if [ -z "${shunit_condition_}" ]; then + # null condition + shunit_return=${SHUNIT_FALSE} + elif [ "${shunit_condition_}" = "${shunit_match_}" ]; then + # possible return value. treating 0 as true, and non-zero as false. + [ ${shunit_condition_} -eq 0 ] && shunit_return=${SHUNIT_FALSE} + else + # (hopefully) a condition + ( eval ${shunit_condition_} ) >/dev/null 2>&1 + [ $? -eq 0 ] && shunit_return=${SHUNIT_FALSE} + fi + + # record the test + if [ ${shunit_return} -eq ${SHUNIT_TRUE} ]; then + _shunit_assertPass + else + _shunit_assertFail "${shunit_message_}" + fi + + unset shunit_message_ shunit_condition_ shunit_match_ + return ${shunit_return} +} +_ASSERT_FALSE_='eval assertFalse --lineno "${LINENO:-}"' + +#----------------------------------------------------------------------------- +# failure functions +# + +#/** +# +# +# void +# +# +# +# +# fail +# string [message] +# +# +# Fails the test immediately, with the optional message. +# +# +#*/ +fail() +{ + ${_SHUNIT_LINENO_} + if [ $# -gt 1 ]; then + _shunit_error "fail() requires one or two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 1 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + + _shunit_assertFail "${shunit_message_}" + + unset shunit_message_ + return ${SHUNIT_FALSE} +} +_FAIL_='eval fail --lineno "${LINENO:-}"' + +#/** +# +# +# void +# +# +# +# +# failNotEquals +# string [message] +# string unexpected +# string actual +# +# +# Fails the test if unexpected and +# actual are not +# equal to one another. The message is optional. +# +# +#*/ +failNotEquals() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "failNotEquals() requires one or two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + shunit_unexpected_=$1 + shunit_actual_=$2 + + _shunit_assertFail "${shunit_message_:+${shunit_message_} }expected:<${shunit_unexpected_}> but was:<${shunit_actual_}>" + + unset shunit_message_ shunit_unexpected_ shunit_actual_ + return ${SHUNIT_FALSE} +} +_FAIL_NOT_EQUALS_='eval failNotEquals --lineno "${LINENO:-}"' + +#/** +# +# +# void +# +# +# +# +# failSame +# string [message] +# +# +# Indicate test failure because arguments were the same. The message is +# optional. +# +# +#*/ +failSame() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "failSame() requires two or three arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + + _shunit_assertFail "${shunit_message_:+${shunit_message_} }expected not same" + + unset shunit_message_ + return ${SHUNIT_FALSE} +} +_FAIL_SAME_='eval failSame --lineno "${LINENO:-}"' + +#/** +# +# +# void +# +# +# +# +# failNotSame +# string [message] +# string expected +# string actual +# +# +# Indicate test failure because arguments were not the same. The +# message is optional. +# +# +#*/ +failNotSame() +{ + ${_SHUNIT_LINENO_} + if [ $# -lt 2 -o $# -gt 3 ]; then + _shunit_error "failNotEquals() requires one or two arguments; $# given" + return ${SHUNIT_ERROR} + fi + _shunit_shouldSkip && return ${SHUNIT_TRUE} + + shunit_message_=${__shunit_lineno} + if [ $# -eq 3 ]; then + shunit_message_="${shunit_message_}$1" + shift + fi + failNotEquals "${shunit_message_}" "$1" "$2" + shunit_return=$? + + unset shunit_message_ + return ${shunit_return} +} +_FAIL_NOT_SAME_='eval failNotSame --lineno "${LINENO:-}"' + +#----------------------------------------------------------------------------- +# skipping functions +# + +#/** +# +# +# void +# +# +# +# +# startSkipping +# +# +# +# This function forces the remaining assert and fail functions to be +# "skipped", i.e. they will have no effect. Each function skipped will be +# recorded so that the total of asserts and fails will not be altered. +# +# +#*/ +startSkipping() +{ + __shunit_skip=${SHUNIT_TRUE} +} + +#/** +# +# +# void +# +# +# +# +# endSkipping +# +# +# +# This function returns calls to the assert and fail functions to their +# default behavior, i.e. they will be called. +# +# +#*/ +endSkipping() +{ + __shunit_skip=${SHUNIT_FALSE} +} + +#/** +# +# +# boolean +# +# +# +# +# isSkipping +# +# +# +# This function returns the state of skipping. +# +# +#*/ +isSkipping() +{ + return ${__shunit_skip} +} + +#----------------------------------------------------------------------------- +# suite functions +# + +#/** +# +# +# void +# +# +# +# +# suite +# +# +# +# This function can be optionally overridden by the user in their test +# suite. +# If this function exists, it will be called when +# shunit2 is sourced. If it does not exist, shUnit2 will +# search the parent script for all functions beginning with the word +# test, and they will be added dynamically to the test +# suite. +# +# +#*/ +# Note: see _shunit_mktempFunc() for actual implementation +# suite() { :; } + +#/** +# +# +# void +# +# +# +# +# suite_addTest +# string function +# +# +# This function adds a function name to the list of tests scheduled for +# execution as part of this test suite. This function should only be called +# from within the suite() function. +# +# +#*/ +suite_addTest() +{ + shunit_func_=${1:-} + + __shunit_suite="${__shunit_suite:+${__shunit_suite} }${shunit_func_}" + __shunit_testsTotal=`expr ${__shunit_testsTotal} + 1` + + unset shunit_func_ +} + +#/** +# +# +# void +# +# +# +# +# oneTimeSetUp +# +# +# +# This function can be be optionally overridden by the user in their +# test suite. +# If this function exists, it will be called once before any tests are +# run. It is useful to prepare a common environment for all tests. +# +# +#*/ +# Note: see _shunit_mktempFunc() for actual implementation +# oneTimeSetUp() { :; } + +#/** +# +# +# void +# +# +# +# +# oneTimeTearDown +# +# +# +# This function can be be optionally overridden by the user in their +# test suite. +# If this function exists, it will be called once after all tests are +# completed. It is useful to clean up the environment after all tests. +# +# +#*/ +# Note: see _shunit_mktempFunc() for actual implementation +# oneTimeTearDown() { :; } + +#/** +# +# +# void +# +# +# +# +# setUp +# +# +# +# This function can be be optionally overridden by the user in their +# test suite. +# If this function exists, it will be called before each test is run. +# It is useful to reset the environment before each test. +# +# +#*/ +# Note: see _shunit_mktempFunc() for actual implementation +# setUp() { :; } + +#/** +# +# +# void +# +# +# +# +# tearDown +# +# +# +# This function can be be optionally overridden by the user in their +# test suite. +# If this function exists, it will be called after each test completes. +# It is useful to clean up the environment after each test. +# +# +#*/ +# Note: see _shunit_mktempFunc() for actual implementation +# tearDown() { :; } + +#------------------------------------------------------------------------------ +# internal shUnit2 functions +# + +# this function is a cross-platform temporary directory creation tool. not all +# OSes have the mktemp function, so one is included here. +_shunit_mktempDir() +{ + # try the standard mktemp function + ( exec mktemp -dqt shunit.XXXXXX 2>/dev/null ) && return + + # the standard mktemp didn't work. doing our own. + if [ -r '/dev/urandom' ]; then + _shunit_random_=`od -vAn -N4 -tx4 "${_shunit_file_}" +#! /bin/sh +exit ${SHUNIT_TRUE} +EOF + chmod +x "${_shunit_file_}" + done + + unset _shunit_file_ +} + +_shunit_cleanup() +{ + _shunit_name_=$1 + + case ${_shunit_name_} in + EXIT) _shunit_signal_=0 ;; + INT) _shunit_signal_=2 ;; + TERM) _shunit_signal_=15 ;; + *) + _shunit_warn "unrecognized trap value (${_shunit_name_})" + _shunit_signal_=0 + ;; + esac + + # do our work + rm -fr "${__shunit_tmpDir}" + + # exit for all non-EXIT signals + if [ ${_shunit_name_} != 'EXIT' ]; then + _shunit_warn "trapped and now handling the (${_shunit_name_}) signal" + # disable EXIT trap + trap 0 + # add 128 to signal and exit + exit `expr ${_shunit_signal_} + 128` + elif [ ${__shunit_reportGenerated} -eq ${SHUNIT_FALSE} ] ; then + _shunit_assertFail 'Unknown failure encountered running a test' + _shunit_generateReport + exit ${SHUNIT_ERROR} + fi + + unset _shunit_name_ _shunit_signal_ +} + +# The actual running of the tests happens here. +_shunit_execSuite() +{ + for _shunit_test_ in ${__shunit_suite}; do + __shunit_testSuccess=${SHUNIT_TRUE} + + # disable skipping + endSkipping + + # execute the per-test setup function + setUp + + # execute the test + echo "${_shunit_test_}" + eval ${_shunit_test_} + + # execute the per-test tear-down function + tearDown + + # update stats + if [ ${__shunit_testSuccess} -eq ${SHUNIT_TRUE} ]; then + __shunit_testsPassed=`expr ${__shunit_testsPassed} + 1` + else + __shunit_testsFailed=`expr ${__shunit_testsFailed} + 1` + fi + done + + unset _shunit_test_ +} + +# This function exits shUnit2 with the appropriate error code and OK/FAILED +# message. +_shunit_generateReport() +{ + _shunit_ok_=${SHUNIT_TRUE} + + # if no exit code was provided one, determine an appropriate one + [ ${__shunit_testsFailed} -gt 0 \ + -o ${__shunit_testSuccess} -eq ${SHUNIT_FALSE} ] \ + && _shunit_ok_=${SHUNIT_FALSE} + + echo + if [ ${__shunit_testsTotal} -eq 1 ]; then + echo "Ran ${__shunit_testsTotal} test." + else + echo "Ran ${__shunit_testsTotal} tests." + fi + + _shunit_failures_='' + _shunit_skipped_='' + [ ${__shunit_assertsFailed} -gt 0 ] \ + && _shunit_failures_="failures=${__shunit_assertsFailed}" + [ ${__shunit_assertsSkipped} -gt 0 ] \ + && _shunit_skipped_="skipped=${__shunit_assertsSkipped}" + + if [ ${_shunit_ok_} -eq ${SHUNIT_TRUE} ]; then + _shunit_msg_='OK' + [ -n "${_shunit_skipped_}" ] \ + && _shunit_msg_="${_shunit_msg_} (${_shunit_skipped_})" + else + _shunit_msg_="FAILED (${_shunit_failures_}" + [ -n "${_shunit_skipped_}" ] \ + && _shunit_msg_="${_shunit_msg_},${_shunit_skipped_}" + _shunit_msg_="${_shunit_msg_})" + fi + + echo + echo ${_shunit_msg_} + __shunit_reportGenerated=${SHUNIT_TRUE} + + unset _shunit_failures_ _shunit_msg_ _shunit_ok_ _shunit_skipped_ +} + +_shunit_shouldSkip() +{ + [ ${__shunit_skip} -eq ${SHUNIT_FALSE} ] && return ${SHUNIT_FALSE} + _shunit_assertSkip +} + +_shunit_assertPass() +{ + __shunit_assertsPassed=`expr ${__shunit_assertsPassed} + 1` + __shunit_assertsTotal=`expr ${__shunit_assertsTotal} + 1` +} + +_shunit_assertFail() +{ + _shunit_msg_=$1 + + __shunit_testSuccess=${SHUNIT_FALSE} + __shunit_assertsFailed=`expr ${__shunit_assertsFailed} + 1` + __shunit_assertsTotal=`expr ${__shunit_assertsTotal} + 1` + echo "${__SHUNIT_ASSERT_MSG_PREFIX}${_shunit_msg_}" + + unset _shunit_msg_ +} + +_shunit_assertSkip() +{ + __shunit_assertsSkipped=`expr ${__shunit_assertsSkipped} + 1` + __shunit_assertsTotal=`expr ${__shunit_assertsTotal} + 1` +} + +#------------------------------------------------------------------------------ +# main +# + +# create a temporary storage location +__shunit_tmpDir=`_shunit_mktempDir` + +# provide a public temporary directory for unit test scripts +# TODO(kward): document this +shunit_tmpDir="${__shunit_tmpDir}/tmp" +mkdir "${shunit_tmpDir}" + +# setup traps to clean up after ourselves +trap '_shunit_cleanup EXIT' 0 +trap '_shunit_cleanup INT' 2 +trap '_shunit_cleanup TERM' 15 + +# create phantom functions to work around issues with Cygwin +_shunit_mktempFunc +PATH="${__shunit_tmpDir}:${PATH}" + +# execute the oneTimeSetUp function (if it exists) +oneTimeSetUp + +# execute the suite function defined in the parent test script +# deprecated as of 2.1.0 +suite + +# if no suite function was defined, dynamically build a list of functions +if [ -z "${__shunit_suite}" ]; then + shunit_funcs_=`grep "^[ \t]*test[A-Za-z0-9_]* *()" ${__SHUNIT_PARENT} \ + |sed 's/[^A-Za-z0-9_]//g'` + for shunit_func_ in ${shunit_funcs_}; do + suite_addTest ${shunit_func_} + done +fi +unset shunit_func_ shunit_funcs_ + +# execute the tests +_shunit_execSuite + +# execute the oneTimeTearDown function (if it exists) +oneTimeTearDown + +# generate the report +_shunit_generateReport + +# that's it folks +[ ${__shunit_testsFailed} -eq 0 ] +exit $? + +#/** +# +#*/ diff --git a/tests/test.sh b/tests/test.sh new file mode 100755 index 0000000..5308ff3 --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,131 @@ +#!/bin/sh + +#set -x + +test_dir=$(dirname $0) +source "$test_dir/../virtualenvwrapper_bashrc" + +export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +test_mkvirtualenv() { + mkvirtualenv "env1" + assertTrue "[ -d $WORKON_HOME/env1 ]" + assertSame "env1" $(basename "$VIRTUAL_ENV") +} + +test_cdvirtual() { + pushd "$(pwd)" >/dev/null + cdvirtualenv + assertSame "$VIRTUAL_ENV" "$(pwd)" + popd >/dev/null +} + +test_cdsitepackages () { + pushd "$(pwd)" >/dev/null + cdsitepackages + pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) + assertSame "$VIRTUAL_ENV/lib/python${pyvers}/site-packages" "$(pwd)" + popd >/dev/null +} + +test_mkvirtualenv_switches () { + mkvirtualenv "env2" + assertTrue virtualenvwrapper_verify_active_environment + assertSame "env2" $(basename "$VIRTUAL_ENV") +} + +test_workon () { + workon env1 + assertTrue virtualenvwrapper_verify_active_environment + assertSame "env1" $(basename "$VIRTUAL_ENV") +} + +test_postactivate_hook () { + echo "echo ENV postactivate > $test_dir/catch_output" > "$WORKON_HOME/env1/bin/postactivate" + + workon env1 + + output=$(cat "$test_dir/catch_output") + assertSame "ENV postactivate" "$output" + + rm -f "$WORKON_HOME/env1/bin/postactivate" +} + +test_deactivate () { + workon env1 + assertNotNull "$VIRTUAL_ENV" + deactivate + assertNull "$VIRTUAL_ENV" + assertFalse virtualenvwrapper_verify_active_environment +} + +test_deactivate_hooks () { + workon env1 + + echo "echo GLOBAL predeactivate >> $test_dir/catch_output" > "$WORKON_HOME/predeactivate" + echo "echo GLOBAL postdeactivate >> $test_dir/catch_output" > "$WORKON_HOME/postdeactivate" + + echo "echo ENV predeactivate >> $test_dir/catch_output" > "$WORKON_HOME/env1/bin/predeactivate" + echo "echo ENV postdeactivate >> $test_dir/catch_output" > "$WORKON_HOME/env1/bin/postdeactivate" + + deactivate + + output=$(cat "$test_dir/catch_output") + expected="ENV predeactivate +GLOBAL predeactivate +ENV postdeactivate +GLOBAL postdeactivate" + assertSame "$expected" "$output" + + rm -f "$WORKON_HOME/env1/bin/predeactivate" + rm -f "$WORKON_HOME/env1/bin/postdeactivate" + rm -f "$WORKON_HOME/predeactivate" + rm -f "$WORKON_HOME/postdeactivate" +} + +test_virtualenvwrapper_show_workon_options () { + mkdir "$WORKON_HOME/not_env" + (cd "$WORKON_HOME"; ln -s env1 link_env) + envs=$(virtualenvwrapper_show_workon_options | tr '\n' ' ') + assertSame "env1 env2 link_env " "$envs" + rmdir "$WORKON_HOME/not_env" + rm -f "$WORKON_HOME/link_env" +} + +test_rmvirtualenv () { + mkvirtualenv "deleteme" + assertTrue "[ -d $WORKON_HOME/deleteme ]" + deactivate + rmvirtualenv "deleteme" + assertFalse "[ -d $WORKON_HOME/deleteme ]" +} + +test_rmvirtualenv_no_such_env () { + assertFalse "[ -d $WORKON_HOME/deleteme ]" + assertTrue "rmvirtualenv deleteme" +} + +test_missing_workon_home () { + save_home="$WORKON_HOME" + WORKON_HOME="/tmp/NO_SUCH_WORKON_HOME" + assertFalse "workon" + assertFalse "mkvirtualenv foo" + assertFalse "rmvirtualenv foo" + WORKON_HOME="$save_home" +} + +. "$test_dir/shunit2" From 78729b0145cf98f7fcedb49eed4cbfc4ca6e890f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 4 Apr 2009 12:22:39 -0400 Subject: [PATCH 046/947] fix virtualenvwrapper_show_workon_options to use find again --- virtualenvwrapper_bashrc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 69d5052..fa9fa2d 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -126,7 +126,9 @@ function rmvirtualenv () { # List the available environments. function virtualenvwrapper_show_workon_options () { virtualenvwrapper_verify_workon_home || return 1 - (cd "$WORKON_HOME"; ls */bin/activate) | sed 's|/bin/activate||' | sort + # NOTE: DO NOT use ls here because colorized versions spew control characters + # into the output list. + (cd "$WORKON_HOME"; find -L . -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort } # List or change working virtual environments From c787ed88bece73b9cb237a45f320b0f557bcd089 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 4 Apr 2009 12:24:42 -0400 Subject: [PATCH 047/947] update change list --- README | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README b/README index ef72a87..2a546d2 100644 --- a/README +++ b/README @@ -130,9 +130,12 @@ For more details, refer to the column published in the May 2008 issue of Python Updates ======= -Upcoming +1.14 - Wrap the virtualenv version of deactivate() with one that lets us invoke the predeactivate hooks. + - Fix virtualenvwrapper_show_workon_options for colorized versions of ls and + write myself a note so I don't break it again later. + - Convert test.sh to use true tests with `shunit2 `_ 1.13 - Fix issue #5 by correctly handling symlinks and limiting the list of envs to things From 9cbb8a4a1a55d2b1ebe787a0cecd6cd0de5a4e2c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 4 Apr 2009 12:24:47 -0400 Subject: [PATCH 048/947] Added tag 1.14 for changeset e31542a0d946 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 886508a..624e0a7 100644 --- a/.hgtags +++ b/.hgtags @@ -19,3 +19,4 @@ d8112e52eadcb83bc72d76a421ceab325711a369 1.9 dda0e4d36a9150968ea6d2d7778d58dbfaf34ba4 1.12 8e73805a97e118524b77da40f25cc42d1ad03e6c 1.13 7c40caf6ce6f9e5bffe4ec35969ba2f19d308f00 1.13 +e31542a0d9464a4cb8594958dd70cb56c32cf455 1.14 From daf418279866f9cd2efd19af771c8355014b4008 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 4 Apr 2009 12:25:03 -0400 Subject: [PATCH 049/947] update version # --- pavement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pavement.py b/pavement.py index 77e298a..24c4341 100644 --- a/pavement.py +++ b/pavement.py @@ -22,7 +22,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.13' +VERSION = '1.14' # Read the long description to give to setup README_FILE = 'README' From 66061c8c8130c953aa89709186ef4eda48d8b18e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 4 Apr 2009 12:25:06 -0400 Subject: [PATCH 050/947] Added tag 1.14 for changeset caf3f2a31fdd --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 624e0a7..eeda0ce 100644 --- a/.hgtags +++ b/.hgtags @@ -20,3 +20,4 @@ dda0e4d36a9150968ea6d2d7778d58dbfaf34ba4 1.12 8e73805a97e118524b77da40f25cc42d1ad03e6c 1.13 7c40caf6ce6f9e5bffe4ec35969ba2f19d308f00 1.13 e31542a0d9464a4cb8594958dd70cb56c32cf455 1.14 +caf3f2a31fdd39539e413390720dff419121f568 1.14 From b93a2b73fe3c7a06879f65a8e45eb10d4ff4eb22 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 4 Apr 2009 12:28:01 -0400 Subject: [PATCH 051/947] use dist_dir option for sdist command --- pavement.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/pavement.py b/pavement.py index 24c4341..b49c421 100644 --- a/pavement.py +++ b/pavement.py @@ -78,8 +78,8 @@ ), - packaging = Bunch( - outdir='~/Desktop', + sdist = Bunch( + dist_dir=os.path.expanduser('~/Desktop'), ), ) @@ -101,12 +101,7 @@ def remake_directories(*dirnames): def sdist(): """Create a source distribution. """ - # Move the output file to the desktop - dist_files = path('dist').glob('*.tar.gz') - dest_dir = path(options.packaging.outdir).expanduser() - for f in dist_files: - f.move(dest_dir) - return + pass @task def html(): From 7d2e8ed7411b92e79e0062125d8bcd727166bc85 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 4 Apr 2009 12:28:06 -0400 Subject: [PATCH 052/947] Added tag 1.14 for changeset 6e54ea32a9d1 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index eeda0ce..e52e84d 100644 --- a/.hgtags +++ b/.hgtags @@ -21,3 +21,4 @@ dda0e4d36a9150968ea6d2d7778d58dbfaf34ba4 1.12 7c40caf6ce6f9e5bffe4ec35969ba2f19d308f00 1.13 e31542a0d9464a4cb8594958dd70cb56c32cf455 1.14 caf3f2a31fdd39539e413390720dff419121f568 1.14 +6e54ea32a9d1c0a73550b6baec0190e894536512 1.14 From 0e1946a8839d3521dc14277629e658d0af689771 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 4 Apr 2009 12:30:47 -0400 Subject: [PATCH 053/947] add tests to sdist package --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 6ecbcd5..5535f95 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,4 +2,4 @@ include README.html include setup.py include paver-minilib.zip include pavement.py -include test.sh +include tests/* From 4c8de91b8ba1c339fd42ad3bd5fc6229e0fe386f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 4 Apr 2009 16:28:26 -0400 Subject: [PATCH 054/947] error handling in mkvirtualenv --- README | 3 +++ tests/test.sh | 31 ++++++++++++++++++++++++++----- virtualenvwrapper_bashrc | 18 +++++++++--------- 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/README b/README index 2a546d2..0998cd9 100644 --- a/README +++ b/README @@ -130,6 +130,9 @@ For more details, refer to the column published in the May 2008 issue of Python Updates ======= +upcoming + - Better error handling in mkvirtualenv. + 1.14 - Wrap the virtualenv version of deactivate() with one that lets us invoke the predeactivate hooks. diff --git a/tests/test.sh b/tests/test.sh index 5308ff3..4f0f7ae 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -23,8 +23,7 @@ setUp () { test_mkvirtualenv() { mkvirtualenv "env1" - assertTrue "[ -d $WORKON_HOME/env1 ]" - assertSame "env1" $(basename "$VIRTUAL_ENV") + assertTrue "Environment directory was not created" "[ -d $WORKON_HOME/env1 ]" } test_cdvirtual() { @@ -38,20 +37,42 @@ test_cdsitepackages () { pushd "$(pwd)" >/dev/null cdsitepackages pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) - assertSame "$VIRTUAL_ENV/lib/python${pyvers}/site-packages" "$(pwd)" + sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" + assertSame "$sitepackages" "$(pwd)" popd >/dev/null } -test_mkvirtualenv_switches () { +test_mkvirtualenv_activates () { mkvirtualenv "env2" assertTrue virtualenvwrapper_verify_active_environment assertSame "env2" $(basename "$VIRTUAL_ENV") } +# test_mkvirtualenv_sitepackages () { +# # Without the option verify that site-packages are copied. +# mkvirtualenv "env3" +# assertSame "env3" "$(basename $VIRTUAL_ENV)" +# pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) +# sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" +# #cat "$sitepackages/easy-install.pth" +# assertTrue "Do not have expected virtualenv.py" "[ -f $sitepackages/virtualenv.py ]" +# rmvirtualenv "env3" +# +# # With the argument, verify that they are not copied. +# mkvirtualenv --no-site-packages "env4" +# assertSame "env4" $(basename "$VIRTUAL_ENV") +# pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) +# sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" +# assertTrue "[ -f $sitepackages/setuptools.pth ]" +# assertTrue "[ -f $sitepackages/easy-install.pth ]" +# assertFalse "Have virtualenv.py but should not" "[ -f $sitepackages/virtualenv.py ]" +# rmvirtualenv "env4" +# } + test_workon () { workon env1 assertTrue virtualenvwrapper_verify_active_environment - assertSame "env1" $(basename "$VIRTUAL_ENV") + assertSame "env1" $(basename "$VIRTUAL_ENV") } test_postactivate_hook () { diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index fa9fa2d..03ec7ea 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -32,12 +32,6 @@ fi WORKON_HOME=$(cd "$WORKON_HOME"; pwd) export WORKON_HOME -VIRTUALENV_WRAPPER_BIN=$(dirname "$0") -if [ "$VIRTUALENV_WRAPPER_BIN" = "." ] -then - VIRTUALENV_WRAPPER_BIN=$(pwd) -fi - # Verify that the WORKON_HOME directory exists function virtualenvwrapper_verify_workon_home () { if [ ! -d "$WORKON_HOME" ] @@ -94,10 +88,14 @@ function virtualenvwrapper_run_hook () { function mkvirtualenv () { eval "envname=\$$#" virtualenvwrapper_verify_workon_home || return 1 - (cd "$WORKON_HOME"; - virtualenv "$@"; + (cd "$WORKON_HOME" && + virtualenv "$@" && virtualenvwrapper_run_hook "./premkvirtualenv" "$envname" ) + # If they passed a help option or got an error from virtualenv, + # the environment won't exist. Use that to tell whether + # we should switch to the environment and run the hook. + [ ! -d "$WORKON_HOME/$envname" ] && return 0 workon "$envname" virtualenvwrapper_source_hook "$WORKON_HOME/postmkvirtualenv" } @@ -128,7 +126,9 @@ function virtualenvwrapper_show_workon_options () { virtualenvwrapper_verify_workon_home || return 1 # NOTE: DO NOT use ls here because colorized versions spew control characters # into the output list. - (cd "$WORKON_HOME"; find -L . -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort + # echo seems a little faster than find, even with -depth 3. + (cd "$WORKON_HOME"; for f in */bin/activate; do echo $f; done) | sed 's|^\./||' | sed 's|/bin/activate||' | sort +# (cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort } # List or change working virtual environments From 2005a1216c27904b08ddb4677c85d1263230f156 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 6 Apr 2009 14:55:53 -0400 Subject: [PATCH 055/947] prep release 1.15 --- README | 3 ++- pavement.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README b/README index 0998cd9..8d3c340 100644 --- a/README +++ b/README @@ -130,8 +130,9 @@ For more details, refer to the column published in the May 2008 issue of Python Updates ======= -upcoming +1.15 - Better error handling in mkvirtualenv. + - Remove bogus VIRTUALENV_WRAPPER_BIN variable. 1.14 - Wrap the virtualenv version of deactivate() with one that lets us invoke diff --git a/pavement.py b/pavement.py index b49c421..6395b06 100644 --- a/pavement.py +++ b/pavement.py @@ -22,7 +22,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.14' +VERSION = '1.15' # Read the long description to give to setup README_FILE = 'README' From 9d595e34f04e98a223e9be74fe1be79ed2f369aa Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 6 Apr 2009 14:55:58 -0400 Subject: [PATCH 056/947] Added tag 1.15 for changeset bddfac3c8fde --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index e52e84d..3642492 100644 --- a/.hgtags +++ b/.hgtags @@ -22,3 +22,4 @@ dda0e4d36a9150968ea6d2d7778d58dbfaf34ba4 1.12 e31542a0d9464a4cb8594958dd70cb56c32cf455 1.14 caf3f2a31fdd39539e413390720dff419121f568 1.14 6e54ea32a9d1c0a73550b6baec0190e894536512 1.14 +bddfac3c8fde9c860c6e942435cff297f989060d 1.15 From a2231d85ae81abfb5fa4caae98a15a174c524425 Mon Sep 17 00:00:00 2001 From: "wam@talyn.cisco.com" Date: Thu, 16 Apr 2009 15:35:21 -0400 Subject: [PATCH 057/947] Allow cdvirtualenv to take an argument which is a directory under the virtualenv root to change into. --- virtualenvwrapper_bashrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 03ec7ea..31d3658 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -281,5 +281,5 @@ function cdsitepackages () { function cdvirtualenv () { virtualenvwrapper_verify_active_environment || return 1 - cd $VIRTUAL_ENV + cd $VIRTUAL_ENV/$1 } From b87f352a442b8fd06c775b4175d3db25a0a18789 Mon Sep 17 00:00:00 2001 From: "wam@talyn.cisco.com" Date: Thu, 16 Apr 2009 16:26:33 -0400 Subject: [PATCH 058/947] Redirect all error messages from stdout to stderr Added directory completion for cdvirtualenv --- virtualenvwrapper_bashrc | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 31d3658..757679f 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -36,7 +36,7 @@ export WORKON_HOME function virtualenvwrapper_verify_workon_home () { if [ ! -d "$WORKON_HOME" ] then - echo "ERROR: Virtual environments directory '$WORKON_HOME' does not exist." + echo "ERROR: Virtual environments directory '$WORKON_HOME' does not exist." >&2 return 1 fi return 0 @@ -47,7 +47,7 @@ function virtualenvwrapper_verify_workon_environment () { typeset env_name="$1" if [ ! -d "$WORKON_HOME/$env_name" ] then - echo "ERROR: Environment '$env_name' does not exist. Create it with 'mkvirtualenv $env_name'." + echo "ERROR: Environment '$env_name' does not exist. Create it with 'mkvirtualenv $env_name'." >&2 return 1 fi return 0 @@ -57,7 +57,7 @@ function virtualenvwrapper_verify_workon_environment () { function virtualenvwrapper_verify_active_environment () { if [ ! -n "${VIRTUAL_ENV}" ] || [ ! -d "${VIRTUAL_ENV}" ] then - echo "ERROR: no virtualenv active, or active virtualenv is missing" + echo "ERROR: no virtualenv active, or active virtualenv is missing" >&2 return 1 fi return 0 @@ -106,14 +106,14 @@ function rmvirtualenv () { virtualenvwrapper_verify_workon_home || return 1 if [ "$env_name" = "" ] then - echo "Please specify an enviroment." + echo "Please specify an enviroment." >&2 return 1 fi env_dir="$WORKON_HOME/$env_name" if [ "$VIRTUAL_ENV" = "$env_dir" ] then - echo "ERROR: You cannot remove the active environment ('$env_name')." - echo "Either switch to another environment, or run 'deactivate'." + echo "ERROR: You cannot remove the active environment ('$env_name')." >&2 + echo "Either switch to another environment, or run 'deactivate'." >&2 return 1 fi virtualenvwrapper_run_hook "$WORKON_HOME/prermvirtualenv" "$env_dir" @@ -149,7 +149,7 @@ function workon () { activate="$WORKON_HOME/$env_name/bin/activate" if [ ! -f "$activate" ] then - echo "ERROR: Environment '$WORKON_HOME/$env_name' does not contain an activate script." + echo "ERROR: Environment '$WORKON_HOME/$env_name' does not contain an activate script." >&2 return 1 fi @@ -206,6 +206,13 @@ if [ -n "$BASH" ] ; then COMPREPLY=( $(compgen -W "`virtualenvwrapper_show_workon_options`" -- ${cur}) ) } + _cdvirtualenv_complete () + { + local cur="$2" + # COMPREPLY=( $(compgen -d -- "${VIRTUAL_ENV}/${cur}" | sed -e "s@${VIRTUAL_ENV}/@@" ) ) + COMPREPLY=( $(cdvirtualenv && compgen -d -- "${cur}" ) ) + } + complete -o nospace -F _cdvirtualenv_complete -S/ cdvirtualenv complete -o default -o nospace -F _virtualenvs workon complete -o default -o nospace -F _virtualenvs rmvirtualenv elif [ -n "$ZSH_VERSION" ] ; then @@ -233,7 +240,7 @@ function add2virtualenv () { if [ ! -d "${site_packages}" ] then - echo "ERROR: currently-active virtualenv does not appear to have a site-packages directory" + echo "ERROR: currently-active virtualenv does not appear to have a site-packages directory" >&2 return 1 fi From 23f5afc896a07b721dbdb82aa4e2b47b145a0cf0 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 25 Apr 2009 10:00:28 -0400 Subject: [PATCH 059/947] Merge in changes to ``cdvirtualenv`` and error messages from wam. Add tests and docs. --- README | 34 +++++++++++++++++++++++++++++++--- tests/test.sh | 2 ++ virtualenvwrapper_bashrc | 4 ++-- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/README b/README index 8d3c340..f7a7922 100644 --- a/README +++ b/README @@ -114,9 +114,32 @@ file does not exist, it will be created first. Quickly Navigating to a virtualenv ================================== -The functions ``cdsitepackages`` and ``cdvirtualenv`` provide quick shortcuts to quickly -``cd`` into the ``site-packages`` directory of the currently-active virtualenv, and to the -root of the currently-active virtualenv, respectively. +There are two functions to provide shortcuts to navigate into the the currently-active +virtualenv. + +cdvirtualenv +============ + +Calling ``cdvirtualenv`` changes the current working directory to the top of the virtualenv (``$VIRTUAL_ENV``). An optional argument is appended to the path, allowing navigation directly into a subdirectory. + +:: + + $ workon pymotw + $ echo $VIRTUAL_ENV + /Users/dhellmann/.virtualenvs/pymotw + $ cdvirtualenv + $ pwd + /Users/dhellmann/.virtualenvs/pymotw + $ cdvirtualenv bin + $ pwd + /Users/dhellmann/.virtualenvs/pymotw/bin + +cdsitepackages +============== + +Because the exact path to the site-packages directory in the virtualenv depends on the +version of Python, ``cdsitepackages`` is provided as a shortcut for ``cdvirtualenv +lib/python${pyvers}/site-packages``. ========== References @@ -130,6 +153,11 @@ For more details, refer to the column published in the May 2008 issue of Python Updates ======= +1.16 + + - Merged in changes to ``cdvirtualenv`` from wam and added tests and docs. + - Merged in changes to make error messages go to stderr, also provided by wam. + 1.15 - Better error handling in mkvirtualenv. - Remove bogus VIRTUALENV_WRAPPER_BIN variable. diff --git a/tests/test.sh b/tests/test.sh index 4f0f7ae..d364368 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -30,6 +30,8 @@ test_cdvirtual() { pushd "$(pwd)" >/dev/null cdvirtualenv assertSame "$VIRTUAL_ENV" "$(pwd)" + cdvirtualenv bin + assertSame "$VIRTUAL_ENV/bin" "$(pwd)" popd >/dev/null } diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 757679f..8c51068 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -276,8 +276,8 @@ function add2virtualenv () { function cdsitepackages () { virtualenvwrapper_verify_active_environment || return 1 pyvers="`python -c 'import sys; print sys.version[:3]'`" - site_packages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" - cd $site_packages + site_packages="lib/python${pyvers}/site-packages" + cdvirtualenv $site_packages } # From fc54ad29d7d1c60170951608db18d6a12f25c9ae Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 25 Apr 2009 10:01:54 -0400 Subject: [PATCH 060/947] remove todo list --- TODO | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 TODO diff --git a/TODO b/TODO deleted file mode 100644 index fbbc52d..0000000 --- a/TODO +++ /dev/null @@ -1,5 +0,0 @@ -######### -TODO List -######### - - - figure out if there's a way to host tarballs on bitbucket.org From 5ef6b538359e362e6676549f1fb1b987cfd4e157 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 25 Apr 2009 10:02:19 -0400 Subject: [PATCH 061/947] bump version --- pavement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pavement.py b/pavement.py index 6395b06..623f591 100644 --- a/pavement.py +++ b/pavement.py @@ -22,7 +22,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.15' +VERSION = '1.16' # Read the long description to give to setup README_FILE = 'README' From e985841beadfd93aeabbc1ddac221af9a05e09f3 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 25 Apr 2009 10:02:21 -0400 Subject: [PATCH 062/947] Added tag 1.16 for changeset 7d9dbc84f25d --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 3642492..135be24 100644 --- a/.hgtags +++ b/.hgtags @@ -23,3 +23,4 @@ e31542a0d9464a4cb8594958dd70cb56c32cf455 1.14 caf3f2a31fdd39539e413390720dff419121f568 1.14 6e54ea32a9d1c0a73550b6baec0190e894536512 1.14 bddfac3c8fde9c860c6e942435cff297f989060d 1.15 +7d9dbc84f25da33c7c458c13874f99535bb6bfa7 1.16 From 2509490e89a411a7915f644e321ec2003dfb3ec6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 30 May 2009 10:46:29 -0400 Subject: [PATCH 063/947] run the tests under zsh as well as explicitly invoking bash --- pavement.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pavement.py b/pavement.py index 623f591..45b0621 100644 --- a/pavement.py +++ b/pavement.py @@ -113,4 +113,5 @@ def html(): @task def test(): - sh('./tests/test.sh') + sh('bash ./tests/test.sh') + sh('SHUNIT_PARENT=./tests/test.sh zsh -o shwordsplit ./tests/test.sh') From c394718c30d771503cb194b6b29765b7c4fc9cbc Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 30 May 2009 11:05:49 -0400 Subject: [PATCH 064/947] import documentation contribution from Steve Steiner --- .hgignore | 5 + MANIFEST.in | 2 + docsource/Makefile | 88 +++++++++++++++++ docsource/command_ref.rst | 45 +++++++++ docsource/conf.py | 194 ++++++++++++++++++++++++++++++++++++++ docsource/index.rst | 164 ++++++++++++++++++++++++++++++++ docsource/make.bat | 112 ++++++++++++++++++++++ pavement.py | 25 +++-- 8 files changed, 628 insertions(+), 7 deletions(-) create mode 100644 docsource/Makefile create mode 100644 docsource/command_ref.rst create mode 100644 docsource/conf.py create mode 100644 docsource/index.rst create mode 100644 docsource/make.bat diff --git a/.hgignore b/.hgignore index fd9f147..dc3ee1c 100644 --- a/.hgignore +++ b/.hgignore @@ -1,5 +1,10 @@ +syntax: glob README.html virtualenvwrapper.egg-info paver-minilib.zip setup.py trace.txt +docs + +syntax: re +.DS_Store diff --git a/MANIFEST.in b/MANIFEST.in index 5535f95..4fe8145 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,3 +3,5 @@ include setup.py include paver-minilib.zip include pavement.py include tests/* +recursive-include docs *.html *.txt *.css *.js *.png +recursive-include docsource *.rst *.txt *.py diff --git a/docsource/Makefile b/docsource/Makefile new file mode 100644 index 0000000..e212b3f --- /dev/null +++ b/docsource/Makefile @@ -0,0 +1,88 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d _build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + -rm -rf _build/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html + @echo + @echo "Build finished. The HTML pages are in _build/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) _build/dirhtml + @echo + @echo "Build finished. The HTML pages are in _build/dirhtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) _build/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) _build/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) _build/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in _build/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) _build/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in _build/qthelp, like this:" + @echo "# qcollectiongenerator _build/qthelp/virtualenvwrapper.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile _build/qthelp/virtualenvwrapper.qhc" + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex + @echo + @echo "Build finished; the LaTeX files are in _build/latex." + @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ + "run these through (pdf)latex." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) _build/changes + @echo + @echo "The overview file is in _build/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) _build/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in _build/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) _build/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in _build/doctest/output.txt." diff --git a/docsource/command_ref.rst b/docsource/command_ref.rst new file mode 100644 index 0000000..eda481c --- /dev/null +++ b/docsource/command_ref.rst @@ -0,0 +1,45 @@ +.. Quick reference documentation for virtualenvwrapper command line functions + Created Thursday, May 28, 2009 by Steve Steiner (ssteinerX@gmail.com) + +================== +Command Reference +================== + +All of the commands below are to be used on the Terminal command line. + +add2virtualenv +-------------- + +add2virtualenv directory1 directory2 ... + +Path management for packages outside of the virtual env. +Based on a contribution from James Bennett and Jannis Leidel. + + +Adds the specified directories to the Python path for the currently-active +virtualenv. + +This will be done by placing the directory names in a path file +named "virtualenv_path_extensions.pth" inside the virtualenv's site-packages +directory; if this file does not exist, it will be created first. + +mkvirtualenv +------------ + +Create a new environment, in the WORKON_HOME. + +Usage: mkvirtualenv [options] ENVNAME + +(where the options are passed directly to virtualenv) + +rmvirtualenv +------------ +Remove an environment, in the WORKON_HOME. + +Usage: rmvirtualenv ENVNAME + +workon +# List or change working virtual environments +# +# Usage: workon [environment_name] +# diff --git a/docsource/conf.py b/docsource/conf.py new file mode 100644 index 0000000..e368b26 --- /dev/null +++ b/docsource/conf.py @@ -0,0 +1,194 @@ +# -*- coding: utf-8 -*- +# +# virtualenvwrapper documentation build configuration file, created by +# sphinx-quickstart on Thu May 28 22:35:13 2009. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.append(os.path.abspath('.')) + +# -- General configuration ----------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'virtualenvwrapper' +copyright = u'2009, Doug Hellmann' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = os.environ['VERSION'] +# The full version, including alpha/beta/rc tags. +release = version + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of documents that shouldn't be included in the build. +#unused_docs = [] + +# List of directories, relative to source directory, that shouldn't be searched +# for source files. +exclude_trees = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# 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, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_use_modindex = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = '' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'virtualenvwrapperdoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +# The paper size ('letter' or 'a4'). +#latex_paper_size = 'letter' + +# The font size ('10pt', '11pt' or '12pt'). +#latex_font_size = '10pt' + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'virtualenvwrapper.tex', u'virtualenvwrapper Documentation', + u'Doug Hellmann', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# Additional stuff for the LaTeX preamble. +#latex_preamble = '' + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_use_modindex = True diff --git a/docsource/index.rst b/docsource/index.rst new file mode 100644 index 0000000..ee94b5b --- /dev/null +++ b/docsource/index.rst @@ -0,0 +1,164 @@ +.. virtualenvwrapper documentation master file, created by + sphinx-quickstart on Thu May 28 22:35:13 2009. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to virtualenvwrapper's documentation! +============================================= + +Contents: + +.. toctree:: + :maxdepth: 2 + + command_ref + +=========== +Quick Setup +=========== + +1. Add a line like ``export WORKON_HOME=$HOME/.virtualenvs`` to your .bashrc. + +2. Add a line like ``source /path/to/this/file/virtualenvwrapper_bashrc`` + to your .bashrc. + +3. Run: ``source ~/.bashrc`` + +4. Run: ``workon`` + +5. A list of environments, empty, is printed. + +6. Run: ``mkvirtualenv temp`` + +7. Run: ``workon`` + +8. A new environment, ``temp`` is created and activated. + +9. This time, the ``temp`` environment is included. + + +=============== +Path Management +=============== + +Sometimes it is desirable to share installed packages that are not in the +system ``site-pacakges`` directory and which you do not want to install in +each virtualenv. In this case, you *could* symlink the source into the +environment ``site-packages`` directory, but it is also easy to add extra +directories to the PYTHONPATH by including them in a .pth file inside +``site-packages`` using ``add2virtualenv``. + +1. Check out the source for a big project, such as Django. +2. Run: ``add2virtualenv path_to_source``. +3. Run: ``add2virtualenv``. +4. A usage message and list of current "extra" paths is printed. + +================== +Activation Scripts +================== + +virtualenvwrapper adds two separate hook scripts you can use to change your +settings when moving between environments. They are *sourced* by ``workon`` at +the appropriate trigger time, allowing them to modify your shell environment. + +Both scripts are bash shell scripts and need to be saved in +``$VIRTUAL_ENV/bin/``. + +postactivate +============ + +The ``postactivate`` script is run after the new environment is enabled. +``$VIRTUAL_ENV`` refers to the new environment at the time the script runs. + +This example script for the PyMOTW environment changes the current working +directory and the PATH variable to refer to the source tree containing the +PyMOTW source. + +:: + + pymotw_root=/Users/dhellmann/Documents/PyMOTW + cd $pymotw_root + PATH=$pymotw_root/bin:$PATH + +predeactivate +============= + +The ``predeactivate`` script is run before the current environment is +deactivated, and can be used to disable or clear settings in your environment. +``$VIRTUAL_ENV`` refers to the old environment at the time the script runs. + +=============== +Path Management +=============== + +The function ``add2virtualenv`` adds the specified directories to the Python +path for the active virtualenv. The directory names passed as argument are +added to a path file named ``virtualenv_path_extensions.pth`` inside the +virtualenv's site-packages directory. If this file does not exist, it will be +created first. + +========== +References +========== + +For more details, refer to the column I wrote for the May 2008 issue of Python +Magazine: `virtualenvwrapper | And Now For Something Completely Different +`_. + +======= +Updates +======= + +1.7 + - Move to bitbucket.org for hosting + - clean up TODO list and svn keywords + - add license section below + +1.6.1 + - More zsh support (fixes to rmvirtualenv) from Byron Clark. + +1.6 + - Add completion support for zsh, courtesy of Ted Leung. + +1.5 + - Fix some issues with spaces in directory or env names. They still don't + really work with virtualenv, though. + - Added documentation for the postactivate and predeactivate scripts. + +1.4 + - Includes a new .pth management function based on work contributed by James + Bennett and Jannis Leidel. + +1.3.x + - Includes a fix for a nasty bug in rmvirtualenv identified by John Shimek. + +======= +License +======= + +Copyright Doug Hellmann, All Rights Reserved + +Permission to use, copy, modify, and distribute this software and +its documentation for any purpose and without fee is hereby +granted, provided that the above copyright notice appear in all +copies and that both that copyright notice and this permission +notice appear in supporting documentation, and that the name of Doug +Hellmann not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN +NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/docsource/make.bat b/docsource/make.bat new file mode 100644 index 0000000..51d1ea6 --- /dev/null +++ b/docsource/make.bat @@ -0,0 +1,112 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +set SPHINXBUILD=sphinx-build +set ALLSPHINXOPTS=-d _build/doctrees %SPHINXOPTS% . +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^` where ^ is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. changes to make an overview over all changed/added/deprecated items + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + goto end +) + +if "%1" == "clean" ( + for /d %%i in (_build\*) do rmdir /q /s %%i + del /q /s _build\* + goto end +) + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% _build/html + echo. + echo.Build finished. The HTML pages are in _build/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% _build/dirhtml + echo. + echo.Build finished. The HTML pages are in _build/dirhtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% _build/pickle + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% _build/json + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% _build/htmlhelp + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in _build/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% _build/qthelp + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in _build/qthelp, like this: + echo.^> qcollectiongenerator _build\qthelp\virtualenvwrapper.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile _build\qthelp\virtualenvwrapper.ghc + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% _build/latex + echo. + echo.Build finished; the LaTeX files are in _build/latex. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% _build/changes + echo. + echo.The overview file is in _build/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% _build/linkcheck + echo. + echo.Link check complete; look for any errors in the above output ^ +or in _build/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% _build/doctest + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in _build/doctest/output.txt. + goto end +) + +:end diff --git a/pavement.py b/pavement.py index 45b0621..58737d2 100644 --- a/pavement.py +++ b/pavement.py @@ -19,10 +19,12 @@ from paver.easy import * import paver.setuputils paver.setuputils.install_distutils_tasks() +import paver.doctools # What project are we building? PROJECT = 'virtualenvwrapper' VERSION = '1.16' +os.environ['VERSION'] = VERSION # Read the long description to give to setup README_FILE = 'README' @@ -78,8 +80,17 @@ ), + sphinx = Bunch( + docroot='.', + builddir='docs', + sourcedir='docsource', + ), + sdist = Bunch( dist_dir=os.path.expanduser('~/Desktop'), + # Tell Paver to include extra parts that we use + # but it doesn't ship in the minilib by default. + extra_files=['doctools'], ), ) @@ -103,13 +114,13 @@ def sdist(): """ pass -@task -def html(): - # FIXME - Switch to sphinx? - outfile = path('README.html') - outfile.unlink() - sh('rst2html.py %s README.html' % README_FILE) - return +# @task +# def html(): +# # FIXME - Switch to sphinx? +# outfile = path('README.html') +# outfile.unlink() +# sh('rst2html.py %s README.html' % README_FILE) +# return @task def test(): From 8dfb27d4353c1f891abbc93b77e18e423a45040b Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 30 May 2009 11:43:15 -0400 Subject: [PATCH 065/947] clean up and update docs, reduce size of readme, start working on packaging changes --- MANIFEST.in | 2 +- README | 197 +------------------------------------- docsource/command_ref.rst | 105 +++++++++++++++----- docsource/conf.py | 4 +- docsource/history.rst | 72 ++++++++++++++ docsource/hooks.rst | 69 +++++++++++++ docsource/index.rst | 141 +++++---------------------- pavement.py | 25 ++--- 8 files changed, 265 insertions(+), 350 deletions(-) create mode 100644 docsource/history.rst create mode 100644 docsource/hooks.rst diff --git a/MANIFEST.in b/MANIFEST.in index 4fe8145..1abea5a 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,4 +4,4 @@ include paver-minilib.zip include pavement.py include tests/* recursive-include docs *.html *.txt *.css *.js *.png -recursive-include docsource *.rst *.txt *.py +recursive-include docsource *.rst diff --git a/README b/README index f7a7922..c7a10a2 100644 --- a/README +++ b/README @@ -2,6 +2,8 @@ virtualenvwrapper ################# +virtualenvwrapper is a set of extensions to Ian Bicking's `virtualenv `_ tool. The extensions include wrappers for creating and deleting virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. + =========== Quick Setup =========== @@ -19,128 +21,6 @@ Quick Setup 7. Run: ``workon`` 8. This time, the ``temp`` environment is included. - -=============== -Path Management -=============== - -Sometimes it is desirable to share installed packages that are not in the system ``site-pacakges`` directory and which you do not want to install in each virtualenv. In this case, you *could* symlink the source into the environment ``site-packages`` directory, but it is also easy to add extra directories to the PYTHONPATH by including them in a .pth file inside ``site-packages`` using ``add2virtualenv``. - -1. Check out the source for a big project, such as Django. -2. Run: ``add2virtualenv path_to_source``. -3. Run: ``add2virtualenv``. -4. A usage message and list of current "extra" paths is printed. - -============ -Hook Scripts -============ - -virtualenvwrapper adds several hook points you can use to change your settings when creating, -deleting, or moving between environments. They are either *sourced* (allowing them to modify -your shell environment) or run as an external program at the appropriate trigger time. - -$VIRTUAL_ENV/bin/postactivate -============================= - -The ``postactivate`` script is sourced after the new environment is enabled. ``$VIRTUAL_ENV`` -refers to the new environment at the time the script runs. - -This example script for the PyMOTW environment changes the current working directory and the -PATH variable to refer to the source tree containing the PyMOTW source. - -:: - - pymotw_root=/Users/dhellmann/Documents/PyMOTW - cd $pymotw_root - PATH=$pymotw_root/bin:$PATH - -$VIRTUAL_ENV/bin/predeactivate -============================== - -The ``predeactivate`` script is source before the current environment is deactivated, and can -be used to disable or clear settings in your environment. ``$VIRTUAL_ENV`` refers to the old -environment at the time the script runs. - -$WORKON_HOME/postactivate -============================= - -The global ``postactivate`` script is sourced after the new environment is enabled and the new -environment's postactivate is sourced (if it exists). ``$VIRTUAL_ENV`` refers to the new -environment at the time the script runs. - -This example script adds a space between the virtual environment name and your old PS1 by making -use of ``_OLD_VIRTUAL_PS1``. - -:: - - PS1="(`basename \"$VIRTUAL_ENV\"`) $_OLD_VIRTUAL_PS1" - -$WORKON_HOME/premkvirtualenv -============================= - -The ``premkvirtualenv`` script is run as an external program after the virtual environment is -created but before the current environment is switched to point to the new env. The current -working directory for the script is ``$WORKON_HOME`` and the name of the new environment is -passed as an argument to the script. - -$WORKON_HOME/postmkvirtualenv -============================= - -The ``postmkvirtualenv`` script is sourced after the new environment is created and -activated. - -$WORKON_HOME/prermvirtualenv -============================ - -The ``prermvirtualenv`` script is run as an external program before the environment is -removed. The full path to the environment directory is passed as an argument to the script. - -$WORKON_HOME/postrmvirtualenv -============================= - -The ``postrmvirtualenv`` script is run as an external program after the environment is -removed. The full path to the environment directory is passed as an argument to the script. - -=============== -Path Management -=============== - -The function ``add2virtualenv`` adds the specified directories to the Python path for the -active virtualenv. The directory names passed as argument are added to a path file named -``virtualenv_path_extensions.pth`` inside the virtualenv's site-packages directory. If this -file does not exist, it will be created first. - -================================== -Quickly Navigating to a virtualenv -================================== - -There are two functions to provide shortcuts to navigate into the the currently-active -virtualenv. - -cdvirtualenv -============ - -Calling ``cdvirtualenv`` changes the current working directory to the top of the virtualenv (``$VIRTUAL_ENV``). An optional argument is appended to the path, allowing navigation directly into a subdirectory. - -:: - - $ workon pymotw - $ echo $VIRTUAL_ENV - /Users/dhellmann/.virtualenvs/pymotw - $ cdvirtualenv - $ pwd - /Users/dhellmann/.virtualenvs/pymotw - $ cdvirtualenv bin - $ pwd - /Users/dhellmann/.virtualenvs/pymotw/bin - -cdsitepackages -============== - -Because the exact path to the site-packages directory in the virtualenv depends on the -version of Python, ``cdsitepackages`` is provided as a shortcut for ``cdvirtualenv -lib/python${pyvers}/site-packages``. - ========== References ========== @@ -149,79 +29,6 @@ For more details, refer to the column published in the May 2008 issue of Python `virtualenvwrapper | And Now For Something Completely Different `_. -======= -Updates -======= - -1.16 - - - Merged in changes to ``cdvirtualenv`` from wam and added tests and docs. - - Merged in changes to make error messages go to stderr, also provided by wam. - -1.15 - - Better error handling in mkvirtualenv. - - Remove bogus VIRTUALENV_WRAPPER_BIN variable. - -1.14 - - Wrap the virtualenv version of deactivate() with one that lets us invoke - the predeactivate hooks. - - Fix virtualenvwrapper_show_workon_options for colorized versions of ls and - write myself a note so I don't break it again later. - - Convert test.sh to use true tests with `shunit2 `_ - -1.13 - - Fix issue #5 by correctly handling symlinks and limiting the list of envs to things - that look like they can be activated. - -1.12 - - Check return value of virtualenvwrapper_verify_workon_home everywhere, thanks to - Jeff Forcier for pointing out the errors. - - Fix instructions at top of README, pointed out by Matthew Scott. - - Add cdvirtualenv and cdsitepackages, contributed by James Bennett. - - Enhance test.sh. - -1.11 - - Optimize virtualenvwrapper_show_workon_options. - - Add global postactivate hook. - -1.10 - - Pull in fix for colorized ls from Jeff Forcier (b42a25f7b74a). - -1.9 - - Add more hooks for operations to run before and after creating or deleting environments based on changes from Chris Hasenpflug. - -1.8.1 - - Corrected a problem with change to mkvirtualenv that lead to release 1.8 by using an alternate fix proposed by James in comments on release 1.4. - -1.8 - - Fix for processing the argument list in mkvirtualenv from jorgevargas (BitBucket issue #1) - -1.7 - - Move to bitbucket.org for hosting - - clean up TODO list and svn keywords - - add license section below - -1.6.1 - - - More zsh support (fixes to rmvirtualenv) from Byron Clark. - -1.6 - - - Add completion support for zsh, courtesy of Ted Leung. - -1.5 - - - Fix some issues with spaces in directory or env names. They still don't really work with virtualenv, though. - - Added documentation for the postactivate and predeactivate scripts. - -1.4 - - - Includes a new .pth management function based on work contributed by James Bennett and Jannis Leidel. - -1.3.x - - - Includes a fix for a nasty bug in rmvirtualenv identified by John Shimek. - ======= License ======= diff --git a/docsource/command_ref.rst b/docsource/command_ref.rst index eda481c..d09d0e1 100644 --- a/docsource/command_ref.rst +++ b/docsource/command_ref.rst @@ -1,45 +1,102 @@ .. Quick reference documentation for virtualenvwrapper command line functions - Created Thursday, May 28, 2009 by Steve Steiner (ssteinerX@gmail.com) + Originally contributed Thursday, May 28, 2009 by Steve Steiner (ssteinerX@gmail.com) -================== +################# Command Reference -================== +################# All of the commands below are to be used on the Terminal command line. -add2virtualenv --------------- - -add2virtualenv directory1 directory2 ... - -Path management for packages outside of the virtual env. -Based on a contribution from James Bennett and Jannis Leidel. - - -Adds the specified directories to the Python path for the currently-active -virtualenv. - -This will be done by placing the directory names in a path file -named "virtualenv_path_extensions.pth" inside the virtualenv's site-packages -directory; if this file does not exist, it will be created first. +===================== +Managing Environments +===================== mkvirtualenv ------------ Create a new environment, in the WORKON_HOME. -Usage: mkvirtualenv [options] ENVNAME +Syntax:: + + mkvirtualenv [options] ENVNAME (where the options are passed directly to virtualenv) rmvirtualenv ------------ + Remove an environment, in the WORKON_HOME. -Usage: rmvirtualenv ENVNAME +Syntax:: + + rmvirtualenv ENVNAME workon -# List or change working virtual environments -# -# Usage: workon [environment_name] -# +------ + +List or change working virtual environments + +Syntax:: + + workon [environment_name] + +If no ``environment_name`` is given the list of available environments is printed to stdout. + +================================== +Quickly Navigating to a virtualenv +================================== + +There are two functions to provide shortcuts to navigate into the the currently-active +virtualenv. + +cdvirtualenv +------------ + +Calling ``cdvirtualenv`` changes the current working directory to the top of the virtualenv (``$VIRTUAL_ENV``). An optional argument is appended to the path, allowing navigation directly into a subdirectory. + +:: + + $ workon pymotw + $ echo $VIRTUAL_ENV + /Users/dhellmann/.virtualenvs/pymotw + $ cdvirtualenv + $ pwd + /Users/dhellmann/.virtualenvs/pymotw + $ cdvirtualenv bin + $ pwd + /Users/dhellmann/.virtualenvs/pymotw/bin + +cdsitepackages +-------------- + +Because the exact path to the site-packages directory in the virtualenv depends on the +version of Python, ``cdsitepackages`` is provided as a shortcut for ``cdvirtualenv +lib/python${pyvers}/site-packages``. + +=============== +Path Management +=============== + +Sometimes it is desirable to share installed packages that are not in the system ``site-pacakges`` directory and which you do not want to install in each virtualenv. In this case, you *could* symlink the source into the environment ``site-packages`` directory, but it is also easy to add extra directories to the PYTHONPATH by including them in a .pth file inside ``site-packages`` using ``add2virtualenv``. + +1. Check out the source for a big project, such as Django. +2. Run: ``add2virtualenv path_to_source``. +3. Run: ``add2virtualenv``. +4. A usage message and list of current "extra" paths is printed. + +add2virtualenv +-------------- + +Adds the specified directories to the Python path for the currently-active +virtualenv. + +Syntax:: + + add2virtualenv directory1 directory2 ... + +Path management for packages outside of the virtual env. +Based on a contribution from James Bennett and Jannis Leidel. + +This will be done by placing the directory names in a path file +named ``virtualenv_path_extensions.pth`` inside the virtualenv's site-packages +directory; if this file does not exist, it will be created first. diff --git a/docsource/conf.py b/docsource/conf.py index e368b26..17a086d 100644 --- a/docsource/conf.py +++ b/docsource/conf.py @@ -138,10 +138,10 @@ #html_additional_pages = {} # If false, no module index is generated. -#html_use_modindex = True +html_use_modindex = False # If false, no index is generated. -#html_use_index = True +html_use_index = False # If true, the index is split into individual pages for each letter. #html_split_index = False diff --git a/docsource/history.rst b/docsource/history.rst new file mode 100644 index 0000000..edb8741 --- /dev/null +++ b/docsource/history.rst @@ -0,0 +1,72 @@ +=============== +Release History +=============== + +1.16 + + - Merged in changes to ``cdvirtualenv`` from wam and added tests and docs. + - Merged in changes to make error messages go to stderr, also provided by wam. + +1.15 + - Better error handling in mkvirtualenv. + - Remove bogus VIRTUALENV_WRAPPER_BIN variable. + +1.14 + - Wrap the virtualenv version of deactivate() with one that lets us invoke + the predeactivate hooks. + - Fix virtualenvwrapper_show_workon_options for colorized versions of ls and + write myself a note so I don't break it again later. + - Convert test.sh to use true tests with `shunit2 `_ + +1.13 + - Fix issue #5 by correctly handling symlinks and limiting the list of envs to things + that look like they can be activated. + +1.12 + - Check return value of virtualenvwrapper_verify_workon_home everywhere, thanks to + Jeff Forcier for pointing out the errors. + - Fix instructions at top of README, pointed out by Matthew Scott. + - Add cdvirtualenv and cdsitepackages, contributed by James Bennett. + - Enhance test.sh. + +1.11 + - Optimize virtualenvwrapper_show_workon_options. + - Add global postactivate hook. + +1.10 + - Pull in fix for colorized ls from Jeff Forcier (b42a25f7b74a). + +1.9 + - Add more hooks for operations to run before and after creating or deleting environments based on changes from Chris Hasenpflug. + +1.8.1 + - Corrected a problem with change to mkvirtualenv that lead to release 1.8 by using an alternate fix proposed by James in comments on release 1.4. + +1.8 + - Fix for processing the argument list in mkvirtualenv from jorgevargas (BitBucket issue #1) + +1.7 + - Move to bitbucket.org for hosting + - clean up TODO list and svn keywords + - add license section below + +1.6.1 + + - More zsh support (fixes to rmvirtualenv) from Byron Clark. + +1.6 + + - Add completion support for zsh, courtesy of Ted Leung. + +1.5 + + - Fix some issues with spaces in directory or env names. They still don't really work with virtualenv, though. + - Added documentation for the postactivate and predeactivate scripts. + +1.4 + + - Includes a new .pth management function based on work contributed by James Bennett and Jannis Leidel. + +1.3.x + + - Includes a fix for a nasty bug in rmvirtualenv identified by John Shimek. diff --git a/docsource/hooks.rst b/docsource/hooks.rst new file mode 100644 index 0000000..6468c3d --- /dev/null +++ b/docsource/hooks.rst @@ -0,0 +1,69 @@ +============ +Hook Scripts +============ + +virtualenvwrapper adds several hook points you can use to change your settings when creating, +deleting, or moving between environments. They are either *sourced* (allowing them to modify +your shell environment) or run as an external program at the appropriate trigger time. + +$VIRTUAL_ENV/bin/postactivate +============================= + +The ``postactivate`` script is sourced after the new environment is enabled. ``$VIRTUAL_ENV`` +refers to the new environment at the time the script runs. + +This example script for the PyMOTW environment changes the current working directory and the +PATH variable to refer to the source tree containing the PyMOTW source. + +:: + + pymotw_root=/Users/dhellmann/Documents/PyMOTW + cd $pymotw_root + PATH=$pymotw_root/bin:$PATH + +$VIRTUAL_ENV/bin/predeactivate +============================== + +The ``predeactivate`` script is source before the current environment is deactivated, and can +be used to disable or clear settings in your environment. ``$VIRTUAL_ENV`` refers to the old +environment at the time the script runs. + +$WORKON_HOME/postactivate +============================= + +The global ``postactivate`` script is sourced after the new environment is enabled and the new +environment's postactivate is sourced (if it exists). ``$VIRTUAL_ENV`` refers to the new +environment at the time the script runs. + +This example script adds a space between the virtual environment name and your old PS1 by making +use of ``_OLD_VIRTUAL_PS1``. + +:: + + PS1="(`basename \"$VIRTUAL_ENV\"`) $_OLD_VIRTUAL_PS1" + +$WORKON_HOME/premkvirtualenv +============================= + +The ``premkvirtualenv`` script is run as an external program after the virtual environment is +created but before the current environment is switched to point to the new env. The current +working directory for the script is ``$WORKON_HOME`` and the name of the new environment is +passed as an argument to the script. + +$WORKON_HOME/postmkvirtualenv +============================= + +The ``postmkvirtualenv`` script is sourced after the new environment is created and +activated. + +$WORKON_HOME/prermvirtualenv +============================ + +The ``prermvirtualenv`` script is run as an external program before the environment is +removed. The full path to the environment directory is passed as an argument to the script. + +$WORKON_HOME/postrmvirtualenv +============================= + +The ``postrmvirtualenv`` script is run as an external program after the environment is +removed. The full path to the environment directory is passed as an argument to the script. diff --git a/docsource/index.rst b/docsource/index.rst index ee94b5b..61f0b90 100644 --- a/docsource/index.rst +++ b/docsource/index.rst @@ -3,135 +3,50 @@ You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -Welcome to virtualenvwrapper's documentation! -============================================= +################# +virtualenvwrapper +################# -Contents: - -.. toctree:: - :maxdepth: 2 - - command_ref +virtualenvwrapper is a set of extensions to Ian Bicking's `virtualenv `_ tool. The extensions include wrappers for creating and deleting virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. =========== Quick Setup =========== -1. Add a line like ``export WORKON_HOME=$HOME/.virtualenvs`` to your .bashrc. - -2. Add a line like ``source /path/to/this/file/virtualenvwrapper_bashrc`` - to your .bashrc. - -3. Run: ``source ~/.bashrc`` - -4. Run: ``workon`` - -5. A list of environments, empty, is printed. - -6. Run: ``mkvirtualenv temp`` - -7. Run: ``workon`` - -8. A new environment, ``temp`` is created and activated. - -9. This time, the ``temp`` environment is included. - - -=============== -Path Management -=============== - -Sometimes it is desirable to share installed packages that are not in the -system ``site-pacakges`` directory and which you do not want to install in -each virtualenv. In this case, you *could* symlink the source into the -environment ``site-packages`` directory, but it is also easy to add extra -directories to the PYTHONPATH by including them in a .pth file inside -``site-packages`` using ``add2virtualenv``. - -1. Check out the source for a big project, such as Django. -2. Run: ``add2virtualenv path_to_source``. -3. Run: ``add2virtualenv``. -4. A usage message and list of current "extra" paths is printed. - -================== -Activation Scripts -================== - -virtualenvwrapper adds two separate hook scripts you can use to change your -settings when moving between environments. They are *sourced* by ``workon`` at -the appropriate trigger time, allowing them to modify your shell environment. - -Both scripts are bash shell scripts and need to be saved in -``$VIRTUAL_ENV/bin/``. - -postactivate -============ +1. Add two lines to your .bashrc to set the location where the virtual environments should live and the location of the script installed with this package:: -The ``postactivate`` script is run after the new environment is enabled. -``$VIRTUAL_ENV`` refers to the new environment at the time the script runs. + export WORKON_HOME=$HOME/.virtualenvs + source /usr/local/bin/virtualenvwrapper_bashrc -This example script for the PyMOTW environment changes the current working -directory and the PATH variable to refer to the source tree containing the -PyMOTW source. +2. Run: ``source ~/.bashrc`` +3. Run: ``workon`` +4. A list of environments, empty, is printed. +5. Run: ``mkvirtualenv temp`` +6. A new environment, ``temp`` is created and activated. +7. Run: ``workon`` +8. This time, the ``temp`` environment is included. -:: - - pymotw_root=/Users/dhellmann/Documents/PyMOTW - cd $pymotw_root - PATH=$pymotw_root/bin:$PATH - -predeactivate -============= - -The ``predeactivate`` script is run before the current environment is -deactivated, and can be used to disable or clear settings in your environment. -``$VIRTUAL_ENV`` refers to the old environment at the time the script runs. +======= +Details +======= -=============== -Path Management -=============== +.. toctree:: + :maxdepth: 2 -The function ``add2virtualenv`` adds the specified directories to the Python -path for the active virtualenv. The directory names passed as argument are -added to a path file named ``virtualenv_path_extensions.pth`` inside the -virtualenv's site-packages directory. If this file does not exist, it will be -created first. + command_ref + hooks + history ========== References ========== +`virtualenv `_, from Ian Bicking, is a pre-requisite to using these extensions. + For more details, refer to the column I wrote for the May 2008 issue of Python Magazine: `virtualenvwrapper | And Now For Something Completely Different `_. -======= -Updates -======= - -1.7 - - Move to bitbucket.org for hosting - - clean up TODO list and svn keywords - - add license section below - -1.6.1 - - More zsh support (fixes to rmvirtualenv) from Byron Clark. - -1.6 - - Add completion support for zsh, courtesy of Ted Leung. - -1.5 - - Fix some issues with spaces in directory or env names. They still don't - really work with virtualenv, though. - - Added documentation for the postactivate and predeactivate scripts. - -1.4 - - Includes a new .pth management function based on work contributed by James - Bennett and Jannis Leidel. - -1.3.x - - Includes a fix for a nasty bug in rmvirtualenv identified by John Shimek. - ======= License ======= @@ -154,11 +69,3 @@ CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - diff --git a/pavement.py b/pavement.py index 58737d2..cac74a6 100644 --- a/pavement.py +++ b/pavement.py @@ -23,7 +23,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.16' +VERSION = '1.17' os.environ['VERSION'] = VERSION # Read the long description to give to setup @@ -88,8 +88,11 @@ sdist = Bunch( dist_dir=os.path.expanduser('~/Desktop'), - # Tell Paver to include extra parts that we use - # but it doesn't ship in the minilib by default. + ), + + # Tell Paver to include extra parts that we use + # but it doesn't ship in the minilib by default. + minilib = Bunch( extra_files=['doctools'], ), @@ -106,7 +109,7 @@ def remake_directories(*dirnames): return @task -@needs(['html', 'generate_setup', 'minilib', +@needs(['html', 'readme_html', 'generate_setup', 'minilib', 'setuptools.command.sdist' ]) def sdist(): @@ -114,13 +117,13 @@ def sdist(): """ pass -# @task -# def html(): -# # FIXME - Switch to sphinx? -# outfile = path('README.html') -# outfile.unlink() -# sh('rst2html.py %s README.html' % README_FILE) -# return +@task +def readme_html(): + # FIXME - Switch to sphinx? + outfile = path('README.html') + outfile.unlink() + sh('rst2html.py %s README.html' % README_FILE) + return @task def test(): From 067243884990557ea8f40c4617bee0f3c028b03e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 30 May 2009 15:41:02 -0400 Subject: [PATCH 066/947] create a simple python package and include the documentation in it so it is installed by default --- .hgignore | 1 + MANIFEST.in | 3 +-- docsource/history.rst | 4 ++++ pavement.py | 45 +++++++++++++++++------------------ virtualenvwrapper/__init__.py | 11 +++++++++ 5 files changed, 39 insertions(+), 25 deletions(-) create mode 100644 virtualenvwrapper/__init__.py diff --git a/.hgignore b/.hgignore index dc3ee1c..3c66385 100644 --- a/.hgignore +++ b/.hgignore @@ -5,6 +5,7 @@ paver-minilib.zip setup.py trace.txt docs +*.pyc syntax: re .DS_Store diff --git a/MANIFEST.in b/MANIFEST.in index 1abea5a..57d9db4 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,6 @@ -include README.html include setup.py include paver-minilib.zip include pavement.py include tests/* -recursive-include docs *.html *.txt *.css *.js *.png +recursive-include virtualenvwrapper *.html *.txt *.css *.js *.png recursive-include docsource *.rst diff --git a/docsource/history.rst b/docsource/history.rst index edb8741..850cbe0 100644 --- a/docsource/history.rst +++ b/docsource/history.rst @@ -2,6 +2,10 @@ Release History =============== +1.17 + + - Added documentation updates provided by Steve Steiner. + 1.16 - Merged in changes to ``cdvirtualenv`` from wam and added tests and docs. diff --git a/pavement.py b/pavement.py index cac74a6..1dfe810 100644 --- a/pavement.py +++ b/pavement.py @@ -33,10 +33,10 @@ # Scan the input for package information # to grab any data files (text, images, etc.) # associated with sub-packages. -# PACKAGE_DATA = paver.setuputils.find_package_data(PROJECT, -# package=PROJECT, -# only_in_packages=True, -# ) +PACKAGE_DATA = paver.setuputils.find_package_data(PROJECT, + package=PROJECT, + only_in_packages=False, + ) options( setup=Bunch( @@ -68,13 +68,9 @@ provides=['virtualenvwrapper', ], requires=['virtualenv'], - - data_files=[('docs', ['README.html']), - ], - - # It seems wrong to have to list recursive packages explicitly. - # packages = sorted(PACKAGE_DATA.keys()), - # package_data=PACKAGE_DATA, + + packages = sorted(PACKAGE_DATA.keys()), + package_data = PACKAGE_DATA, zip_safe=False, @@ -109,23 +105,26 @@ def remake_directories(*dirnames): return @task -@needs(['html', 'readme_html', 'generate_setup', 'minilib', - 'setuptools.command.sdist' +@needs('paver.doctools.html') +def html(options): + destdir = path(PROJECT) / 'docs' + destdir.rmtree() + builtdocs = path(options.builddir) / "html" + builtdocs.move(destdir) + return + +@task +@needs(['html', + 'generate_setup', 'minilib', + 'setuptools.command.sdist', ]) -def sdist(): +def sdist(options): """Create a source distribution. """ pass - -@task -def readme_html(): - # FIXME - Switch to sphinx? - outfile = path('README.html') - outfile.unlink() - sh('rst2html.py %s README.html' % README_FILE) - return - + @task def test(): sh('bash ./tests/test.sh') sh('SHUNIT_PARENT=./tests/test.sh zsh -o shwordsplit ./tests/test.sh') + return diff --git a/virtualenvwrapper/__init__.py b/virtualenvwrapper/__init__.py new file mode 100644 index 0000000..ff06eb9 --- /dev/null +++ b/virtualenvwrapper/__init__.py @@ -0,0 +1,11 @@ +"""virtualenvwrapper module +""" + +if __name__ == '__main__': + import os + import webbrowser + docs_root = os.path.join(os.path.dirname(__file__), 'docs', 'index.html') + webbrowser.open_new('file://' + docs_root) +else: + import warnings + warnings.warn('Use virtualenvwrapper_bashrc to set up your shell environment.') From 70a687f9966de0fb1b7b1a89f9113dbd264cdd9f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 30 May 2009 15:58:52 -0400 Subject: [PATCH 067/947] cannot run package from command line, so just warn on import --- virtualenvwrapper/__init__.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/virtualenvwrapper/__init__.py b/virtualenvwrapper/__init__.py index ff06eb9..4f492f9 100644 --- a/virtualenvwrapper/__init__.py +++ b/virtualenvwrapper/__init__.py @@ -1,11 +1,6 @@ """virtualenvwrapper module """ -if __name__ == '__main__': - import os - import webbrowser - docs_root = os.path.join(os.path.dirname(__file__), 'docs', 'index.html') - webbrowser.open_new('file://' + docs_root) -else: - import warnings - warnings.warn('Use virtualenvwrapper_bashrc to set up your shell environment.') +import warnings +docs_root = os.path.join(os.path.dirname(__file__), 'docs', 'index.html') +warnings.warn('Use virtualenvwrapper_bashrc to set up your shell environment. See %s for details.' % docs_root) From b660c5f75fcde9f94a6e87e8e3367ab1b75d86d9 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 30 May 2009 16:11:12 -0400 Subject: [PATCH 068/947] add feature list; clean up hook list; fix bug in warning message generation --- README | 9 +++++ docsource/hooks.rst | 69 +++++++++++++++-------------------- docsource/index.rst | 9 +++++ virtualenvwrapper/__init__.py | 2 +- 4 files changed, 49 insertions(+), 40 deletions(-) diff --git a/README b/README index c7a10a2..6ce39b3 100644 --- a/README +++ b/README @@ -4,6 +4,15 @@ virtualenvwrapper virtualenvwrapper is a set of extensions to Ian Bicking's `virtualenv `_ tool. The extensions include wrappers for creating and deleting virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. +======== +Features +======== + + 1. Organizes all of your virtual environments in one place. + 2. Wrappers for creating and deleting environments, including user-configurable hooks. + 3. Use a single command to switch between environments. + 4. Tab completion for commands that take a virtual environment as argument. + =========== Quick Setup =========== diff --git a/docsource/hooks.rst b/docsource/hooks.rst index 6468c3d..06031c3 100644 --- a/docsource/hooks.rst +++ b/docsource/hooks.rst @@ -2,18 +2,17 @@ Hook Scripts ============ -virtualenvwrapper adds several hook points you can use to change your settings when creating, -deleting, or moving between environments. They are either *sourced* (allowing them to modify -your shell environment) or run as an external program at the appropriate trigger time. +virtualenvwrapper adds several hook points you can use to change your settings, shell environment, or other configuration values when creating, deleting, or moving between environments. They are either *sourced* (allowing them to modify your shell environment) or *run* as an external program at the appropriate trigger time. -$VIRTUAL_ENV/bin/postactivate -============================= +Environment Hooks +================= -The ``postactivate`` script is sourced after the new environment is enabled. ``$VIRTUAL_ENV`` -refers to the new environment at the time the script runs. +postactivate +------------ -This example script for the PyMOTW environment changes the current working directory and the -PATH variable to refer to the source tree containing the PyMOTW source. +The ``$VIRTUAL_ENV/bin/postactivate`` script is sourced after the new environment is enabled. ``$VIRTUAL_ENV`` refers to the new environment at the time the script runs. + +This example script for the PyMOTW environment changes the current working directory and the PATH variable to refer to the source tree containing the PyMOTW source. :: @@ -21,49 +20,41 @@ PATH variable to refer to the source tree containing the PyMOTW source. cd $pymotw_root PATH=$pymotw_root/bin:$PATH -$VIRTUAL_ENV/bin/predeactivate -============================== +predeactivate +------------- + +The ``$VIRTUAL_ENV/bin/predeactivate`` script is sourced before the current environment is deactivated, and can be used to disable or clear settings in your environment. ``$VIRTUAL_ENV`` refers to the old environment at the time the script runs. -The ``predeactivate`` script is source before the current environment is deactivated, and can -be used to disable or clear settings in your environment. ``$VIRTUAL_ENV`` refers to the old -environment at the time the script runs. +Global Hooks +============ -$WORKON_HOME/postactivate -============================= +postactivate +------------ -The global ``postactivate`` script is sourced after the new environment is enabled and the new -environment's postactivate is sourced (if it exists). ``$VIRTUAL_ENV`` refers to the new -environment at the time the script runs. +The global ``$WORKON_HOME/postactivate`` script is sourced after the new environment is enabled and the new environment's postactivate is sourced (if it exists). ``$VIRTUAL_ENV`` refers to the new environment at the time the script runs. -This example script adds a space between the virtual environment name and your old PS1 by making -use of ``_OLD_VIRTUAL_PS1``. +This example script adds a space between the virtual environment name and your old PS1 by making use of ``_OLD_VIRTUAL_PS1``. :: PS1="(`basename \"$VIRTUAL_ENV\"`) $_OLD_VIRTUAL_PS1" -$WORKON_HOME/premkvirtualenv -============================= +premkvirtualenv +--------------- -The ``premkvirtualenv`` script is run as an external program after the virtual environment is -created but before the current environment is switched to point to the new env. The current -working directory for the script is ``$WORKON_HOME`` and the name of the new environment is -passed as an argument to the script. +The ``$WORKON_HOME/premkvirtualenv`` script is run as an external program after the virtual environment is created but before the current environment is switched to point to the new env. The current working directory for the script is ``$WORKON_HOME`` and the name of the new environment is passed as an argument to the script. -$WORKON_HOME/postmkvirtualenv -============================= +postmkvirtualenv +---------------- -The ``postmkvirtualenv`` script is sourced after the new environment is created and -activated. +The ``$WORKON_HOME/postmkvirtualenv`` script is sourced after the new environment is created and activated. -$WORKON_HOME/prermvirtualenv -============================ +prermvirtualenv +--------------- -The ``prermvirtualenv`` script is run as an external program before the environment is -removed. The full path to the environment directory is passed as an argument to the script. +The ``$WORKON_HOME/prermvirtualenv`` script is run as an external program before the environment is removed. The full path to the environment directory is passed as an argument to the script. -$WORKON_HOME/postrmvirtualenv -============================= +postrmvirtualenv +---------------- -The ``postrmvirtualenv`` script is run as an external program after the environment is -removed. The full path to the environment directory is passed as an argument to the script. +The ``$WORKON_HOME/postrmvirtualenv`` script is run as an external program after the environment is removed. The full path to the environment directory is passed as an argument to the script. diff --git a/docsource/index.rst b/docsource/index.rst index 61f0b90..a66bb57 100644 --- a/docsource/index.rst +++ b/docsource/index.rst @@ -9,6 +9,15 @@ virtualenvwrapper virtualenvwrapper is a set of extensions to Ian Bicking's `virtualenv `_ tool. The extensions include wrappers for creating and deleting virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. +======== +Features +======== + + 1. Organizes all of your virtual environments in one place. + 2. Wrappers for creating and deleting environments, including user-configurable hooks. + 3. Use a single command to switch between environments. + 4. Tab completion for commands that take a virtual environment as argument. + =========== Quick Setup =========== diff --git a/virtualenvwrapper/__init__.py b/virtualenvwrapper/__init__.py index 4f492f9..1dbce95 100644 --- a/virtualenvwrapper/__init__.py +++ b/virtualenvwrapper/__init__.py @@ -1,6 +1,6 @@ """virtualenvwrapper module """ -import warnings +import os, warnings docs_root = os.path.join(os.path.dirname(__file__), 'docs', 'index.html') warnings.warn('Use virtualenvwrapper_bashrc to set up your shell environment. See %s for details.' % docs_root) From cb88e74ed6577853c109c129567eb75889c4a9ea Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 30 May 2009 16:16:59 -0400 Subject: [PATCH 069/947] formatting tweaks --- README | 27 +++------------------------ docsource/index.rst | 19 +++---------------- 2 files changed, 6 insertions(+), 40 deletions(-) diff --git a/README b/README index 6ce39b3..1fbb536 100644 --- a/README +++ b/README @@ -30,33 +30,12 @@ Quick Setup 7. Run: ``workon`` 8. This time, the ``temp`` environment is included. -========== -References -========== - -For more details, refer to the column published in the May 2008 issue of Python Magazine: -`virtualenvwrapper | And Now For Something Completely Different -`_. - ======= License ======= Copyright Doug Hellmann, All Rights Reserved -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that copyright notice and this permission -notice appear in supporting documentation, and that the name of Doug -Hellmann not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN -NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS -OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, -NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Doug Hellmann not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. + +DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/docsource/index.rst b/docsource/index.rst index a66bb57..2119ad4 100644 --- a/docsource/index.rst +++ b/docsource/index.rst @@ -62,19 +62,6 @@ License Copyright Doug Hellmann, All Rights Reserved -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that copyright notice and this permission -notice appear in supporting documentation, and that the name of Doug -Hellmann not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN -NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS -OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, -NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Doug Hellmann not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. + +DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. From dcd20d0a3086e2748a758817a13076fc83a40f2f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 31 May 2009 12:55:41 -0400 Subject: [PATCH 070/947] incorporate personal site templates into a build that lets me generate hosted docs --HG-- rename : docsource/conf.py => sphinx/pkg/conf.py --- .hgignore | 2 + docsource/Makefile | 88 -------------- docsource/make.bat | 112 ----------------- pavement.py | 70 +++++++++-- {docsource => sphinx/pkg}/conf.py | 4 +- sphinx/web/conf.py | 194 ++++++++++++++++++++++++++++++ sphinx/web/templates/layout.html | 118 ++++++++++++++++++ 7 files changed, 378 insertions(+), 210 deletions(-) delete mode 100644 docsource/Makefile delete mode 100644 docsource/make.bat rename {docsource => sphinx/pkg}/conf.py (99%) create mode 100644 sphinx/web/conf.py create mode 100755 sphinx/web/templates/layout.html diff --git a/.hgignore b/.hgignore index 3c66385..2394fd8 100644 --- a/.hgignore +++ b/.hgignore @@ -6,6 +6,8 @@ setup.py trace.txt docs *.pyc +sphinx/web/templates/base.html syntax: re .DS_Store +^web/ diff --git a/docsource/Makefile b/docsource/Makefile deleted file mode 100644 index e212b3f..0000000 --- a/docsource/Makefile +++ /dev/null @@ -1,88 +0,0 @@ -# Makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -PAPER = - -# Internal variables. -PAPEROPT_a4 = -D latex_paper_size=a4 -PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d _build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . - -.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest - -help: - @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " dirhtml to make HTML files named index.html in directories" - @echo " pickle to make pickle files" - @echo " json to make JSON files" - @echo " htmlhelp to make HTML files and a HTML help project" - @echo " qthelp to make HTML files and a qthelp project" - @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" - @echo " changes to make an overview of all changed/added/deprecated items" - @echo " linkcheck to check all external links for integrity" - @echo " doctest to run all doctests embedded in the documentation (if enabled)" - -clean: - -rm -rf _build/* - -html: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html - @echo - @echo "Build finished. The HTML pages are in _build/html." - -dirhtml: - $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) _build/dirhtml - @echo - @echo "Build finished. The HTML pages are in _build/dirhtml." - -pickle: - $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) _build/pickle - @echo - @echo "Build finished; now you can process the pickle files." - -json: - $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) _build/json - @echo - @echo "Build finished; now you can process the JSON files." - -htmlhelp: - $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) _build/htmlhelp - @echo - @echo "Build finished; now you can run HTML Help Workshop with the" \ - ".hhp project file in _build/htmlhelp." - -qthelp: - $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) _build/qthelp - @echo - @echo "Build finished; now you can run "qcollectiongenerator" with the" \ - ".qhcp project file in _build/qthelp, like this:" - @echo "# qcollectiongenerator _build/qthelp/virtualenvwrapper.qhcp" - @echo "To view the help file:" - @echo "# assistant -collectionFile _build/qthelp/virtualenvwrapper.qhc" - -latex: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex - @echo - @echo "Build finished; the LaTeX files are in _build/latex." - @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ - "run these through (pdf)latex." - -changes: - $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) _build/changes - @echo - @echo "The overview file is in _build/changes." - -linkcheck: - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) _build/linkcheck - @echo - @echo "Link check complete; look for any errors in the above output " \ - "or in _build/linkcheck/output.txt." - -doctest: - $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) _build/doctest - @echo "Testing of doctests in the sources finished, look at the " \ - "results in _build/doctest/output.txt." diff --git a/docsource/make.bat b/docsource/make.bat deleted file mode 100644 index 51d1ea6..0000000 --- a/docsource/make.bat +++ /dev/null @@ -1,112 +0,0 @@ -@ECHO OFF - -REM Command file for Sphinx documentation - -set SPHINXBUILD=sphinx-build -set ALLSPHINXOPTS=-d _build/doctrees %SPHINXOPTS% . -if NOT "%PAPER%" == "" ( - set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% -) - -if "%1" == "" goto help - -if "%1" == "help" ( - :help - echo.Please use `make ^` where ^ is one of - echo. html to make standalone HTML files - echo. dirhtml to make HTML files named index.html in directories - echo. pickle to make pickle files - echo. json to make JSON files - echo. htmlhelp to make HTML files and a HTML help project - echo. qthelp to make HTML files and a qthelp project - echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter - echo. changes to make an overview over all changed/added/deprecated items - echo. linkcheck to check all external links for integrity - echo. doctest to run all doctests embedded in the documentation if enabled - goto end -) - -if "%1" == "clean" ( - for /d %%i in (_build\*) do rmdir /q /s %%i - del /q /s _build\* - goto end -) - -if "%1" == "html" ( - %SPHINXBUILD% -b html %ALLSPHINXOPTS% _build/html - echo. - echo.Build finished. The HTML pages are in _build/html. - goto end -) - -if "%1" == "dirhtml" ( - %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% _build/dirhtml - echo. - echo.Build finished. The HTML pages are in _build/dirhtml. - goto end -) - -if "%1" == "pickle" ( - %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% _build/pickle - echo. - echo.Build finished; now you can process the pickle files. - goto end -) - -if "%1" == "json" ( - %SPHINXBUILD% -b json %ALLSPHINXOPTS% _build/json - echo. - echo.Build finished; now you can process the JSON files. - goto end -) - -if "%1" == "htmlhelp" ( - %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% _build/htmlhelp - echo. - echo.Build finished; now you can run HTML Help Workshop with the ^ -.hhp project file in _build/htmlhelp. - goto end -) - -if "%1" == "qthelp" ( - %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% _build/qthelp - echo. - echo.Build finished; now you can run "qcollectiongenerator" with the ^ -.qhcp project file in _build/qthelp, like this: - echo.^> qcollectiongenerator _build\qthelp\virtualenvwrapper.qhcp - echo.To view the help file: - echo.^> assistant -collectionFile _build\qthelp\virtualenvwrapper.ghc - goto end -) - -if "%1" == "latex" ( - %SPHINXBUILD% -b latex %ALLSPHINXOPTS% _build/latex - echo. - echo.Build finished; the LaTeX files are in _build/latex. - goto end -) - -if "%1" == "changes" ( - %SPHINXBUILD% -b changes %ALLSPHINXOPTS% _build/changes - echo. - echo.The overview file is in _build/changes. - goto end -) - -if "%1" == "linkcheck" ( - %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% _build/linkcheck - echo. - echo.Link check complete; look for any errors in the above output ^ -or in _build/linkcheck/output.txt. - goto end -) - -if "%1" == "doctest" ( - %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% _build/doctest - echo. - echo.Testing of doctests in the sources finished, look at the ^ -results in _build/doctest/output.txt. - goto end -) - -:end diff --git a/pavement.py b/pavement.py index 1dfe810..eb7e584 100644 --- a/pavement.py +++ b/pavement.py @@ -20,6 +20,7 @@ import paver.setuputils paver.setuputils.install_distutils_tasks() import paver.doctools +import docpaver # What project are we building? PROJECT = 'virtualenvwrapper' @@ -49,7 +50,7 @@ author = 'Doug Hellmann', author_email = 'doug.hellmann@gmail.com', - url = 'http://www.doughellmann.com/projects/virtualenvwrapper/', + url = 'http://www.doughellmann.com/projects/%s/' % PROJECT, download_url = 'http://www.doughellmann.com/downloads/%s-%s.tar.gz' % \ (PROJECT, VERSION), @@ -78,8 +79,29 @@ sphinx = Bunch( docroot='.', - builddir='docs', sourcedir='docsource', + builder='html', + template_args={'project':PROJECT} + ), + + html=Bunch( + templates='pkg', + builddir='docs', + confdir='sphinx/pkg', + ), + + website=Bunch( + templates = 'web', + builddir = 'web', + confdir='sphinx/web', + + # What server hosts the website? + server = 'www.doughellmann.com', + server_path = '/var/www/doughellmann/DocumentRoot/docs/%s/' % PROJECT, + + # What template should be used for the web site HTML? + template_source = '~/Devel/personal/doughellmann/templates/base.html', + template_dest = 'sphinx/web/templates/base.html', ), sdist = Bunch( @@ -94,6 +116,31 @@ ) +@task +def html(options): + # Build the docs + docpaver.html(options) + # Move them into place for packaging + destdir = path(PROJECT) / 'docs' + destdir.rmtree() + builtdocs = path(options.builddir) / "html" + builtdocs.move(destdir) + return + +@task +def website(options): + """Create local copy of website files. + """ + # Make sure the base template is updated + dest = path(options.website.template_dest).expanduser() + src = path(options.website.template_source).expanduser() + if not dest.exists() or (src.mtime > dest.mtime): + dest.dirname().mkdir() + src.copy(dest) + # Build the docs + docpaver.run_sphinx(options, 'website') + return + def remake_directories(*dirnames): """Remove the directories and recreate them. """ @@ -105,14 +152,21 @@ def remake_directories(*dirnames): return @task -@needs('paver.doctools.html') -def html(options): - destdir = path(PROJECT) / 'docs' - destdir.rmtree() - builtdocs = path(options.builddir) / "html" - builtdocs.move(destdir) +def installwebsite(options): + """Rebuild and copy website files to the remote server. + """ + # Clean up + remake_directories(options.website.builddir) + # Rebuild + website(options) + # Copy to the server + os.environ['RSYNC_RSH'] = '/usr/bin/ssh' + src_path = path(options.website.builddir) / 'html' + sh('cd %s; rsync --archive --delete --verbose . %s:%s' % + (src_path, options.website.server, options.website.server_path)) return + @task @needs(['html', 'generate_setup', 'minilib', diff --git a/docsource/conf.py b/sphinx/pkg/conf.py similarity index 99% rename from docsource/conf.py rename to sphinx/pkg/conf.py index 17a086d..7634fdc 100644 --- a/docsource/conf.py +++ b/sphinx/pkg/conf.py @@ -25,7 +25,7 @@ extensions = [] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ['templates'] # The suffix of source filenames. source_suffix = '.rst' @@ -120,7 +120,7 @@ # 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, # 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, # using the given strftime format. diff --git a/sphinx/web/conf.py b/sphinx/web/conf.py new file mode 100644 index 0000000..7634fdc --- /dev/null +++ b/sphinx/web/conf.py @@ -0,0 +1,194 @@ +# -*- coding: utf-8 -*- +# +# virtualenvwrapper documentation build configuration file, created by +# sphinx-quickstart on Thu May 28 22:35:13 2009. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.append(os.path.abspath('.')) + +# -- General configuration ----------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'virtualenvwrapper' +copyright = u'2009, Doug Hellmann' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = os.environ['VERSION'] +# The full version, including alpha/beta/rc tags. +release = version + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of documents that shouldn't be included in the build. +#unused_docs = [] + +# List of directories, relative to source directory, that shouldn't be searched +# for source files. +exclude_trees = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# 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, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +html_use_modindex = False + +# If false, no index is generated. +html_use_index = False + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = '' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'virtualenvwrapperdoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +# The paper size ('letter' or 'a4'). +#latex_paper_size = 'letter' + +# The font size ('10pt', '11pt' or '12pt'). +#latex_font_size = '10pt' + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'virtualenvwrapper.tex', u'virtualenvwrapper Documentation', + u'Doug Hellmann', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# Additional stuff for the LaTeX preamble. +#latex_preamble = '' + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_use_modindex = True diff --git a/sphinx/web/templates/layout.html b/sphinx/web/templates/layout.html new file mode 100755 index 0000000..7118594 --- /dev/null +++ b/sphinx/web/templates/layout.html @@ -0,0 +1,118 @@ +{% extends "base.html" %} + +{% block title %}{{ title }} - {{ project }}{% endblock %} + +{% block head_before_css %} + + +{% endblock %} + +{% block head %} + + + + + +{%- block rellinks %} + {%- if hasdoc('about') %} + + {%- endif %} + + + {%- if hasdoc('copyright') %} + + {%- endif %} + + {%- if parents %} + + {%- endif %} + {%- if next %} + + {%- endif %} + {%- if prev %} + + {%- endif %} +{%- endblock %} +{% endblock %} + +{% block sidebar %} +{%- block sidebartoc %} +{%- if display_toc %} +

Page Contents

+ {{ toc }} +{%- endif %} +{%- endblock %} + +

Navigation

+ Top
+{% if next or prev %} + {%- if prev %} + Previous: {{ prev.title }}
+ {%- endif %} + + {%- if next %} + Next: {{ next.title }}
+ {%- endif %} +{% endif %} + {{project}} Home
+ + {%- if show_source and has_source and sourcename %} +

{{ _('This Page') }}

+ {{ _('Show Source') }} + + {%- endif %} + +

+ Creative Commons License +

+{% endblock %} + +{% block sidebar_l %} +{% endblock %} + +{% block content %} +{% block body %}{% endblock %} +{% endblock %} + +{% block footer %} +

+ {%- if hasdoc('copyright') %} + © Copyright {{ copyright }}. + {%- else %} + © Copyright {{ copyright }}. + {%- endif %} + {%- if last_updated %} + | Last updated on {{ last_updated }}. + {%- endif %} + {%- if show_sphinx %} + | Created using Sphinx. + {%- endif %} + | Design based on "Leaves" by SmallPark +

+ + +{% endblock %} From ab66af9e0df6abb399f0c27f49ff6942694da4fa Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 31 May 2009 13:15:02 -0400 Subject: [PATCH 071/947] add installation test task --- pavement.py | 14 ++++++++++++-- tests/test_install.sh | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100755 tests/test_install.sh diff --git a/pavement.py b/pavement.py index eb7e584..f712968 100644 --- a/pavement.py +++ b/pavement.py @@ -20,7 +20,11 @@ import paver.setuputils paver.setuputils.install_distutils_tasks() import paver.doctools -import docpaver +try: + import docpaver +except: + import warnings + warnings.warn('docpaver was not found, will not be able to produce documentation') # What project are we building? PROJECT = 'virtualenvwrapper' @@ -176,7 +180,13 @@ def sdist(options): """Create a source distribution. """ pass - + +@task +@needs(['sdist']) +def test_install(options): + sh('./tests/test_install.sh "%s" "%s"' % (options.sdist.dist_dir, VERSION)) + return + @task def test(): sh('bash ./tests/test.sh') diff --git a/tests/test_install.sh b/tests/test_install.sh new file mode 100755 index 0000000..88fc9e4 --- /dev/null +++ b/tests/test_install.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Test installation of virtualenvwrapper in a new virtualenv. +# + +test_dir=$(dirname $0) +dist_dir="$1" +version="$2" + +export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" +mkvirtualenv "installtest" +easy_install "$dist_dir/virtualenvwrapper-$version.tar.gz" +RC=$? + +rm -rf "$WORKON_HOME" +exit $RC From eec8f00c86cd04ebe2bcbe867de96bacc9802752 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 31 May 2009 13:15:49 -0400 Subject: [PATCH 072/947] Added tag 1.17 for changeset 749030a692a0 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 135be24..d062893 100644 --- a/.hgtags +++ b/.hgtags @@ -24,3 +24,4 @@ caf3f2a31fdd39539e413390720dff419121f568 1.14 6e54ea32a9d1c0a73550b6baec0190e894536512 1.14 bddfac3c8fde9c860c6e942435cff297f989060d 1.15 7d9dbc84f25da33c7c458c13874f99535bb6bfa7 1.16 +749030a692a0b8bfe580b9ec86a1911580a8b3fa 1.17 From eb2d5f536fd3579ab8c154564d7c15dc88b6e449 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 5 Jun 2009 09:04:46 -0400 Subject: [PATCH 073/947] update pavement to use sphinxcontrib.paverutils --- pavement.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pavement.py b/pavement.py index f712968..21697d1 100644 --- a/pavement.py +++ b/pavement.py @@ -19,16 +19,16 @@ from paver.easy import * import paver.setuputils paver.setuputils.install_distutils_tasks() -import paver.doctools +#import paver.doctools try: - import docpaver + from sphinxcontrib import paverutils except: import warnings - warnings.warn('docpaver was not found, will not be able to produce documentation') + warnings.warn('sphinxcontrib.paverutils was not found, you will not be able to produce documentation') # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.17' +VERSION = '1.17.1' os.environ['VERSION'] = VERSION # Read the long description to give to setup @@ -123,7 +123,7 @@ @task def html(options): # Build the docs - docpaver.html(options) + paverutils.html(options) # Move them into place for packaging destdir = path(PROJECT) / 'docs' destdir.rmtree() @@ -142,7 +142,7 @@ def website(options): dest.dirname().mkdir() src.copy(dest) # Build the docs - docpaver.run_sphinx(options, 'website') + paverutils.run_sphinx(options, 'website') return def remake_directories(*dirnames): From 5551a4a16d5faecf6d5b58a2fda592e68fb4d67c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 5 Jun 2009 09:04:51 -0400 Subject: [PATCH 074/947] Added tag 1.17.1 for changeset 10fbaab7da41 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index d062893..d2a4f7e 100644 --- a/.hgtags +++ b/.hgtags @@ -25,3 +25,4 @@ caf3f2a31fdd39539e413390720dff419121f568 1.14 bddfac3c8fde9c860c6e942435cff297f989060d 1.15 7d9dbc84f25da33c7c458c13874f99535bb6bfa7 1.16 749030a692a0b8bfe580b9ec86a1911580a8b3fa 1.17 +10fbaab7da41d5a0ef70e46fd53cc450e3d91a3d 1.17.1 From 0cf5fc598c4c4bc6aeb0a3ca32fcd192169e3f33 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 22 Jun 2009 15:05:11 -0400 Subject: [PATCH 075/947] fix issue #10 by removing warning and using an error at runtime --- docsource/history.rst | 4 ++++ pavement.py | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docsource/history.rst b/docsource/history.rst index 850cbe0..7e5b1c2 100644 --- a/docsource/history.rst +++ b/docsource/history.rst @@ -2,6 +2,10 @@ Release History =============== +1.18 + + - Remove warning during installation if sphinxcontrib.paverutils is not installed. (#10) + 1.17 - Added documentation updates provided by Steve Steiner. diff --git a/pavement.py b/pavement.py index 21697d1..48ca7e3 100644 --- a/pavement.py +++ b/pavement.py @@ -23,8 +23,7 @@ try: from sphinxcontrib import paverutils except: - import warnings - warnings.warn('sphinxcontrib.paverutils was not found, you will not be able to produce documentation') + paverutils = None # What project are we building? PROJECT = 'virtualenvwrapper' @@ -122,6 +121,8 @@ @task def html(options): + if paverutils is None: + raise RuntimeError('Building HTML documentation requires the sphinxcontrib.paverutils package') # Build the docs paverutils.html(options) # Move them into place for packaging @@ -135,6 +136,8 @@ def html(options): def website(options): """Create local copy of website files. """ + if paverutils is None: + raise RuntimeError('Building the website requires the sphinxcontrib.paverutils package') # Make sure the base template is updated dest = path(options.website.template_dest).expanduser() src = path(options.website.template_source).expanduser() From 0cadf76f9019158f7df7480a3fabdef9b5609d95 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 22 Jun 2009 15:12:13 -0400 Subject: [PATCH 076/947] add docs for deactivate to resolve issue #12 --- docsource/command_ref.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docsource/command_ref.rst b/docsource/command_ref.rst index d09d0e1..db7ca8d 100644 --- a/docsource/command_ref.rst +++ b/docsource/command_ref.rst @@ -42,6 +42,19 @@ Syntax:: If no ``environment_name`` is given the list of available environments is printed to stdout. +deactivate +---------- + +Switch from a virtual environment to the system-installed version of Python. + +Syntax:: + + deactivate + +.. note:: + + This command is actually part of virtualenv, but is wrapped to provide before and after hooks, just as workon does for activate. + ================================== Quickly Navigating to a virtualenv ================================== From 0dd489d124f74d231bbd4a691516ef3f3abb45b5 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 22 Jun 2009 15:21:46 -0400 Subject: [PATCH 077/947] add basic developer info to the documentation --- docsource/developers.rst | 129 +++++++++++++++++++++++++++++++++++++++ docsource/history.rst | 2 + docsource/index.rst | 1 + 3 files changed, 132 insertions(+) create mode 100644 docsource/developers.rst diff --git a/docsource/developers.rst b/docsource/developers.rst new file mode 100644 index 0000000..87a8021 --- /dev/null +++ b/docsource/developers.rst @@ -0,0 +1,129 @@ +############## +For Developers +############## + +If you would like to contribute, these instructions should help you get started. Patches, bug reports, and feature requests are all welcome through the `BitBucket site `_. Contributions in the form of patches or pull requests are easier to integrate and will receive priority attention. + +Building Documentation +====================== + +The documentation for virtualenvwrapper is written in reStructuredText and converted to HTML using Sphinx. The build itself is driven by Paver. You will need the following packages in order to build the docs: + +- Sphinx +- Paver +- sphinxcontrib.paverutils + +Once all of them are installed into a virtualenv using easy_install, run ``paver html`` to generate the HTML version of the documentation:: + + $ paver html + ---> pavement.html + ---> sphinxcontrib.paverutils.html + mkdir ./docs/html (mode 511) + sphinx-build -b html -d ./docs/doctrees -c sphinx/pkg -Aproject=virtualenvwrapper ./docsource ./docs/html + Running Sphinx v0.6.1 + loading pickled environment... done + building [html]: targets for 4 source files that are out of date + updating environment: 1 added, 1 changed, 0 removed + reading sources... [ 50%] developers + reading sources... [100%] index + + /Users/dhellmann/Devel/virtualenvwrapper/src/docsource/developers.rst:19: (WARNING/2) Literal block expected; none found. + looking for now-outdated files... none found + pickling environment... done + checking consistency... done + preparing documents... done + writing output... [ 20%] command_ref + writing output... [ 40%] developers + writing output... [ 60%] history + writing output... [ 80%] hooks + writing output... [100%] index + + writing additional files... search + copying static files... WARNING: static directory '/Users/dhellmann/Devel/virtualenvwrapper/src/sphinx/pkg/static' does not exist + done + dumping search index... done + dumping object inventory... done + build succeeded, 2 warnings. + rmtree virtualenvwrapper/docs () {} + move docs/html virtualenvwrapper/docs + + +Running Tests +============= + +The test suite for virtualenvwrapper uses `shunit2 `_. To run the tests under both bash and zsh, use ``paver test``. To add new tests, modify the ``tests/test.sh`` script with new test functions. + +:: + + $ paver test + ---> pavement.test + bash ./tests/test.sh + + test_mkvirtualenv + New python executable in env1/bin/python + Installing setuptools............done. + + test_cdvirtual + + test_cdsitepackages + + test_mkvirtualenv_activates + New python executable in env2/bin/python + Installing setuptools............done. + + test_workon + + test_postactivate_hook + + test_deactivate + + test_deactivate_hooks + + test_virtualenvwrapper_show_workon_options + + test_rmvirtualenv + New python executable in deleteme/bin/python + Installing setuptools............done. + + test_rmvirtualenv_no_such_env + + test_missing_workon_home + + Ran 12 tests. + + OK + SHUNIT_PARENT=./tests/test.sh zsh -o shwordsplit ./tests/test.sh + + test_mkvirtualenv + New python executable in env1/bin/python + Installing setuptools............done. + + test_cdvirtual + + test_cdsitepackages + + test_mkvirtualenv_activates + New python executable in env2/bin/python + Installing setuptools............done. + + test_workon + + test_postactivate_hook + + test_deactivate + + test_deactivate_hooks + + test_virtualenvwrapper_show_workon_options + + test_rmvirtualenv + New python executable in deleteme/bin/python + Installing setuptools............done. + + test_rmvirtualenv_no_such_env + + test_missing_workon_home + + Ran 12 tests. + + OK \ No newline at end of file diff --git a/docsource/history.rst b/docsource/history.rst index 7e5b1c2..a3ca446 100644 --- a/docsource/history.rst +++ b/docsource/history.rst @@ -5,6 +5,8 @@ Release History 1.18 - Remove warning during installation if sphinxcontrib.paverutils is not installed. (#10) + - Added some basic developer information to the documentation. + - Added documentation for deactivate command. 1.17 diff --git a/docsource/index.rst b/docsource/index.rst index 2119ad4..ae5b5c9 100644 --- a/docsource/index.rst +++ b/docsource/index.rst @@ -45,6 +45,7 @@ Details command_ref hooks history + developers ========== References From 02de9225879145c3af7551fecc6868aad5154e50 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 22 Jun 2009 15:23:01 -0400 Subject: [PATCH 078/947] don't forget the destdir info --- docsource/developers.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docsource/developers.rst b/docsource/developers.rst index 87a8021..15ca7e2 100644 --- a/docsource/developers.rst +++ b/docsource/developers.rst @@ -47,6 +47,7 @@ Once all of them are installed into a virtualenv using easy_install, run ``paver rmtree virtualenvwrapper/docs () {} move docs/html virtualenvwrapper/docs +The output version of the documentation ends up in ``./virtualenvwrapper/docs`` inside your sandbox. Running Tests ============= From fb68447f9400405626f4bbe24b05f3c23ceabf48 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 22 Jun 2009 15:23:46 -0400 Subject: [PATCH 079/947] bump version number --- pavement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pavement.py b/pavement.py index 48ca7e3..a5f0c28 100644 --- a/pavement.py +++ b/pavement.py @@ -27,7 +27,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.17.1' +VERSION = '1.18' os.environ['VERSION'] = VERSION # Read the long description to give to setup From 7364b418394a5093c5781ccb7273c5c14c64e1de Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 22 Jun 2009 15:23:50 -0400 Subject: [PATCH 080/947] Added tag 1.18 for changeset 24190e878fa8 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index d2a4f7e..fc8f3cf 100644 --- a/.hgtags +++ b/.hgtags @@ -26,3 +26,4 @@ bddfac3c8fde9c860c6e942435cff297f989060d 1.15 7d9dbc84f25da33c7c458c13874f99535bb6bfa7 1.16 749030a692a0b8bfe580b9ec86a1911580a8b3fa 1.17 10fbaab7da41d5a0ef70e46fd53cc450e3d91a3d 1.17.1 +24190e878fa8e6caf37f67b5c42b1b52304baa62 1.18 From 476d1520192fad4c2eca771394290e1ebdb80719 Mon Sep 17 00:00:00 2001 From: "matt@sprout.staffknex.com" Date: Thu, 9 Jul 2009 09:46:02 -0400 Subject: [PATCH 081/947] Applying my own ridiculous formatting to the README file. Give me 72 characters or give me death! --- README | 58 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/README b/README index 1fbb536..86bd4f0 100644 --- a/README +++ b/README @@ -2,33 +2,45 @@ virtualenvwrapper ################# -virtualenvwrapper is a set of extensions to Ian Bicking's `virtualenv `_ tool. The extensions include wrappers for creating and deleting virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. +virtualenvwrapper is a set of extensions to Ian Bicking's `virtualenv +`_ tool. The extensions include +wrappers for creating and deleting virtual environments and otherwise +managing your development workflow, making it easier to work on more +than one project at a time without introducing conflicts in their +dependencies. ======== Features ======== - 1. Organizes all of your virtual environments in one place. - 2. Wrappers for creating and deleting environments, including user-configurable hooks. - 3. Use a single command to switch between environments. - 4. Tab completion for commands that take a virtual environment as argument. +1. Organizes all of your virtual environments in one place. + +2. Wrappers for creating and deleting environments, including + user-configurable hooks. + +3. Use a single command to switch between environments. + +4. Tab completion for commands that take a virtual environment as + argument. =========== Quick Setup =========== -1. Add two lines to your .bashrc to set the location where the virtual environments should live and the location of the script installed with this package:: +1. Add two lines to your .bashrc to set the location where the virtual + environments should live and the location of the script installed + with this package:: - export WORKON_HOME=$HOME/.virtualenvs - source /usr/local/bin/virtualenvwrapper_bashrc + export WORKON_HOME=$HOME/.virtualenvs + source /usr/local/bin/virtualenvwrapper_bashrc -2. Run: ``source ~/.bashrc`` -3. Run: ``workon`` -4. A list of environments, empty, is printed. -5. Run: ``mkvirtualenv temp`` -6. A new environment, ``temp`` is created and activated. -7. Run: ``workon`` -8. This time, the ``temp`` environment is included. +2. Run: ``source ~/.bashrc`` +3. Run: ``workon`` +4. A list of environments, empty, is printed. +5. Run: ``mkvirtualenv temp`` +6. A new environment, ``temp`` is created and activated. +7. Run: ``workon`` +8. This time, the ``temp`` environment is included. ======= License @@ -36,6 +48,18 @@ License Copyright Doug Hellmann, All Rights Reserved -Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Doug Hellmann not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Doug Hellmann not be used +in advertising or publicity pertaining to distribution of the software +without specific, written prior permission. -DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. From 945bd4b4df1bd054d490e2eab90e9d8fa5779847 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 18 Jul 2009 16:36:37 -0400 Subject: [PATCH 082/947] incorporate patch from Sascha Brossmann to fix #15 --- docsource/history.rst | 4 ++++ pavement.py | 2 +- virtualenvwrapper_bashrc | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docsource/history.rst b/docsource/history.rst index a3ca446..5a7d8de 100644 --- a/docsource/history.rst +++ b/docsource/history.rst @@ -2,6 +2,10 @@ Release History =============== +1.18.1 + + - Incorporate patch from Sascha Brossmann to fix a issue #15. Directory normalization was causing ``WORKON_HOME`` to appear to be a missing directory if there were control characters in the output of ``pwd``. + 1.18 - Remove warning during installation if sphinxcontrib.paverutils is not installed. (#10) diff --git a/pavement.py b/pavement.py index a5f0c28..2ef46d3 100644 --- a/pavement.py +++ b/pavement.py @@ -27,7 +27,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.18' +VERSION = '1.18.1' os.environ['VERSION'] = VERSION # Read the long description to give to setup diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 8c51068..fcf7741 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -29,7 +29,7 @@ fi # Normalize the directory name in case it includes # relative path components. -WORKON_HOME=$(cd "$WORKON_HOME"; pwd) +WORKON_HOME=$(sh -c 'cd "$WORKON_HOME"; pwd') export WORKON_HOME # Verify that the WORKON_HOME directory exists From 552b77fe6bb2a12528c779d14f450229d30e18d1 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 28 Jul 2009 09:08:41 -0400 Subject: [PATCH 083/947] fix for ticket #14: relative paths don't work with add2virtualenv --- docsource/history.rst | 4 ++++ pavement.py | 2 +- tests/test.sh | 20 ++++++++++++++++++++ virtualenvwrapper_bashrc | 7 ++++++- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/docsource/history.rst b/docsource/history.rst index 5a7d8de..5380279 100644 --- a/docsource/history.rst +++ b/docsource/history.rst @@ -2,6 +2,10 @@ Release History =============== +1.19 + + - Fix problem with add2virtualenv and relative paths. Thanks to Doug Latornell for the bug report James Bennett for the suggested fix. + 1.18.1 - Incorporate patch from Sascha Brossmann to fix a issue #15. Directory normalization was causing ``WORKON_HOME`` to appear to be a missing directory if there were control characters in the output of ``pwd``. diff --git a/pavement.py b/pavement.py index 2ef46d3..4313114 100644 --- a/pavement.py +++ b/pavement.py @@ -27,7 +27,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.18.1' +VERSION = '1.19' os.environ['VERSION'] = VERSION # Read the long description to give to setup diff --git a/tests/test.sh b/tests/test.sh index d364368..41d1b9f 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -151,4 +151,24 @@ test_missing_workon_home () { WORKON_HOME="$save_home" } +test_add2virtualenv () { + mkvirtualenv "pathtest" + add2virtualenv "/full/path" + cdsitepackages + path_file="./virtualenv_path_extensions.pth" + assertTrue "No /full/path in `cat $path_file`" "grep /full/path $path_file" + cd - +} + +test_add2virtualenv_relative () { + mkvirtualenv "pathtest" + parent_dir=$(dirname $(pwd)) + base_dir=$(basename $(pwd)) + add2virtualenv "../$base_dir" + cdsitepackages + path_file="./virtualenv_path_extensions.pth" + assertTrue "No $parent_dir/$base_dir in \"`cat $path_file`\"" "grep \"$parent_dir/$base_dir\" $path_file" + cd - >/dev/null 2>&1 +} + . "$test_dir/shunit2" diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index fcf7741..dd2df99 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -261,7 +261,12 @@ function add2virtualenv () { touch "$path_file" for pydir in "$@" do - echo "$pydir" >> "$path_file" + absolute_path=$(python -c "import os; print os.path.abspath(\"$pydir\")") + if [ "$absolute_path" != "$pydir" ] + then + echo "Warning: Converting \"$pydir\" to \"$absolute_path\"" 1>&2 + fi + echo "$absolute_path" >> "$path_file" done return 0 } From 747d22c746df6c221c969582716baca4bf90bace Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 28 Jul 2009 09:08:43 -0400 Subject: [PATCH 084/947] Added tag 1.19 for changeset 8af191bfa3c8 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index fc8f3cf..7aa2262 100644 --- a/.hgtags +++ b/.hgtags @@ -27,3 +27,4 @@ bddfac3c8fde9c860c6e942435cff297f989060d 1.15 749030a692a0b8bfe580b9ec86a1911580a8b3fa 1.17 10fbaab7da41d5a0ef70e46fd53cc450e3d91a3d 1.17.1 24190e878fa8e6caf37f67b5c42b1b52304baa62 1.18 +8af191bfa3c823bd5528ce99d0fb8fe72cc1a5d6 1.19 From eb1b36930b4258f179e0cf65e5b50f5e81acf3df Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 28 Jul 2009 09:11:23 -0400 Subject: [PATCH 085/947] moved main website source files --- pavement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pavement.py b/pavement.py index 4313114..1334241 100644 --- a/pavement.py +++ b/pavement.py @@ -103,7 +103,7 @@ server_path = '/var/www/doughellmann/DocumentRoot/docs/%s/' % PROJECT, # What template should be used for the web site HTML? - template_source = '~/Devel/personal/doughellmann/templates/base.html', + template_source = '~/Devel/doughellmann/doughellmann/templates/base.html', template_dest = 'sphinx/web/templates/base.html', ), From 98c5d6d5db7b59bbb341f2a07349a4a2f6a3806f Mon Sep 17 00:00:00 2001 From: Sander Smits Date: Tue, 11 Aug 2009 19:27:07 +0200 Subject: [PATCH 086/947] added lssitepackages command --- virtualenvwrapper_bashrc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index dd2df99..486a0f9 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -295,3 +295,18 @@ function cdvirtualenv () { virtualenvwrapper_verify_active_environment || return 1 cd $VIRTUAL_ENV/$1 } + +# +# lssitepackages +# +# Shows the content of the site-packages directory of the currently-active +# virtualenv +# + +function lssitepackages () { + virtualenvwrapper_verify_active_environment || return 1 + pyvers="`python -c 'import sys; print sys.version[:3]'`" + site_packages="lib/python${pyvers}/site-packages" + echo "$VIRTUAL_ENV/$site_packages" + ls -l $VIRTUAL_ENV/$site_packages +} From dbc08323f3643687c76a199a1b585a568beba4d8 Mon Sep 17 00:00:00 2001 From: Sander Smits Date: Tue, 11 Aug 2009 19:35:45 +0200 Subject: [PATCH 087/947] added lssitepackages info --- docsource/command_ref.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docsource/command_ref.rst b/docsource/command_ref.rst index db7ca8d..50bf746 100644 --- a/docsource/command_ref.rst +++ b/docsource/command_ref.rst @@ -113,3 +113,9 @@ Based on a contribution from James Bennett and Jannis Leidel. This will be done by placing the directory names in a path file named ``virtualenv_path_extensions.pth`` inside the virtualenv's site-packages directory; if this file does not exist, it will be created first. + + +lssitepackages +-------------- + +Calling ``lssitepackages`` shows the content of the ``site-packages`` directory of the currently-active virtualenv. \ No newline at end of file From 6a76afa73a1c199ac60edcb36e6e3e1faba06f0b Mon Sep 17 00:00:00 2001 From: Sander Smits Date: Tue, 11 Aug 2009 19:38:36 +0200 Subject: [PATCH 088/947] added a white-line at the end --- docsource/command_ref.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docsource/command_ref.rst b/docsource/command_ref.rst index 50bf746..9e52ad7 100644 --- a/docsource/command_ref.rst +++ b/docsource/command_ref.rst @@ -118,4 +118,4 @@ directory; if this file does not exist, it will be created first. lssitepackages -------------- -Calling ``lssitepackages`` shows the content of the ``site-packages`` directory of the currently-active virtualenv. \ No newline at end of file +Calling ``lssitepackages`` shows the content of the ``site-packages`` directory of the currently-active virtualenv. From d5f35e9c49ed848fd6b9d82d3a0573b072b7e70f Mon Sep 17 00:00:00 2001 From: Sander Smits Date: Tue, 11 Aug 2009 19:53:09 +0200 Subject: [PATCH 089/947] lssitepackages now also shows contents of virtualenv_path_extensions.pth, if that file exists --- virtualenvwrapper_bashrc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 486a0f9..bac5ebe 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -306,7 +306,15 @@ function cdvirtualenv () { function lssitepackages () { virtualenvwrapper_verify_active_environment || return 1 pyvers="`python -c 'import sys; print sys.version[:3]'`" - site_packages="lib/python${pyvers}/site-packages" - echo "$VIRTUAL_ENV/$site_packages" - ls -l $VIRTUAL_ENV/$site_packages + site_packages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" + echo "$site_packages" + ls -l $site_packages + + path_file="$site_packages/virtualenv_path_extensions.pth" + if [ -f "$path_file" ] + then + echo + echo "virtualenv_path_extensions.pth:" + cat "$path_file" + fi } From 5fc101f12a184737d0d9e7391d84c7eb99139734 Mon Sep 17 00:00:00 2001 From: Sander Smits Date: Tue, 11 Aug 2009 20:44:36 +0200 Subject: [PATCH 090/947] added simple lssitepackages test --- tests/test.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test.sh b/tests/test.sh index 41d1b9f..b7f59a7 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -148,6 +148,7 @@ test_missing_workon_home () { assertFalse "workon" assertFalse "mkvirtualenv foo" assertFalse "rmvirtualenv foo" + assertFalse "lssitepackages" WORKON_HOME="$save_home" } @@ -171,4 +172,9 @@ test_add2virtualenv_relative () { cd - >/dev/null 2>&1 } +test_lssitepackages () { + mkvirtualenv "lssitepackagestest" + assertTrue "lssitepackages" +} + . "$test_dir/shunit2" From 29359ae5c66cfc15a952844cb7d9cbe36948360d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 13 Aug 2009 08:31:06 -0400 Subject: [PATCH 091/947] minor code cleanup --- docsource/history.rst | 6 ++++++ tests/test.sh | 19 +++++++++++++++++- virtualenvwrapper_bashrc | 42 ++++++++++++++++------------------------ 3 files changed, 41 insertions(+), 26 deletions(-) diff --git a/docsource/history.rst b/docsource/history.rst index 5380279..e8001ad 100644 --- a/docsource/history.rst +++ b/docsource/history.rst @@ -2,6 +2,12 @@ Release History =============== +1.20 + + - Incorporate lssitepackages feature from Sander Smits. + - Refactor some of the functions that were using copy-and-paste code to build path names. + - Add a few tests. + 1.19 - Fix problem with add2virtualenv and relative paths. Thanks to Doug Latornell for the bug report James Bennett for the suggested fix. diff --git a/tests/test.sh b/tests/test.sh index b7f59a7..f9ba1f9 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -26,6 +26,12 @@ test_mkvirtualenv() { assertTrue "Environment directory was not created" "[ -d $WORKON_HOME/env1 ]" } +test_get_python_version() { + expected=$(python -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d.) + actual=$(virtualenvwrapper_get_python_version) + assertSame "$expected" "$actual" +} + test_cdvirtual() { pushd "$(pwd)" >/dev/null cdvirtualenv @@ -174,7 +180,18 @@ test_add2virtualenv_relative () { test_lssitepackages () { mkvirtualenv "lssitepackagestest" - assertTrue "lssitepackages" + contents="$(lssitepackages)" + assertTrue "No easy-install.pth in $contents" "echo $contents | grep easy-install.pth" } +test_lssitepackages_add2virtualenv () { + mkvirtualenv "lssitepackagestest" + parent_dir=$(dirname $(pwd)) + base_dir=$(basename $(pwd)) + add2virtualenv "../$base_dir" + contents="$(lssitepackages)" + assertTrue "No $base_dir in $contents" "echo $contents | grep $base_dir" +} + + . "$test_dir/shunit2" diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index bac5ebe..eeb7aa5 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -63,6 +63,7 @@ function virtualenvwrapper_verify_active_environment () { return 0 } +# Run a hook script in the current shell function virtualenvwrapper_source_hook () { scriptname="$1" if [ -f "$scriptname" ] @@ -71,6 +72,7 @@ function virtualenvwrapper_source_hook () { fi } +# Run a hook script in its own shell function virtualenvwrapper_run_hook () { scriptname="$1" shift @@ -219,6 +221,16 @@ elif [ -n "$ZSH_VERSION" ] ; then compctl -g "`virtualenvwrapper_show_workon_options`" workon rmvirtualenv fi +# Prints the Python version string for the current interpreter. +function virtualenvwrapper_get_python_version () { + python -c 'import sys; print ".".join(str(p) for p in sys.version_info[:2])' +} + +# Prints the path to the site-packages directory for the current environment. +function virtualenvwrapper_get_site_packages_dir () { + echo "$VIRTUAL_ENV/lib/python`virtualenvwrapper_get_python_version`/site-packages" +} + # Path management for packages outside of the virtual env. # Based on a contribution from James Bennett and Jannis Leidel. # @@ -230,13 +242,11 @@ fi # "virtualenv_path_extensions.pth" inside the virtualenv's # site-packages directory; if this file does not exist, it will be # created first. -# function add2virtualenv () { virtualenvwrapper_verify_active_environment || return 1 - pyvers="`python -c 'import sys; print sys.version[:3]'`" - site_packages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" + site_packages="`virtualenvwrapper_get_site_packages_dir`" if [ ! -d "${site_packages}" ] then @@ -271,44 +281,26 @@ function add2virtualenv () { return 0 } -# -# cdsitepackages -# # Does a ``cd`` to the site-packages directory of the currently-active # virtualenv. -# - function cdsitepackages () { virtualenvwrapper_verify_active_environment || return 1 - pyvers="`python -c 'import sys; print sys.version[:3]'`" - site_packages="lib/python${pyvers}/site-packages" - cdvirtualenv $site_packages + site_packages="`virtualenvwrapper_get_site_packages_dir`" + cd "$site_packages" } -# -# cdvirtualenv -# # Does a ``cd`` to the root of the currently-active virtualenv. -# - function cdvirtualenv () { virtualenvwrapper_verify_active_environment || return 1 cd $VIRTUAL_ENV/$1 } -# -# lssitepackages -# # Shows the content of the site-packages directory of the currently-active # virtualenv -# - function lssitepackages () { virtualenvwrapper_verify_active_environment || return 1 - pyvers="`python -c 'import sys; print sys.version[:3]'`" - site_packages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" - echo "$site_packages" - ls -l $site_packages + site_packages="`virtualenvwrapper_get_site_packages_dir`" + ls $@ $site_packages path_file="$site_packages/virtualenv_path_extensions.pth" if [ -f "$path_file" ] From d07dcf8130f15d28a85968ec39257ed5b6ce4d2e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 13 Aug 2009 08:31:43 -0400 Subject: [PATCH 092/947] prepare release --- pavement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pavement.py b/pavement.py index 1334241..ab64228 100644 --- a/pavement.py +++ b/pavement.py @@ -27,7 +27,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.19' +VERSION = '1.20' os.environ['VERSION'] = VERSION # Read the long description to give to setup From 72b282def2d14ead2730ec6c9e64980cde2c74d6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 13 Aug 2009 08:31:46 -0400 Subject: [PATCH 093/947] Added tag 1.20 for changeset ed873ac408ff --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 7aa2262..92a7d06 100644 --- a/.hgtags +++ b/.hgtags @@ -28,3 +28,4 @@ bddfac3c8fde9c860c6e942435cff297f989060d 1.15 10fbaab7da41d5a0ef70e46fd53cc450e3d91a3d 1.17.1 24190e878fa8e6caf37f67b5c42b1b52304baa62 1.18 8af191bfa3c823bd5528ce99d0fb8fe72cc1a5d6 1.19 +ed873ac408ff14b8e40137bd4caedbd798c96cb8 1.20 From 35e54073593d4f120cbf03bb5d244d3f31d8d513 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Nov 2009 14:20:33 -0500 Subject: [PATCH 094/947] improve handling for missing WORKON_HOME variable or directory; add test for #18 - can't reproduce --- docsource/history.rst | 4 ++++ docsource/index.rst | 20 ++++++++++++-------- pavement.py | 2 ++ tests/test.sh | 8 ++++++++ tests/test_misconfigured.sh | 32 ++++++++++++++++++++++++++++++++ virtualenvwrapper_bashrc | 26 +++++++++++++++----------- 6 files changed, 73 insertions(+), 19 deletions(-) create mode 100644 tests/test_misconfigured.sh diff --git a/docsource/history.rst b/docsource/history.rst index e8001ad..fa4dfb1 100644 --- a/docsource/history.rst +++ b/docsource/history.rst @@ -2,6 +2,10 @@ Release History =============== +1.21 + + - Better protection of ``$WORKON_HOME`` does not exist when the wrapper script is sourced. + 1.20 - Incorporate lssitepackages feature from Sander Smits. diff --git a/docsource/index.rst b/docsource/index.rst index ae5b5c9..7928a41 100644 --- a/docsource/index.rst +++ b/docsource/index.rst @@ -22,18 +22,22 @@ Features Quick Setup =========== -1. Add two lines to your .bashrc to set the location where the virtual environments should live and the location of the script installed with this package:: +1. Create a directory to hold all of the virtual environments. The default is + ``$HOME/.virtualenvs``. + +2. Add two lines to your .bashrc to set the location where the virtual environments should + live and the location of the script installed with this package:: export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper_bashrc -2. Run: ``source ~/.bashrc`` -3. Run: ``workon`` -4. A list of environments, empty, is printed. -5. Run: ``mkvirtualenv temp`` -6. A new environment, ``temp`` is created and activated. -7. Run: ``workon`` -8. This time, the ``temp`` environment is included. +3. Run: ``source ~/.bashrc`` +4. Run: ``workon`` +5. A list of environments, empty, is printed. +6. Run: ``mkvirtualenv temp`` +7. A new environment, ``temp`` is created and activated. +8. Run: ``workon`` +9. This time, the ``temp`` environment is included. ======= Details diff --git a/pavement.py b/pavement.py index ab64228..6dd54a9 100644 --- a/pavement.py +++ b/pavement.py @@ -194,4 +194,6 @@ def test_install(options): def test(): sh('bash ./tests/test.sh') sh('SHUNIT_PARENT=./tests/test.sh zsh -o shwordsplit ./tests/test.sh') + sh('bash ./tests/test_misconfigured.sh') + sh('SHUNIT_PARENT=./tests/test_misconfigured.sh zsh -o shwordsplit ./tests/test.sh') return diff --git a/tests/test.sh b/tests/test.sh index f9ba1f9..7d753a9 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -135,6 +135,14 @@ test_virtualenvwrapper_show_workon_options () { rm -f "$WORKON_HOME/link_env" } +test_virtualenvwrapper_show_workon_options_no_envs () { + old_home="$WORKON_HOME" + export WORKON_HOME=${TMPDIR:/tmp}/$$ + envs=$(virtualenvwrapper_show_workon_options | tr '\n' ' ') + assertSame "" "$envs" + export WORKON_HOME="$old_home" +} + test_rmvirtualenv () { mkvirtualenv "deleteme" assertTrue "[ -d $WORKON_HOME/deleteme ]" diff --git a/tests/test_misconfigured.sh b/tests/test_misconfigured.sh new file mode 100644 index 0000000..d778b54 --- /dev/null +++ b/tests/test_misconfigured.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +#set -x + +test_dir=$(dirname $0) + +export SCRATCH_DIR="${TMPDIR:-/tmp}/$$" + +oneTimeSetUp() { + rm -rf "$SCRATCH_DIR" + mkdir -p "$SCRATCH_DIR" +} + +oneTimeTearDown() { + rm -rf "$SCRATCH_DIR" +} + +test_workon_home_missing () { + export WORKON_HOME="$SCRATCH_DIR/no_such_subdir" + $SHELL -ec "source $test_dir/../virtualenvwrapper_bashrc" 2>/dev/null + RC=$? + assertSame "1" "$RC" +} + +test_shell_expansion_fails () { + export WORKON_HOME="$SCRATCH_DIR/\$no_such_var" + $SHELL -ec "source $test_dir/../virtualenvwrapper_bashrc" 2>/dev/null + RC=$? + assertSame "1" "$RC" +} + +. "$test_dir/shunit2" diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index eeb7aa5..7ed8429 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -6,18 +6,20 @@ # # Setup: # -# 1. Add a line like "export WORKON_HOME=$HOME/.virtualenvs" +# 1. Create a directory to hold the virtual environments. +# (mkdir $HOME/.virtualenvs). +# 2. Add a line like "export WORKON_HOME=$HOME/.virtualenvs" # to your .bashrc. -# 2. Add a line like "source /path/to/this/file/virtualenvwrapper_bashrc" +# 3. Add a line like "source /path/to/this/file/virtualenvwrapper_bashrc" # to your .bashrc. -# 3. Run: source ~/.bashrc -# 4. Run: workon -# 5. A list of environments, empty, is printed. -# 6. Run: mkvirtualenv temp -# 7. Run: workon -# 8. This time, the "temp" environment is included. -# 9. Run: workon temp -# 10. The virtual environment is activated. +# 4. Run: source ~/.bashrc +# 5. Run: workon +# 6. A list of environments, empty, is printed. +# 7. Run: mkvirtualenv temp +# 8. Run: workon +# 9. This time, the "temp" environment is included. +# 10. Run: workon temp +# 11. The virtual environment is activated. # # Make sure there is a default value for WORKON_HOME. @@ -29,7 +31,7 @@ fi # Normalize the directory name in case it includes # relative path components. -WORKON_HOME=$(sh -c 'cd "$WORKON_HOME"; pwd') +WORKON_HOME=$(python -c "import os; print os.path.abspath(os.path.expandshell(os.path.expanduser(\"$pydir\")))") export WORKON_HOME # Verify that the WORKON_HOME directory exists @@ -42,6 +44,8 @@ function virtualenvwrapper_verify_workon_home () { return 0 } +virtualenvwrapper_verify_workon_home + # Verify that the requested environment exists function virtualenvwrapper_verify_workon_environment () { typeset env_name="$1" From 5ff47393c27dce8163a58a0cbcd5ad01cf89d1cb Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Nov 2009 15:08:46 -0500 Subject: [PATCH 095/947] verify that virtualenv is installed; correct use of python to fix the WORKON_HOME value; more tests --- pavement.py | 1 - tests/test.sh | 16 ++++++++++++++-- tests/test_misconfigured.sh | 22 ++++++++++++++++++---- virtualenvwrapper_bashrc | 21 +++++++++++++++++++-- 4 files changed, 51 insertions(+), 9 deletions(-) diff --git a/pavement.py b/pavement.py index 6dd54a9..1b3e245 100644 --- a/pavement.py +++ b/pavement.py @@ -195,5 +195,4 @@ def test(): sh('bash ./tests/test.sh') sh('SHUNIT_PARENT=./tests/test.sh zsh -o shwordsplit ./tests/test.sh') sh('bash ./tests/test_misconfigured.sh') - sh('SHUNIT_PARENT=./tests/test_misconfigured.sh zsh -o shwordsplit ./tests/test.sh') return diff --git a/tests/test.sh b/tests/test.sh index 7d753a9..bd5d2cd 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -56,6 +56,18 @@ test_mkvirtualenv_activates () { assertSame "env2" $(basename "$VIRTUAL_ENV") } +test_no_virtualenv () { + old_path="$PATH" + PATH="/usr/bin:/usr/local/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$HOME/bin" + mkvirtualenv should_not_be_created # 2>/dev/null + RC=$? + # Restore the path before testing because + # the test script depends on commands in the + # path. + export PATH="$old_path" + assertSame "$RC" "1" +} + # test_mkvirtualenv_sitepackages () { # # Without the option verify that site-packages are copied. # mkvirtualenv "env3" @@ -137,8 +149,8 @@ test_virtualenvwrapper_show_workon_options () { test_virtualenvwrapper_show_workon_options_no_envs () { old_home="$WORKON_HOME" - export WORKON_HOME=${TMPDIR:/tmp}/$$ - envs=$(virtualenvwrapper_show_workon_options | tr '\n' ' ') + export WORKON_HOME=${TMPDIR:-/tmp}/$$ + envs=$(virtualenvwrapper_show_workon_options 2>/dev/null | tr '\n' ' ') assertSame "" "$envs" export WORKON_HOME="$old_home" } diff --git a/tests/test_misconfigured.sh b/tests/test_misconfigured.sh index d778b54..e56af68 100644 --- a/tests/test_misconfigured.sh +++ b/tests/test_misconfigured.sh @@ -15,16 +15,30 @@ oneTimeTearDown() { rm -rf "$SCRATCH_DIR" } -test_workon_home_missing () { +test_workon_home_missing_bash () { export WORKON_HOME="$SCRATCH_DIR/no_such_subdir" - $SHELL -ec "source $test_dir/../virtualenvwrapper_bashrc" 2>/dev/null + bash -ec "source $test_dir/../virtualenvwrapper_bashrc" 2>/dev/null RC=$? assertSame "1" "$RC" } -test_shell_expansion_fails () { +test_workon_home_missing_zsh () { + export WORKON_HOME="$SCRATCH_DIR/no_such_subdir" + zsh -ec "source $test_dir/../virtualenvwrapper_bashrc" 2>/dev/null + RC=$? + assertSame "1" "$RC" +} + +test_shell_expansion_fails_bash () { + export WORKON_HOME="$SCRATCH_DIR/\$no_such_var" + bash -ec "source $test_dir/../virtualenvwrapper_bashrc" 2>/dev/null + RC=$? + assertSame "1" "$RC" +} + +test_shell_expansion_fails_zsh () { export WORKON_HOME="$SCRATCH_DIR/\$no_such_var" - $SHELL -ec "source $test_dir/../virtualenvwrapper_bashrc" 2>/dev/null + zsh -ec "source $test_dir/../virtualenvwrapper_bashrc" 2>/dev/null RC=$? assertSame "1" "$RC" } diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 7ed8429..e383659 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -31,7 +31,7 @@ fi # Normalize the directory name in case it includes # relative path components. -WORKON_HOME=$(python -c "import os; print os.path.abspath(os.path.expandshell(os.path.expanduser(\"$pydir\")))") +WORKON_HOME=$(python -c "import os; print os.path.abspath(os.path.expandvars(os.path.expanduser(\"$WORKON_HOME\")))") export WORKON_HOME # Verify that the WORKON_HOME directory exists @@ -46,6 +46,22 @@ function virtualenvwrapper_verify_workon_home () { virtualenvwrapper_verify_workon_home +# Verify that virtualenv is installed and visible +function virtualenvwrapper_verify_virtualenv () { + venv=$(which virtualenv | grep -v "not found") + if [ "$venv" = "" ] + then + echo "ERROR: virtualenvwrapper could not find virtualenv in your path" >&2 + return 1 + fi + if [ ! -e "$venv" ] + then + echo "ERROR: Found virtualenv in path as \"$venv\" but that does not exist" >&2 + return 1 + fi + return 0 +} + # Verify that the requested environment exists function virtualenvwrapper_verify_workon_environment () { typeset env_name="$1" @@ -94,6 +110,7 @@ function virtualenvwrapper_run_hook () { function mkvirtualenv () { eval "envname=\$$#" virtualenvwrapper_verify_workon_home || return 1 + virtualenvwrapper_verify_virtualenv || return 1 (cd "$WORKON_HOME" && virtualenv "$@" && virtualenvwrapper_run_hook "./premkvirtualenv" "$envname" @@ -133,7 +150,7 @@ function virtualenvwrapper_show_workon_options () { # NOTE: DO NOT use ls here because colorized versions spew control characters # into the output list. # echo seems a little faster than find, even with -depth 3. - (cd "$WORKON_HOME"; for f in */bin/activate; do echo $f; done) | sed 's|^\./||' | sed 's|/bin/activate||' | sort + (cd "$WORKON_HOME"; for f in */bin/activate; do echo $f; done) 2>/dev/null | sed 's|^\./||' | sed 's|/bin/activate||' | sort # (cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort } From ea2a6bf5360111bc914feac97ef27d98a4cd1815 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Nov 2009 15:14:13 -0500 Subject: [PATCH 096/947] Added tag 1.21 for changeset c11ee7913230 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 92a7d06..adfe5e6 100644 --- a/.hgtags +++ b/.hgtags @@ -29,3 +29,4 @@ bddfac3c8fde9c860c6e942435cff297f989060d 1.15 24190e878fa8e6caf37f67b5c42b1b52304baa62 1.18 8af191bfa3c823bd5528ce99d0fb8fe72cc1a5d6 1.19 ed873ac408ff14b8e40137bd4caedbd798c96cb8 1.20 +c11ee79132302cf9f6c229f336dcaea5e1dea474 1.21 From 244ad9ba15343e755737a5ded8c9ecc001933c70 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Nov 2009 15:14:31 -0500 Subject: [PATCH 097/947] update version for new release --- pavement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pavement.py b/pavement.py index 1b3e245..42e7eba 100644 --- a/pavement.py +++ b/pavement.py @@ -27,7 +27,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.20' +VERSION = '1.21' os.environ['VERSION'] = VERSION # Read the long description to give to setup From dd62ffbfae3d854fb9e0c12ab3727b5289a61703 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Nov 2009 15:14:41 -0500 Subject: [PATCH 098/947] Added tag 1.21 for changeset 2190584becc7 --- .hgtags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.hgtags b/.hgtags index adfe5e6..c014309 100644 --- a/.hgtags +++ b/.hgtags @@ -30,3 +30,5 @@ bddfac3c8fde9c860c6e942435cff297f989060d 1.15 8af191bfa3c823bd5528ce99d0fb8fe72cc1a5d6 1.19 ed873ac408ff14b8e40137bd4caedbd798c96cb8 1.20 c11ee79132302cf9f6c229f336dcaea5e1dea474 1.21 +c11ee79132302cf9f6c229f336dcaea5e1dea474 1.21 +2190584becc72c84c2bdcd3daed4b51377a414f2 1.21 From 0f8ad7b7e10a63eeaa3f7d6d493a9a1a9db727e5 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Nov 2009 15:19:21 -0500 Subject: [PATCH 099/947] update README instructions --- README | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/README b/README index 86bd4f0..b887c45 100644 --- a/README +++ b/README @@ -27,20 +27,22 @@ Features Quick Setup =========== -1. Add two lines to your .bashrc to set the location where the virtual - environments should live and the location of the script installed - with this package:: +1. Create a directory to hold all of the virtual environments. The default is + ``$HOME/.virtualenvs``. - export WORKON_HOME=$HOME/.virtualenvs - source /usr/local/bin/virtualenvwrapper_bashrc +2. Add two lines to your .bashrc to set the location where the virtual environments should + live and the location of the script installed with this package:: -2. Run: ``source ~/.bashrc`` -3. Run: ``workon`` -4. A list of environments, empty, is printed. -5. Run: ``mkvirtualenv temp`` -6. A new environment, ``temp`` is created and activated. -7. Run: ``workon`` -8. This time, the ``temp`` environment is included. + export WORKON_HOME=$HOME/.virtualenvs + source /usr/local/bin/virtualenvwrapper_bashrc + +3. Run: ``source ~/.bashrc`` +4. Run: ``workon`` +5. A list of environments, empty, is printed. +6. Run: ``mkvirtualenv temp`` +7. A new environment, ``temp`` is created and activated. +8. Run: ``workon`` +9. This time, the ``temp`` environment is included. ======= License From e35688fb6e3368892060d4720e782ac4008c8208 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 6 Dec 2009 10:06:00 -0500 Subject: [PATCH 100/947] add mode specification for emacs --- virtualenvwrapper_bashrc | 1 + 1 file changed, 1 insertion(+) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index e383659..b751f5b 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -1,3 +1,4 @@ +# -*- mode: shell-script -*- # # Shell functions to act as wrapper for Ian Bicking's virtualenv # (http://pypi.python.org/pypi/virtualenv) From 8fa939f12375bb7d4ef9f0c1b053cda65a2e2925 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 7 Dec 2009 08:56:59 -0500 Subject: [PATCH 101/947] automatically create hook scripts --- docsource/history.rst | 5 ++++ tests/test.sh | 14 ++++++++++ virtualenvwrapper_bashrc | 56 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/docsource/history.rst b/docsource/history.rst index fa4dfb1..fa9e03d 100644 --- a/docsource/history.rst +++ b/docsource/history.rst @@ -2,6 +2,11 @@ Release History =============== +1.22 + + - Automatically create any missing hook scripts as stubs with + comments to expose the feature in case users are not aware of it. + 1.21 - Better protection of ``$WORKON_HOME`` does not exist when the wrapper script is sourced. diff --git a/tests/test.sh b/tests/test.sh index bd5d2cd..c193eec 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -24,6 +24,20 @@ setUp () { test_mkvirtualenv() { mkvirtualenv "env1" assertTrue "Environment directory was not created" "[ -d $WORKON_HOME/env1 ]" + for hook in postactivate predeactivate postdeactivate + do + assertTrue "env1 $hook was not created" "[ -f $WORKON_HOME/env1/bin/$hook ]" + assertTrue "env1 $hook is not executable" "[ -x $WORKON_HOME/env1/bin/$hook ]" + done +} + +test_virtualenvwrapper_initialize() { + virtualenvwrapper_initialize + for hook in premkvirtualenv postmkvirtualenv prermvirtualenv postrmvirtualenv preactivate postactivate predeactivate postdeactivate + do + assertTrue "Global $hook was not created" "[ -f $WORKON_HOME/$hook ]" + assertTrue "Global $hook is not executable" "[ -x $WORKON_HOME/$hook ]" + done } test_get_python_version() { diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index b751f5b..10688c2 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -45,7 +45,54 @@ function virtualenvwrapper_verify_workon_home () { return 0 } -virtualenvwrapper_verify_workon_home +# Create a hook script +# +# Usage: virtualenvwrapper_make_hook filename comment +# +function virtualenvwrapper_make_hook () { + filename="$1" + comment="$2" + if [ ! -f "$filename" ] + then + #echo "Creating $filename" + cat - > "$filename" < Date: Mon, 7 Dec 2009 08:57:05 -0500 Subject: [PATCH 102/947] Added tag 1.22 for changeset eddb2921783c --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index c014309..8d7e696 100644 --- a/.hgtags +++ b/.hgtags @@ -32,3 +32,4 @@ ed873ac408ff14b8e40137bd4caedbd798c96cb8 1.20 c11ee79132302cf9f6c229f336dcaea5e1dea474 1.21 c11ee79132302cf9f6c229f336dcaea5e1dea474 1.21 2190584becc72c84c2bdcd3daed4b51377a414f2 1.21 +eddb2921783cbf2c8f04f896f8e861e70c5f1068 1.22 From 1fe262a22c257114771d638b45f0c56abb02d867 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 7 Dec 2009 08:58:26 -0500 Subject: [PATCH 103/947] bump version --- pavement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pavement.py b/pavement.py index 42e7eba..0a4daad 100644 --- a/pavement.py +++ b/pavement.py @@ -27,7 +27,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.21' +VERSION = '1.22' os.environ['VERSION'] = VERSION # Read the long description to give to setup From 51ef68767d2c33935c4cf861143886f20a929ded Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 7 Dec 2009 08:58:31 -0500 Subject: [PATCH 104/947] Added tag 1.22 for changeset c50385e9c99b --- .hgtags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.hgtags b/.hgtags index 8d7e696..cd61054 100644 --- a/.hgtags +++ b/.hgtags @@ -33,3 +33,5 @@ c11ee79132302cf9f6c229f336dcaea5e1dea474 1.21 c11ee79132302cf9f6c229f336dcaea5e1dea474 1.21 2190584becc72c84c2bdcd3daed4b51377a414f2 1.21 eddb2921783cbf2c8f04f896f8e861e70c5f1068 1.22 +eddb2921783cbf2c8f04f896f8e861e70c5f1068 1.22 +c50385e9c99b207f56a968926b0f7e21a2b09366 1.22 From f19032a88772aac523e49c75f8d4a8c61397c6b3 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 12 Dec 2009 08:49:51 -0500 Subject: [PATCH 105/947] fix the postmkvirtualenv hook --- tests/test.sh | 11 +++++++++++ virtualenvwrapper_bashrc | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/test.sh b/tests/test.sh index c193eec..006e7ca 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -70,6 +70,17 @@ test_mkvirtualenv_activates () { assertSame "env2" $(basename "$VIRTUAL_ENV") } +test_postmkvirtualenv () { + echo "echo GLOBAL postmkvirtualenv > $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" + mkvirtualenv "env3" + output=$(cat "$test_dir/catch_output") + expected="GLOBAL postmkvirtualenv" + assertSame "$expected" "$output" + rm -f "$WORKON_HOME/postmkvirtualenv" + deactivate + rmvirtualenv "env3" +} + test_no_virtualenv () { old_path="$PATH" PATH="/usr/bin:/usr/local/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$HOME/bin" diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 10688c2..6a81e74 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -173,7 +173,7 @@ function mkvirtualenv () { virtualenvwrapper_make_hook "$WORKON_HOME/$envname/bin/postdeactivate" "This hook is sourced after the virtualenv is deactivated." # Now activate the new environment workon "$envname" - virtualenvwrapper_source_hook "$WORKON_HOME/$envname/postmkvirtualenv" + virtualenvwrapper_source_hook "$WORKON_HOME/postmkvirtualenv" } # Remove an environment, in the WORKON_HOME. From 3f968841f3c49314c43a79deca237b2be55fbf56 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 12 Dec 2009 09:12:27 -0500 Subject: [PATCH 106/947] test both mkvirtualenv hooks --- tests/test.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index 006e7ca..f05196c 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -70,12 +70,17 @@ test_mkvirtualenv_activates () { assertSame "env2" $(basename "$VIRTUAL_ENV") } -test_postmkvirtualenv () { - echo "echo GLOBAL postmkvirtualenv > $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" +test_mkvirtualenv_hooks () { + export pre_test_dir=$(cd "$test_dir"; pwd) + echo "echo GLOBAL premkvirtualenv >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" + chmod +x "$WORKON_HOME/premkvirtualenv" + echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" mkvirtualenv "env3" output=$(cat "$test_dir/catch_output") - expected="GLOBAL postmkvirtualenv" + expected="GLOBAL premkvirtualenv +GLOBAL postmkvirtualenv" assertSame "$expected" "$output" + rm -f "$WORKON_HOME/premkvirtualenv" rm -f "$WORKON_HOME/postmkvirtualenv" deactivate rmvirtualenv "env3" From d5adb43768b0524b8713199074e9774207482ffa Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 12 Dec 2009 09:14:09 -0500 Subject: [PATCH 107/947] prep for release --- docsource/history.rst | 5 +++++ pavement.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docsource/history.rst b/docsource/history.rst index fa9e03d..7fdd026 100644 --- a/docsource/history.rst +++ b/docsource/history.rst @@ -2,6 +2,11 @@ Release History =============== +1.23 + + - Resolve a bug with the postmkvirtualenv hook not being run + properly. Refer to issues #19 and #20 for complete details. + 1.22 - Automatically create any missing hook scripts as stubs with diff --git a/pavement.py b/pavement.py index 0a4daad..b9a4c11 100644 --- a/pavement.py +++ b/pavement.py @@ -27,7 +27,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.22' +VERSION = '1.23' os.environ['VERSION'] = VERSION # Read the long description to give to setup From 885f77302b4e259b503b115ebd160bf88598fd8c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 12 Dec 2009 09:14:16 -0500 Subject: [PATCH 108/947] Added tag 1.23 for changeset e55e8a54de7b --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index cd61054..8ee82c2 100644 --- a/.hgtags +++ b/.hgtags @@ -35,3 +35,4 @@ c11ee79132302cf9f6c229f336dcaea5e1dea474 1.21 eddb2921783cbf2c8f04f896f8e861e70c5f1068 1.22 eddb2921783cbf2c8f04f896f8e861e70c5f1068 1.22 c50385e9c99b207f56a968926b0f7e21a2b09366 1.22 +e55e8a54de7be78b8400632ab004abb29aaa8899 1.23 From b7b99628d8792f2f5ac76bc480ccde4769acaa92 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 24 Dec 2009 09:16:41 -0500 Subject: [PATCH 109/947] fix preactivate scripts; warn for existing scripts that need to be executable but are not --- .hgignore | 1 + tests/test.sh | 64 +++++++++++++++++++++++++++++++--------- virtualenvwrapper_bashrc | 9 +++++- 3 files changed, 59 insertions(+), 15 deletions(-) diff --git a/.hgignore b/.hgignore index 2394fd8..24aaa95 100644 --- a/.hgignore +++ b/.hgignore @@ -7,6 +7,7 @@ trace.txt docs *.pyc sphinx/web/templates/base.html +tests/catch_output syntax: re .DS_Store diff --git a/tests/test.sh b/tests/test.sh index f05196c..549e1a6 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -40,6 +40,24 @@ test_virtualenvwrapper_initialize() { done } +test_virtualenvwrapper_run_hook() { + echo "echo run >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/test_hook" + chmod +x "$WORKON_HOME/test_hook" + virtualenvwrapper_run_hook "$WORKON_HOME/test_hook" + output=$(cat "$test_dir/catch_output") + expected="run" + assertSame "$expected" "$output" +} + +test_virtualenvwrapper_run_hook_permissions() { + echo "echo run >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/test_hook" + chmod -x "$WORKON_HOME/test_hook" + virtualenvwrapper_run_hook "$WORKON_HOME/test_hook" + output=$(cat "$test_dir/catch_output") + expected="" + assertSame "$expected" "$output" +} + test_get_python_version() { expected=$(python -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d.) actual=$(virtualenvwrapper_get_python_version) @@ -125,15 +143,32 @@ test_workon () { assertSame "env1" $(basename "$VIRTUAL_ENV") } -test_postactivate_hook () { - echo "echo ENV postactivate > $test_dir/catch_output" > "$WORKON_HOME/env1/bin/postactivate" - +test_workon_activate_hooks () { + for t in pre post + do + echo "echo GLOBAL ${t}activate >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/${t}activate" + chmod +x "$WORKON_HOME/${t}activate" + echo "echo ENV ${t}activate >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/env1/bin/${t}activate" + chmod +x "$WORKON_HOME/env1/bin/${t}activate" + done + + rm "$test_dir/catch_output" + workon env1 output=$(cat "$test_dir/catch_output") - assertSame "ENV postactivate" "$output" + expected="GLOBAL preactivate +ENV preactivate +GLOBAL postactivate +ENV postactivate" + + assertSame "$expected" "$output" - rm -f "$WORKON_HOME/env1/bin/postactivate" + for t in pre post + do + rm -f "$WORKON_HOME/env1/bin/${t}activate" + rm -f "$WORKON_HOME/${t}activate" + done } test_deactivate () { @@ -147,11 +182,11 @@ test_deactivate () { test_deactivate_hooks () { workon env1 - echo "echo GLOBAL predeactivate >> $test_dir/catch_output" > "$WORKON_HOME/predeactivate" - echo "echo GLOBAL postdeactivate >> $test_dir/catch_output" > "$WORKON_HOME/postdeactivate" - - echo "echo ENV predeactivate >> $test_dir/catch_output" > "$WORKON_HOME/env1/bin/predeactivate" - echo "echo ENV postdeactivate >> $test_dir/catch_output" > "$WORKON_HOME/env1/bin/postdeactivate" + for t in pre post + do + echo "echo GLOBAL ${t}deactivate >> $test_dir/catch_output" > "$WORKON_HOME/${t}deactivate" + echo "echo ENV ${t}deactivate >> $test_dir/catch_output" > "$WORKON_HOME/env1/bin/${t}deactivate" + done deactivate @@ -162,10 +197,11 @@ ENV postdeactivate GLOBAL postdeactivate" assertSame "$expected" "$output" - rm -f "$WORKON_HOME/env1/bin/predeactivate" - rm -f "$WORKON_HOME/env1/bin/postdeactivate" - rm -f "$WORKON_HOME/predeactivate" - rm -f "$WORKON_HOME/postdeactivate" + for t in pre post + do + rm -f "$WORKON_HOME/env1/bin/${t}activate" + rm -f "$WORKON_HOME/${t}activate" + done } test_virtualenvwrapper_show_workon_options () { diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 6a81e74..1d67119 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -134,6 +134,7 @@ function virtualenvwrapper_verify_active_environment () { # Run a hook script in the current shell function virtualenvwrapper_source_hook () { scriptname="$1" + #echo "Looking for hook $scriptname" if [ -f "$scriptname" ] then source "$scriptname" @@ -144,9 +145,13 @@ function virtualenvwrapper_source_hook () { function virtualenvwrapper_run_hook () { scriptname="$1" shift + #echo "Looking for hook $scriptname" if [ -x "$scriptname" ] then "$scriptname" "$@" + elif [ -e "$scriptname" ] + then + echo "Warning: Found \"$scriptname\" but it is not executable." 1>&2 fi } @@ -237,6 +242,9 @@ function workon () { then deactivate fi + + virtualenvwrapper_run_hook "$WORKON_HOME/preactivate" + virtualenvwrapper_run_hook "$WORKON_HOME/$env_name/bin/preactivate" source "$activate" @@ -263,7 +271,6 @@ function workon () { }' virtualenvwrapper_source_hook "$WORKON_HOME/postactivate" - virtualenvwrapper_source_hook "$VIRTUAL_ENV/bin/postactivate" return 0 From c344cdd3b4284fc04a9f0a4d3480e18b1cb4ba45 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 24 Dec 2009 09:18:55 -0500 Subject: [PATCH 110/947] bump version and update history --- docsource/history.rst | 5 +++++ pavement.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docsource/history.rst b/docsource/history.rst index 7fdd026..ff711fd 100644 --- a/docsource/history.rst +++ b/docsource/history.rst @@ -2,6 +2,11 @@ Release History =============== +1.24 + + - Resolve a bug with the preactivate hook not being run properly. + Refer to issue #21 for complete details. + 1.23 - Resolve a bug with the postmkvirtualenv hook not being run diff --git a/pavement.py b/pavement.py index b9a4c11..59e1681 100644 --- a/pavement.py +++ b/pavement.py @@ -27,7 +27,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.23' +VERSION = '1.24' os.environ['VERSION'] = VERSION # Read the long description to give to setup From f6b50a685fb08cfa36e1be9fa29a1036fa631e8e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 24 Dec 2009 09:18:58 -0500 Subject: [PATCH 111/947] Added tag 1.24 for changeset b243d023094b --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 8ee82c2..f5f2137 100644 --- a/.hgtags +++ b/.hgtags @@ -36,3 +36,4 @@ eddb2921783cbf2c8f04f896f8e861e70c5f1068 1.22 eddb2921783cbf2c8f04f896f8e861e70c5f1068 1.22 c50385e9c99b207f56a968926b0f7e21a2b09366 1.22 e55e8a54de7be78b8400632ab004abb29aaa8899 1.23 +b243d023094b6b0ef1b834dcc100f8c342c67537 1.24 From 427b1b3efbcc4adedd72aefbc708f1e77c1bfe69 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 28 Jan 2010 08:40:29 -0500 Subject: [PATCH 112/947] add license and home page info to top of script --- virtualenvwrapper_bashrc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 1d67119..634f35a 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -3,7 +3,28 @@ # Shell functions to act as wrapper for Ian Bicking's virtualenv # (http://pypi.python.org/pypi/virtualenv) # - +# +# Copyright Doug Hellmann, All Rights Reserved +# +# Permission to use, copy, modify, and distribute this software and its +# documentation for any purpose and without fee is hereby granted, +# provided that the above copyright notice appear in all copies and that +# both that copyright notice and this permission notice appear in +# supporting documentation, and that the name of Doug Hellmann not be used +# in advertising or publicity pertaining to distribution of the software +# without specific, written prior permission. +# +# DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +# EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +# USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. +# +# +# Project home page: http://www.doughellmann.com/projects/virtualenvwrapper/ +# # # Setup: # From 37271167906de15ae66aa4964ae31bed76870498 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 28 Jan 2010 08:42:10 -0500 Subject: [PATCH 113/947] bump version num before new release --- pavement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pavement.py b/pavement.py index 59e1681..3ceef46 100644 --- a/pavement.py +++ b/pavement.py @@ -27,7 +27,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.24' +VERSION = '1.24.1' os.environ['VERSION'] = VERSION # Read the long description to give to setup From 5ec6bf2d873a13e3dcad0876bc6302c8d3fde298 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 28 Jan 2010 08:42:12 -0500 Subject: [PATCH 114/947] Added tag 1.24.1 for changeset 4a8870326d84 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index f5f2137..130b7c5 100644 --- a/.hgtags +++ b/.hgtags @@ -37,3 +37,4 @@ eddb2921783cbf2c8f04f896f8e861e70c5f1068 1.22 c50385e9c99b207f56a968926b0f7e21a2b09366 1.22 e55e8a54de7be78b8400632ab004abb29aaa8899 1.23 b243d023094b6b0ef1b834dcc100f8c342c67537 1.24 +4a8870326d84f97d5539b586b21419ba330fea48 1.24.1 From 61a2f90bf54b18a7a43c2406380827ec46e1083c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 13 Feb 2010 11:49:48 -0500 Subject: [PATCH 115/947] switch doc theme for packaged docs; add link to Rich Leland's screencast --- README | 4 ++++ docsource/index.rst | 37 ++++++++++++++++++++++++++++++------- sphinx/pkg/conf.py | 2 +- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/README b/README index b887c45..81158ca 100644 --- a/README +++ b/README @@ -23,6 +23,10 @@ Features 4. Tab completion for commands that take a virtual environment as argument. +Rich Leland has created a short `screencast +`__ +showing off the features of virtualenvwrapper. + =========== Quick Setup =========== diff --git a/docsource/index.rst b/docsource/index.rst index 7928a41..cbc1175 100644 --- a/docsource/index.rst +++ b/docsource/index.rst @@ -7,7 +7,12 @@ virtualenvwrapper ################# -virtualenvwrapper is a set of extensions to Ian Bicking's `virtualenv `_ tool. The extensions include wrappers for creating and deleting virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. +virtualenvwrapper is a set of extensions to Ian Bicking's `virtualenv +`_ tool. The extensions +include wrappers for creating and deleting virtual environments and +otherwise managing your development workflow, making it easier to work +on more than one project at a time without introducing conflicts in +their dependencies. ======== Features @@ -55,18 +60,36 @@ Details References ========== -`virtualenv `_, from Ian Bicking, is a pre-requisite to using these extensions. +`virtualenv `_, from Ian +Bicking, is a pre-requisite to using these extensions. -For more details, refer to the column I wrote for the May 2008 issue of Python -Magazine: `virtualenvwrapper | And Now For Something Completely Different +For more details, refer to the column I wrote for the May 2008 issue +of Python Magazine: `virtualenvwrapper | And Now For Something +Completely Different `_. +Rich Leland has created a short `screencast +`__ +showing off the features of virtualenvwrapper. + ======= License ======= Copyright Doug Hellmann, All Rights Reserved -Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Doug Hellmann not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. - -DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Doug Hellmann not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/sphinx/pkg/conf.py b/sphinx/pkg/conf.py index 7634fdc..1045433 100644 --- a/sphinx/pkg/conf.py +++ b/sphinx/pkg/conf.py @@ -91,7 +91,7 @@ # The theme to use for HTML and HTML Help pages. Major themes that come with # Sphinx are currently 'default' and 'sphinxdoc'. -html_theme = 'default' +html_theme = 'sphinxdoc' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the From 17eec7b773217741cf9d06db75dc388f6aaf30a8 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 13 Feb 2010 12:24:43 -0500 Subject: [PATCH 116/947] add user-provided tips to the docs --- docsource/developers.rst | 25 +++++-- docsource/index.rst | 1 + docsource/tips.rst | 151 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 171 insertions(+), 6 deletions(-) create mode 100644 docsource/tips.rst diff --git a/docsource/developers.rst b/docsource/developers.rst index 15ca7e2..50fd757 100644 --- a/docsource/developers.rst +++ b/docsource/developers.rst @@ -2,18 +2,27 @@ For Developers ############## -If you would like to contribute, these instructions should help you get started. Patches, bug reports, and feature requests are all welcome through the `BitBucket site `_. Contributions in the form of patches or pull requests are easier to integrate and will receive priority attention. +If you would like to contribute, these instructions should help you +get started. Patches, bug reports, and feature requests are all +welcome through the `BitBucket site +`_. Contributions +in the form of patches or pull requests are easier to integrate and +will receive priority attention. Building Documentation ====================== -The documentation for virtualenvwrapper is written in reStructuredText and converted to HTML using Sphinx. The build itself is driven by Paver. You will need the following packages in order to build the docs: +The documentation for virtualenvwrapper is written in reStructuredText +and converted to HTML using Sphinx. The build itself is driven by +Paver. You will need the following packages in order to build the +docs: - Sphinx - Paver - sphinxcontrib.paverutils -Once all of them are installed into a virtualenv using easy_install, run ``paver html`` to generate the HTML version of the documentation:: +Once all of them are installed into a virtualenv using easy_install, +run ``paver html`` to generate the HTML version of the documentation:: $ paver html ---> pavement.html @@ -47,12 +56,16 @@ Once all of them are installed into a virtualenv using easy_install, run ``paver rmtree virtualenvwrapper/docs () {} move docs/html virtualenvwrapper/docs -The output version of the documentation ends up in ``./virtualenvwrapper/docs`` inside your sandbox. +The output version of the documentation ends up in +``./virtualenvwrapper/docs`` inside your sandbox. Running Tests ============= -The test suite for virtualenvwrapper uses `shunit2 `_. To run the tests under both bash and zsh, use ``paver test``. To add new tests, modify the ``tests/test.sh`` script with new test functions. +The test suite for virtualenvwrapper uses `shunit2 +`_. To run the tests under both bash +and zsh, use ``paver test``. To add new tests, modify the +``tests/test.sh`` script with new test functions. :: @@ -127,4 +140,4 @@ The test suite for virtualenvwrapper uses `shunit2 `__ +and I'll add it here. + +zsh Prompt +========== + +From `Nat `_: + +Using zsh, I added some bits to ``$WORKON_HOME/post(de)activate`` to show +the active virtualenv on the right side of my screen instead. + +in ``postactivate``:: + + PS1="$_OLD_VIRTUAL_PS1" + _OLD_RPROMPT="$RPROMPT" + RPROMPT="%{${fg_bold[white]}%}(env: %{${fg[green]}%}`basename \"$VIRTUAL_ENV\"`%{${fg_bold[white]}%})%{${reset_color}%} $RPROMPT" + +and in ``postdeactivate``:: + + RPROMPT="$_OLD_RPROMPT" + +Adjust colors according to your own personal tastes or environment. + +Updating cached ``$PATH`` entries +================================= + +From `Nat `_: + +I also added the command 'rehash' to ``$WORKON_HOME/postactivate`` and +``$WORKON_HOME/postdeactivate`` as I was having some problems with zsh +not picking up the new paths immediately. + +Tying to pip's virtualenv support +================================= + +Via http://becomingguru.com/: + +Add this to your shell login script to make pip use the same directory +for virtualenvs as virtualenvwrapper:: + + export PIP_VIRTUALENV_BASE=$WORKON_HOME + +and Via Nat: + +in addition to what becomingguru said, this line is key:: + + export PIP_RESPECT_VIRTUALENV=true + +That makes pip detect an active virtualenv and install to it, without +having to pass it the -E parameter. + +Creating Project Work Directories +================================= + +Via `James `_: + +In the ``postmkvirtualenv`` script I have the following to create a +directory based on the project name, add that directory to the python +path and then cd into it:: + + proj_name=$(echo $VIRTUAL_ENV|awk -F'/' '{print $NF}') + mkdir $HOME/projects/$proj_name + add2virtualenv $HOME/projects/$proj_name + cd $HOME/projects/$proj_name + + +In the ``postactivate`` script I have it set to automatically change +to the project directory when I use the workon command:: + + proj_name=$(echo $VIRTUAL_ENV|awk -F'/' '{print $NF}') + cd ~/projects/$proj_name + +Automatically Run workon When Entering a Directory +================================================== + +`Justin Lily posted +`__ +about about some code he added to his shell environment to look at the +directory each time he runs ``cd``. If it finds a ``.venv`` file, it +activates the environment named within. On leaving that directory, +the current virtualenv is automatically deactivated. + +`Harry Marr `__ +wrote a similar function that works with `git repositories +`__. + +Installing Common Tools Automatically in New Environments +========================================================= + +Via `rizumu `__: + +I have this postmkvirtualenv to install the get a basic setup. + +:: + + $ cat postmkvirtualenv + #!/usr/bin/env bash + curl -O http://python-distribute.org/distribute_setup.p... />python distribute_setup.py + rm distribute_setup.py + easy_install pip==dev + pip install Mercurial + +Then I have a pip requirement file with my dev tools. + +:: + + $ cat developer_requirements.txt + ipdb + ipython + pastescript + nose + http://douglatornell.ca/software/python/Nosy-1.0.tar.gz + coverage + sphinx + grin + pyflakes + pep8 + +Then each project has it's own pip requirement file for things like +PIL, psycopg2, django-apps, numpy, etc. + +Changing the Default Behavior of ``cd`` +======================================= + +Via `mae `__: + +This is supposed to be executed after workon, that is as a +``postactivate`` hook. It basically overrides ``cd`` to know about the +VENV so instead of doing ``cd`` to go to ``~`` you will go to the venv +root, IMO very handy and I can't live without it anymore. if you pass +it a proper path then it will do the right thing. + +:: + + cd () { + if (( $# == 0 )) + then + builtin cd $VIRTUAL_ENV + else + builtin cd "$@" + fi + } + + cd From 253bbd9160a8352d67e74d28794e68462ba93903 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 13 Feb 2010 12:26:40 -0500 Subject: [PATCH 117/947] update history --- docsource/history.rst | 5 +++++ docsource/index.rst | 2 ++ docsource/tips.rst | 2 ++ 3 files changed, 9 insertions(+) diff --git a/docsource/history.rst b/docsource/history.rst index ff711fd..bf53694 100644 --- a/docsource/history.rst +++ b/docsource/history.rst @@ -2,6 +2,11 @@ Release History =============== +1.24.1 + + - Add user provided :ref:`tips-and-tricks` section. + - Add link to Rich Leland's screencast to :ref:`references` section. + 1.24 - Resolve a bug with the preactivate hook not being run properly. diff --git a/docsource/index.rst b/docsource/index.rst index 4299e9b..40b1ccd 100644 --- a/docsource/index.rst +++ b/docsource/index.rst @@ -57,6 +57,8 @@ Details history developers +.. _references: + ========== References ========== diff --git a/docsource/tips.rst b/docsource/tips.rst index 5fd5734..6113987 100644 --- a/docsource/tips.rst +++ b/docsource/tips.rst @@ -1,3 +1,5 @@ +.. _tips-and-tricks: + ================= Tips and Tricks ================= From ba9b21f319361cf14691a66d5d5fcc3fd79c81b7 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 13 Feb 2010 12:27:51 -0500 Subject: [PATCH 118/947] update history and bump version --- docsource/history.rst | 6 +++++- pavement.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docsource/history.rst b/docsource/history.rst index bf53694..9e67674 100644 --- a/docsource/history.rst +++ b/docsource/history.rst @@ -2,11 +2,15 @@ Release History =============== -1.24.1 +1.24.2 - Add user provided :ref:`tips-and-tricks` section. - Add link to Rich Leland's screencast to :ref:`references` section. +1.24.1 + + - Add license text to the header of the script. + 1.24 - Resolve a bug with the preactivate hook not being run properly. diff --git a/pavement.py b/pavement.py index 3ceef46..d97f92a 100644 --- a/pavement.py +++ b/pavement.py @@ -27,7 +27,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.24.1' +VERSION = '1.24.2' os.environ['VERSION'] = VERSION # Read the long description to give to setup From 8615cf7278935922c59917511d10747aa864034b Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 13 Feb 2010 12:27:55 -0500 Subject: [PATCH 119/947] Added tag 1.24.2 for changeset f31869779141 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 130b7c5..6c74796 100644 --- a/.hgtags +++ b/.hgtags @@ -38,3 +38,4 @@ c50385e9c99b207f56a968926b0f7e21a2b09366 1.22 e55e8a54de7be78b8400632ab004abb29aaa8899 1.23 b243d023094b6b0ef1b834dcc100f8c342c67537 1.24 4a8870326d84f97d5539b586b21419ba330fea48 1.24.1 +f318697791416cf0897091718d542e8045854233 1.24.2 From f54ea7aa189a0d48441964320c011737d1f88f92 Mon Sep 17 00:00:00 2001 From: Michael Elsdoerfer Date: Wed, 17 Feb 2010 01:13:17 +0100 Subject: [PATCH 120/947] Make sure that paths added via 'add2virtualenv' always end up being listed *before* regularily installed packages in sys.path. This ensures that you can always use the command to replace an installed package with a out-of-virtualenv version. --- virtualenvwrapper_bashrc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 634f35a..7cfd800 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -356,7 +356,9 @@ function add2virtualenv () { return 1 fi - path_file="$site_packages/virtualenv_path_extensions.pth" + # Prefix with _ to ensure we are loaded as early as possible, + # and at least before easy_install.pth. + path_file="$site_packages/_virtualenv_path_extensions.pth" if [ "$*" = "" ] then @@ -370,7 +372,12 @@ function add2virtualenv () { return 1 fi - touch "$path_file" + if [ ! -x "$path_file" ] + then + echo "import sys; sys.__plen = len(sys.path)" >> "$path_file" + echo "import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)" >> "$path_file" + fi + for pydir in "$@" do absolute_path=$(python -c "import os; print os.path.abspath(\"$pydir\")") @@ -378,7 +385,8 @@ function add2virtualenv () { then echo "Warning: Converting \"$pydir\" to \"$absolute_path\"" 1>&2 fi - echo "$absolute_path" >> "$path_file" + contents=$(cat "$path_file") + echo "$contents" | sed "1a $absolute_path" > "$path_file" done return 0 } From 294cfcb09926d61531a640efaf614b0a03186be0 Mon Sep 17 00:00:00 2001 From: Michael Elsdoerfer Date: Wed, 17 Feb 2010 01:41:53 +0100 Subject: [PATCH 121/947] New -d option to 'add2virtualenv' which allows removal of a path previously added. --- virtualenvwrapper_bashrc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 7cfd800..270a5de 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -372,6 +372,13 @@ function add2virtualenv () { return 1 fi + remove=0 + if [ "$1" = "-d" ] + then + remove=1 + shift + fi + if [ ! -x "$path_file" ] then echo "import sys; sys.__plen = len(sys.path)" >> "$path_file" @@ -385,8 +392,14 @@ function add2virtualenv () { then echo "Warning: Converting \"$pydir\" to \"$absolute_path\"" 1>&2 fi + contents=$(cat "$path_file") - echo "$contents" | sed "1a $absolute_path" > "$path_file" + if [ $remove -eq 1 ] + then + echo "$contents" | sed "\:^$absolute_path$: d" > "$path_file" + else + echo "$contents" | sed "1a $absolute_path" > "$path_file" + fi done return 0 } From 556584ff209b71fc0186f2c4b673d0f92e3f4c96 Mon Sep 17 00:00:00 2001 From: Michael Elsdoerfer Date: Wed, 17 Feb 2010 01:42:42 +0100 Subject: [PATCH 122/947] Test for existance of path file was broken, used the wrong test. --- virtualenvwrapper_bashrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 270a5de..fba2a3e 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -379,7 +379,7 @@ function add2virtualenv () { shift fi - if [ ! -x "$path_file" ] + if [ ! -f "$path_file" ] then echo "import sys; sys.__plen = len(sys.path)" >> "$path_file" echo "import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)" >> "$path_file" From b7380d8e78edb9f7b9b9f5c3d41d68d2e2154dbc Mon Sep 17 00:00:00 2001 From: Michael Elsdoerfer Date: Wed, 17 Feb 2010 01:46:00 +0100 Subject: [PATCH 123/947] When echoing the current list of paths, do not include the 'import' lines. --- virtualenvwrapper_bashrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index fba2a3e..c0245e6 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -367,7 +367,7 @@ function add2virtualenv () { then echo echo "Existing paths:" - cat "$path_file" + cat "$path_file" | grep -v "^import" fi return 1 fi From cee90348e0275936cafe0365c670d2af745f63ea Mon Sep 17 00:00:00 2001 From: Michael Elsdoerfer Date: Wed, 17 Feb 2010 01:46:24 +0100 Subject: [PATCH 124/947] I didn't know about 'sed -i', makes this a lot easier. --- virtualenvwrapper_bashrc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index c0245e6..a676045 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -393,12 +393,11 @@ function add2virtualenv () { echo "Warning: Converting \"$pydir\" to \"$absolute_path\"" 1>&2 fi - contents=$(cat "$path_file") if [ $remove -eq 1 ] then - echo "$contents" | sed "\:^$absolute_path$: d" > "$path_file" + sed -i "\:^$absolute_path$: d" "$path_file" else - echo "$contents" | sed "1a $absolute_path" > "$path_file" + sed -i "1a $absolute_path" "$path_file" fi done return 0 From d5bf7d4c91feb30f2ff8eedb82cf36555fd1331a Mon Sep 17 00:00:00 2001 From: William McVey Date: Thu, 25 Feb 2010 10:58:48 -0500 Subject: [PATCH 125/947] Added tab completion and pathname argument handling to cdsitepackages --- virtualenvwrapper_bashrc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 634f35a..96cfa1d 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -316,7 +316,13 @@ if [ -n "$BASH" ] ; then # COMPREPLY=( $(compgen -d -- "${VIRTUAL_ENV}/${cur}" | sed -e "s@${VIRTUAL_ENV}/@@" ) ) COMPREPLY=( $(cdvirtualenv && compgen -d -- "${cur}" ) ) } + _cdsitepackages_complete () + { + local cur="$2" + COMPREPLY=( $(cdsitepackages && compgen -d -- "${cur}" ) ) + } complete -o nospace -F _cdvirtualenv_complete -S/ cdvirtualenv + complete -o nospace -F _cdsitepackages_complete -S/ cdsitepackages complete -o default -o nospace -F _virtualenvs workon complete -o default -o nospace -F _virtualenvs rmvirtualenv elif [ -n "$ZSH_VERSION" ] ; then @@ -388,7 +394,7 @@ function add2virtualenv () { function cdsitepackages () { virtualenvwrapper_verify_active_environment || return 1 site_packages="`virtualenvwrapper_get_site_packages_dir`" - cd "$site_packages" + cd "$site_packages"/$1 } # Does a ``cd`` to the root of the currently-active virtualenv. From 3bc9e444ef6084b8cd7298f93e6efb6dfb80ce61 Mon Sep 17 00:00:00 2001 From: William McVey Date: Thu, 25 Feb 2010 11:17:13 -0500 Subject: [PATCH 126/947] Updated with expanded capability of cdsitepackages to cd to a subdir --- docsource/command_ref.rst | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docsource/command_ref.rst b/docsource/command_ref.rst index 9e52ad7..71018f1 100644 --- a/docsource/command_ref.rst +++ b/docsource/command_ref.rst @@ -84,7 +84,16 @@ cdsitepackages Because the exact path to the site-packages directory in the virtualenv depends on the version of Python, ``cdsitepackages`` is provided as a shortcut for ``cdvirtualenv -lib/python${pyvers}/site-packages``. +lib/python${pyvers}/site-packages``. An optional argument is also allowed, to specify +a directory hierarchy within the ``site-packages`` directory to change into. + +:: + $ workon pymotw + $ echo $VIRTUAL_ENV + /Users/dhellmann/.virtualenvs/pymotw + $ cdsitepackages PyMOTW/bisect/ + $ pwd + /Users/dhellmann/.virtualenvs/pymotw/lib/python2.6/site-packages/PyMOTW/bisect =============== Path Management From 2223c836a1e0e17fa82aa57ea585eb0d472ed7a2 Mon Sep 17 00:00:00 2001 From: William McVey Date: Thu, 25 Feb 2010 14:13:19 -0500 Subject: [PATCH 127/947] Added test for cdsitepackages with argument --- tests/test.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test.sh b/tests/test.sh index 549e1a6..52fe4de 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -82,6 +82,16 @@ test_cdsitepackages () { popd >/dev/null } +test_cdsitepackages_with_arg () { + pushd "$(pwd)" >/dev/null + pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) + sitepackage_subdir="$VIRTUAL_ENV/lib/python${pyvers}/site-packages/subdir" + mkdir -p "${sitepackage_subdir}" + cdsitepackages subdir + assertSame "$sitepackage_subdir" "$(pwd)" + popd >/dev/null +} + test_mkvirtualenv_activates () { mkvirtualenv "env2" assertTrue virtualenvwrapper_verify_active_environment From f33eb46476ad83373140abb97a965408bcafdf71 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 26 Feb 2010 10:58:55 -0500 Subject: [PATCH 128/947] Added tag 1.25 for changeset 06229877a640 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 6c74796..61e1aee 100644 --- a/.hgtags +++ b/.hgtags @@ -39,3 +39,4 @@ e55e8a54de7be78b8400632ab004abb29aaa8899 1.23 b243d023094b6b0ef1b834dcc100f8c342c67537 1.24 4a8870326d84f97d5539b586b21419ba330fea48 1.24.1 f318697791416cf0897091718d542e8045854233 1.24.2 +06229877a640ecb490faf46f923d8be916a0ebed 1.25 From 4a44aa9bdc5a4ea8a587b58213eb62ce825de6d7 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 9 Mar 2010 07:40:24 -0500 Subject: [PATCH 129/947] run all tests on all shells --- pavement.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pavement.py b/pavement.py index e118389..10805ca 100644 --- a/pavement.py +++ b/pavement.py @@ -192,7 +192,7 @@ def test_install(options): @task def test(): - sh('bash ./tests/test.sh') - sh('SHUNIT_PARENT=./tests/test.sh zsh -o shwordsplit ./tests/test.sh') - sh('bash ./tests/test_misconfigured.sh') + for shell_cmd in [ 'bash', 'sh', 'SHUNIT_PARENT=./tests/test.sh zsh -o shwordsplit' ]: + sh('%s ./tests/test.sh' % shell_cmd) + sh('%s ./tests/test_misconfigured.sh' % shell_cmd) return From 63b7caf1bd04c6cad14326443ee9e66b6917b18a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 20 Mar 2010 09:01:10 -0400 Subject: [PATCH 130/947] break up the tests to make it easier to run only part of them --HG-- rename : tests/test_install.sh => tests/manual_test_install.sh --- pavement.py | 12 +- ...test_install.sh => manual_test_install.sh} | 2 +- tests/test.sh | 253 ------------------ tests/test_add2virtualenv.sh | 45 ++++ tests/test_cd.sh | 53 ++++ tests/test_ls.sh | 40 +++ tests/test_mkvirtualenv.sh | 90 +++++++ tests/test_rmvirtualenv.sh | 73 +++++ tests/test_run_hook.sh | 42 +++ tests/test_workon.sh | 119 ++++++++ 10 files changed, 472 insertions(+), 257 deletions(-) rename tests/{test_install.sh => manual_test_install.sh} (80%) create mode 100644 tests/test_add2virtualenv.sh create mode 100644 tests/test_cd.sh create mode 100644 tests/test_ls.sh create mode 100644 tests/test_mkvirtualenv.sh create mode 100644 tests/test_rmvirtualenv.sh create mode 100644 tests/test_run_hook.sh create mode 100644 tests/test_workon.sh diff --git a/pavement.py b/pavement.py index 10805ca..ebe6647 100644 --- a/pavement.py +++ b/pavement.py @@ -192,7 +192,13 @@ def test_install(options): @task def test(): - for shell_cmd in [ 'bash', 'sh', 'SHUNIT_PARENT=./tests/test.sh zsh -o shwordsplit' ]: - sh('%s ./tests/test.sh' % shell_cmd) - sh('%s ./tests/test_misconfigured.sh' % shell_cmd) + #test_scripts = glob.glob('./tests/test*.sh') + test_scripts = path('tests').glob('test*.sh') + for shell_cmd in [ 'bash', 'sh', 'SHUNIT_PARENT=%(test_script)s zsh -o shwordsplit' ]: + for test_script in test_scripts: + base_cmd = shell_cmd + ' %(test_script)s' + cmd = base_cmd % locals() + print '*' * 80 + print + sh(cmd) return diff --git a/tests/test_install.sh b/tests/manual_test_install.sh similarity index 80% rename from tests/test_install.sh rename to tests/manual_test_install.sh index 88fc9e4..2056ef5 100755 --- a/tests/test_install.sh +++ b/tests/manual_test_install.sh @@ -9,7 +9,7 @@ version="$2" export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" mkvirtualenv "installtest" -easy_install "$dist_dir/virtualenvwrapper-$version.tar.gz" +pip install "$dist_dir/virtualenvwrapper-$version.tar.gz" RC=$? rm -rf "$WORKON_HOME" diff --git a/tests/test.sh b/tests/test.sh index 52fe4de..6f8077e 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -21,16 +21,6 @@ setUp () { rm -f "$test_dir/catch_output" } -test_mkvirtualenv() { - mkvirtualenv "env1" - assertTrue "Environment directory was not created" "[ -d $WORKON_HOME/env1 ]" - for hook in postactivate predeactivate postdeactivate - do - assertTrue "env1 $hook was not created" "[ -f $WORKON_HOME/env1/bin/$hook ]" - assertTrue "env1 $hook is not executable" "[ -x $WORKON_HOME/env1/bin/$hook ]" - done -} - test_virtualenvwrapper_initialize() { virtualenvwrapper_initialize for hook in premkvirtualenv postmkvirtualenv prermvirtualenv postrmvirtualenv preactivate postactivate predeactivate postdeactivate @@ -40,254 +30,11 @@ test_virtualenvwrapper_initialize() { done } -test_virtualenvwrapper_run_hook() { - echo "echo run >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/test_hook" - chmod +x "$WORKON_HOME/test_hook" - virtualenvwrapper_run_hook "$WORKON_HOME/test_hook" - output=$(cat "$test_dir/catch_output") - expected="run" - assertSame "$expected" "$output" -} - -test_virtualenvwrapper_run_hook_permissions() { - echo "echo run >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/test_hook" - chmod -x "$WORKON_HOME/test_hook" - virtualenvwrapper_run_hook "$WORKON_HOME/test_hook" - output=$(cat "$test_dir/catch_output") - expected="" - assertSame "$expected" "$output" -} - test_get_python_version() { expected=$(python -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d.) actual=$(virtualenvwrapper_get_python_version) assertSame "$expected" "$actual" } -test_cdvirtual() { - pushd "$(pwd)" >/dev/null - cdvirtualenv - assertSame "$VIRTUAL_ENV" "$(pwd)" - cdvirtualenv bin - assertSame "$VIRTUAL_ENV/bin" "$(pwd)" - popd >/dev/null -} - -test_cdsitepackages () { - pushd "$(pwd)" >/dev/null - cdsitepackages - pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) - sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" - assertSame "$sitepackages" "$(pwd)" - popd >/dev/null -} - -test_cdsitepackages_with_arg () { - pushd "$(pwd)" >/dev/null - pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) - sitepackage_subdir="$VIRTUAL_ENV/lib/python${pyvers}/site-packages/subdir" - mkdir -p "${sitepackage_subdir}" - cdsitepackages subdir - assertSame "$sitepackage_subdir" "$(pwd)" - popd >/dev/null -} - -test_mkvirtualenv_activates () { - mkvirtualenv "env2" - assertTrue virtualenvwrapper_verify_active_environment - assertSame "env2" $(basename "$VIRTUAL_ENV") -} - -test_mkvirtualenv_hooks () { - export pre_test_dir=$(cd "$test_dir"; pwd) - echo "echo GLOBAL premkvirtualenv >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" - chmod +x "$WORKON_HOME/premkvirtualenv" - echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" - mkvirtualenv "env3" - output=$(cat "$test_dir/catch_output") - expected="GLOBAL premkvirtualenv -GLOBAL postmkvirtualenv" - assertSame "$expected" "$output" - rm -f "$WORKON_HOME/premkvirtualenv" - rm -f "$WORKON_HOME/postmkvirtualenv" - deactivate - rmvirtualenv "env3" -} - -test_no_virtualenv () { - old_path="$PATH" - PATH="/usr/bin:/usr/local/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$HOME/bin" - mkvirtualenv should_not_be_created # 2>/dev/null - RC=$? - # Restore the path before testing because - # the test script depends on commands in the - # path. - export PATH="$old_path" - assertSame "$RC" "1" -} - -# test_mkvirtualenv_sitepackages () { -# # Without the option verify that site-packages are copied. -# mkvirtualenv "env3" -# assertSame "env3" "$(basename $VIRTUAL_ENV)" -# pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) -# sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" -# #cat "$sitepackages/easy-install.pth" -# assertTrue "Do not have expected virtualenv.py" "[ -f $sitepackages/virtualenv.py ]" -# rmvirtualenv "env3" -# -# # With the argument, verify that they are not copied. -# mkvirtualenv --no-site-packages "env4" -# assertSame "env4" $(basename "$VIRTUAL_ENV") -# pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) -# sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" -# assertTrue "[ -f $sitepackages/setuptools.pth ]" -# assertTrue "[ -f $sitepackages/easy-install.pth ]" -# assertFalse "Have virtualenv.py but should not" "[ -f $sitepackages/virtualenv.py ]" -# rmvirtualenv "env4" -# } - -test_workon () { - workon env1 - assertTrue virtualenvwrapper_verify_active_environment - assertSame "env1" $(basename "$VIRTUAL_ENV") -} - -test_workon_activate_hooks () { - for t in pre post - do - echo "echo GLOBAL ${t}activate >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/${t}activate" - chmod +x "$WORKON_HOME/${t}activate" - echo "echo ENV ${t}activate >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/env1/bin/${t}activate" - chmod +x "$WORKON_HOME/env1/bin/${t}activate" - done - - rm "$test_dir/catch_output" - - workon env1 - - output=$(cat "$test_dir/catch_output") - expected="GLOBAL preactivate -ENV preactivate -GLOBAL postactivate -ENV postactivate" - - assertSame "$expected" "$output" - - for t in pre post - do - rm -f "$WORKON_HOME/env1/bin/${t}activate" - rm -f "$WORKON_HOME/${t}activate" - done -} - -test_deactivate () { - workon env1 - assertNotNull "$VIRTUAL_ENV" - deactivate - assertNull "$VIRTUAL_ENV" - assertFalse virtualenvwrapper_verify_active_environment -} - -test_deactivate_hooks () { - workon env1 - - for t in pre post - do - echo "echo GLOBAL ${t}deactivate >> $test_dir/catch_output" > "$WORKON_HOME/${t}deactivate" - echo "echo ENV ${t}deactivate >> $test_dir/catch_output" > "$WORKON_HOME/env1/bin/${t}deactivate" - done - - deactivate - - output=$(cat "$test_dir/catch_output") - expected="ENV predeactivate -GLOBAL predeactivate -ENV postdeactivate -GLOBAL postdeactivate" - assertSame "$expected" "$output" - - for t in pre post - do - rm -f "$WORKON_HOME/env1/bin/${t}activate" - rm -f "$WORKON_HOME/${t}activate" - done -} - -test_virtualenvwrapper_show_workon_options () { - mkdir "$WORKON_HOME/not_env" - (cd "$WORKON_HOME"; ln -s env1 link_env) - envs=$(virtualenvwrapper_show_workon_options | tr '\n' ' ') - assertSame "env1 env2 link_env " "$envs" - rmdir "$WORKON_HOME/not_env" - rm -f "$WORKON_HOME/link_env" -} - -test_virtualenvwrapper_show_workon_options_no_envs () { - old_home="$WORKON_HOME" - export WORKON_HOME=${TMPDIR:-/tmp}/$$ - envs=$(virtualenvwrapper_show_workon_options 2>/dev/null | tr '\n' ' ') - assertSame "" "$envs" - export WORKON_HOME="$old_home" -} - -test_rmvirtualenv () { - mkvirtualenv "deleteme" - assertTrue "[ -d $WORKON_HOME/deleteme ]" - deactivate - rmvirtualenv "deleteme" - assertFalse "[ -d $WORKON_HOME/deleteme ]" -} - -test_rmvirtualenv_no_such_env () { - assertFalse "[ -d $WORKON_HOME/deleteme ]" - assertTrue "rmvirtualenv deleteme" -} - -test_missing_workon_home () { - save_home="$WORKON_HOME" - WORKON_HOME="/tmp/NO_SUCH_WORKON_HOME" - assertFalse "workon" - assertFalse "mkvirtualenv foo" - assertFalse "rmvirtualenv foo" - assertFalse "lssitepackages" - WORKON_HOME="$save_home" -} - -test_add2virtualenv () { - mkvirtualenv "pathtest" - add2virtualenv "/full/path" - cdsitepackages - path_file="./virtualenv_path_extensions.pth" - assertTrue "No /full/path in `cat $path_file`" "grep /full/path $path_file" - cd - -} - -test_add2virtualenv_relative () { - mkvirtualenv "pathtest" - parent_dir=$(dirname $(pwd)) - base_dir=$(basename $(pwd)) - add2virtualenv "../$base_dir" - cdsitepackages - path_file="./virtualenv_path_extensions.pth" - assertTrue "No $parent_dir/$base_dir in \"`cat $path_file`\"" "grep \"$parent_dir/$base_dir\" $path_file" - cd - >/dev/null 2>&1 -} - -test_lssitepackages () { - mkvirtualenv "lssitepackagestest" - contents="$(lssitepackages)" - assertTrue "No easy-install.pth in $contents" "echo $contents | grep easy-install.pth" -} - -test_lssitepackages_add2virtualenv () { - mkvirtualenv "lssitepackagestest" - parent_dir=$(dirname $(pwd)) - base_dir=$(basename $(pwd)) - add2virtualenv "../$base_dir" - contents="$(lssitepackages)" - assertTrue "No $base_dir in $contents" "echo $contents | grep $base_dir" -} - . "$test_dir/shunit2" diff --git a/tests/test_add2virtualenv.sh b/tests/test_add2virtualenv.sh new file mode 100644 index 0000000..8247b5f --- /dev/null +++ b/tests/test_add2virtualenv.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +#set -x + +test_dir=$(dirname $0) +source "$test_dir/../virtualenvwrapper_bashrc" + +export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +test_add2virtualenv () { + mkvirtualenv "pathtest" + add2virtualenv "/full/path" + cdsitepackages + path_file="./virtualenv_path_extensions.pth" + assertTrue "No /full/path in `cat $path_file`" "grep /full/path $path_file" + cd - +} + +test_add2virtualenv_relative () { + mkvirtualenv "pathtest" + parent_dir=$(dirname $(pwd)) + base_dir=$(basename $(pwd)) + add2virtualenv "../$base_dir" + cdsitepackages + path_file="./virtualenv_path_extensions.pth" + assertTrue "No $parent_dir/$base_dir in \"`cat $path_file`\"" "grep \"$parent_dir/$base_dir\" $path_file" + cd - >/dev/null 2>&1 +} + + +. "$test_dir/shunit2" diff --git a/tests/test_cd.sh b/tests/test_cd.sh new file mode 100644 index 0000000..62122d0 --- /dev/null +++ b/tests/test_cd.sh @@ -0,0 +1,53 @@ +#!/bin/sh + +#set -x + +test_dir=$(dirname $0) +source "$test_dir/../virtualenvwrapper_bashrc" + +export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +test_cdvirtual() { + pushd "$(pwd)" >/dev/null + cdvirtualenv + assertSame "$VIRTUAL_ENV" "$(pwd)" + cdvirtualenv bin + assertSame "$VIRTUAL_ENV/bin" "$(pwd)" + popd >/dev/null +} + +test_cdsitepackages () { + pushd "$(pwd)" >/dev/null + cdsitepackages + pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) + sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" + assertSame "$sitepackages" "$(pwd)" + popd >/dev/null +} + +test_cdsitepackages_with_arg () { + pushd "$(pwd)" >/dev/null + pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) + sitepackage_subdir="$VIRTUAL_ENV/lib/python${pyvers}/site-packages/subdir" + mkdir -p "${sitepackage_subdir}" + cdsitepackages subdir + assertSame "$sitepackage_subdir" "$(pwd)" + popd >/dev/null +} + + +. "$test_dir/shunit2" diff --git a/tests/test_ls.sh b/tests/test_ls.sh new file mode 100644 index 0000000..63f58c3 --- /dev/null +++ b/tests/test_ls.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +#set -x + +test_dir=$(dirname $0) +source "$test_dir/../virtualenvwrapper_bashrc" + +export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +test_lssitepackages () { + mkvirtualenv "lssitepackagestest" + contents="$(lssitepackages)" + assertTrue "No easy-install.pth in $contents" "echo $contents | grep easy-install.pth" +} + +test_lssitepackages_add2virtualenv () { + mkvirtualenv "lssitepackagestest" + parent_dir=$(dirname $(pwd)) + base_dir=$(basename $(pwd)) + add2virtualenv "../$base_dir" + contents="$(lssitepackages)" + assertTrue "No $base_dir in $contents" "echo $contents | grep $base_dir" +} + + +. "$test_dir/shunit2" diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh new file mode 100644 index 0000000..cf32475 --- /dev/null +++ b/tests/test_mkvirtualenv.sh @@ -0,0 +1,90 @@ +#!/bin/sh + +#set -x + +test_dir=$(dirname $0) +source "$test_dir/../virtualenvwrapper_bashrc" + +export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +test_mkvirtualenv() { + mkvirtualenv "env1" + assertTrue "Environment directory was not created" "[ -d $WORKON_HOME/env1 ]" + for hook in postactivate predeactivate postdeactivate + do + assertTrue "env1 $hook was not created" "[ -f $WORKON_HOME/env1/bin/$hook ]" + assertTrue "env1 $hook is not executable" "[ -x $WORKON_HOME/env1/bin/$hook ]" + done +} + +test_mkvirtualenv_activates () { + mkvirtualenv "env2" + assertTrue virtualenvwrapper_verify_active_environment + assertSame "env2" $(basename "$VIRTUAL_ENV") +} + +test_mkvirtualenv_hooks () { + export pre_test_dir=$(cd "$test_dir"; pwd) + echo "echo GLOBAL premkvirtualenv >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" + chmod +x "$WORKON_HOME/premkvirtualenv" + echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" + mkvirtualenv "env3" + output=$(cat "$test_dir/catch_output") + expected="GLOBAL premkvirtualenv +GLOBAL postmkvirtualenv" + assertSame "$expected" "$output" + rm -f "$WORKON_HOME/premkvirtualenv" + rm -f "$WORKON_HOME/postmkvirtualenv" + deactivate + rmvirtualenv "env3" +} + +test_no_virtualenv () { + old_path="$PATH" + PATH="/usr/bin:/usr/local/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$HOME/bin" + mkvirtualenv should_not_be_created # 2>/dev/null + RC=$? + # Restore the path before testing because + # the test script depends on commands in the + # path. + export PATH="$old_path" + assertSame "$RC" "1" +} + +# test_mkvirtualenv_sitepackages () { +# # Without the option verify that site-packages are copied. +# mkvirtualenv "env3" +# assertSame "env3" "$(basename $VIRTUAL_ENV)" +# pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) +# sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" +# #cat "$sitepackages/easy-install.pth" +# assertTrue "Do not have expected virtualenv.py" "[ -f $sitepackages/virtualenv.py ]" +# rmvirtualenv "env3" +# +# # With the argument, verify that they are not copied. +# mkvirtualenv --no-site-packages "env4" +# assertSame "env4" $(basename "$VIRTUAL_ENV") +# pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) +# sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" +# assertTrue "[ -f $sitepackages/setuptools.pth ]" +# assertTrue "[ -f $sitepackages/easy-install.pth ]" +# assertFalse "Have virtualenv.py but should not" "[ -f $sitepackages/virtualenv.py ]" +# rmvirtualenv "env4" +# } + + +. "$test_dir/shunit2" diff --git a/tests/test_rmvirtualenv.sh b/tests/test_rmvirtualenv.sh new file mode 100644 index 0000000..4b9c8a4 --- /dev/null +++ b/tests/test_rmvirtualenv.sh @@ -0,0 +1,73 @@ +#!/bin/sh + +#set -x + +test_dir=$(dirname $0) +source "$test_dir/../virtualenvwrapper_bashrc" + +export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +test_rmvirtualenv () { + mkvirtualenv "deleteme" + assertTrue "[ -d $WORKON_HOME/deleteme ]" + deactivate + rmvirtualenv "deleteme" + assertFalse "[ -d $WORKON_HOME/deleteme ]" +} + +test_rmvirtualenv_no_such_env () { + assertFalse "[ -d $WORKON_HOME/deleteme ]" + assertTrue "rmvirtualenv deleteme" +} + +test_add2virtualenv () { + mkvirtualenv "pathtest" + add2virtualenv "/full/path" + cdsitepackages + path_file="./virtualenv_path_extensions.pth" + assertTrue "No /full/path in `cat $path_file`" "grep /full/path $path_file" + cd - +} + +test_add2virtualenv_relative () { + mkvirtualenv "pathtest" + parent_dir=$(dirname $(pwd)) + base_dir=$(basename $(pwd)) + add2virtualenv "../$base_dir" + cdsitepackages + path_file="./virtualenv_path_extensions.pth" + assertTrue "No $parent_dir/$base_dir in \"`cat $path_file`\"" "grep \"$parent_dir/$base_dir\" $path_file" + cd - >/dev/null 2>&1 +} + +test_lssitepackages () { + mkvirtualenv "lssitepackagestest" + contents="$(lssitepackages)" + assertTrue "No easy-install.pth in $contents" "echo $contents | grep easy-install.pth" +} + +test_lssitepackages_add2virtualenv () { + mkvirtualenv "lssitepackagestest" + parent_dir=$(dirname $(pwd)) + base_dir=$(basename $(pwd)) + add2virtualenv "../$base_dir" + contents="$(lssitepackages)" + assertTrue "No $base_dir in $contents" "echo $contents | grep $base_dir" +} + + +. "$test_dir/shunit2" diff --git a/tests/test_run_hook.sh b/tests/test_run_hook.sh new file mode 100644 index 0000000..ac28faa --- /dev/null +++ b/tests/test_run_hook.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +#set -x + +test_dir=$(dirname $0) +source "$test_dir/../virtualenvwrapper_bashrc" + +export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +test_virtualenvwrapper_run_hook() { + echo "echo run >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/test_hook" + chmod +x "$WORKON_HOME/test_hook" + virtualenvwrapper_run_hook "$WORKON_HOME/test_hook" + output=$(cat "$test_dir/catch_output") + expected="run" + assertSame "$expected" "$output" +} + +test_virtualenvwrapper_run_hook_permissions() { + echo "echo run >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/test_hook" + chmod -x "$WORKON_HOME/test_hook" + virtualenvwrapper_run_hook "$WORKON_HOME/test_hook" + output=$(cat "$test_dir/catch_output") + expected="" + assertSame "$expected" "$output" +} + +. "$test_dir/shunit2" diff --git a/tests/test_workon.sh b/tests/test_workon.sh new file mode 100644 index 0000000..e311a05 --- /dev/null +++ b/tests/test_workon.sh @@ -0,0 +1,119 @@ +#!/bin/sh + +#set -x + +test_dir=$(dirname $0) +source "$test_dir/../virtualenvwrapper_bashrc" + +export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + mkvirtualenv "env1" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +test_workon () { + workon env1 + assertTrue virtualenvwrapper_verify_active_environment + assertSame "env1" $(basename "$VIRTUAL_ENV") +} + +test_workon_activate_hooks () { + for t in pre post + do + echo "echo GLOBAL ${t}activate >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/${t}activate" + chmod +x "$WORKON_HOME/${t}activate" + echo "echo ENV ${t}activate >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/env1/bin/${t}activate" + chmod +x "$WORKON_HOME/env1/bin/${t}activate" + done + + rm "$test_dir/catch_output" + + workon env1 + + output=$(cat "$test_dir/catch_output") + expected="GLOBAL preactivate +ENV preactivate +GLOBAL postactivate +ENV postactivate" + + assertSame "$expected" "$output" + + for t in pre post + do + rm -f "$WORKON_HOME/env1/bin/${t}activate" + rm -f "$WORKON_HOME/${t}activate" + done +} + +test_deactivate () { + workon env1 + assertNotNull "$VIRTUAL_ENV" + deactivate + assertNull "$VIRTUAL_ENV" + assertFalse virtualenvwrapper_verify_active_environment +} + +test_deactivate_hooks () { + workon env1 + + for t in pre post + do + echo "echo GLOBAL ${t}deactivate >> $test_dir/catch_output" > "$WORKON_HOME/${t}deactivate" + echo "echo ENV ${t}deactivate >> $test_dir/catch_output" > "$WORKON_HOME/env1/bin/${t}deactivate" + done + + deactivate + + output=$(cat "$test_dir/catch_output") + expected="ENV predeactivate +GLOBAL predeactivate +ENV postdeactivate +GLOBAL postdeactivate" + assertSame "$expected" "$output" + + for t in pre post + do + rm -f "$WORKON_HOME/env1/bin/${t}activate" + rm -f "$WORKON_HOME/${t}activate" + done +} + +test_virtualenvwrapper_show_workon_options () { + mkdir "$WORKON_HOME/not_env" + (cd "$WORKON_HOME"; ln -s env1 link_env) + envs=$(virtualenvwrapper_show_workon_options | tr '\n' ' ') + assertSame "env1 link_env " "$envs" + rmdir "$WORKON_HOME/not_env" + rm -f "$WORKON_HOME/link_env" +} + +test_virtualenvwrapper_show_workon_options_no_envs () { + old_home="$WORKON_HOME" + export WORKON_HOME=${TMPDIR:-/tmp}/$$ + envs=$(virtualenvwrapper_show_workon_options 2>/dev/null | tr '\n' ' ') + assertSame "" "$envs" + export WORKON_HOME="$old_home" +} + +test_missing_workon_home () { + save_home="$WORKON_HOME" + WORKON_HOME="/tmp/NO_SUCH_WORKON_HOME" + assertFalse "workon" + assertFalse "mkvirtualenv foo" + assertFalse "rmvirtualenv foo" + assertFalse "lssitepackages" + WORKON_HOME="$save_home" +} + +. "$test_dir/shunit2" From 853b0007f8ec618cf4bbf7945c9b64c84cbb2ab4 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 20 Mar 2010 09:06:21 -0400 Subject: [PATCH 131/947] remove directories likely to contain a site-wide virtualenv installation and hide the error message because we expect mkvirtualenv to fail --- tests/test_mkvirtualenv.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index cf32475..c9f6b73 100644 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -55,8 +55,8 @@ GLOBAL postmkvirtualenv" test_no_virtualenv () { old_path="$PATH" - PATH="/usr/bin:/usr/local/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$HOME/bin" - mkvirtualenv should_not_be_created # 2>/dev/null + PATH="/usr/bin:/bin:/usr/sbin:/sbin" + mkvirtualenv should_not_be_created 2>/dev/null RC=$? # Restore the path before testing because # the test script depends on commands in the From 0f803031443fc2797b2c3e18488d888df22420cc Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 20 Mar 2010 10:18:46 -0400 Subject: [PATCH 132/947] fix #26 by quieting the error message during init and only showing it when an action is explicitly taken by the user --- tests/test.sh | 19 +++++++++++++++ tests/test_cd.sh | 16 +++++++++++++ tests/test_ls.sh | 8 +++++++ tests/test_misconfigured.sh | 46 ------------------------------------- tests/test_mkvirtualenv.sh | 14 ++++++++--- tests/test_rmvirtualenv.sh | 43 +++++++--------------------------- tests/test_workon.sh | 14 +++++------ virtualenvwrapper_bashrc | 8 +++++-- 8 files changed, 74 insertions(+), 94 deletions(-) delete mode 100644 tests/test_misconfigured.sh diff --git a/tests/test.sh b/tests/test.sh index 6f8077e..3247555 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -30,6 +30,25 @@ test_virtualenvwrapper_initialize() { done } +test_virtualenvwrapper_verify_workon_home() { + assertTrue "WORKON_HOME not verified" virtualenvwrapper_verify_workon_home +} + +test_virtualenvwrapper_verify_workon_home_missing_dir() { + old_home="$WORKON_HOME" + WORKON_HOME="$WORKON_HOME/not_there" + assertFalse "WORKON_HOME verified unexpectedly" virtualenvwrapper_verify_workon_home + WORKON_HOME="$old_home" +} + +test_virtualenvwrapper_verify_workon_home_missing_dir_quiet_init() { + old_home="$WORKON_HOME" + export WORKON_HOME="$WORKON_HOME/not_there" + output=`$SHELL $test_dir/../virtualenvwrapper_bashrc 2>&1` + assertSame "" "$output" + WORKON_HOME="$old_home" +} + test_get_python_version() { expected=$(python -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d.) actual=$(virtualenvwrapper_get_python_version) diff --git a/tests/test_cd.sh b/tests/test_cd.sh index 62122d0..6a2b24d 100644 --- a/tests/test_cd.sh +++ b/tests/test_cd.sh @@ -49,5 +49,21 @@ test_cdsitepackages_with_arg () { popd >/dev/null } +test_cdvirtualenv_no_workon_home () { + old_home="$WORKON_HOME" + export WORKON_HOME="$WORKON_HOME/not_there" + output=`cdvirtualenv 2>&1` + assertTrue "Did not see expected message" "echo $output | grep 'does not exist'" + WORKON_HOME="$old_home" +} + +test_cdsitepackages_no_workon_home () { + old_home="$WORKON_HOME" + export WORKON_HOME="$WORKON_HOME/not_there" + output=`cdsitepackages 2>&1` + assertTrue "Did not see expected message" "echo $output | grep 'does not exist'" + WORKON_HOME="$old_home" +} + . "$test_dir/shunit2" diff --git a/tests/test_ls.sh b/tests/test_ls.sh index 63f58c3..3a9c4a0 100644 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -36,5 +36,13 @@ test_lssitepackages_add2virtualenv () { assertTrue "No $base_dir in $contents" "echo $contents | grep $base_dir" } +test_no_workon_home () { + old_home="$WORKON_HOME" + export WORKON_HOME="$WORKON_HOME/not_there" + output=`lssitepackages should_not_be_created 2>&1` + assertTrue "Did not see expected message" "echo $output | grep 'does not exist'" + WORKON_HOME="$old_home" +} + . "$test_dir/shunit2" diff --git a/tests/test_misconfigured.sh b/tests/test_misconfigured.sh deleted file mode 100644 index e56af68..0000000 --- a/tests/test_misconfigured.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh - -#set -x - -test_dir=$(dirname $0) - -export SCRATCH_DIR="${TMPDIR:-/tmp}/$$" - -oneTimeSetUp() { - rm -rf "$SCRATCH_DIR" - mkdir -p "$SCRATCH_DIR" -} - -oneTimeTearDown() { - rm -rf "$SCRATCH_DIR" -} - -test_workon_home_missing_bash () { - export WORKON_HOME="$SCRATCH_DIR/no_such_subdir" - bash -ec "source $test_dir/../virtualenvwrapper_bashrc" 2>/dev/null - RC=$? - assertSame "1" "$RC" -} - -test_workon_home_missing_zsh () { - export WORKON_HOME="$SCRATCH_DIR/no_such_subdir" - zsh -ec "source $test_dir/../virtualenvwrapper_bashrc" 2>/dev/null - RC=$? - assertSame "1" "$RC" -} - -test_shell_expansion_fails_bash () { - export WORKON_HOME="$SCRATCH_DIR/\$no_such_var" - bash -ec "source $test_dir/../virtualenvwrapper_bashrc" 2>/dev/null - RC=$? - assertSame "1" "$RC" -} - -test_shell_expansion_fails_zsh () { - export WORKON_HOME="$SCRATCH_DIR/\$no_such_var" - zsh -ec "source $test_dir/../virtualenvwrapper_bashrc" 2>/dev/null - RC=$? - assertSame "1" "$RC" -} - -. "$test_dir/shunit2" diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index c9f6b73..3167c49 100644 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -21,7 +21,7 @@ setUp () { rm -f "$test_dir/catch_output" } -test_mkvirtualenv() { +test_create() { mkvirtualenv "env1" assertTrue "Environment directory was not created" "[ -d $WORKON_HOME/env1 ]" for hook in postactivate predeactivate postdeactivate @@ -31,13 +31,13 @@ test_mkvirtualenv() { done } -test_mkvirtualenv_activates () { +test_activates () { mkvirtualenv "env2" assertTrue virtualenvwrapper_verify_active_environment assertSame "env2" $(basename "$VIRTUAL_ENV") } -test_mkvirtualenv_hooks () { +test_hooks () { export pre_test_dir=$(cd "$test_dir"; pwd) echo "echo GLOBAL premkvirtualenv >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" chmod +x "$WORKON_HOME/premkvirtualenv" @@ -65,6 +65,14 @@ test_no_virtualenv () { assertSame "$RC" "1" } +test_no_workon_home () { + old_home="$WORKON_HOME" + export WORKON_HOME="$WORKON_HOME/not_there" + output=`mkvirtualenv should_not_be_created 2>&1` + assertTrue "Did not see expected message" "echo $output | grep 'does not exist'" + WORKON_HOME="$old_home" +} + # test_mkvirtualenv_sitepackages () { # # Without the option verify that site-packages are copied. # mkvirtualenv "env3" diff --git a/tests/test_rmvirtualenv.sh b/tests/test_rmvirtualenv.sh index 4b9c8a4..e26e1ea 100644 --- a/tests/test_rmvirtualenv.sh +++ b/tests/test_rmvirtualenv.sh @@ -21,7 +21,7 @@ setUp () { rm -f "$test_dir/catch_output" } -test_rmvirtualenv () { +test_remove () { mkvirtualenv "deleteme" assertTrue "[ -d $WORKON_HOME/deleteme ]" deactivate @@ -29,44 +29,17 @@ test_rmvirtualenv () { assertFalse "[ -d $WORKON_HOME/deleteme ]" } -test_rmvirtualenv_no_such_env () { +test_no_such_env () { assertFalse "[ -d $WORKON_HOME/deleteme ]" assertTrue "rmvirtualenv deleteme" } -test_add2virtualenv () { - mkvirtualenv "pathtest" - add2virtualenv "/full/path" - cdsitepackages - path_file="./virtualenv_path_extensions.pth" - assertTrue "No /full/path in `cat $path_file`" "grep /full/path $path_file" - cd - -} - -test_add2virtualenv_relative () { - mkvirtualenv "pathtest" - parent_dir=$(dirname $(pwd)) - base_dir=$(basename $(pwd)) - add2virtualenv "../$base_dir" - cdsitepackages - path_file="./virtualenv_path_extensions.pth" - assertTrue "No $parent_dir/$base_dir in \"`cat $path_file`\"" "grep \"$parent_dir/$base_dir\" $path_file" - cd - >/dev/null 2>&1 -} - -test_lssitepackages () { - mkvirtualenv "lssitepackagestest" - contents="$(lssitepackages)" - assertTrue "No easy-install.pth in $contents" "echo $contents | grep easy-install.pth" -} - -test_lssitepackages_add2virtualenv () { - mkvirtualenv "lssitepackagestest" - parent_dir=$(dirname $(pwd)) - base_dir=$(basename $(pwd)) - add2virtualenv "../$base_dir" - contents="$(lssitepackages)" - assertTrue "No $base_dir in $contents" "echo $contents | grep $base_dir" +test_no_workon_home () { + old_home="$WORKON_HOME" + export WORKON_HOME="$WORKON_HOME/not_there" + output=`rmvirtualenv should_not_be_created 2>&1` + assertTrue "Did not see expected message" "echo $output | grep 'does not exist'" + WORKON_HOME="$old_home" } diff --git a/tests/test_workon.sh b/tests/test_workon.sh index e311a05..b0098d1 100644 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -106,14 +106,12 @@ test_virtualenvwrapper_show_workon_options_no_envs () { export WORKON_HOME="$old_home" } -test_missing_workon_home () { - save_home="$WORKON_HOME" - WORKON_HOME="/tmp/NO_SUCH_WORKON_HOME" - assertFalse "workon" - assertFalse "mkvirtualenv foo" - assertFalse "rmvirtualenv foo" - assertFalse "lssitepackages" - WORKON_HOME="$save_home" +test_no_workon_home () { + old_home="$WORKON_HOME" + export WORKON_HOME="$WORKON_HOME/not_there" + output=`workon should_not_be_created 2>&1` + assertTrue "Did not see expected message" "echo $output | grep 'does not exist'" + WORKON_HOME="$old_home" } . "$test_dir/shunit2" diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 96cfa1d..76ce70a 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -60,7 +60,7 @@ export WORKON_HOME function virtualenvwrapper_verify_workon_home () { if [ ! -d "$WORKON_HOME" ] then - echo "ERROR: Virtual environments directory '$WORKON_HOME' does not exist." >&2 + [ "$1" != "-q" ] && echo "ERROR: Virtual environments directory '$WORKON_HOME' does not exist. Create it or set WORKON_HOME to an existing directory." >&2 return 1 fi return 0 @@ -90,7 +90,7 @@ EOF # Set up virtualenvwrapper properly function virtualenvwrapper_initialize () { - virtualenvwrapper_verify_workon_home || return 1 + virtualenvwrapper_verify_workon_home -q || return 1 # mkvirtualenv virtualenvwrapper_make_hook "$WORKON_HOME/premkvirtualenv" \ "This hook is run after a new virtualenv is created and before it is activated." @@ -352,6 +352,7 @@ function virtualenvwrapper_get_site_packages_dir () { # created first. function add2virtualenv () { + virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 site_packages="`virtualenvwrapper_get_site_packages_dir`" @@ -392,6 +393,7 @@ function add2virtualenv () { # Does a ``cd`` to the site-packages directory of the currently-active # virtualenv. function cdsitepackages () { + virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 site_packages="`virtualenvwrapper_get_site_packages_dir`" cd "$site_packages"/$1 @@ -399,6 +401,7 @@ function cdsitepackages () { # Does a ``cd`` to the root of the currently-active virtualenv. function cdvirtualenv () { + virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 cd $VIRTUAL_ENV/$1 } @@ -406,6 +409,7 @@ function cdvirtualenv () { # Shows the content of the site-packages directory of the currently-active # virtualenv function lssitepackages () { + virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 site_packages="`virtualenvwrapper_get_site_packages_dir`" ls $@ $site_packages From aa94706a90ef3ebdc3549f0e83c28593348f864f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 20 Mar 2010 10:21:52 -0400 Subject: [PATCH 133/947] preparing version 1.26 for release --- docsource/history.rst | 8 ++++++++ pavement.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docsource/history.rst b/docsource/history.rst index 4d2dd65..7d41bad 100644 --- a/docsource/history.rst +++ b/docsource/history.rst @@ -2,6 +2,14 @@ Release History =============== +1.26 + + - Fix a problem with error messages showing up during init for users + with the wrappers installed site-wide but who are not actually + using them. See issue #26. + - Split up the tests into multiple files. + - Run all tests with all supported shells. + 1.25 - Merged in changes to cdsitepackages from William McVey. It now diff --git a/pavement.py b/pavement.py index ebe6647..3d22da4 100644 --- a/pavement.py +++ b/pavement.py @@ -27,7 +27,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.25' +VERSION = '1.26' os.environ['VERSION'] = VERSION # Read the long description to give to setup From 55a909e5d7f4c2b27a7f484571cca436004a648a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 20 Mar 2010 10:21:54 -0400 Subject: [PATCH 134/947] Added tag 1.26 for changeset 51eef82a39d4 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 61e1aee..7d0622e 100644 --- a/.hgtags +++ b/.hgtags @@ -40,3 +40,4 @@ b243d023094b6b0ef1b834dcc100f8c342c67537 1.24 4a8870326d84f97d5539b586b21419ba330fea48 1.24.1 f318697791416cf0897091718d542e8045854233 1.24.2 06229877a640ecb490faf46f923d8be916a0ebed 1.25 +51eef82a39d431cee156fea7005fa1631e21655e 1.26 From bb6c695768aa2495d09fad1652f158050a8906ed Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Mon, 22 Mar 2010 13:42:30 +0100 Subject: [PATCH 135/947] add testpackage setup.py --- README | 2 +- docsource/command_ref.rst | 9 ++++++++ docsource/developers.rst | 3 ++- docsource/history.rst | 2 ++ tests/test.sh | 32 ++++++++++++++++++++++++- tests/testpackage/setup.py | 13 +++++++++++ tests/testpackage/testscript.py | 7 ++++++ virtualenvwrapper_bashrc | 41 ++++++++++++++++++++++++++++++++- 8 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 tests/testpackage/setup.py create mode 100644 tests/testpackage/testscript.py diff --git a/README b/README index 81158ca..6bee6a5 100644 --- a/README +++ b/README @@ -15,7 +15,7 @@ Features 1. Organizes all of your virtual environments in one place. -2. Wrappers for creating and deleting environments, including +2. Wrappers for creating, copying and deleting environments, including user-configurable hooks. 3. Use a single command to switch between environments. diff --git a/docsource/command_ref.rst b/docsource/command_ref.rst index 9e52ad7..b84507c 100644 --- a/docsource/command_ref.rst +++ b/docsource/command_ref.rst @@ -31,6 +31,15 @@ Syntax:: rmvirtualenv ENVNAME +cpvirtualenv +------------ + +Duplicate an environment, in the WORKON_HOME. + +Syntax:: + + cpvirtualenv ENVNAME TARGETENVNAME + workon ------ diff --git a/docsource/developers.rst b/docsource/developers.rst index 50fd757..9d1d19b 100644 --- a/docsource/developers.rst +++ b/docsource/developers.rst @@ -19,7 +19,8 @@ docs: - Sphinx - Paver -- sphinxcontrib.paverutils +- docutils +- sphinxcontrib-paverutils Once all of them are installed into a virtualenv using easy_install, run ``paver html`` to generate the HTML version of the documentation:: diff --git a/docsource/history.rst b/docsource/history.rst index ff711fd..70182ee 100644 --- a/docsource/history.rst +++ b/docsource/history.rst @@ -1,6 +1,8 @@ =============== Release History =============== + + - Added cpvirtualenv command [Thomas Desvenain] 1.24 diff --git a/tests/test.sh b/tests/test.sh index 549e1a6..7354042 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -21,6 +21,10 @@ setUp () { rm -f "$test_dir/catch_output" } +tearDown() { + echo +} + test_mkvirtualenv() { mkvirtualenv "env1" assertTrue "Environment directory was not created" "[ -d $WORKON_HOME/env1 ]" @@ -267,7 +271,7 @@ test_add2virtualenv_relative () { test_lssitepackages () { mkvirtualenv "lssitepackagestest" contents="$(lssitepackages)" - assertTrue "No easy-install.pth in $contents" "echo $contents | grep easy-install.pth" + assertTrue "No easy-install.pth in $/contents" "echo $contents | grep easy-install.pth" } test_lssitepackages_add2virtualenv () { @@ -279,5 +283,31 @@ test_lssitepackages_add2virtualenv () { assertTrue "No $base_dir in $contents" "echo $contents | grep $base_dir" } +test_cpvirtualenv () { + mkvirtualenv "cpvirtualenvtest" + $VIRTUAL_ENV/bin/easy_install "tests/testpackage" + cpvirtualenv "cpvirtualenvtest" "cpvirtualenvcopy" + deactivate + rmvirtualenv "cpvirtualenvtest" + workon "cpvirtualenvcopy" + testscript="$(which testscript.py)" + assertSame "$testscript" $(echo "$WORKON_HOME/cpvirtualenvcopy/bin/testscript.py") + testscriptcontent="$(cat $testscript)" + assertTrue "No cpvirtualenvtest in $/testscriptcontent" "echo $testscriptcontent | grep cpvirtualenvtest" + assertTrue virtualenvwrapper_verify_active_environment + assertSame "cpvirtualenvcopy" $(basename "$VIRTUAL_ENV") + cdvirtualenv + assertSame "$VIRTUAL_ENV" "$(pwd)" +} + +test_cprelocatablevirtualenv () { + mkvirtualenv "cprelocatabletest" + virtualenv --relocatable "$WORKON_HOME/cprelocatabletest" + cpvirtualenv "cprelocatabletest" "cprelocatablecopy" + assertTrue virtualenvwrapper_verify_active_environment + assertSame "cprelocatablecopy" $(basename "$VIRTUAL_ENV") + cdvirtualenv + assertSame "$VIRTUAL_ENV" "$(pwd)" +} . "$test_dir/shunit2" diff --git a/tests/testpackage/setup.py b/tests/testpackage/setup.py new file mode 100644 index 0000000..4e12a12 --- /dev/null +++ b/tests/testpackage/setup.py @@ -0,0 +1,13 @@ +# Test package for virtualenvwrapper tests +from setuptools import setup + +version = '1.0' + +setup( + name='testpackage', + version=version, + description="Fake package", + author="Ingeniweb", + author_email='thomas.desvenain@gmail.com', + url='http://pypi.python.org/pypi/testpackage/', + ) diff --git a/tests/testpackage/testscript.py b/tests/testpackage/testscript.py new file mode 100644 index 0000000..835111f --- /dev/null +++ b/tests/testpackage/testscript.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python + +""" +A test script +""" + +print "Hello world" diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 634f35a..11f7017 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -319,8 +319,9 @@ if [ -n "$BASH" ] ; then complete -o nospace -F _cdvirtualenv_complete -S/ cdvirtualenv complete -o default -o nospace -F _virtualenvs workon complete -o default -o nospace -F _virtualenvs rmvirtualenv + complete -o default -o nospace -F _virtualenvs cpvirtualenv elif [ -n "$ZSH_VERSION" ] ; then - compctl -g "`virtualenvwrapper_show_workon_options`" workon rmvirtualenv + compctl -g "`virtualenvwrapper_show_workon_options`" workon rmvirtualenv cpvirtualenv fi # Prints the Python version string for the current interpreter. @@ -412,3 +413,41 @@ function lssitepackages () { cat "$path_file" fi } + +function cpvirtualenv() { + + typeset env_name="$1" + if [ "$env_name" = "" ] + then + virtualenvwrapper_show_workon_options + return 1 + fi + typeset new_env="$2" + if [ "$new_env" = "" ] + then + echo "Please specify target virtualenv" + return 1 + fi + if [echo "$WORKON_HOME" | grep -e "/$"] + then + env_home="$WORKON_HOME" + else + env_home="$WORKON_HOME/" + fi + source_env="$env_home$env_name" + target_env="$env_home$new_env" + + cp -r "$source_env" "$target_env" + for script in $( ls $target_env/bin/* ) + do + newscript="$script-new" + sed "s|$source_env|$target_env|g" < "$script" > "$newscript" + mv "$newscript" "$script" + chmod a+x "$script" + done + + virtualenv "$target_env" --relocatable + sed "s/VIRTUAL_ENV\(.*\)$env_name/VIRTUAL_ENV\1$new_env/g" < "$source_env/bin/activate" > "$target_env/bin/activate" + echo "Created $new_env virtualenv" + workon "$new_env" +} From da4fd435c0723e5a511e56581aff7a85e3d17ff4 Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Mon, 22 Mar 2010 14:13:29 +0100 Subject: [PATCH 136/947] added script to setup.py --- tests/testpackage/setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/testpackage/setup.py b/tests/testpackage/setup.py index 4e12a12..67623e5 100644 --- a/tests/testpackage/setup.py +++ b/tests/testpackage/setup.py @@ -10,4 +10,5 @@ author="Ingeniweb", author_email='thomas.desvenain@gmail.com', url='http://pypi.python.org/pypi/testpackage/', + scripts=['testscript.py'] ) From 0f467cef707638232711fcef269869a5312cb34c Mon Sep 17 00:00:00 2001 From: Thomas Desvenain Date: Mon, 22 Mar 2010 15:14:33 +0100 Subject: [PATCH 137/947] added test that copied virtualenv exists --- tests/test_cp.sh | 4 ++++ virtualenvwrapper_bashrc | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/test_cp.sh b/tests/test_cp.sh index ada5764..664a11e 100644 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -49,6 +49,10 @@ test_cprelocatablevirtualenv () { assertSame "$VIRTUAL_ENV" "$(pwd)" } +test_cp_notexists () { + out="$(cpvirtualenv virtualenvthatdoesntexist foo)" + assertSame "$out" "virtualenvthatdoesntexist virtualenv doesn't exist" +} . "$test_dir/shunit2" diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index 835c8aa..de4a6fb 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -438,7 +438,7 @@ function cpvirtualenv() { echo "Please specify target virtualenv" return 1 fi - if [echo "$WORKON_HOME" | grep -e "/$"] + if echo "$WORKON_HOME" | grep -e "/$" then env_home="$WORKON_HOME" else @@ -446,6 +446,12 @@ function cpvirtualenv() { fi source_env="$env_home$env_name" target_env="$env_home$new_env" + + if [ ! -e "$source_env" ] + then + echo "$env_name virtualenv doesn't exist" + return 1 + fi cp -r "$source_env" "$target_env" for script in $( ls $target_env/bin/* ) From a37786daf9f29c8c1b54955fbdb0c28b877e363f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 31 Mar 2010 11:34:39 -0400 Subject: [PATCH 138/947] ignore build files created by tests --- .hgignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.hgignore b/.hgignore index 24aaa95..2ff7dd1 100644 --- a/.hgignore +++ b/.hgignore @@ -8,6 +8,9 @@ docs *.pyc sphinx/web/templates/base.html tests/catch_output +tests/testpackage/build +tests/testpackage/dist +tests/testpackage/testpackage.egg-info syntax: re .DS_Store From 765815e67581d50d09c575e77b0b80e75c07eb66 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 31 Mar 2010 11:34:51 -0400 Subject: [PATCH 139/947] quiet tests --- pavement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pavement.py b/pavement.py index f028af7..a5f7de5 100644 --- a/pavement.py +++ b/pavement.py @@ -194,7 +194,7 @@ def test_install(options): def test(): #test_scripts = glob.glob('./tests/test*.sh') test_scripts = path('tests').glob('test*.sh') - print test_scripts + #print test_scripts for shell_cmd in [ 'bash', 'sh', 'SHUNIT_PARENT=%(test_script)s zsh -o shwordsplit' ]: for test_script in test_scripts: base_cmd = shell_cmd + ' %(test_script)s' From 7f3c969e37a1f49cd3291bc7409141118ab30c3f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 31 Mar 2010 11:51:01 -0400 Subject: [PATCH 140/947] flush formatting prints --- pavement.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pavement.py b/pavement.py index a5f7de5..ccf8f28 100644 --- a/pavement.py +++ b/pavement.py @@ -9,6 +9,7 @@ # Standard library import copy import os +import sys # Third-party @@ -201,5 +202,6 @@ def test(): cmd = base_cmd % locals() print '*' * 80 print + sys.stdout.flush() sh(cmd) return From 530069a16bc9c8abae845306e0f1d23f5e48dee3 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 31 Mar 2010 11:51:12 -0400 Subject: [PATCH 141/947] touch up tests --- tests/test_cp.sh | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/tests/test_cp.sh b/tests/test_cp.sh index 664a11e..1e295a8 100644 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -7,46 +7,42 @@ source "$test_dir/../virtualenvwrapper_bashrc" export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" -oneTimeSetUp() { +setUp () { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" + echo + rm -f "$test_dir/catch_output" } -oneTimeTearDown() { +tearDown() { rm -rf "$WORKON_HOME" } -setUp () { - echo - rm -f "$test_dir/catch_output" -} - test_cpvirtualenv () { - mkvirtualenv "cpvirtualenvtest" - $VIRTUAL_ENV/bin/easy_install "tests/testpackage" - cpvirtualenv "cpvirtualenvtest" "cpvirtualenvcopy" + mkvirtualenv "source" + (cd tests/testpackage && python setup.py install) + cpvirtualenv "source" "destination" deactivate - rmvirtualenv "cpvirtualenvtest" - workon "cpvirtualenvcopy" + rmvirtualenv "source" + workon "destination" testscript="$(which testscript.py)" - assertSame "$testscript" $(echo "$WORKON_HOME/cpvirtualenvcopy/bin/testscript.py") + assertTrue "Environment test script not found in path" "[ $WORKON_HOME/destination/bin/testscript.py -ef $testscript ]" testscriptcontent="$(cat $testscript)" assertTrue "No cpvirtualenvtest in $/testscriptcontent" "echo $testscriptcontent | grep cpvirtualenvtest" assertTrue virtualenvwrapper_verify_active_environment - assertSame "cpvirtualenvcopy" $(basename "$VIRTUAL_ENV") - cdvirtualenv - assertSame "$VIRTUAL_ENV" "$(pwd)" + assertSame "Wrong virtualenv name" "destination" $(basename "$VIRTUAL_ENV") } test_cprelocatablevirtualenv () { - mkvirtualenv "cprelocatabletest" - virtualenv --relocatable "$WORKON_HOME/cprelocatabletest" - cpvirtualenv "cprelocatabletest" "cprelocatablecopy" + mkvirtualenv "source" + (cd tests/testpackage && python setup.py install) + assertTrue "virtualenv --relocatable \"$WORKON_HOME/source\"" + cpvirtualenv "source" "destination" + testscript="$(which testscript.py)" + assertTrue "Environment test script not the same as copy" "[ $WORKON_HOME/destination/bin/testscript.py -ef $testscript ]" assertTrue virtualenvwrapper_verify_active_environment - assertSame "cprelocatablecopy" $(basename "$VIRTUAL_ENV") - cdvirtualenv - assertSame "$VIRTUAL_ENV" "$(pwd)" + assertSame "Wrong virtualenv name" "destination" $(basename "$VIRTUAL_ENV") } test_cp_notexists () { From 413eb4708bf42d857d04a1a831a7cc7f0661ee3a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 31 Mar 2010 11:54:24 -0400 Subject: [PATCH 142/947] undo merge, tests moved to separate files --- tests/test.sh | 284 +++----------------------------------------------- 1 file changed, 15 insertions(+), 269 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index 7354042..3247555 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -21,20 +21,6 @@ setUp () { rm -f "$test_dir/catch_output" } -tearDown() { - echo -} - -test_mkvirtualenv() { - mkvirtualenv "env1" - assertTrue "Environment directory was not created" "[ -d $WORKON_HOME/env1 ]" - for hook in postactivate predeactivate postdeactivate - do - assertTrue "env1 $hook was not created" "[ -f $WORKON_HOME/env1/bin/$hook ]" - assertTrue "env1 $hook is not executable" "[ -x $WORKON_HOME/env1/bin/$hook ]" - done -} - test_virtualenvwrapper_initialize() { virtualenvwrapper_initialize for hook in premkvirtualenv postmkvirtualenv prermvirtualenv postrmvirtualenv preactivate postactivate predeactivate postdeactivate @@ -44,22 +30,23 @@ test_virtualenvwrapper_initialize() { done } -test_virtualenvwrapper_run_hook() { - echo "echo run >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/test_hook" - chmod +x "$WORKON_HOME/test_hook" - virtualenvwrapper_run_hook "$WORKON_HOME/test_hook" - output=$(cat "$test_dir/catch_output") - expected="run" - assertSame "$expected" "$output" +test_virtualenvwrapper_verify_workon_home() { + assertTrue "WORKON_HOME not verified" virtualenvwrapper_verify_workon_home } -test_virtualenvwrapper_run_hook_permissions() { - echo "echo run >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/test_hook" - chmod -x "$WORKON_HOME/test_hook" - virtualenvwrapper_run_hook "$WORKON_HOME/test_hook" - output=$(cat "$test_dir/catch_output") - expected="" - assertSame "$expected" "$output" +test_virtualenvwrapper_verify_workon_home_missing_dir() { + old_home="$WORKON_HOME" + WORKON_HOME="$WORKON_HOME/not_there" + assertFalse "WORKON_HOME verified unexpectedly" virtualenvwrapper_verify_workon_home + WORKON_HOME="$old_home" +} + +test_virtualenvwrapper_verify_workon_home_missing_dir_quiet_init() { + old_home="$WORKON_HOME" + export WORKON_HOME="$WORKON_HOME/not_there" + output=`$SHELL $test_dir/../virtualenvwrapper_bashrc 2>&1` + assertSame "" "$output" + WORKON_HOME="$old_home" } test_get_python_version() { @@ -68,246 +55,5 @@ test_get_python_version() { assertSame "$expected" "$actual" } -test_cdvirtual() { - pushd "$(pwd)" >/dev/null - cdvirtualenv - assertSame "$VIRTUAL_ENV" "$(pwd)" - cdvirtualenv bin - assertSame "$VIRTUAL_ENV/bin" "$(pwd)" - popd >/dev/null -} - -test_cdsitepackages () { - pushd "$(pwd)" >/dev/null - cdsitepackages - pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) - sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" - assertSame "$sitepackages" "$(pwd)" - popd >/dev/null -} - -test_mkvirtualenv_activates () { - mkvirtualenv "env2" - assertTrue virtualenvwrapper_verify_active_environment - assertSame "env2" $(basename "$VIRTUAL_ENV") -} - -test_mkvirtualenv_hooks () { - export pre_test_dir=$(cd "$test_dir"; pwd) - echo "echo GLOBAL premkvirtualenv >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" - chmod +x "$WORKON_HOME/premkvirtualenv" - echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" - mkvirtualenv "env3" - output=$(cat "$test_dir/catch_output") - expected="GLOBAL premkvirtualenv -GLOBAL postmkvirtualenv" - assertSame "$expected" "$output" - rm -f "$WORKON_HOME/premkvirtualenv" - rm -f "$WORKON_HOME/postmkvirtualenv" - deactivate - rmvirtualenv "env3" -} - -test_no_virtualenv () { - old_path="$PATH" - PATH="/usr/bin:/usr/local/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$HOME/bin" - mkvirtualenv should_not_be_created # 2>/dev/null - RC=$? - # Restore the path before testing because - # the test script depends on commands in the - # path. - export PATH="$old_path" - assertSame "$RC" "1" -} - -# test_mkvirtualenv_sitepackages () { -# # Without the option verify that site-packages are copied. -# mkvirtualenv "env3" -# assertSame "env3" "$(basename $VIRTUAL_ENV)" -# pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) -# sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" -# #cat "$sitepackages/easy-install.pth" -# assertTrue "Do not have expected virtualenv.py" "[ -f $sitepackages/virtualenv.py ]" -# rmvirtualenv "env3" -# -# # With the argument, verify that they are not copied. -# mkvirtualenv --no-site-packages "env4" -# assertSame "env4" $(basename "$VIRTUAL_ENV") -# pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) -# sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" -# assertTrue "[ -f $sitepackages/setuptools.pth ]" -# assertTrue "[ -f $sitepackages/easy-install.pth ]" -# assertFalse "Have virtualenv.py but should not" "[ -f $sitepackages/virtualenv.py ]" -# rmvirtualenv "env4" -# } - -test_workon () { - workon env1 - assertTrue virtualenvwrapper_verify_active_environment - assertSame "env1" $(basename "$VIRTUAL_ENV") -} - -test_workon_activate_hooks () { - for t in pre post - do - echo "echo GLOBAL ${t}activate >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/${t}activate" - chmod +x "$WORKON_HOME/${t}activate" - echo "echo ENV ${t}activate >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/env1/bin/${t}activate" - chmod +x "$WORKON_HOME/env1/bin/${t}activate" - done - - rm "$test_dir/catch_output" - - workon env1 - - output=$(cat "$test_dir/catch_output") - expected="GLOBAL preactivate -ENV preactivate -GLOBAL postactivate -ENV postactivate" - - assertSame "$expected" "$output" - - for t in pre post - do - rm -f "$WORKON_HOME/env1/bin/${t}activate" - rm -f "$WORKON_HOME/${t}activate" - done -} - -test_deactivate () { - workon env1 - assertNotNull "$VIRTUAL_ENV" - deactivate - assertNull "$VIRTUAL_ENV" - assertFalse virtualenvwrapper_verify_active_environment -} - -test_deactivate_hooks () { - workon env1 - - for t in pre post - do - echo "echo GLOBAL ${t}deactivate >> $test_dir/catch_output" > "$WORKON_HOME/${t}deactivate" - echo "echo ENV ${t}deactivate >> $test_dir/catch_output" > "$WORKON_HOME/env1/bin/${t}deactivate" - done - - deactivate - - output=$(cat "$test_dir/catch_output") - expected="ENV predeactivate -GLOBAL predeactivate -ENV postdeactivate -GLOBAL postdeactivate" - assertSame "$expected" "$output" - - for t in pre post - do - rm -f "$WORKON_HOME/env1/bin/${t}activate" - rm -f "$WORKON_HOME/${t}activate" - done -} - -test_virtualenvwrapper_show_workon_options () { - mkdir "$WORKON_HOME/not_env" - (cd "$WORKON_HOME"; ln -s env1 link_env) - envs=$(virtualenvwrapper_show_workon_options | tr '\n' ' ') - assertSame "env1 env2 link_env " "$envs" - rmdir "$WORKON_HOME/not_env" - rm -f "$WORKON_HOME/link_env" -} - -test_virtualenvwrapper_show_workon_options_no_envs () { - old_home="$WORKON_HOME" - export WORKON_HOME=${TMPDIR:-/tmp}/$$ - envs=$(virtualenvwrapper_show_workon_options 2>/dev/null | tr '\n' ' ') - assertSame "" "$envs" - export WORKON_HOME="$old_home" -} - -test_rmvirtualenv () { - mkvirtualenv "deleteme" - assertTrue "[ -d $WORKON_HOME/deleteme ]" - deactivate - rmvirtualenv "deleteme" - assertFalse "[ -d $WORKON_HOME/deleteme ]" -} - -test_rmvirtualenv_no_such_env () { - assertFalse "[ -d $WORKON_HOME/deleteme ]" - assertTrue "rmvirtualenv deleteme" -} - -test_missing_workon_home () { - save_home="$WORKON_HOME" - WORKON_HOME="/tmp/NO_SUCH_WORKON_HOME" - assertFalse "workon" - assertFalse "mkvirtualenv foo" - assertFalse "rmvirtualenv foo" - assertFalse "lssitepackages" - WORKON_HOME="$save_home" -} - -test_add2virtualenv () { - mkvirtualenv "pathtest" - add2virtualenv "/full/path" - cdsitepackages - path_file="./virtualenv_path_extensions.pth" - assertTrue "No /full/path in `cat $path_file`" "grep /full/path $path_file" - cd - -} - -test_add2virtualenv_relative () { - mkvirtualenv "pathtest" - parent_dir=$(dirname $(pwd)) - base_dir=$(basename $(pwd)) - add2virtualenv "../$base_dir" - cdsitepackages - path_file="./virtualenv_path_extensions.pth" - assertTrue "No $parent_dir/$base_dir in \"`cat $path_file`\"" "grep \"$parent_dir/$base_dir\" $path_file" - cd - >/dev/null 2>&1 -} - -test_lssitepackages () { - mkvirtualenv "lssitepackagestest" - contents="$(lssitepackages)" - assertTrue "No easy-install.pth in $/contents" "echo $contents | grep easy-install.pth" -} - -test_lssitepackages_add2virtualenv () { - mkvirtualenv "lssitepackagestest" - parent_dir=$(dirname $(pwd)) - base_dir=$(basename $(pwd)) - add2virtualenv "../$base_dir" - contents="$(lssitepackages)" - assertTrue "No $base_dir in $contents" "echo $contents | grep $base_dir" -} - -test_cpvirtualenv () { - mkvirtualenv "cpvirtualenvtest" - $VIRTUAL_ENV/bin/easy_install "tests/testpackage" - cpvirtualenv "cpvirtualenvtest" "cpvirtualenvcopy" - deactivate - rmvirtualenv "cpvirtualenvtest" - workon "cpvirtualenvcopy" - testscript="$(which testscript.py)" - assertSame "$testscript" $(echo "$WORKON_HOME/cpvirtualenvcopy/bin/testscript.py") - testscriptcontent="$(cat $testscript)" - assertTrue "No cpvirtualenvtest in $/testscriptcontent" "echo $testscriptcontent | grep cpvirtualenvtest" - assertTrue virtualenvwrapper_verify_active_environment - assertSame "cpvirtualenvcopy" $(basename "$VIRTUAL_ENV") - cdvirtualenv - assertSame "$VIRTUAL_ENV" "$(pwd)" -} - -test_cprelocatablevirtualenv () { - mkvirtualenv "cprelocatabletest" - virtualenv --relocatable "$WORKON_HOME/cprelocatabletest" - cpvirtualenv "cprelocatabletest" "cprelocatablecopy" - assertTrue virtualenvwrapper_verify_active_environment - assertSame "cprelocatablecopy" $(basename "$VIRTUAL_ENV") - cdvirtualenv - assertSame "$VIRTUAL_ENV" "$(pwd)" -} . "$test_dir/shunit2" From 55de7c43801fe0dba299573151054b9eda37a26e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 31 Mar 2010 12:09:23 -0400 Subject: [PATCH 143/947] add note about relocatable side-effect --- docsource/command_ref.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docsource/command_ref.rst b/docsource/command_ref.rst index 71cc59e..4b46733 100644 --- a/docsource/command_ref.rst +++ b/docsource/command_ref.rst @@ -40,6 +40,11 @@ Syntax:: cpvirtualenv ENVNAME TARGETENVNAME +.. note:: + + The environment created by the copy operation is made `relocatable + `__. + workon ------ From 3249cab46397d9c467038fbf87786314f7aa6758 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 31 Mar 2010 12:10:10 -0400 Subject: [PATCH 144/947] bump version; pre-release code cleanup --- docsource/history.rst | 2 ++ pavement.py | 2 +- virtualenvwrapper_bashrc | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docsource/history.rst b/docsource/history.rst index 63f9495..d2fde96 100644 --- a/docsource/history.rst +++ b/docsource/history.rst @@ -1,6 +1,8 @@ =============== Release History =============== + +1.27 - Added cpvirtualenv command [Thomas Desvenain] diff --git a/pavement.py b/pavement.py index ccf8f28..63cb9ba 100644 --- a/pavement.py +++ b/pavement.py @@ -28,7 +28,7 @@ # What project are we building? PROJECT = 'virtualenvwrapper' -VERSION = '1.26' +VERSION = '1.27' os.environ['VERSION'] = VERSION # Read the long description to give to setup diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper_bashrc index de4a6fb..c238f77 100644 --- a/virtualenvwrapper_bashrc +++ b/virtualenvwrapper_bashrc @@ -424,6 +424,7 @@ function lssitepackages () { fi } +# Duplicate the named virtualenv to make a new one. function cpvirtualenv() { typeset env_name="$1" From aaf59c5c31c2508b3c7abb37bb17c33422fd5bf3 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 31 Mar 2010 12:10:15 -0400 Subject: [PATCH 145/947] Added tag 1.27 for changeset 3edf5f224815 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 7d0622e..7965f96 100644 --- a/.hgtags +++ b/.hgtags @@ -41,3 +41,4 @@ b243d023094b6b0ef1b834dcc100f8c342c67537 1.24 f318697791416cf0897091718d542e8045854233 1.24.2 06229877a640ecb490faf46f923d8be916a0ebed 1.25 51eef82a39d431cee156fea7005fa1631e21655e 1.26 +3edf5f22481587608f8c172f8758014446a2d888 1.27 From 27f3b4c8bed53064ebc327dbc166a7026a64712b Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 31 Mar 2010 12:22:58 -0400 Subject: [PATCH 146/947] add explicit check for virtualenv in the test --- tests/test_mkvirtualenv.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index 3167c49..71e2c83 100644 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -56,6 +56,7 @@ GLOBAL postmkvirtualenv" test_no_virtualenv () { old_path="$PATH" PATH="/usr/bin:/bin:/usr/sbin:/sbin" + assertFalse "Found virtualenv in $(which virtualenv)" "which virtualenv" mkvirtualenv should_not_be_created 2>/dev/null RC=$? # Restore the path before testing because From c6d163d16fb2729663eb124b121bd1f4944da97c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 31 Mar 2010 12:23:06 -0400 Subject: [PATCH 147/947] Added tag 1.27 for changeset d64869519c2e --- .hgtags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.hgtags b/.hgtags index 7965f96..8e79c99 100644 --- a/.hgtags +++ b/.hgtags @@ -42,3 +42,5 @@ f318697791416cf0897091718d542e8045854233 1.24.2 06229877a640ecb490faf46f923d8be916a0ebed 1.25 51eef82a39d431cee156fea7005fa1631e21655e 1.26 3edf5f22481587608f8c172f8758014446a2d888 1.27 +3edf5f22481587608f8c172f8758014446a2d888 1.27 +d64869519c2e0553303cfeeb0918271564c72beb 1.27 From 57579a7a678da74fab8fe387c64d0ef421ae46b5 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 31 Mar 2010 18:55:54 -0400 Subject: [PATCH 148/947] add todo list and design notes for hook scripts --- venv.org | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 venv.org diff --git a/venv.org b/venv.org new file mode 100644 index 0000000..8640297 --- /dev/null +++ b/venv.org @@ -0,0 +1,51 @@ +# Org-mode notes and task list + +* TODO convert to distribute for packaging + - get rid of newvenvw and virtualenvwrapper virtualenvs and re-create + +* TODO plugin system for hooks [0/5] + - http://bitbucket.org/dhellmann/virtualenvwrapper/issue/28/ + - use Distribute/setuptools + - namespace package `virtualenvwrapper` to hold plugins I write, but + not required for other authors + - [ ] how to specify execution order between plugin providers? + - plugins could provide a "phase" function for sorting + - return an integer, let the plugin author community sort out the + ranges + - alphabetical by plugin name + - undefined + - [ ] "user script" plugin implementation + - uses pkg_resources to get contents of hook scripts out of + python package and run them + - move all/most existing hook execution here + - handles both global & local hooks + - [ ] cli app to run the hooks + - [ ] how does cli app handle the "sourced" hook scripts + - ability to `cd` into a specific directory, for example + - separate plugin points for "foo_run_hook" and + "foo_source_hook", handled differently by the calling script + - run hooks are executed first (implement in any language) + - source hooks are dumped to text files and then sourced + (implement in shell language) + - [ ] expose each hook point as an entry point function + - [ ] requirements + - automatically install packages based on requirements file + given to pip + - separate hook, or let a package just use postmkvirtualenv? + - [ ] mkvirtualenv [0/2] + - [ ] pre + - [ ] post + - [ ] activate [0/2] + - [ ] pre + - [ ] post + - [ ] deactivate [0/2] + - [ ] pre + - [ ] post + - [ ] rmvirtualenv [0/2] + - [ ] pre + - [ ] post + - [ ] documentation for how to publish your own hooks + +* TODO add pre/post hooks for cpvirtualenv + - add new ones or just invoke existing hooks? + From 23b9eb07081916dd8cd6d62ad5d874ac93e3c178 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 31 Mar 2010 18:59:41 -0400 Subject: [PATCH 149/947] reorg todo list --- venv.org | 57 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/venv.org b/venv.org index 8640297..491d5bf 100644 --- a/venv.org +++ b/venv.org @@ -3,49 +3,56 @@ * TODO convert to distribute for packaging - get rid of newvenvw and virtualenvwrapper virtualenvs and re-create -* TODO plugin system for hooks [0/5] +* plugin system for hooks - http://bitbucket.org/dhellmann/virtualenvwrapper/issue/28/ - - use Distribute/setuptools + - use Distribute/setuptools entry points - namespace package `virtualenvwrapper` to hold plugins I write, but not required for other authors - - [ ] how to specify execution order between plugin providers? + +** TODO how to specify execution order between plugin providers? - plugins could provide a "phase" function for sorting - return an integer, let the plugin author community sort out the ranges - alphabetical by plugin name - undefined - - [ ] "user script" plugin implementation + +** TODO "user script" plugin implementation - uses pkg_resources to get contents of hook scripts out of python package and run them - move all/most existing hook execution here - handles both global & local hooks - - [ ] cli app to run the hooks - - [ ] how does cli app handle the "sourced" hook scripts + +** TODO cli app to run the hooks + +** TODO how does cli app handle the "sourced" hook scripts - ability to `cd` into a specific directory, for example - separate plugin points for "foo_run_hook" and "foo_source_hook", handled differently by the calling script - run hooks are executed first (implement in any language) - source hooks are dumped to text files and then sourced (implement in shell language) - - [ ] expose each hook point as an entry point function - - [ ] requirements - - automatically install packages based on requirements file - given to pip - - separate hook, or let a package just use postmkvirtualenv? - - [ ] mkvirtualenv [0/2] - - [ ] pre - - [ ] post - - [ ] activate [0/2] - - [ ] pre - - [ ] post - - [ ] deactivate [0/2] - - [ ] pre - - [ ] post - - [ ] rmvirtualenv [0/2] - - [ ] pre - - [ ] post - - [ ] documentation for how to publish your own hooks + +** TODO expose each hook point as an entry point function + - [ ] requirements + - automatically install packages based on requirements file + given to pip + - separate hook, or let a package just use postmkvirtualenv? + - if provide as a separate hook, run /before/ postmkvirtualenv + - [ ] mkvirtualenv [0/2] + - [ ] pre + - [ ] post + - [ ] activate [0/2] + - [ ] pre + - [ ] post + - [ ] deactivate [0/2] + - [ ] pre + - [ ] post + - [ ] rmvirtualenv [0/2] + - [ ] pre + - [ ] post + +** TODO documentation for how to publish your own hooks + * TODO add pre/post hooks for cpvirtualenv - add new ones or just invoke existing hooks? - From b0f372d488d74c8a36fe35bfc1aa10931715f917 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 31 Mar 2010 21:43:21 -0400 Subject: [PATCH 150/947] start moving from paver back to make and distribute --HG-- rename : README => README.rst rename : docsource/command_ref.rst => docs/source/command_ref.rst rename : docsource/developers.rst => docs/source/developers.rst rename : docsource/history.rst => docs/source/history.rst rename : docsource/hooks.rst => docs/source/hooks.rst rename : docsource/index.rst => docs/source/index.rst rename : docsource/tips.rst => docs/source/tips.rst --- .hgignore | 8 +- MANIFEST.in | 5 +- Makefile | 8 + README => README.rst | 0 distribute_setup.py | 477 +++++++++++++++++++++ docs/Makefile | 89 ++++ {docsource => docs/source}/command_ref.rst | 0 docs/source/conf.py | 194 +++++++++ {docsource => docs/source}/developers.rst | 0 {docsource => docs/source}/history.rst | 0 {docsource => docs/source}/hooks.rst | 0 {docsource => docs/source}/index.rst | 0 {docsource => docs/source}/tips.rst | 0 setup.py | 157 +++++++ 14 files changed, 932 insertions(+), 6 deletions(-) create mode 100644 Makefile rename README => README.rst (100%) create mode 100644 distribute_setup.py create mode 100644 docs/Makefile rename {docsource => docs/source}/command_ref.rst (100%) create mode 100644 docs/source/conf.py rename {docsource => docs/source}/developers.rst (100%) rename {docsource => docs/source}/history.rst (100%) rename {docsource => docs/source}/hooks.rst (100%) rename {docsource => docs/source}/index.rst (100%) rename {docsource => docs/source}/tips.rst (100%) create mode 100644 setup.py diff --git a/.hgignore b/.hgignore index 2ff7dd1..5f2e7ad 100644 --- a/.hgignore +++ b/.hgignore @@ -1,16 +1,18 @@ syntax: glob +distribute*.egg +distribute*.tar.gz README.html virtualenvwrapper.egg-info -paver-minilib.zip -setup.py trace.txt -docs +dist +docs/build *.pyc sphinx/web/templates/base.html tests/catch_output tests/testpackage/build tests/testpackage/dist tests/testpackage/testpackage.egg-info +virtualenvwrapper/docs syntax: re .DS_Store diff --git a/MANIFEST.in b/MANIFEST.in index 57d9db4..eadfcfd 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,5 @@ include setup.py -include paver-minilib.zip -include pavement.py +include distribute_setup.py include tests/* recursive-include virtualenvwrapper *.html *.txt *.css *.js *.png -recursive-include docsource *.rst +recursive-include docs *.rst diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..50fc058 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ + +sdist: html + python setup.py sdist + +html: + rm -rf virtualenvwrapper/docs + (cd docs && $(MAKE) html) + cp -r docs/build/html virtualenvwrapper/docs diff --git a/README b/README.rst similarity index 100% rename from README rename to README.rst diff --git a/distribute_setup.py b/distribute_setup.py new file mode 100644 index 0000000..0021336 --- /dev/null +++ b/distribute_setup.py @@ -0,0 +1,477 @@ +#!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 sys +import time +import fnmatch +import tempfile +import tarfile +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.10" +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): + # 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'): + log.warn('Something went wrong during the installation.') + log.warn('See the error message above.') + finally: + os.chdir(old_wd) + + +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) + # 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 _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 + + +def _same_content(path, content): + return open(path).read() == content + +def _no_sandbox(function): + def __no_sandbox(*args, **kw): + try: + from setuptools.sandbox import DirectorySandbox + def violation(*args): + pass + DirectorySandbox._old = DirectorySandbox._violation + DirectorySandbox._violation = violation + patched = True + except ImportError: + patched = False + + try: + return function(*args, **kw) + finally: + if patched: + DirectorySandbox._violation = DirectorySandbox._old + del DirectorySandbox._old + + return __no_sandbox + +@_no_sandbox +def _rename_path(path): + new_name = path + '.OLD.%s' % time.time() + log.warn('Renaming %s into %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('Removing 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 + + +def _after_install(dist): + log.warn('After install bootstrap.') + placeholder = dist.get_command_obj('install').install_purelib + _create_fake_setuptools_pkg_info(placeholder) + +@_no_sandbox +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) + f = open(pkg_info, 'w') + 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() + +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 + + +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) + elif option == '--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('Patched done.') + _relaunch() + + +def _relaunch(): + log.warn('Relaunching...') + # we have to relaunch the process + 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 main(argv, version=DEFAULT_VERSION): + """Install or upgrade setuptools and EasyInstall""" + tarball = download_setuptools() + _install(tarball) + + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..af893ed --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,89 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source + +.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + -rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/virtualenvwrapper.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/virtualenvwrapper.qhc" + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ + "run these through (pdf)latex." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." diff --git a/docsource/command_ref.rst b/docs/source/command_ref.rst similarity index 100% rename from docsource/command_ref.rst rename to docs/source/command_ref.rst diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..eada610 --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,194 @@ +# -*- coding: utf-8 -*- +# +# virtualenvwrapper documentation build configuration file, created by +# sphinx-quickstart on Wed Mar 31 21:25:16 2010. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.append(os.path.abspath('.')) + +# -- General configuration ----------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['sphinx.ext.autodoc'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'virtualenvwrapper' +copyright = u'2010, Doug Hellmann' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '2.0' +# The full version, including alpha/beta/rc tags. +release = '2.0' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of documents that shouldn't be included in the build. +#unused_docs = [] + +# List of directories, relative to source directory, that shouldn't be searched +# for source files. +exclude_trees = [] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# 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, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_use_modindex = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = '' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'virtualenvwrapperdoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +# The paper size ('letter' or 'a4'). +#latex_paper_size = 'letter' + +# The font size ('10pt', '11pt' or '12pt'). +#latex_font_size = '10pt' + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'virtualenvwrapper.tex', u'virtualenvwrapper Documentation', + u'Doug Hellmann', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# Additional stuff for the LaTeX preamble. +#latex_preamble = '' + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_use_modindex = True diff --git a/docsource/developers.rst b/docs/source/developers.rst similarity index 100% rename from docsource/developers.rst rename to docs/source/developers.rst diff --git a/docsource/history.rst b/docs/source/history.rst similarity index 100% rename from docsource/history.rst rename to docs/source/history.rst diff --git a/docsource/hooks.rst b/docs/source/hooks.rst similarity index 100% rename from docsource/hooks.rst rename to docs/source/hooks.rst diff --git a/docsource/index.rst b/docs/source/index.rst similarity index 100% rename from docsource/index.rst rename to docs/source/index.rst diff --git a/docsource/tips.rst b/docs/source/tips.rst similarity index 100% rename from docsource/tips.rst rename to docs/source/tips.rst diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..1e82a45 --- /dev/null +++ b/setup.py @@ -0,0 +1,157 @@ +#!/usr/bin/env python + +PROJECT = 'virtualenvwrapper' +VERSION = '2.0' + +# Bootstrap installation of Distribute +import distribute_setup +distribute_setup.use_setuptools() + +from setuptools import setup, find_packages + +from distutils.util import convert_path +from fnmatch import fnmatchcase +import os +import sys + +try: + long_description = open('README.rst', 'rt').read() +except IOError: + long_description = '' + +################################################################################ +# find_package_data is an Ian Bicking creation. + +# Provided as an attribute, so you can append to these instead +# of replicating them: +standard_exclude = ('*.py', '*.pyc', '*~', '.*', '*.bak', '*.swp*') +standard_exclude_directories = ('.*', 'CVS', '_darcs', './build', + './dist', 'EGG-INFO', '*.egg-info') + +def find_package_data( + where='.', package='', + exclude=standard_exclude, + exclude_directories=standard_exclude_directories, + only_in_packages=True, + show_ignored=False): + """ + Return a dictionary suitable for use in ``package_data`` + in a distutils ``setup.py`` file. + + The dictionary looks like:: + + {'package': [files]} + + Where ``files`` is a list of all the files in that package that + don't match anything in ``exclude``. + + If ``only_in_packages`` is true, then top-level directories that + are not packages won't be included (but directories under packages + will). + + Directories matching any pattern in ``exclude_directories`` will + be ignored; by default directories with leading ``.``, ``CVS``, + and ``_darcs`` will be ignored. + + If ``show_ignored`` is true, then all the files that aren't + included in package data are shown on stderr (for debugging + purposes). + + Note patterns use wildcards, or can be exact paths (including + leading ``./``), and all searching is case-insensitive. + + This function is by Ian Bicking. + """ + + out = {} + stack = [(convert_path(where), '', package, only_in_packages)] + while stack: + where, prefix, package, only_in_packages = stack.pop(0) + for name in os.listdir(where): + fn = os.path.join(where, name) + if os.path.isdir(fn): + bad_name = False + for pattern in exclude_directories: + if (fnmatchcase(name, pattern) + or fn.lower() == pattern.lower()): + bad_name = True + if show_ignored: + print >> sys.stderr, ( + "Directory %s ignored by pattern %s" + % (fn, pattern)) + break + if bad_name: + continue + if os.path.isfile(os.path.join(fn, '__init__.py')): + if not package: + new_package = name + else: + new_package = package + '.' + name + stack.append((fn, '', new_package, False)) + else: + stack.append((fn, prefix + name + '/', package, only_in_packages)) + elif package or not only_in_packages: + # is a file + bad_name = False + for pattern in exclude: + if (fnmatchcase(name, pattern) + or fn.lower() == pattern.lower()): + bad_name = True + if show_ignored: + print >> sys.stderr, ( + "File %s ignored by pattern %s" + % (fn, pattern)) + break + if bad_name: + continue + out.setdefault(package, []).append(prefix+name) + return out +################################################################################ + + +setup( + name = PROJECT, + version = VERSION, + + description = 'Enhancements to virtualenv', + long_description = long_description, + + author = 'Doug Hellmann', + author_email = 'doug.hellmann@gmail.com', + + url = 'http://www.doughellmann.com/projects/%s/' % PROJECT, + download_url = 'http://www.doughellmann.com/downloads/%s-%s.tar.gz' % \ + (PROJECT, VERSION), + + classifiers = [ 'Development Status :: 5 - Production/Stable', + 'License :: OSI Approved :: BSD License', + 'Programming Language :: Python', + 'Intended Audience :: Developers', + 'Environment :: Console', + ], + + platforms = ('Any',), + + scripts = ['virtualenvwrapper_bashrc', + ], + + provides=['virtualenvwrapper', + ], + requires=['virtualenv'], + + packages = find_packages(), + include_package_data = True, + # Scan the input for package information + # to grab any data files (text, images, etc.) + # associated with sub-packages. + package_data = find_package_data(PROJECT, + package=PROJECT, + only_in_packages=False, + ), + + entry_points = { +# 'console_scripts': [ 'ical2org = ical2org.app:main' ], + }, + + zip_safe=False, + ) From 024a049e7fe19dfe144467abb40121e1ea75a328 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 31 Mar 2010 22:03:16 -0400 Subject: [PATCH 151/947] add test rules --- Makefile | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Makefile b/Makefile index 50fc058..2eee3f4 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,32 @@ +.PHONY: sdist sdist: html python setup.py sdist +.PHONY: html html: rm -rf virtualenvwrapper/docs (cd docs && $(MAKE) html) cp -r docs/build/html virtualenvwrapper/docs + +TEST_SCRIPTS=$(wildcard tests/test*.sh) + +.PHONY: test test-bash test-sh test-zsh test-loop +test: test-bash test-sh test-zsh + +test-bash: + TEST_SHELL=bash $(MAKE) test-loop + +test-sh: + TEST_SHELL=sh $(MAKE) test-loop + +test-zsh: + TEST_SHELL="zsh -o shwordsplit" $(MAKE) test-loop + +test-loop: + @for test_script in $(wildcard tests/test*.sh) ; do \ + echo '********************************************************************************' ; \ + echo "Running $$test_script with $(TEST_SHELL)" ; \ + SHUNIT_PARENT=$$test_script $(TEST_SHELL) $$test_script ; \ + echo ; \ + done From af542414001e23fe23013bd5690bcc7ef25c5771 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 31 Mar 2010 22:06:10 -0400 Subject: [PATCH 152/947] more tasks --- venv.org | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/venv.org b/venv.org index 491d5bf..4e8928d 100644 --- a/venv.org +++ b/venv.org @@ -1,13 +1,21 @@ # Org-mode notes and task list -* TODO convert to distribute for packaging +* TODO convert to distribute for packaging [1/2] - get rid of newvenvw and virtualenvwrapper virtualenvs and re-create + - [X] pavement.py to setup.py + - [ ] sphinx conf.py needs to get version from setup.py somehow + - [ ] separate rules for making website + - [ ] installwebsite + - [ ] register + - [ ] test for installation * plugin system for hooks - http://bitbucket.org/dhellmann/virtualenvwrapper/issue/28/ - use Distribute/setuptools entry points - namespace package `virtualenvwrapper` to hold plugins I write, but not required for other authors + - bump version to 2, since the user script implementation is moving + and this is a major update ** TODO how to specify execution order between plugin providers? - plugins could provide a "phase" function for sorting @@ -32,7 +40,7 @@ - source hooks are dumped to text files and then sourced (implement in shell language) -** TODO expose each hook point as an entry point function +** TODO expose each hook point as an entry point function [0/5] - [ ] requirements - automatically install packages based on requirements file given to pip From e733a71c32c752c21a4f21f40d4d1244098b6857 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 31 Mar 2010 22:13:18 -0400 Subject: [PATCH 153/947] set version in Makefile before building html --HG-- rename : sphinx/pkg/conf.py => docs/sphinx/pkg/conf.py rename : sphinx/web/conf.py => docs/sphinx/web/conf.py rename : sphinx/web/templates/layout.html => docs/sphinx/web/templates/layout.html --- Makefile | 4 ++++ docs/source/conf.py | 22 +++++++++---------- {sphinx => docs/sphinx}/pkg/conf.py | 0 {sphinx => docs/sphinx}/web/conf.py | 0 .../sphinx}/web/templates/layout.html | 0 5 files changed, 15 insertions(+), 11 deletions(-) rename {sphinx => docs/sphinx}/pkg/conf.py (100%) rename {sphinx => docs/sphinx}/web/conf.py (100%) rename {sphinx => docs/sphinx}/web/templates/layout.html (100%) diff --git a/Makefile b/Makefile index 2eee3f4..3f07806 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +export VERSION=$(shell python setup.py --version) .PHONY: sdist sdist: html @@ -9,6 +10,9 @@ html: (cd docs && $(MAKE) html) cp -r docs/build/html virtualenvwrapper/docs +.PHONY: website +website: + TEST_SCRIPTS=$(wildcard tests/test*.sh) .PHONY: test test-bash test-sh test-zsh test-loop diff --git a/docs/source/conf.py b/docs/source/conf.py index eada610..1045433 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # virtualenvwrapper documentation build configuration file, created by -# sphinx-quickstart on Wed Mar 31 21:25:16 2010. +# sphinx-quickstart on Thu May 28 22:35:13 2009. # # This file is execfile()d with the current directory set to its containing dir. # @@ -22,10 +22,10 @@ # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.autodoc'] +extensions = [] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ['templates'] # The suffix of source filenames. source_suffix = '.rst' @@ -38,16 +38,16 @@ # General information about the project. project = u'virtualenvwrapper' -copyright = u'2010, Doug Hellmann' +copyright = u'2009, Doug Hellmann' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '2.0' +version = os.environ['VERSION'] # The full version, including alpha/beta/rc tags. -release = '2.0' +release = version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -64,7 +64,7 @@ # List of directories, relative to source directory, that shouldn't be searched # for source files. -exclude_trees = [] +exclude_trees = ['_build'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None @@ -91,7 +91,7 @@ # The theme to use for HTML and HTML Help pages. Major themes that come with # Sphinx are currently 'default' and 'sphinxdoc'. -html_theme = 'default' +html_theme = 'sphinxdoc' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -120,7 +120,7 @@ # 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, # 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, # using the given strftime format. @@ -138,10 +138,10 @@ #html_additional_pages = {} # If false, no module index is generated. -#html_use_modindex = True +html_use_modindex = False # If false, no index is generated. -#html_use_index = True +html_use_index = False # If true, the index is split into individual pages for each letter. #html_split_index = False diff --git a/sphinx/pkg/conf.py b/docs/sphinx/pkg/conf.py similarity index 100% rename from sphinx/pkg/conf.py rename to docs/sphinx/pkg/conf.py diff --git a/sphinx/web/conf.py b/docs/sphinx/web/conf.py similarity index 100% rename from sphinx/web/conf.py rename to docs/sphinx/web/conf.py diff --git a/sphinx/web/templates/layout.html b/docs/sphinx/web/templates/layout.html similarity index 100% rename from sphinx/web/templates/layout.html rename to docs/sphinx/web/templates/layout.html From a564d02c051b93fda5869e17a39c60f7f08be1b6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 31 Mar 2010 22:26:26 -0400 Subject: [PATCH 154/947] add rules for updating website --- .hgignore | 1 + Makefile | 18 +++- docs/source/conf.py | 194 -------------------------------------------- 3 files changed, 17 insertions(+), 196 deletions(-) delete mode 100644 docs/source/conf.py diff --git a/.hgignore b/.hgignore index 5f2e7ad..9da8d34 100644 --- a/.hgignore +++ b/.hgignore @@ -6,6 +6,7 @@ virtualenvwrapper.egg-info trace.txt dist docs/build +docs/website *.pyc sphinx/web/templates/base.html tests/catch_output diff --git a/Makefile b/Makefile index 3f07806..31e06cf 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,32 @@ +# Get the version of the app. This is used in the doc build. export VERSION=$(shell python setup.py --version) +# Default target is to build the source distribution. .PHONY: sdist sdist: html python setup.py sdist +# Documentation .PHONY: html html: rm -rf virtualenvwrapper/docs - (cd docs && $(MAKE) html) + (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/pkg") cp -r docs/build/html virtualenvwrapper/docs +# Website copy of documentation .PHONY: website -website: +website: docs/sphinx/web/templates/base.html + rm -rf docs/website + (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/web" BUILDDIR="website") +installwebsite: website + (cd docs/website/html && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper2/) + +# Copy the base template from my website build directory +docs/sphinx/web/templates/base.html: ~/Devel/doughellmann/doughellmann/templates/base.html + cp $< $@ + +# Testing TEST_SCRIPTS=$(wildcard tests/test*.sh) .PHONY: test test-bash test-sh test-zsh test-loop diff --git a/docs/source/conf.py b/docs/source/conf.py deleted file mode 100644 index 1045433..0000000 --- a/docs/source/conf.py +++ /dev/null @@ -1,194 +0,0 @@ -# -*- coding: utf-8 -*- -# -# virtualenvwrapper documentation build configuration file, created by -# sphinx-quickstart on Thu May 28 22:35:13 2009. -# -# This file is execfile()d with the current directory set to its containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys, os - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.append(os.path.abspath('.')) - -# -- General configuration ----------------------------------------------------- - -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = [] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['templates'] - -# The suffix of source filenames. -source_suffix = '.rst' - -# The encoding of source files. -#source_encoding = 'utf-8' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'virtualenvwrapper' -copyright = u'2009, Doug Hellmann' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = os.environ['VERSION'] -# The full version, including alpha/beta/rc tags. -release = version - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -#language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -#today = '' -# Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' - -# List of documents that shouldn't be included in the build. -#unused_docs = [] - -# List of directories, relative to source directory, that shouldn't be searched -# for source files. -exclude_trees = ['_build'] - -# The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -#add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -#show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] - - -# -- Options for HTML output --------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. Major themes that come with -# Sphinx are currently 'default' and 'sphinxdoc'. -html_theme = 'sphinxdoc' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -#html_theme_options = {} - -# Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -#html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -#html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -#html_favicon = None - -# 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, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['static'] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -#html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -#html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -#html_additional_pages = {} - -# If false, no module index is generated. -html_use_modindex = False - -# If false, no index is generated. -html_use_index = False - -# If true, the index is split into individual pages for each letter. -#html_split_index = False - -# If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -#html_use_opensearch = '' - -# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = '' - -# Output file base name for HTML help builder. -htmlhelp_basename = 'virtualenvwrapperdoc' - - -# -- Options for LaTeX output -------------------------------------------------- - -# The paper size ('letter' or 'a4'). -#latex_paper_size = 'letter' - -# The font size ('10pt', '11pt' or '12pt'). -#latex_font_size = '10pt' - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). -latex_documents = [ - ('index', 'virtualenvwrapper.tex', u'virtualenvwrapper Documentation', - u'Doug Hellmann', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -#latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -#latex_use_parts = False - -# Additional stuff for the LaTeX preamble. -#latex_preamble = '' - -# Documents to append as an appendix to all manuals. -#latex_appendices = [] - -# If false, no module index is generated. -#latex_use_modindex = True From 0baa49ad76c2e76c30b92c850a4b653a765f5a1a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 31 Mar 2010 22:26:58 -0400 Subject: [PATCH 155/947] don't need pavement.py any more --- pavement.py | 207 ---------------------------------------------------- 1 file changed, 207 deletions(-) delete mode 100644 pavement.py diff --git a/pavement.py b/pavement.py deleted file mode 100644 index 63cb9ba..0000000 --- a/pavement.py +++ /dev/null @@ -1,207 +0,0 @@ -#!/usr/bin/env python -# encoding: utf-8 -# -# Copyright (c) 2009 Doug Hellmann All rights reserved. -# -""" -""" - -# Standard library -import copy -import os -import sys - -# Third-party - -# Set up Paver -import paver -import paver.misctasks -from paver.path import path -from paver.easy import * -import paver.setuputils -paver.setuputils.install_distutils_tasks() -#import paver.doctools -try: - from sphinxcontrib import paverutils -except: - paverutils = None - -# What project are we building? -PROJECT = 'virtualenvwrapper' -VERSION = '1.27' -os.environ['VERSION'] = VERSION - -# Read the long description to give to setup -README_FILE = 'README' -README = path(README_FILE).text() - -# Scan the input for package information -# to grab any data files (text, images, etc.) -# associated with sub-packages. -PACKAGE_DATA = paver.setuputils.find_package_data(PROJECT, - package=PROJECT, - only_in_packages=False, - ) - -options( - setup=Bunch( - name = PROJECT, - version = VERSION, - - description = 'Enhancements to virtualenv', - long_description = README, - - author = 'Doug Hellmann', - author_email = 'doug.hellmann@gmail.com', - - url = 'http://www.doughellmann.com/projects/%s/' % PROJECT, - download_url = 'http://www.doughellmann.com/downloads/%s-%s.tar.gz' % \ - (PROJECT, VERSION), - - classifiers = [ 'Development Status :: 5 - Production/Stable', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: Python', - 'Intended Audience :: Developers', - 'Environment :: Console', - ], - - platforms = ('Any',), - - scripts = ['virtualenvwrapper_bashrc', - ], - - provides=['virtualenvwrapper', - ], - requires=['virtualenv'], - - packages = sorted(PACKAGE_DATA.keys()), - package_data = PACKAGE_DATA, - - zip_safe=False, - - ), - - sphinx = Bunch( - docroot='.', - sourcedir='docsource', - builder='html', - template_args={'project':PROJECT} - ), - - html=Bunch( - templates='pkg', - builddir='docs', - confdir='sphinx/pkg', - ), - - website=Bunch( - templates = 'web', - builddir = 'web', - confdir='sphinx/web', - - # What server hosts the website? - server = 'www.doughellmann.com', - server_path = '/var/www/doughellmann/DocumentRoot/docs/%s/' % PROJECT, - - # What template should be used for the web site HTML? - template_source = '~/Devel/doughellmann/doughellmann/templates/base.html', - template_dest = 'sphinx/web/templates/base.html', - ), - - sdist = Bunch( - dist_dir=os.path.expanduser('~/Desktop'), - ), - - # Tell Paver to include extra parts that we use - # but it doesn't ship in the minilib by default. - minilib = Bunch( - extra_files=['doctools'], - ), - -) - -@task -def html(options): - if paverutils is None: - raise RuntimeError('Building HTML documentation requires the sphinxcontrib.paverutils package') - # Build the docs - paverutils.html(options) - # Move them into place for packaging - destdir = path(PROJECT) / 'docs' - destdir.rmtree() - builtdocs = path(options.builddir) / "html" - builtdocs.move(destdir) - return - -@task -def website(options): - """Create local copy of website files. - """ - if paverutils is None: - raise RuntimeError('Building the website requires the sphinxcontrib.paverutils package') - # Make sure the base template is updated - dest = path(options.website.template_dest).expanduser() - src = path(options.website.template_source).expanduser() - if not dest.exists() or (src.mtime > dest.mtime): - dest.dirname().mkdir() - src.copy(dest) - # Build the docs - paverutils.run_sphinx(options, 'website') - return - -def remake_directories(*dirnames): - """Remove the directories and recreate them. - """ - for d in dirnames: - d = path(d) - if d.exists(): - d.rmtree() - d.mkdir() - return - -@task -def installwebsite(options): - """Rebuild and copy website files to the remote server. - """ - # Clean up - remake_directories(options.website.builddir) - # Rebuild - website(options) - # Copy to the server - os.environ['RSYNC_RSH'] = '/usr/bin/ssh' - src_path = path(options.website.builddir) / 'html' - sh('cd %s; rsync --archive --delete --verbose . %s:%s' % - (src_path, options.website.server, options.website.server_path)) - return - - -@task -@needs(['html', - 'generate_setup', 'minilib', - 'setuptools.command.sdist', - ]) -def sdist(options): - """Create a source distribution. - """ - pass - -@task -@needs(['sdist']) -def test_install(options): - sh('./tests/test_install.sh "%s" "%s"' % (options.sdist.dist_dir, VERSION)) - return - -@task -def test(): - #test_scripts = glob.glob('./tests/test*.sh') - test_scripts = path('tests').glob('test*.sh') - #print test_scripts - for shell_cmd in [ 'bash', 'sh', 'SHUNIT_PARENT=%(test_script)s zsh -o shwordsplit' ]: - for test_script in test_scripts: - base_cmd = shell_cmd + ' %(test_script)s' - cmd = base_cmd % locals() - print '*' * 80 - print - sys.stdout.flush() - sh(cmd) - return From 5e3b2c6305542f46a614f9c40856ffd6d7a83999 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 1 Apr 2010 08:04:45 -0400 Subject: [PATCH 156/947] update installation test --- Makefile | 7 +++++-- tests/manual_test_install.sh | 33 ++++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 31e06cf..3cca837 100644 --- a/Makefile +++ b/Makefile @@ -29,8 +29,8 @@ docs/sphinx/web/templates/base.html: ~/Devel/doughellmann/doughellmann/templates # Testing TEST_SCRIPTS=$(wildcard tests/test*.sh) -.PHONY: test test-bash test-sh test-zsh test-loop -test: test-bash test-sh test-zsh +.PHONY: test test-bash test-sh test-zsh test-loop test-install +test: test-bash test-sh test-zsh test-install test-bash: TEST_SHELL=bash $(MAKE) test-loop @@ -48,3 +48,6 @@ test-loop: SHUNIT_PARENT=$$test_script $(TEST_SHELL) $$test_script ; \ echo ; \ done + +test-install: + bash ./tests/manual_test_install.sh `pwd`/dist "$(VERSION)" \ No newline at end of file diff --git a/tests/manual_test_install.sh b/tests/manual_test_install.sh index 2056ef5..ec948ce 100755 --- a/tests/manual_test_install.sh +++ b/tests/manual_test_install.sh @@ -4,13 +4,32 @@ # test_dir=$(dirname $0) -dist_dir="$1" -version="$2" +source "$test_dir/../virtualenvwrapper_bashrc" export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" -mkvirtualenv "installtest" -pip install "$dist_dir/virtualenvwrapper-$version.tar.gz" -RC=$? -rm -rf "$WORKON_HOME" -exit $RC +VERSION=$(python setup.py --version) + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + mkvirtualenv "installtest" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo +} + +test_install () { + dist_dir=$(dirname $test_dir)/dist + pip install "$dist_dir/virtualenvwrapper-$VERSION.tar.gz" + RC=$? + assertTrue "Error code $RC" "[ $RC -eq 0 ]" + assertTrue "Missing wrapper script" "[ -f $WORKON_HOME/installtest/bin/virtualenvwrapper_bashrc ]" +} + +. "$test_dir/shunit2" From 281bcff92b96a409ef718e183234460bd89f6a02 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 1 Apr 2010 08:06:23 -0400 Subject: [PATCH 157/947] add register rule --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index 3cca837..ad5ddca 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,11 @@ website: docs/sphinx/web/templates/base.html installwebsite: website (cd docs/website/html && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper2/) +# Register the new version on pypi +.PHONY: register +register: + python setup.py register + # Copy the base template from my website build directory docs/sphinx/web/templates/base.html: ~/Devel/doughellmann/doughellmann/templates/base.html cp $< $@ From 88434546d4363e0303af15fca219cd20f9ad2600 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 1 Apr 2010 08:23:07 -0400 Subject: [PATCH 158/947] rename wrapper script --HG-- rename : virtualenvwrapper_bashrc => virtualenvwrapper.sh --- README.rst | 17 +++++++++++--- docs/source/index.rst | 22 ++++++++++++++----- setup.py | 2 +- tests/manual_test_install.sh | 5 +++-- tests/test.sh | 4 ++-- tests/test_add2virtualenv.sh | 2 +- tests/test_cd.sh | 2 +- tests/test_cp.sh | 2 +- tests/test_ls.sh | 2 +- tests/test_mkvirtualenv.sh | 2 +- tests/test_rmvirtualenv.sh | 2 +- tests/test_run_hook.sh | 2 +- tests/test_workon.sh | 2 +- ...lenvwrapper_bashrc => virtualenvwrapper.sh | 0 14 files changed, 45 insertions(+), 21 deletions(-) rename virtualenvwrapper_bashrc => virtualenvwrapper.sh (100%) diff --git a/README.rst b/README.rst index 6bee6a5..232b894 100644 --- a/README.rst +++ b/README.rst @@ -34,11 +34,13 @@ Quick Setup 1. Create a directory to hold all of the virtual environments. The default is ``$HOME/.virtualenvs``. -2. Add two lines to your .bashrc to set the location where the virtual environments should - live and the location of the script installed with this package:: +2. Add two lines to your shell startup script (``.bashrc``, + ``.bash_profile``, etc.) to set the location where the virtual + environments should live and the location of the script installed + with this package:: export WORKON_HOME=$HOME/.virtualenvs - source /usr/local/bin/virtualenvwrapper_bashrc + source /usr/local/bin/virtualenvwrapper.sh 3. Run: ``source ~/.bashrc`` 4. Run: ``workon`` @@ -48,6 +50,15 @@ Quick Setup 8. Run: ``workon`` 9. This time, the ``temp`` environment is included. +Upgrading from 1.x +================== + +The shell script containing the wrapper functions has been renamed in +the 2.x series to reflect the fact that shells other than bash are +supported. In your startup file, change ``source +/usr/local/bin/virtualenvwrapper_bashrc`` to ``source +/usr/local/bin/virtualenvwrapper.sh``. + ======= License ======= diff --git a/docs/source/index.rst b/docs/source/index.rst index 40b1ccd..1240e8d 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -18,10 +18,13 @@ their dependencies. Features ======== - 1. Organizes all of your virtual environments in one place. - 2. Wrappers for creating and deleting environments, including user-configurable hooks. - 3. Use a single command to switch between environments. - 4. Tab completion for commands that take a virtual environment as argument. +1. Organizes all of your virtual environments in one place. +2. Wrappers for managing your virtual environments (create, delete, + copy). +3. Use a single command to switch between environments. +4. Tab completion for commands that take a virtual environment as + argument. +5. User-configurable hooks for all operations. =========== Quick Setup @@ -34,7 +37,7 @@ Quick Setup live and the location of the script installed with this package:: export WORKON_HOME=$HOME/.virtualenvs - source /usr/local/bin/virtualenvwrapper_bashrc + source /usr/local/bin/virtualenvwrapper.sh 3. Run: ``source ~/.bashrc`` 4. Run: ``workon`` @@ -44,6 +47,15 @@ Quick Setup 8. Run: ``workon`` 9. This time, the ``temp`` environment is included. +Upgrading from 1.x +================== + +The shell script containing the wrapper functions has been renamed in +the 2.x series to reflect the fact that shells other than bash are +supported. In your startup file, change ``source +/usr/local/bin/virtualenvwrapper_bashrc`` to ``source +/usr/local/bin/virtualenvwrapper.sh``. + ======= Details ======= diff --git a/setup.py b/setup.py index 1e82a45..c668251 100644 --- a/setup.py +++ b/setup.py @@ -132,7 +132,7 @@ def find_package_data( platforms = ('Any',), - scripts = ['virtualenvwrapper_bashrc', + scripts = ['virtualenvwrapper.sh', ], provides=['virtualenvwrapper', diff --git a/tests/manual_test_install.sh b/tests/manual_test_install.sh index ec948ce..5907bd2 100755 --- a/tests/manual_test_install.sh +++ b/tests/manual_test_install.sh @@ -4,7 +4,7 @@ # test_dir=$(dirname $0) -source "$test_dir/../virtualenvwrapper_bashrc" +source "$test_dir/../virtualenvwrapper.sh" export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" @@ -14,6 +14,7 @@ oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" mkvirtualenv "installtest" + (cd "$test_dir/.." && make sdist) } oneTimeTearDown() { @@ -29,7 +30,7 @@ test_install () { pip install "$dist_dir/virtualenvwrapper-$VERSION.tar.gz" RC=$? assertTrue "Error code $RC" "[ $RC -eq 0 ]" - assertTrue "Missing wrapper script" "[ -f $WORKON_HOME/installtest/bin/virtualenvwrapper_bashrc ]" + assertTrue "Missing wrapper script" "[ -f $WORKON_HOME/installtest/bin/virtualenvwrapper.sh ]" } . "$test_dir/shunit2" diff --git a/tests/test.sh b/tests/test.sh index 3247555..4e7b015 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -3,7 +3,7 @@ #set -x test_dir=$(dirname $0) -source "$test_dir/../virtualenvwrapper_bashrc" +source "$test_dir/../virtualenvwrapper.sh" export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" @@ -44,7 +44,7 @@ test_virtualenvwrapper_verify_workon_home_missing_dir() { test_virtualenvwrapper_verify_workon_home_missing_dir_quiet_init() { old_home="$WORKON_HOME" export WORKON_HOME="$WORKON_HOME/not_there" - output=`$SHELL $test_dir/../virtualenvwrapper_bashrc 2>&1` + output=`$SHELL $test_dir/../virtualenvwrapper.sh 2>&1` assertSame "" "$output" WORKON_HOME="$old_home" } diff --git a/tests/test_add2virtualenv.sh b/tests/test_add2virtualenv.sh index 8247b5f..43d3ca1 100644 --- a/tests/test_add2virtualenv.sh +++ b/tests/test_add2virtualenv.sh @@ -3,7 +3,7 @@ #set -x test_dir=$(dirname $0) -source "$test_dir/../virtualenvwrapper_bashrc" +source "$test_dir/../virtualenvwrapper.sh" export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" diff --git a/tests/test_cd.sh b/tests/test_cd.sh index 6a2b24d..a6b5f0d 100644 --- a/tests/test_cd.sh +++ b/tests/test_cd.sh @@ -3,7 +3,7 @@ #set -x test_dir=$(dirname $0) -source "$test_dir/../virtualenvwrapper_bashrc" +source "$test_dir/../virtualenvwrapper.sh" export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" diff --git a/tests/test_cp.sh b/tests/test_cp.sh index 1e295a8..06e23a4 100644 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -3,7 +3,7 @@ #set -x test_dir=$(dirname $0) -source "$test_dir/../virtualenvwrapper_bashrc" +source "$test_dir/../virtualenvwrapper.sh" export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" diff --git a/tests/test_ls.sh b/tests/test_ls.sh index 3a9c4a0..b28e1f3 100644 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -3,7 +3,7 @@ #set -x test_dir=$(dirname $0) -source "$test_dir/../virtualenvwrapper_bashrc" +source "$test_dir/../virtualenvwrapper.sh" export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index 71e2c83..73acee8 100644 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -3,7 +3,7 @@ #set -x test_dir=$(dirname $0) -source "$test_dir/../virtualenvwrapper_bashrc" +source "$test_dir/../virtualenvwrapper.sh" export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" diff --git a/tests/test_rmvirtualenv.sh b/tests/test_rmvirtualenv.sh index e26e1ea..44cbd02 100644 --- a/tests/test_rmvirtualenv.sh +++ b/tests/test_rmvirtualenv.sh @@ -3,7 +3,7 @@ #set -x test_dir=$(dirname $0) -source "$test_dir/../virtualenvwrapper_bashrc" +source "$test_dir/../virtualenvwrapper.sh" export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" diff --git a/tests/test_run_hook.sh b/tests/test_run_hook.sh index ac28faa..f72a227 100644 --- a/tests/test_run_hook.sh +++ b/tests/test_run_hook.sh @@ -3,7 +3,7 @@ #set -x test_dir=$(dirname $0) -source "$test_dir/../virtualenvwrapper_bashrc" +source "$test_dir/../virtualenvwrapper.sh" export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" diff --git a/tests/test_workon.sh b/tests/test_workon.sh index b0098d1..1db8ff9 100644 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -3,7 +3,7 @@ #set -x test_dir=$(dirname $0) -source "$test_dir/../virtualenvwrapper_bashrc" +source "$test_dir/../virtualenvwrapper.sh" export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" diff --git a/virtualenvwrapper_bashrc b/virtualenvwrapper.sh similarity index 100% rename from virtualenvwrapper_bashrc rename to virtualenvwrapper.sh From c2aebe5c4fc3fd3d25e6bacb471902823c0cfffb Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 1 Apr 2010 09:01:42 -0400 Subject: [PATCH 159/947] start implementing hook loader and a couple of sample hooks --- setup.py | 6 ++- virtualenvwrapper.sh | 2 +- virtualenvwrapper/__init__.py | 4 +- virtualenvwrapper/hook_loader.py | 30 +++++++++++ virtualenvwrapper/make_hooks.py | 13 +++++ .../make_hooks_pre_initialize.sh | 51 +++++++++++++++++++ virtualenvwrapper/user_scripts.py | 12 +++++ .../user_scripts_pre_initialize.sh | 5 ++ 8 files changed, 118 insertions(+), 5 deletions(-) create mode 100644 virtualenvwrapper/hook_loader.py create mode 100644 virtualenvwrapper/make_hooks.py create mode 100644 virtualenvwrapper/make_hooks_pre_initialize.sh create mode 100644 virtualenvwrapper/user_scripts.py create mode 100644 virtualenvwrapper/user_scripts_pre_initialize.sh diff --git a/setup.py b/setup.py index c668251..cd499da 100644 --- a/setup.py +++ b/setup.py @@ -150,7 +150,11 @@ def find_package_data( ), entry_points = { -# 'console_scripts': [ 'ical2org = ical2org.app:main' ], + #'console_scripts': [ 'venvw_hook = virtualenvwrapper.hook_loader:main' ], + 'virtualenvwrapper.pre_initialize_source': [ + 'user_scripts = virtualenvwrapper.user_scripts:pre_initialize_source', + 'make_hooks = virtualenvwrapper.make_hooks:pre_initialize_source', + ], }, zip_safe=False, diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index c238f77..4e3d12f 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -32,7 +32,7 @@ # (mkdir $HOME/.virtualenvs). # 2. Add a line like "export WORKON_HOME=$HOME/.virtualenvs" # to your .bashrc. -# 3. Add a line like "source /path/to/this/file/virtualenvwrapper_bashrc" +# 3. Add a line like "source /path/to/this/file/virtualenvwrapper.sh" # to your .bashrc. # 4. Run: source ~/.bashrc # 5. Run: workon diff --git a/virtualenvwrapper/__init__.py b/virtualenvwrapper/__init__.py index 1dbce95..59336ae 100644 --- a/virtualenvwrapper/__init__.py +++ b/virtualenvwrapper/__init__.py @@ -1,6 +1,4 @@ """virtualenvwrapper module """ -import os, warnings -docs_root = os.path.join(os.path.dirname(__file__), 'docs', 'index.html') -warnings.warn('Use virtualenvwrapper_bashrc to set up your shell environment. See %s for details.' % docs_root) +__import__('pkg_resources').declare_namespace(__name__) diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py new file mode 100644 index 0000000..2c5d7a1 --- /dev/null +++ b/virtualenvwrapper/hook_loader.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +# encoding: utf-8 +# +# Copyright (c) 2010 Doug Hellmann. All rights reserved. +# +"""Load hooks for virtualenvwrapper. +""" + +import optparse + +import pkg_resources + +def main(): + parser = optparse.OptionParser( + usage='usage: %prog [options] [options]', + prog='virtualenvwrapper.hook_loader', + description='Manage hooks for virtualenvwrapper', + ) + options, args = parser.parse_args() + + hook = args[0] + print hook + + for ep in pkg_resources.iter_entry_points('virtualenvwrapper.%s' % hook): + plugin = ep.load() + print plugin() + return 0 + +if __name__ == '__main__': + main() diff --git a/virtualenvwrapper/make_hooks.py b/virtualenvwrapper/make_hooks.py new file mode 100644 index 0000000..b8ea121 --- /dev/null +++ b/virtualenvwrapper/make_hooks.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python +# encoding: utf-8 +# +# Copyright (c) 2010 Doug Hellmann. All rights reserved. +# +"""Plugin to create hooks during initialization phase. +""" + +import pkg_resources + +def pre_initialize_source(): + return pkg_resources.resource_string(__name__, 'make_hooks_pre_initialize.sh') + diff --git a/virtualenvwrapper/make_hooks_pre_initialize.sh b/virtualenvwrapper/make_hooks_pre_initialize.sh new file mode 100644 index 0000000..a355594 --- /dev/null +++ b/virtualenvwrapper/make_hooks_pre_initialize.sh @@ -0,0 +1,51 @@ +# +# Create the default hooks, if they do not exist on startup. +# + +# Create a hook script +# +# Usage: virtualenvwrapper_make_hook filename comment +# +function virtualenvwrapper_make_hook () { + filename="$1" + comment="$2" + if [ ! -f "$filename" ] + then + #echo "Creating $filename" + cat - > "$filename" < Date: Fri, 2 Apr 2010 08:16:08 -0400 Subject: [PATCH 160/947] implement initialize hooks --HG-- rename : virtualenvwrapper/user_scripts_pre_initialize.sh => virtualenvwrapper/user_scripts_initialize.sh --- setup.py | 8 +- tests/test.sh | 1 + virtualenvwrapper.sh | 75 +++---------------- virtualenvwrapper/hook_loader.py | 55 +++++++++++++- virtualenvwrapper/make_hooks.py | 63 +++++++++++++++- .../make_hooks_pre_initialize.sh | 51 ------------- virtualenvwrapper/user_scripts.py | 11 ++- ...itialize.sh => user_scripts_initialize.sh} | 2 +- 8 files changed, 141 insertions(+), 125 deletions(-) delete mode 100644 virtualenvwrapper/make_hooks_pre_initialize.sh rename virtualenvwrapper/{user_scripts_pre_initialize.sh => user_scripts_initialize.sh} (69%) diff --git a/setup.py b/setup.py index cd499da..e59f429 100644 --- a/setup.py +++ b/setup.py @@ -151,10 +151,12 @@ def find_package_data( entry_points = { #'console_scripts': [ 'venvw_hook = virtualenvwrapper.hook_loader:main' ], - 'virtualenvwrapper.pre_initialize_source': [ - 'user_scripts = virtualenvwrapper.user_scripts:pre_initialize_source', - 'make_hooks = virtualenvwrapper.make_hooks:pre_initialize_source', + 'virtualenvwrapper.initialize_source': [ + 'user_scripts = virtualenvwrapper.user_scripts:initialize_source', ], + 'virtualenvwrapper.initialize': [ + 'make_hooks = virtualenvwrapper.make_hooks:initialize', + ] }, zip_safe=False, diff --git a/tests/test.sh b/tests/test.sh index 4e7b015..698c644 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -28,6 +28,7 @@ test_virtualenvwrapper_initialize() { assertTrue "Global $hook was not created" "[ -f $WORKON_HOME/$hook ]" assertTrue "Global $hook is not executable" "[ -x $WORKON_HOME/$hook ]" done + assertTrue "Log file was not created" "[ -f $WORKON_HOME/hook.log ]" } test_virtualenvwrapper_verify_workon_home() { diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 4e3d12f..9384a64 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -66,51 +66,24 @@ function virtualenvwrapper_verify_workon_home () { return 0 } -# Create a hook script -# -# Usage: virtualenvwrapper_make_hook filename comment -# -function virtualenvwrapper_make_hook () { - filename="$1" - comment="$2" - if [ ! -f "$filename" ] - then - #echo "Creating $filename" - cat - > "$filename" <>$TMPDIR/$$.hook + source $TMPDIR/$$.hook + rm -f $TMPDIR/$$.hook +} + +# Run a hook script in its own shell +function virtualenvwrapper_run_hook () { + python -m virtualenvwrapper.hook_loader "$@" } # Set up virtualenvwrapper properly function virtualenvwrapper_initialize () { virtualenvwrapper_verify_workon_home -q || return 1 - # mkvirtualenv - virtualenvwrapper_make_hook "$WORKON_HOME/premkvirtualenv" \ - "This hook is run after a new virtualenv is created and before it is activated." - virtualenvwrapper_make_hook "$WORKON_HOME/postmkvirtualenv" \ - "This hook is run after a new virtualenv is activated." - # rmvirtualenv - virtualenvwrapper_make_hook "$WORKON_HOME/prermvirtualenv" \ - "This hook is run before a virtualenv is deleted." - virtualenvwrapper_make_hook "$WORKON_HOME/postrmvirtualenv" \ - "This hook is run after a virtualenv is deleted." - # deactivate - virtualenvwrapper_make_hook "$WORKON_HOME/predeactivate" \ - "This hook is run before every virtualenv is deactivated." - virtualenvwrapper_make_hook "$WORKON_HOME/postdeactivate" \ - "This hook is run after every virtualenv is deactivated." - # activate - virtualenvwrapper_make_hook "$WORKON_HOME/preactivate" \ - "This hook is run before every virtualenv is activated." - virtualenvwrapper_make_hook "$WORKON_HOME/postactivate" \ - "This hook is run after every virtualenv is activated." + virtualenvwrapper_run_hook initialize + virtualenvwrapper_source_hook initialize } virtualenvwrapper_initialize @@ -152,30 +125,6 @@ function virtualenvwrapper_verify_active_environment () { return 0 } -# Run a hook script in the current shell -function virtualenvwrapper_source_hook () { - scriptname="$1" - #echo "Looking for hook $scriptname" - if [ -f "$scriptname" ] - then - source "$scriptname" - fi -} - -# Run a hook script in its own shell -function virtualenvwrapper_run_hook () { - scriptname="$1" - shift - #echo "Looking for hook $scriptname" - if [ -x "$scriptname" ] - then - "$scriptname" "$@" - elif [ -e "$scriptname" ] - then - echo "Warning: Found \"$scriptname\" but it is not executable." 1>&2 - fi -} - # Create a new environment, in the WORKON_HOME. # # Usage: mkvirtualenv [options] ENVNAME diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 2c5d7a1..2569631 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -6,24 +6,73 @@ """Load hooks for virtualenvwrapper. """ +import logging import optparse +import os import pkg_resources def main(): parser = optparse.OptionParser( - usage='usage: %prog [options] [options]', + usage='usage: %prog [options] []', prog='virtualenvwrapper.hook_loader', description='Manage hooks for virtualenvwrapper', ) + parser.add_option('-s', '--source', + help='Print the shell commands to be run in the current shell', + action='store_true', + dest='sourcing', + default=False, + ) + parser.add_option('-v', '--verbose', + help='Show more information on the console', + action='store_const', + const=2, + default=1, + dest='verbose_level', + ) + parser.add_option('-q', '--quiet', + help='Show less information on the console', + action='store_const', + const=0, + dest='verbose_level', + ) + parser.disable_interspersed_args() # stop when we hit an option without an '-' options, args = parser.parse_args() + # Set up logging to a file and to the console + logging.basicConfig( + filename=os.path.expandvars(os.path.join('$WORKON_HOME', 'hook.log')), + level=logging.DEBUG, + format='%(asctime)s %(levelname)s %(name)s %(message)s', + ) + console = logging.StreamHandler() + console_level = [ logging.WARNING, + logging.INFO, + logging.DEBUG, + ][options.verbose_level] + console.setLevel(console_level) + formatter = logging.Formatter('%(message)s') + console.setFormatter(formatter) + logging.getLogger('').addHandler(console) + + # Determine which hook we're running + if not args: + parser.error('Please specify the hook to run') hook = args[0] - print hook for ep in pkg_resources.iter_entry_points('virtualenvwrapper.%s' % hook): plugin = ep.load() - print plugin() + if options.sourcing: + # Show the shell commands so they can + # be run in the calling shell. + contents = (plugin(args[1:]) or '').strip() + if contents: + print contents + print + else: + # Just run the plugin ourselves + plugin(args[1:]) return 0 if __name__ == '__main__': diff --git a/virtualenvwrapper/make_hooks.py b/virtualenvwrapper/make_hooks.py index b8ea121..24ac5ef 100644 --- a/virtualenvwrapper/make_hooks.py +++ b/virtualenvwrapper/make_hooks.py @@ -6,8 +6,67 @@ """Plugin to create hooks during initialization phase. """ +import logging +import os +import stat + +log = logging.getLogger(__name__) + import pkg_resources -def pre_initialize_source(): - return pkg_resources.resource_string(__name__, 'make_hooks_pre_initialize.sh') +GLOBAL_HOOKS = [ + # initialize + ("initialize", + "This hook is run during the startup phase when loading virtualenvwrapper.sh."), + + # mkvirtualenv + ("premkvirtualenv", + "This hook is run after a new virtualenv is created and before it is activated."), + ("postmkvirtualenv", + "This hook is run after a new virtualenv is activated."), + + # rmvirtualenv + ("prermvirtualenv", + "This hook is run before a virtualenv is deleted."), + ("postrmvirtualenv", + "This hook is run after a virtualenv is deleted."), + + # deactivate + ("predeactivate", + "This hook is run before every virtualenv is deactivated."), + ("postdeactivate", + "This hook is run after every virtualenv is deactivated."), + + # activate + ("preactivate", + "This hook is run before every virtualenv is activated."), + ("postactivate", + "This hook is run after every virtualenv is activated."), + + ] + +def make_hook(filename, comment, permissions): + """Create a hook script. + + :param filename: The name of the file to write. + :param comment: The comment to insert into the file. + """ + filename = os.path.expanduser(os.path.expandvars(filename)) + if not os.path.exists(filename): + log.info('Creating %s', filename) + with open(filename, 'wt') as f: + f.write("""#!/bin/sh +# %s + +""" % comment) + os.chmod(filename, permissions) + return + + +def initialize(args): + permissions = stat.S_IRWXU | stat.S_IRWXG | stat.S_IROTH | stat.S_IXOTH + for filename, comment in GLOBAL_HOOKS: + make_hook(os.path.join('$WORKON_HOME', filename), comment, permissions) + return + diff --git a/virtualenvwrapper/make_hooks_pre_initialize.sh b/virtualenvwrapper/make_hooks_pre_initialize.sh deleted file mode 100644 index a355594..0000000 --- a/virtualenvwrapper/make_hooks_pre_initialize.sh +++ /dev/null @@ -1,51 +0,0 @@ -# -# Create the default hooks, if they do not exist on startup. -# - -# Create a hook script -# -# Usage: virtualenvwrapper_make_hook filename comment -# -function virtualenvwrapper_make_hook () { - filename="$1" - comment="$2" - if [ ! -f "$filename" ] - then - #echo "Creating $filename" - cat - > "$filename" < Date: Fri, 2 Apr 2010 09:13:29 -0400 Subject: [PATCH 161/947] convert more hooks; stop running tests when we see a failure or error --- Makefile | 2 +- setup.py | 7 +++ tests/test.sh | 6 +++ virtualenvwrapper.sh | 20 +++++---- virtualenvwrapper/hook_loader.py | 2 +- virtualenvwrapper/make_hooks.py | 29 +++++++++--- virtualenvwrapper/user_scripts.py | 47 ++++++++++++++++++-- virtualenvwrapper/user_scripts_initialize.sh | 5 --- 8 files changed, 93 insertions(+), 25 deletions(-) delete mode 100644 virtualenvwrapper/user_scripts_initialize.sh diff --git a/Makefile b/Makefile index ad5ddca..d90792c 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ test-loop: @for test_script in $(wildcard tests/test*.sh) ; do \ echo '********************************************************************************' ; \ echo "Running $$test_script with $(TEST_SHELL)" ; \ - SHUNIT_PARENT=$$test_script $(TEST_SHELL) $$test_script ; \ + SHUNIT_PARENT=$$test_script $(TEST_SHELL) $$test_script || exit 1 ; \ echo ; \ done diff --git a/setup.py b/setup.py index e59f429..88f8657 100644 --- a/setup.py +++ b/setup.py @@ -154,6 +154,13 @@ def find_package_data( 'virtualenvwrapper.initialize_source': [ 'user_scripts = virtualenvwrapper.user_scripts:initialize_source', ], + 'virtualenvwrapper.pre_mkvirtualenv': [ + 'user_scripts = virtualenvwrapper.user_scripts:pre_mkvirtualenv', + 'make_hooks = virtualenvwrapper.make_hooks:pre_mkvirtualenv', + ], + 'virtualenvwrapper.post_mkvirtualenv_source': [ + 'user_scripts = virtualenvwrapper.user_scripts:post_mkvirtualenv_source', + ], 'virtualenvwrapper.initialize': [ 'make_hooks = virtualenvwrapper.make_hooks:initialize', ] diff --git a/tests/test.sh b/tests/test.sh index 698c644..0dc0591 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -29,6 +29,12 @@ test_virtualenvwrapper_initialize() { assertTrue "Global $hook is not executable" "[ -x $WORKON_HOME/$hook ]" done assertTrue "Log file was not created" "[ -f $WORKON_HOME/hook.log ]" + export pre_test_dir=$(cd "$test_dir"; pwd) + echo "echo GLOBAL initialize >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/initialize" + virtualenvwrapper_initialize + output=$(cat "$test_dir/catch_output") + expected="GLOBAL initialize" + assertSame "$expected" "$output" } test_virtualenvwrapper_verify_workon_home() { diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 9384a64..5fb4e09 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -51,9 +51,12 @@ then export WORKON_HOME="$HOME/.virtualenvs" fi +# Locate the global Python where virtualenvwrapper is installed. +VIRTUALENVWRAPPER_PYTHON="$(which python)" + # Normalize the directory name in case it includes # relative path components. -WORKON_HOME=$(python -c "import os; print os.path.abspath(os.path.expandvars(os.path.expanduser(\"$WORKON_HOME\")))") +WORKON_HOME=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os; print os.path.abspath(os.path.expandvars(os.path.expanduser(\"$WORKON_HOME\")))") export WORKON_HOME # Verify that the WORKON_HOME directory exists @@ -66,17 +69,19 @@ function virtualenvwrapper_verify_workon_home () { return 0 } +HOOK_VERBOSE_OPTION="-v" # Run a hook script in the current shell function virtualenvwrapper_source_hook () { - python -m virtualenvwrapper.hook_loader --source "${1}_source" >>$TMPDIR/$$.hook + "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION \ + --source "${1}_source" >>$TMPDIR/$$.hook source $TMPDIR/$$.hook rm -f $TMPDIR/$$.hook } # Run a hook script in its own shell function virtualenvwrapper_run_hook () { - python -m virtualenvwrapper.hook_loader "$@" + "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION "$@" } # Set up virtualenvwrapper properly @@ -136,19 +141,16 @@ function mkvirtualenv () { virtualenvwrapper_verify_virtualenv || return 1 (cd "$WORKON_HOME" && virtualenv "$@" && - virtualenvwrapper_run_hook "./premkvirtualenv" "$envname" + virtualenvwrapper_run_hook "pre_mkvirtualenv" "$envname" ) # If they passed a help option or got an error from virtualenv, # the environment won't exist. Use that to tell whether # we should switch to the environment and run the hook. [ ! -d "$WORKON_HOME/$envname" ] && return 0 - # Create stubs for the environment-specific hook scripts. - virtualenvwrapper_make_hook "$WORKON_HOME/$envname/bin/postactivate" "This hook is sourced after the virtualenv is activated." - virtualenvwrapper_make_hook "$WORKON_HOME/$envname/bin/predeactivate" "This hook is sourced before the virtualenv is deactivated." - virtualenvwrapper_make_hook "$WORKON_HOME/$envname/bin/postdeactivate" "This hook is sourced after the virtualenv is deactivated." # Now activate the new environment workon "$envname" - virtualenvwrapper_source_hook "$WORKON_HOME/postmkvirtualenv" + virtualenvwrapper_run_hook "post_mkvirtualenv" + virtualenvwrapper_source_hook "post_mkvirtualenv" } # Remove an environment, in the WORKON_HOME. diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 2569631..a7a4b52 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -52,7 +52,7 @@ def main(): logging.DEBUG, ][options.verbose_level] console.setLevel(console_level) - formatter = logging.Formatter('%(message)s') + formatter = logging.Formatter('%(name)s %(message)s') console.setFormatter(formatter) logging.getLogger('').addHandler(console) diff --git a/virtualenvwrapper/make_hooks.py b/virtualenvwrapper/make_hooks.py index 24ac5ef..9f3203f 100644 --- a/virtualenvwrapper/make_hooks.py +++ b/virtualenvwrapper/make_hooks.py @@ -14,6 +14,8 @@ import pkg_resources +PERMISSIONS = stat.S_IRWXU | stat.S_IRWXG | stat.S_IROTH | stat.S_IXOTH + GLOBAL_HOOKS = [ # initialize ("initialize", @@ -42,10 +44,23 @@ "This hook is run before every virtualenv is activated."), ("postactivate", "This hook is run after every virtualenv is activated."), - ] -def make_hook(filename, comment, permissions): +LOCAL_HOOKS = [ + # deactivate + ("predeactivate", + "This hook is run before the virtualenv is deactivated."), + ("postdeactivate", + "This hook is run after the virtualenv is deactivated."), + + # activate + ("preactivate", + "This hook is run before the virtualenv is activated."), + ("postactivate", + "This hook is run after the virtualenv is activated."), + ] + +def make_hook(filename, comment): """Create a hook script. :param filename: The name of the file to write. @@ -59,14 +74,18 @@ def make_hook(filename, comment, permissions): # %s """ % comment) - os.chmod(filename, permissions) + os.chmod(filename, PERMISSIONS) return def initialize(args): - permissions = stat.S_IRWXU | stat.S_IRWXG | stat.S_IROTH | stat.S_IXOTH for filename, comment in GLOBAL_HOOKS: - make_hook(os.path.join('$WORKON_HOME', filename), comment, permissions) + make_hook(os.path.join('$WORKON_HOME', filename), comment) return +def pre_mkvirtualenv(args): + envname=args[0] + for filename, comment in LOCAL_HOOKS: + make_hook(os.path.join('$WORKON_HOME', envname, 'bin', filename), comment) + return diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 53f81a6..20bcec2 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -7,13 +7,52 @@ """ import logging +import os +import subprocess import pkg_resources log = logging.getLogger(__name__) -def initialize_source(args): - script_name = 'user_scripts_initialize.sh' - fname = pkg_resources.resource_filename(__name__, script_name) - log.debug('Looking for %s in %s', script_name, fname) +def get_script_source(script_name): + """Retrieve the source code for a script. + """ + script_path = pkg_resources.resource_filename(__name__, script_name) + if not script_path: + raise RuntimeError('Missing script for %s', script_name) + log.debug('Looking for %s in %s', script_name, script_path) return pkg_resources.resource_string(__name__, script_name) + + +def run_script(script_path, *args): + """Execute a script in a subshell. + """ + if os.path.exists(script_path): + log.debug('Running %s', script_path) + subprocess.call([script_path] + list(args), shell=True) + return + +# HOOKS + +def initialize_source(args): + return """ +# +# Run user-provided initialization scripts +# +[ -f "$WORKON_HOME/initialize" ] && source "$WORKON_HOME/initialize" +""" + +def pre_mkvirtualenv(args): + log.debug('pre_mkvirtualenv') + script_path = os.path.expandvars(os.path.join('$WORKON_HOME', 'premkvirtualenv')) + run_script(script_path, *args) + return + +def post_mkvirtualenv_source(args): + return """ +# +# Run user-provided mkvirtualenv scripts +# +[ -f "$WORKON_HOME/postmkvirtualenv" ] && source "$WORKON_HOME/postmkvirtualenv" +[ -f "$VIRTUAL_ENV/bin/postmkvirtualenv" ] && source "$VIRTUAL_ENV/bin/postmkvirtualenv" +""" diff --git a/virtualenvwrapper/user_scripts_initialize.sh b/virtualenvwrapper/user_scripts_initialize.sh deleted file mode 100644 index 734b895..0000000 --- a/virtualenvwrapper/user_scripts_initialize.sh +++ /dev/null @@ -1,5 +0,0 @@ -# -# Run user-provided initialization scripts -# -global_script="$WORKON_HOME/initialize" -[ -f "$global_script" ] && source "$global_script" From 50208a0de1bee31064e68556723c1138ee8693b5 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 3 Apr 2010 07:17:00 -0400 Subject: [PATCH 162/947] all existing tests are passing again --- Makefile | 7 +++- setup.py | 28 +++++++++++-- tests/test_run_hook.sh | 30 ++++++++++---- tests/test_workon.sh | 5 ++- virtualenvwrapper.sh | 37 +++++++---------- virtualenvwrapper/hook_loader.py | 2 + virtualenvwrapper/user_scripts.py | 69 +++++++++++++++++++++++++++++-- 7 files changed, 138 insertions(+), 40 deletions(-) diff --git a/Makefile b/Makefile index d90792c..0537f3b 100644 --- a/Makefile +++ b/Makefile @@ -34,8 +34,11 @@ docs/sphinx/web/templates/base.html: ~/Devel/doughellmann/doughellmann/templates # Testing TEST_SCRIPTS=$(wildcard tests/test*.sh) -.PHONY: test test-bash test-sh test-zsh test-loop test-install -test: test-bash test-sh test-zsh test-install +.PHONY: develop test test-bash test-sh test-zsh test-loop test-install +test: develop test-bash test-sh test-zsh test-install + +develop: + python setup.py develop test-bash: TEST_SHELL=bash $(MAKE) test-loop diff --git a/setup.py b/setup.py index 88f8657..a0a1f9b 100644 --- a/setup.py +++ b/setup.py @@ -151,9 +151,13 @@ def find_package_data( entry_points = { #'console_scripts': [ 'venvw_hook = virtualenvwrapper.hook_loader:main' ], + 'virtualenvwrapper.initialize': [ + 'make_hooks = virtualenvwrapper.make_hooks:initialize', + ], 'virtualenvwrapper.initialize_source': [ 'user_scripts = virtualenvwrapper.user_scripts:initialize_source', ], + 'virtualenvwrapper.pre_mkvirtualenv': [ 'user_scripts = virtualenvwrapper.user_scripts:pre_mkvirtualenv', 'make_hooks = virtualenvwrapper.make_hooks:pre_mkvirtualenv', @@ -161,9 +165,27 @@ def find_package_data( 'virtualenvwrapper.post_mkvirtualenv_source': [ 'user_scripts = virtualenvwrapper.user_scripts:post_mkvirtualenv_source', ], - 'virtualenvwrapper.initialize': [ - 'make_hooks = virtualenvwrapper.make_hooks:initialize', - ] + + 'virtualenvwrapper.pre_rmvirtualenv': [ + 'user_scripts = virtualenvwrapper.user_scripts:pre_rmvirtualenv', + ], + 'virtualenvwrapper.post_rmvirtualenv': [ + 'user_scripts = virtualenvwrapper.user_scripts:post_rmvirtualenv', + ], + + 'virtualenvwrapper.pre_activate': [ + 'user_scripts = virtualenvwrapper.user_scripts:pre_activate', + ], + 'virtualenvwrapper.post_activate_source': [ + 'user_scripts = virtualenvwrapper.user_scripts:post_activate_source', + ], + + 'virtualenvwrapper.pre_deactivate_source': [ + 'user_scripts = virtualenvwrapper.user_scripts:pre_deactivate_source', + ], + 'virtualenvwrapper.post_deactivate_source': [ + 'user_scripts = virtualenvwrapper.user_scripts:post_deactivate_source', + ], }, zip_safe=False, diff --git a/tests/test_run_hook.sh b/tests/test_run_hook.sh index f72a227..0b89878 100644 --- a/tests/test_run_hook.sh +++ b/tests/test_run_hook.sh @@ -2,14 +2,14 @@ #set -x -test_dir=$(dirname $0) -source "$test_dir/../virtualenvwrapper.sh" - export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" +test_dir=$(dirname $0) + oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" } oneTimeTearDown() { @@ -19,21 +19,33 @@ oneTimeTearDown() { setUp () { echo rm -f "$test_dir/catch_output" + rm -f "$WORKON_HOME/initialize" + rm -f "$WORKON_HOME/prermvirtualenv" } test_virtualenvwrapper_run_hook() { - echo "echo run >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/test_hook" - chmod +x "$WORKON_HOME/test_hook" - virtualenvwrapper_run_hook "$WORKON_HOME/test_hook" + echo "echo run >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/initialize" + chmod +x "$WORKON_HOME/initialize" + virtualenvwrapper_run_hook "initialize" + output=$(cat "$test_dir/catch_output") + expected="run" + assertSame "$expected" "$output" +} + +test_virtualenvwrapper_source_hook_permissions() { + echo "echo run >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/initialize" + chmod -x "$WORKON_HOME/initialize" + virtualenvwrapper_run_hook "initialize" output=$(cat "$test_dir/catch_output") expected="run" assertSame "$expected" "$output" } test_virtualenvwrapper_run_hook_permissions() { - echo "echo run >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/test_hook" - chmod -x "$WORKON_HOME/test_hook" - virtualenvwrapper_run_hook "$WORKON_HOME/test_hook" + echo "echo run $@ >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/prermvirtualenv" + chmod -x "$WORKON_HOME/prermvirtualenv" + touch "$test_dir/catch_output" + virtualenvwrapper_run_hook "pre_rmvirtualenv" "foo" output=$(cat "$test_dir/catch_output") expected="" assertSame "$expected" "$output" diff --git a/tests/test_workon.sh b/tests/test_workon.sh index 1db8ff9..5c17c88 100644 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -37,7 +37,8 @@ test_workon_activate_hooks () { chmod +x "$WORKON_HOME/env1/bin/${t}activate" done - rm "$test_dir/catch_output" + rm -f "$test_dir/catch_output" + touch "$test_dir/catch_output" workon env1 @@ -73,6 +74,8 @@ test_deactivate_hooks () { echo "echo ENV ${t}deactivate >> $test_dir/catch_output" > "$WORKON_HOME/env1/bin/${t}deactivate" done + touch "$test_dir/catch_output" + deactivate output=$(cat "$test_dir/catch_output") diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 5fb4e09..e21bbb7 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -71,24 +71,23 @@ function virtualenvwrapper_verify_workon_home () { HOOK_VERBOSE_OPTION="-v" -# Run a hook script in the current shell -function virtualenvwrapper_source_hook () { +# Run the hooks +function virtualenvwrapper_run_hook () { + # First anything that runs directly from the plugin + "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION "$@" + # Now anything that wants to run inside this shell + hook_name="$1" + shift # get rid of hook name "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION \ - --source "${1}_source" >>$TMPDIR/$$.hook + --source "${hook_name}_source" "$@" >>$TMPDIR/$$.hook source $TMPDIR/$$.hook rm -f $TMPDIR/$$.hook } -# Run a hook script in its own shell -function virtualenvwrapper_run_hook () { - "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION "$@" -} - # Set up virtualenvwrapper properly function virtualenvwrapper_initialize () { virtualenvwrapper_verify_workon_home -q || return 1 - virtualenvwrapper_run_hook initialize - virtualenvwrapper_source_hook initialize + virtualenvwrapper_run_hook "initialize" } virtualenvwrapper_initialize @@ -150,7 +149,6 @@ function mkvirtualenv () { # Now activate the new environment workon "$envname" virtualenvwrapper_run_hook "post_mkvirtualenv" - virtualenvwrapper_source_hook "post_mkvirtualenv" } # Remove an environment, in the WORKON_HOME. @@ -169,9 +167,9 @@ function rmvirtualenv () { echo "Either switch to another environment, or run 'deactivate'." >&2 return 1 fi - virtualenvwrapper_run_hook "$WORKON_HOME/prermvirtualenv" "$env_dir" + virtualenvwrapper_run_hook "pre_rmvirtualenv" "$env_name" rm -rf "$env_dir" - virtualenvwrapper_run_hook "$WORKON_HOME/postrmvirtualenv" "$env_dir" + virtualenvwrapper_run_hook "post_rmvirtualenv" "$env_name" } # List the available environments. @@ -215,8 +213,7 @@ function workon () { deactivate fi - virtualenvwrapper_run_hook "$WORKON_HOME/preactivate" - virtualenvwrapper_run_hook "$WORKON_HOME/$env_name/bin/preactivate" + virtualenvwrapper_run_hook "pre_activate" "$env_name" source "$activate" @@ -227,10 +224,10 @@ function workon () { eval 'function deactivate () { # Call the local hook before the global so we can undo # any settings made by the local postactivate first. - virtualenvwrapper_source_hook "$VIRTUAL_ENV/bin/predeactivate" - virtualenvwrapper_source_hook "$WORKON_HOME/predeactivate" + virtualenvwrapper_run_hook "pre_deactivate" env_postdeactivate_hook="$VIRTUAL_ENV/bin/postdeactivate" + old_env=$(basename "$VIRTUAL_ENV") # Restore the original definition of deactivate eval "$virtualenvwrapper_saved_deactivate" @@ -238,12 +235,10 @@ function workon () { # Instead of recursing, this calls the now restored original function. deactivate - virtualenvwrapper_source_hook "$env_postdeactivate_hook" - virtualenvwrapper_source_hook "$WORKON_HOME/postdeactivate" + virtualenvwrapper_run_hook "post_deactivate" "$old_env" }' - virtualenvwrapper_source_hook "$WORKON_HOME/postactivate" - virtualenvwrapper_source_hook "$VIRTUAL_ENV/bin/postactivate" + virtualenvwrapper_run_hook "post_activate" return 0 } diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index a7a4b52..3e5989b 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -56,6 +56,8 @@ def main(): console.setFormatter(formatter) logging.getLogger('').addHandler(console) + logging.getLogger(__name__).debug('cli args %s', args) + # Determine which hook we're running if not args: parser.error('Please specify the hook to run') diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 20bcec2..a1c78af 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -32,27 +32,88 @@ def run_script(script_path, *args): subprocess.call([script_path] + list(args), shell=True) return +def run_global(script_name, *args): + script_path = os.path.expandvars(os.path.join('$WORKON_HOME', script_name)) + run_script(script_path, *args) + return + +def run_local_from_arg(script_name, *args): + script_path = os.path.expandvars(os.path.join('$WORKON_HOME', args[0], 'bin', script_name)) + run_script(script_path, *args) + return + +def run_local_from_env(script_name, *args): + script_path = os.path.expandvars(os.path.join('$VIRTUAL_ENV', 'bin', script_name)) + run_script(script_path, *args) + return + + # HOOKS def initialize_source(args): return """ # -# Run user-provided initialization scripts +# Run user-provided scripts # [ -f "$WORKON_HOME/initialize" ] && source "$WORKON_HOME/initialize" """ def pre_mkvirtualenv(args): log.debug('pre_mkvirtualenv') - script_path = os.path.expandvars(os.path.join('$WORKON_HOME', 'premkvirtualenv')) - run_script(script_path, *args) + run_global('premkvirtualenv') return def post_mkvirtualenv_source(args): return """ # -# Run user-provided mkvirtualenv scripts +# Run user-provided scripts # [ -f "$WORKON_HOME/postmkvirtualenv" ] && source "$WORKON_HOME/postmkvirtualenv" [ -f "$VIRTUAL_ENV/bin/postmkvirtualenv" ] && source "$VIRTUAL_ENV/bin/postmkvirtualenv" """ + +def pre_rmvirtualenv(args): + log.debug('pre_rmvirtualenv') + run_global('prermvirtualenv', *args) + return + +def post_rmvirtualenv(args): + log.debug('post_rmvirtualenv') + run_global('postrmvirtualenv', *args) + return + +def pre_activate(args): + log.debug('pre_activate') + run_global('preactivate', *args) + run_local_from_arg('preactivate', *args) + return + +def post_activate_source(args): + log.debug('post_activate') + return """ +# +# Run user-provided scripts +# +[ -f "$WORKON_HOME/postactivate" ] && source "$WORKON_HOME/postactivate" +[ -f "$VIRTUAL_ENV/bin/postactivate" ] && source "$VIRTUAL_ENV/bin/postactivate" +""" + +def pre_deactivate_source(args): + log.debug('pre_deactivate') + return """ +# +# Run user-provided scripts +# +[ -f "$VIRTUAL_ENV/bin/predeactivate" ] && source "$VIRTUAL_ENV/bin/predeactivate" +[ -f "$WORKON_HOME/predeactivate" ] && source "$WORKON_HOME/predeactivate" +""" + +def post_deactivate_source(args): + log.debug('post_deactivate') + return """ +# +# Run user-provided scripts +# +[ -f "$WORKON_HOME/%(env_name)s/bin/postdeactivate" ] && source "$WORKON_HOME/%(env_name)s/bin/postdeactivate" +[ -f "$WORKON_HOME/postdeactivate" ] && source "$WORKON_HOME/postdeactivate" +""" % { 'env_name':args[0] } From d9448167a9b52d17680e086ad5191e129a843d55 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 3 Apr 2010 07:19:34 -0400 Subject: [PATCH 163/947] comment out debug logging --- virtualenvwrapper/hook_loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 3e5989b..debbbeb 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -56,7 +56,7 @@ def main(): console.setFormatter(formatter) logging.getLogger('').addHandler(console) - logging.getLogger(__name__).debug('cli args %s', args) + #logging.getLogger(__name__).debug('cli args %s', args) # Determine which hook we're running if not args: From 8bb2541f247c0fdd17054c3ead14a67b200e3028 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 3 Apr 2010 07:45:23 -0400 Subject: [PATCH 164/947] minor doc updates and formatting changes --- docs/source/command_ref.rst | 55 +++++++++------ docs/source/developers.rst | 129 +++++++----------------------------- docs/source/hooks.rst | 44 +++++++++--- 3 files changed, 94 insertions(+), 134 deletions(-) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 4b46733..dd9594d 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -20,7 +20,7 @@ Syntax:: mkvirtualenv [options] ENVNAME -(where the options are passed directly to virtualenv) +(any options are passed directly to ``virtualenv``) rmvirtualenv ------------ @@ -54,12 +54,14 @@ Syntax:: workon [environment_name] -If no ``environment_name`` is given the list of available environments is printed to stdout. +If no ``environment_name`` is given the list of available environments +is printed to stdout. deactivate ---------- -Switch from a virtual environment to the system-installed version of Python. +Switch from a virtual environment to the system-installed version of +Python. Syntax:: @@ -67,19 +69,23 @@ Syntax:: .. note:: - This command is actually part of virtualenv, but is wrapped to provide before and after hooks, just as workon does for activate. + This command is actually part of virtualenv, but is wrapped to + provide before and after hooks, just as workon does for activate. ================================== Quickly Navigating to a virtualenv ================================== -There are two functions to provide shortcuts to navigate into the the currently-active -virtualenv. +There are two functions to provide shortcuts to navigate into the the +currently-active virtualenv. cdvirtualenv ------------ -Calling ``cdvirtualenv`` changes the current working directory to the top of the virtualenv (``$VIRTUAL_ENV``). An optional argument is appended to the path, allowing navigation directly into a subdirectory. +Calling ``cdvirtualenv`` changes the current working directory to the +top of the virtualenv (``$VIRTUAL_ENV``). An optional argument is +appended to the path, allowing navigation directly into a +subdirectory. :: @@ -96,10 +102,12 @@ Calling ``cdvirtualenv`` changes the current working directory to the top of the cdsitepackages -------------- -Because the exact path to the site-packages directory in the virtualenv depends on the -version of Python, ``cdsitepackages`` is provided as a shortcut for ``cdvirtualenv -lib/python${pyvers}/site-packages``. An optional argument is also allowed, to specify -a directory hierarchy within the ``site-packages`` directory to change into. +Because the exact path to the site-packages directory in the +virtualenv depends on the version of Python, ``cdsitepackages`` is +provided as a shortcut for ``cdvirtualenv +lib/python${pyvers}/site-packages``. An optional argument is also +allowed, to specify a directory hierarchy within the ``site-packages`` +directory to change into. :: $ workon pymotw @@ -113,7 +121,12 @@ a directory hierarchy within the ``site-packages`` directory to change into. Path Management =============== -Sometimes it is desirable to share installed packages that are not in the system ``site-pacakges`` directory and which you do not want to install in each virtualenv. In this case, you *could* symlink the source into the environment ``site-packages`` directory, but it is also easy to add extra directories to the PYTHONPATH by including them in a .pth file inside ``site-packages`` using ``add2virtualenv``. +Sometimes it is desirable to share installed packages that are not in +the system ``site-pacakges`` directory and which you do not want to +install in each virtualenv. In this case, you *could* symlink the +source into the environment ``site-packages`` directory, but it is +also easy to add extra directories to the PYTHONPATH by including them +in a .pth file inside ``site-packages`` using ``add2virtualenv``. 1. Check out the source for a big project, such as Django. 2. Run: ``add2virtualenv path_to_source``. @@ -123,22 +136,24 @@ Sometimes it is desirable to share installed packages that are not in the system add2virtualenv -------------- -Adds the specified directories to the Python path for the currently-active -virtualenv. +Adds the specified directories to the Python path for the +currently-active virtualenv. Syntax:: add2virtualenv directory1 directory2 ... -Path management for packages outside of the virtual env. -Based on a contribution from James Bennett and Jannis Leidel. +Path management for packages outside of the virtual env. Based on a +contribution from James Bennett and Jannis Leidel. -This will be done by placing the directory names in a path file -named ``virtualenv_path_extensions.pth`` inside the virtualenv's site-packages -directory; if this file does not exist, it will be created first. +This will be done by placing the directory names in a path file named +``virtualenv_path_extensions.pth`` inside the virtualenv's +site-packages directory; if this file does not exist, it will be +created first. lssitepackages -------------- -Calling ``lssitepackages`` shows the content of the ``site-packages`` directory of the currently-active virtualenv. +Calling ``lssitepackages`` shows the content of the ``site-packages`` +directory of the currently-active virtualenv. diff --git a/docs/source/developers.rst b/docs/source/developers.rst index 9d1d19b..bffbbac 100644 --- a/docs/source/developers.rst +++ b/docs/source/developers.rst @@ -18,45 +18,41 @@ Paver. You will need the following packages in order to build the docs: - Sphinx -- Paver - docutils -- sphinxcontrib-paverutils -Once all of them are installed into a virtualenv using easy_install, -run ``paver html`` to generate the HTML version of the documentation:: +Once all of the tools are installed into a virtualenv using +pip, run ``make html`` to generate the HTML version of the +documentation:: - $ paver html - ---> pavement.html - ---> sphinxcontrib.paverutils.html - mkdir ./docs/html (mode 511) - sphinx-build -b html -d ./docs/doctrees -c sphinx/pkg -Aproject=virtualenvwrapper ./docsource ./docs/html - Running Sphinx v0.6.1 + $ make html + rm -rf virtualenvwrapper/docs + (cd docs && make html SPHINXOPTS="-c sphinx/pkg") + sphinx-build -b html -d build/doctrees -c sphinx/pkg source build/html + Running Sphinx v0.6.4 loading pickled environment... done - building [html]: targets for 4 source files that are out of date - updating environment: 1 added, 1 changed, 0 removed - reading sources... [ 50%] developers - reading sources... [100%] index - - /Users/dhellmann/Devel/virtualenvwrapper/src/docsource/developers.rst:19: (WARNING/2) Literal block expected; none found. + building [html]: targets for 2 source files that are out of date + updating environment: 0 added, 2 changed, 0 removed + reading sources... [ 50%] command_ref + reading sources... [100%] developers + looking for now-outdated files... none found pickling environment... done checking consistency... done preparing documents... done - writing output... [ 20%] command_ref - writing output... [ 40%] developers - writing output... [ 60%] history - writing output... [ 80%] hooks + writing output... [ 33%] command_ref + writing output... [ 66%] developers writing output... [100%] index - + writing additional files... search - copying static files... WARNING: static directory '/Users/dhellmann/Devel/virtualenvwrapper/src/sphinx/pkg/static' does not exist + copying static files... WARNING: static directory '/Users/dhellmann/Devel/virtualenvwrapper/plugins/docs/sphinx/pkg/static' does not exist done dumping search index... done dumping object inventory... done - build succeeded, 2 warnings. - rmtree virtualenvwrapper/docs () {} - move docs/html virtualenvwrapper/docs - + build succeeded, 1 warning. + + Build finished. The HTML pages are in build/html. + cp -r docs/build/html virtualenvwrapper/docs + The output version of the documentation ends up in ``./virtualenvwrapper/docs`` inside your sandbox. @@ -64,81 +60,6 @@ Running Tests ============= The test suite for virtualenvwrapper uses `shunit2 -`_. To run the tests under both bash -and zsh, use ``paver test``. To add new tests, modify the -``tests/test.sh`` script with new test functions. - -:: - - $ paver test - ---> pavement.test - bash ./tests/test.sh - - test_mkvirtualenv - New python executable in env1/bin/python - Installing setuptools............done. - - test_cdvirtual - - test_cdsitepackages - - test_mkvirtualenv_activates - New python executable in env2/bin/python - Installing setuptools............done. - - test_workon - - test_postactivate_hook - - test_deactivate - - test_deactivate_hooks - - test_virtualenvwrapper_show_workon_options - - test_rmvirtualenv - New python executable in deleteme/bin/python - Installing setuptools............done. - - test_rmvirtualenv_no_such_env - - test_missing_workon_home - - Ran 12 tests. - - OK - SHUNIT_PARENT=./tests/test.sh zsh -o shwordsplit ./tests/test.sh - - test_mkvirtualenv - New python executable in env1/bin/python - Installing setuptools............done. - - test_cdvirtual - - test_cdsitepackages - - test_mkvirtualenv_activates - New python executable in env2/bin/python - Installing setuptools............done. - - test_workon - - test_postactivate_hook - - test_deactivate - - test_deactivate_hooks - - test_virtualenvwrapper_show_workon_options - - test_rmvirtualenv - New python executable in deleteme/bin/python - Installing setuptools............done. - - test_rmvirtualenv_no_such_env - - test_missing_workon_home - - Ran 12 tests. - - OK +`_. To run the tests under bash, sh, +and zsh, use ``make test``. To add new tests, modify or create an +appropriate script in the ``tests`` directory. diff --git a/docs/source/hooks.rst b/docs/source/hooks.rst index 06031c3..6b9bd44 100644 --- a/docs/source/hooks.rst +++ b/docs/source/hooks.rst @@ -2,7 +2,11 @@ Hook Scripts ============ -virtualenvwrapper adds several hook points you can use to change your settings, shell environment, or other configuration values when creating, deleting, or moving between environments. They are either *sourced* (allowing them to modify your shell environment) or *run* as an external program at the appropriate trigger time. +virtualenvwrapper adds several hook points you can use to change your +settings, shell environment, or other configuration values when +creating, deleting, or moving between environments. They are either +*sourced* (allowing them to modify your shell environment) or *run* as +an external program at the appropriate trigger time. Environment Hooks ================= @@ -10,9 +14,13 @@ Environment Hooks postactivate ------------ -The ``$VIRTUAL_ENV/bin/postactivate`` script is sourced after the new environment is enabled. ``$VIRTUAL_ENV`` refers to the new environment at the time the script runs. +The ``$VIRTUAL_ENV/bin/postactivate`` script is sourced after the new +environment is enabled. ``$VIRTUAL_ENV`` refers to the new environment +at the time the script runs. -This example script for the PyMOTW environment changes the current working directory and the PATH variable to refer to the source tree containing the PyMOTW source. +This example script for the PyMOTW environment changes the current +working directory and the PATH variable to refer to the source tree +containing the PyMOTW source. :: @@ -23,7 +31,10 @@ This example script for the PyMOTW environment changes the current working direc predeactivate ------------- -The ``$VIRTUAL_ENV/bin/predeactivate`` script is sourced before the current environment is deactivated, and can be used to disable or clear settings in your environment. ``$VIRTUAL_ENV`` refers to the old environment at the time the script runs. +The ``$VIRTUAL_ENV/bin/predeactivate`` script is sourced before the +current environment is deactivated, and can be used to disable or +clear settings in your environment. ``$VIRTUAL_ENV`` refers to the old +environment at the time the script runs. Global Hooks ============ @@ -31,9 +42,13 @@ Global Hooks postactivate ------------ -The global ``$WORKON_HOME/postactivate`` script is sourced after the new environment is enabled and the new environment's postactivate is sourced (if it exists). ``$VIRTUAL_ENV`` refers to the new environment at the time the script runs. +The global ``$WORKON_HOME/postactivate`` script is sourced after the +new environment is enabled and the new environment's postactivate is +sourced (if it exists). ``$VIRTUAL_ENV`` refers to the new environment +at the time the script runs. -This example script adds a space between the virtual environment name and your old PS1 by making use of ``_OLD_VIRTUAL_PS1``. +This example script adds a space between the virtual environment name +and your old PS1 by making use of ``_OLD_VIRTUAL_PS1``. :: @@ -42,19 +57,28 @@ This example script adds a space between the virtual environment name and your o premkvirtualenv --------------- -The ``$WORKON_HOME/premkvirtualenv`` script is run as an external program after the virtual environment is created but before the current environment is switched to point to the new env. The current working directory for the script is ``$WORKON_HOME`` and the name of the new environment is passed as an argument to the script. +The ``$WORKON_HOME/premkvirtualenv`` script is run as an external +program after the virtual environment is created but before the +current environment is switched to point to the new env. The current +working directory for the script is ``$WORKON_HOME`` and the name of +the new environment is passed as an argument to the script. postmkvirtualenv ---------------- -The ``$WORKON_HOME/postmkvirtualenv`` script is sourced after the new environment is created and activated. +The ``$WORKON_HOME/postmkvirtualenv`` script is sourced after the new +environment is created and activated. prermvirtualenv --------------- -The ``$WORKON_HOME/prermvirtualenv`` script is run as an external program before the environment is removed. The full path to the environment directory is passed as an argument to the script. +The ``$WORKON_HOME/prermvirtualenv`` script is run as an external +program before the environment is removed. The full path to the +environment directory is passed as an argument to the script. postrmvirtualenv ---------------- -The ``$WORKON_HOME/postrmvirtualenv`` script is run as an external program after the environment is removed. The full path to the environment directory is passed as an argument to the script. +The ``$WORKON_HOME/postrmvirtualenv`` script is run as an external +program after the environment is removed. The full path to the +environment directory is passed as an argument to the script. From 4922a3fd89b6f0da9efb2b0f1a185ae5af0e8be7 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 3 Apr 2010 16:57:15 -0400 Subject: [PATCH 165/947] quiet hook loader --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index e21bbb7..9dfc26e 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -69,7 +69,7 @@ function virtualenvwrapper_verify_workon_home () { return 0 } -HOOK_VERBOSE_OPTION="-v" +#HOOK_VERBOSE_OPTION="-v" # Run the hooks function virtualenvwrapper_run_hook () { From 7bc348bb16ea8923769d13dac4c7a678c6d71341 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 3 Apr 2010 16:57:55 -0400 Subject: [PATCH 166/947] use the user's current shell as the default interpreter in the hook script --- virtualenvwrapper/make_hooks.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/virtualenvwrapper/make_hooks.py b/virtualenvwrapper/make_hooks.py index 9f3203f..eb47848 100644 --- a/virtualenvwrapper/make_hooks.py +++ b/virtualenvwrapper/make_hooks.py @@ -49,15 +49,15 @@ LOCAL_HOOKS = [ # deactivate ("predeactivate", - "This hook is run before the virtualenv is deactivated."), + "This hook is run before this virtualenv is deactivated."), ("postdeactivate", - "This hook is run after the virtualenv is deactivated."), + "This hook is run after this virtualenv is deactivated."), # activate ("preactivate", - "This hook is run before the virtualenv is activated."), + "This hook is run before this virtualenv is activated."), ("postactivate", - "This hook is run after the virtualenv is activated."), + "This hook is run after this virtualenv is activated."), ] def make_hook(filename, comment): @@ -70,10 +70,10 @@ def make_hook(filename, comment): if not os.path.exists(filename): log.info('Creating %s', filename) with open(filename, 'wt') as f: - f.write("""#!/bin/sh -# %s + f.write("""#!%(shell)s +# %(comment)s -""" % comment) +""" % {'comment':comment, 'shell':os.environ.get('SHELL', '/bin/sh')}) os.chmod(filename, PERMISSIONS) return From 19b3de708a83a08eb0829e28bfad7b5fcbfd121b Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 3 Apr 2010 16:59:14 -0400 Subject: [PATCH 167/947] add VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV variable for postdeactivate scripts --- virtualenvwrapper/user_scripts.py | 51 ++++++++++++++++--------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index a1c78af..a991567 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -14,38 +14,32 @@ log = logging.getLogger(__name__) -def get_script_source(script_name): - """Retrieve the source code for a script. - """ - script_path = pkg_resources.resource_filename(__name__, script_name) - if not script_path: - raise RuntimeError('Missing script for %s', script_name) - log.debug('Looking for %s in %s', script_name, script_path) - return pkg_resources.resource_string(__name__, script_name) - def run_script(script_path, *args): """Execute a script in a subshell. """ if os.path.exists(script_path): - log.debug('Running %s', script_path) - subprocess.call([script_path] + list(args), shell=True) +# with open(script_path, 'rt') as f: +# print '+' * 80 +# print f.read() +# print '+' * 80 + cmd = [script_path] + list(args) + log.debug('Running %s', str(cmd)) + try: + return_code = subprocess.call(cmd) + except OSError, msg: + log.error('ERROR: Could not run %s. %s', script_path, str(msg)) + #log.debug('Returned %s', return_code) return + def run_global(script_name, *args): + """Run a script from $WORKON_HOME. + """ script_path = os.path.expandvars(os.path.join('$WORKON_HOME', script_name)) run_script(script_path, *args) return -def run_local_from_arg(script_name, *args): - script_path = os.path.expandvars(os.path.join('$WORKON_HOME', args[0], 'bin', script_name)) - run_script(script_path, *args) - return - -def run_local_from_env(script_name, *args): - script_path = os.path.expandvars(os.path.join('$VIRTUAL_ENV', 'bin', script_name)) - run_script(script_path, *args) - return # HOOKS @@ -59,35 +53,40 @@ def initialize_source(args): """ def pre_mkvirtualenv(args): - log.debug('pre_mkvirtualenv') - run_global('premkvirtualenv') + log.debug('pre_mkvirtualenv %s', str(args)) + run_global('premkvirtualenv', *args) return + def post_mkvirtualenv_source(args): return """ # # Run user-provided scripts # [ -f "$WORKON_HOME/postmkvirtualenv" ] && source "$WORKON_HOME/postmkvirtualenv" -[ -f "$VIRTUAL_ENV/bin/postmkvirtualenv" ] && source "$VIRTUAL_ENV/bin/postmkvirtualenv" """ + def pre_rmvirtualenv(args): log.debug('pre_rmvirtualenv') run_global('prermvirtualenv', *args) return + def post_rmvirtualenv(args): log.debug('post_rmvirtualenv') run_global('postrmvirtualenv', *args) return + def pre_activate(args): log.debug('pre_activate') run_global('preactivate', *args) - run_local_from_arg('preactivate', *args) + script_path = os.path.expandvars(os.path.join('$WORKON_HOME', args[0], 'bin', 'preactivate')) + run_script(script_path, *args) return + def post_activate_source(args): log.debug('post_activate') return """ @@ -98,6 +97,7 @@ def post_activate_source(args): [ -f "$VIRTUAL_ENV/bin/postactivate" ] && source "$VIRTUAL_ENV/bin/postactivate" """ + def pre_deactivate_source(args): log.debug('pre_deactivate') return """ @@ -108,12 +108,15 @@ def pre_deactivate_source(args): [ -f "$WORKON_HOME/predeactivate" ] && source "$WORKON_HOME/predeactivate" """ + def post_deactivate_source(args): log.debug('post_deactivate') return """ # # Run user-provided scripts # +VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV="$WORKON_HOME/%(env_name)s" [ -f "$WORKON_HOME/%(env_name)s/bin/postdeactivate" ] && source "$WORKON_HOME/%(env_name)s/bin/postdeactivate" [ -f "$WORKON_HOME/postdeactivate" ] && source "$WORKON_HOME/postdeactivate" +unset VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV """ % { 'env_name':args[0] } From 64730996caaf27a02ea8e2c7dfc06199b40df5d3 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 3 Apr 2010 16:59:30 -0400 Subject: [PATCH 168/947] test cleanup and enhancement --- tests/test_mkvirtualenv.sh | 7 +++---- tests/test_run_hook.sh | 4 +++- tests/test_workon.sh | 10 +++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index 73acee8..e0ca3cb 100644 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -3,13 +3,12 @@ #set -x test_dir=$(dirname $0) -source "$test_dir/../virtualenvwrapper.sh" - export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" } oneTimeTearDown() { @@ -39,12 +38,12 @@ test_activates () { test_hooks () { export pre_test_dir=$(cd "$test_dir"; pwd) - echo "echo GLOBAL premkvirtualenv >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" + echo "echo GLOBAL premkvirtualenv \`pwd\` \"\$@\" >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" chmod +x "$WORKON_HOME/premkvirtualenv" echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" mkvirtualenv "env3" output=$(cat "$test_dir/catch_output") - expected="GLOBAL premkvirtualenv + expected="GLOBAL premkvirtualenv $WORKON_HOME env3 GLOBAL postmkvirtualenv" assertSame "$expected" "$output" rm -f "$WORKON_HOME/premkvirtualenv" diff --git a/tests/test_run_hook.sh b/tests/test_run_hook.sh index 0b89878..34b675e 100644 --- a/tests/test_run_hook.sh +++ b/tests/test_run_hook.sh @@ -42,13 +42,15 @@ test_virtualenvwrapper_source_hook_permissions() { } test_virtualenvwrapper_run_hook_permissions() { + echo "#!/bin/sh" > "$WORKON_HOME/prermvirtualenv" echo "echo run $@ >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/prermvirtualenv" chmod -x "$WORKON_HOME/prermvirtualenv" touch "$test_dir/catch_output" - virtualenvwrapper_run_hook "pre_rmvirtualenv" "foo" + error=$(virtualenvwrapper_run_hook "pre_rmvirtualenv" "foo" 2>&1 | grep "ERROR") output=$(cat "$test_dir/catch_output") expected="" assertSame "$expected" "$output" + assertSame "virtualenvwrapper.user_scripts ERROR: Could not run $WORKON_HOME/prermvirtualenv. [Errno 13] Permission denied" "$error" } . "$test_dir/shunit2" diff --git a/tests/test_workon.sh b/tests/test_workon.sh index 5c17c88..4b4e62f 100644 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -3,13 +3,13 @@ #set -x test_dir=$(dirname $0) -source "$test_dir/../virtualenvwrapper.sh" export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" mkvirtualenv "env1" } @@ -70,8 +70,8 @@ test_deactivate_hooks () { for t in pre post do - echo "echo GLOBAL ${t}deactivate >> $test_dir/catch_output" > "$WORKON_HOME/${t}deactivate" - echo "echo ENV ${t}deactivate >> $test_dir/catch_output" > "$WORKON_HOME/env1/bin/${t}deactivate" + echo "echo GLOBAL ${t}deactivate \$VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV >> $test_dir/catch_output" > "$WORKON_HOME/${t}deactivate" + echo "echo ENV ${t}deactivate \$VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV >> $test_dir/catch_output" > "$WORKON_HOME/env1/bin/${t}deactivate" done touch "$test_dir/catch_output" @@ -81,8 +81,8 @@ test_deactivate_hooks () { output=$(cat "$test_dir/catch_output") expected="ENV predeactivate GLOBAL predeactivate -ENV postdeactivate -GLOBAL postdeactivate" +ENV postdeactivate $WORKON_HOME/env1 +GLOBAL postdeactivate $WORKON_HOME/env1" assertSame "$expected" "$output" for t in pre post From 2c46edff8d34f867bb1ca873eba8ff1fbf3d12ab Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 3 Apr 2010 17:20:04 -0400 Subject: [PATCH 169/947] start overhauling doc content --- docs/source/command_ref.rst | 22 +++++ docs/source/developers.rst | 17 ++++ docs/source/extensions.rst | 7 ++ docs/source/hooks.rst | 88 +++----------------- docs/source/index.rst | 7 +- docs/source/plugins.rst | 19 +++++ docs/source/scripts.rst | 157 ++++++++++++++++++++++++++++++++++++ 7 files changed, 235 insertions(+), 82 deletions(-) create mode 100644 docs/source/extensions.rst create mode 100644 docs/source/plugins.rst create mode 100644 docs/source/scripts.rst diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index dd9594d..e83d48e 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -22,6 +22,11 @@ Syntax:: (any options are passed directly to ``virtualenv``) +.. seealso:: + + * :ref:`hooks-scripts-premkvirtualenv` + * :ref:`hooks-scripts-postmkvirtualenv` + rmvirtualenv ------------ @@ -31,6 +36,11 @@ Syntax:: rmvirtualenv ENVNAME +.. seealso:: + + * :ref:`hooks-scripts-prermvirtualenv` + * :ref:`hooks-scripts-postrmvirtualenv` + cpvirtualenv ------------ @@ -57,6 +67,13 @@ Syntax:: If no ``environment_name`` is given the list of available environments is printed to stdout. +.. seealso:: + + * :ref:`hooks-scripts-predeactivate` + * :ref:`hooks-scripts-postdeactivate` + * :ref:`hooks-scripts-preactivate` + * :ref:`hooks-scripts-postactivate` + deactivate ---------- @@ -72,6 +89,11 @@ Syntax:: This command is actually part of virtualenv, but is wrapped to provide before and after hooks, just as workon does for activate. +.. seealso:: + + * :ref:`hooks-scripts-predeactivate` + * :ref:`hooks-scripts-postdeactivate` + ================================== Quickly Navigating to a virtualenv ================================== diff --git a/docs/source/developers.rst b/docs/source/developers.rst index bffbbac..9d396cd 100644 --- a/docs/source/developers.rst +++ b/docs/source/developers.rst @@ -63,3 +63,20 @@ The test suite for virtualenvwrapper uses `shunit2 `_. To run the tests under bash, sh, and zsh, use ``make test``. To add new tests, modify or create an appropriate script in the ``tests`` directory. + +.. _developers-extensions: + +Creating Extension Plugins +========================== + +virtualenvwrapper adds several hook points you can use to modify its +behavior. End-users can provide simple shell scripts (see +:ref:`hook-scripts`). Extensions can also be implemented in Python by +using the ``setuptools`` style *entry points*. + +Types of Hooks +-------------- + +Existing Hook Points +-------------------- + diff --git a/docs/source/extensions.rst b/docs/source/extensions.rst new file mode 100644 index 0000000..d176bdb --- /dev/null +++ b/docs/source/extensions.rst @@ -0,0 +1,7 @@ +===================== + Existing Extensions +===================== + +make_hooks + +user_scripts diff --git a/docs/source/hooks.rst b/docs/source/hooks.rst index 6b9bd44..3114e32 100644 --- a/docs/source/hooks.rst +++ b/docs/source/hooks.rst @@ -1,84 +1,14 @@ -============ -Hook Scripts -============ +=============================== + Customizing Virtualenvwrapper +=============================== virtualenvwrapper adds several hook points you can use to change your settings, shell environment, or other configuration values when -creating, deleting, or moving between environments. They are either -*sourced* (allowing them to modify your shell environment) or *run* as -an external program at the appropriate trigger time. +creating, deleting, or moving between environments. These hooks are +exposed in two ways: -Environment Hooks -================= +.. toctree:: + :maxdepth: 1 -postactivate ------------- - -The ``$VIRTUAL_ENV/bin/postactivate`` script is sourced after the new -environment is enabled. ``$VIRTUAL_ENV`` refers to the new environment -at the time the script runs. - -This example script for the PyMOTW environment changes the current -working directory and the PATH variable to refer to the source tree -containing the PyMOTW source. - -:: - - pymotw_root=/Users/dhellmann/Documents/PyMOTW - cd $pymotw_root - PATH=$pymotw_root/bin:$PATH - -predeactivate -------------- - -The ``$VIRTUAL_ENV/bin/predeactivate`` script is sourced before the -current environment is deactivated, and can be used to disable or -clear settings in your environment. ``$VIRTUAL_ENV`` refers to the old -environment at the time the script runs. - -Global Hooks -============ - -postactivate ------------- - -The global ``$WORKON_HOME/postactivate`` script is sourced after the -new environment is enabled and the new environment's postactivate is -sourced (if it exists). ``$VIRTUAL_ENV`` refers to the new environment -at the time the script runs. - -This example script adds a space between the virtual environment name -and your old PS1 by making use of ``_OLD_VIRTUAL_PS1``. - -:: - - PS1="(`basename \"$VIRTUAL_ENV\"`) $_OLD_VIRTUAL_PS1" - -premkvirtualenv ---------------- - -The ``$WORKON_HOME/premkvirtualenv`` script is run as an external -program after the virtual environment is created but before the -current environment is switched to point to the new env. The current -working directory for the script is ``$WORKON_HOME`` and the name of -the new environment is passed as an argument to the script. - -postmkvirtualenv ----------------- - -The ``$WORKON_HOME/postmkvirtualenv`` script is sourced after the new -environment is created and activated. - -prermvirtualenv ---------------- - -The ``$WORKON_HOME/prermvirtualenv`` script is run as an external -program before the environment is removed. The full path to the -environment directory is passed as an argument to the script. - -postrmvirtualenv ----------------- - -The ``$WORKON_HOME/postrmvirtualenv`` script is run as an external -program after the environment is removed. The full path to the -environment directory is passed as an argument to the script. + scripts + plugins diff --git a/docs/source/index.rst b/docs/source/index.rst index 1240e8d..e2f354d 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -3,9 +3,9 @@ You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -################# -virtualenvwrapper -################# +########################### +virtualenvwrapper |release| +########################### virtualenvwrapper is a set of extensions to Ian Bicking's `virtualenv `_ tool. The extensions @@ -68,6 +68,7 @@ Details tips history developers + extensions .. _references: diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst new file mode 100644 index 0000000..71e7bdc --- /dev/null +++ b/docs/source/plugins.rst @@ -0,0 +1,19 @@ +.. _developers-extensions: + +=================== + Extension Plugins +=================== + +virtualenvwrapper adds several hook points you can use to modify its +behavior. End-users can provide simple shell scripts (see +:ref:`hook-scripts`). Extensions can also be implemented in Python by +using the ``setuptools`` style *entry points*. + +Types of Hooks +-------------- + +Existing Hook Points +-------------------- + +Logging +------- diff --git a/docs/source/scripts.rst b/docs/source/scripts.rst new file mode 100644 index 0000000..0a036b5 --- /dev/null +++ b/docs/source/scripts.rst @@ -0,0 +1,157 @@ +.. _hooks-scripts: + +Per-User Hook Scripts +===================== + +The end-user customization scripts are either *sourced* (allowing them +to modify your shell environment) or *run* as an external program at +the appropriate trigger time. + +.. _hooks-scripts-initialize: + +initialize +---------- + + :Global/Local: global + :Argument(s): None + :Sourced/Run: run + +``$WORKON_HOME/initialize`` is sourced when ``virtualenvwrapper.sh`` +is loaded into your environment. Use it to adjust global settings +when virtualenvwrapper is enabled. + +.. _hooks-scripts-premkvirtualenv: + +premkvirtualenv +--------------- + + :Global/Local: global + :Argument(s): name of new environment + :Sourced/Run: run + +``$WORKON_HOME/premkvirtualenv`` is run as an external program after +the virtual environment is created but before the current environment +is switched to point to the new env. The current working directory for +the script is ``$WORKON_HOME`` and the name of the new environment is +passed as an argument to the script. + +.. _hooks-scripts-postmkvirtualenv: + +postmkvirtualenv +---------------- + + :Global/Local: global + :Argument(s): none + :Sourced/Run: sourced + +``$WORKON_HOME/postmkvirtualenv`` is sourced after the new environment +is created and activated. + +.. _hooks-scripts-preactivate: + +preactivate +----------- + + :Global/Local: global, local + :Argument(s): environment name + :Sourced/Run: run + +The global ``$WORKON_HOME/preactivate`` script is run before the new +environment is enabled. The environment name is passed as the first +argument. + +The local ``$VIRTUAL_ENV/bin/preactivate`` hook is run before the new +environment is enabled. The environment name is passed as the first +argument. + +.. _hooks-scripts-postactivate: + +postactivate +------------ + + :Global/Local: global, local + :Argument(s): none + :Sourced/Run: sourced + +The global ``$WORKON_HOME/postactivate`` script is sourced after the +new environment is enabled. ``$VIRTUAL_ENV`` refers to the new +environment at the time the script runs. + +This example script adds a space between the virtual environment name +and your old PS1 by making use of ``_OLD_VIRTUAL_PS1``. + +:: + + PS1="(`basename \"$VIRTUAL_ENV\"`) $_OLD_VIRTUAL_PS1" + +The local ``$VIRTUAL_ENV/bin/postactivate`` script is sourced after +the new environment is enabled. ``$VIRTUAL_ENV`` refers to the new +environment at the time the script runs. + +This example script for the PyMOTW environment changes the current +working directory and the PATH variable to refer to the source tree +containing the PyMOTW source. + +:: + + pymotw_root=/Users/dhellmann/Documents/PyMOTW + cd $pymotw_root + PATH=$pymotw_root/bin:$PATH + +.. _hooks-scripts-predeactivate: + +predeactivate +------------- + + :Global/Local: local, global + :Argument(s): none + :Sourced/Run: sourced + +The local ``$VIRTUAL_ENV/bin/predeactivate`` script is sourced before the +current environment is deactivated, and can be used to disable or +clear settings in your environment. ``$VIRTUAL_ENV`` refers to the old +environment at the time the script runs. + +The global ``$WORKON_HOME/predeactivate`` script is sourced before the +current environment is deactivated. ``$VIRTUAL_ENV`` refers to the +old environment at the time the script runs. + +.. _hooks-scripts-postdeactivate: + +postdeactivate +-------------- + + :Global/Local: local, global + :Argument(s): none + :Sourced/Run: sourced + +The ``$VIRTUAL_ENV/bin/postdeactivate`` script is sourced after the +current environment is deactivated, and can be used to disable or +clear settings in your environment. The path to the environment just +deactivated is available in ``$VIRTUALENVWRAPPER_LAST_VIRTUALENV``. + +.. _hooks-scripts-prermvirtualenv: + +prermvirtualenv +--------------- + + :Global/Local: global + :Argument(s): environment name + :Sourced/Run: run + +The ``$WORKON_HOME/prermvirtualenv`` script is run as an external +program before the environment is removed. The full path to the +environment directory is passed as an argument to the script. + +.. _hooks-scripts-postrmvirtualenv: + +postrmvirtualenv +---------------- + + :Global/Local: global + :Argument(s): environment name + :Sourced/Run: run + +The ``$WORKON_HOME/postrmvirtualenv`` script is run as an external +program after the environment is removed. The full path to the +environment directory is passed as an argument to the script. From a257f735f2b1e20fd38a5607f013632a47df2bb4 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 4 Apr 2010 08:01:28 -0400 Subject: [PATCH 170/947] move make_hooks functionality into user_scripts, since they are related --- setup.py | 3 +- virtualenvwrapper/make_hooks.py | 91 ------------------------------- virtualenvwrapper/user_scripts.py | 78 ++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 93 deletions(-) delete mode 100644 virtualenvwrapper/make_hooks.py diff --git a/setup.py b/setup.py index a0a1f9b..902fe27 100644 --- a/setup.py +++ b/setup.py @@ -152,7 +152,7 @@ def find_package_data( entry_points = { #'console_scripts': [ 'venvw_hook = virtualenvwrapper.hook_loader:main' ], 'virtualenvwrapper.initialize': [ - 'make_hooks = virtualenvwrapper.make_hooks:initialize', + 'user_scripts = virtualenvwrapper.user_scripts:initialize', ], 'virtualenvwrapper.initialize_source': [ 'user_scripts = virtualenvwrapper.user_scripts:initialize_source', @@ -160,7 +160,6 @@ def find_package_data( 'virtualenvwrapper.pre_mkvirtualenv': [ 'user_scripts = virtualenvwrapper.user_scripts:pre_mkvirtualenv', - 'make_hooks = virtualenvwrapper.make_hooks:pre_mkvirtualenv', ], 'virtualenvwrapper.post_mkvirtualenv_source': [ 'user_scripts = virtualenvwrapper.user_scripts:post_mkvirtualenv_source', diff --git a/virtualenvwrapper/make_hooks.py b/virtualenvwrapper/make_hooks.py deleted file mode 100644 index eb47848..0000000 --- a/virtualenvwrapper/make_hooks.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env python -# encoding: utf-8 -# -# Copyright (c) 2010 Doug Hellmann. All rights reserved. -# -"""Plugin to create hooks during initialization phase. -""" - -import logging -import os -import stat - -log = logging.getLogger(__name__) - -import pkg_resources - -PERMISSIONS = stat.S_IRWXU | stat.S_IRWXG | stat.S_IROTH | stat.S_IXOTH - -GLOBAL_HOOKS = [ - # initialize - ("initialize", - "This hook is run during the startup phase when loading virtualenvwrapper.sh."), - - # mkvirtualenv - ("premkvirtualenv", - "This hook is run after a new virtualenv is created and before it is activated."), - ("postmkvirtualenv", - "This hook is run after a new virtualenv is activated."), - - # rmvirtualenv - ("prermvirtualenv", - "This hook is run before a virtualenv is deleted."), - ("postrmvirtualenv", - "This hook is run after a virtualenv is deleted."), - - # deactivate - ("predeactivate", - "This hook is run before every virtualenv is deactivated."), - ("postdeactivate", - "This hook is run after every virtualenv is deactivated."), - - # activate - ("preactivate", - "This hook is run before every virtualenv is activated."), - ("postactivate", - "This hook is run after every virtualenv is activated."), - ] - -LOCAL_HOOKS = [ - # deactivate - ("predeactivate", - "This hook is run before this virtualenv is deactivated."), - ("postdeactivate", - "This hook is run after this virtualenv is deactivated."), - - # activate - ("preactivate", - "This hook is run before this virtualenv is activated."), - ("postactivate", - "This hook is run after this virtualenv is activated."), - ] - -def make_hook(filename, comment): - """Create a hook script. - - :param filename: The name of the file to write. - :param comment: The comment to insert into the file. - """ - filename = os.path.expanduser(os.path.expandvars(filename)) - if not os.path.exists(filename): - log.info('Creating %s', filename) - with open(filename, 'wt') as f: - f.write("""#!%(shell)s -# %(comment)s - -""" % {'comment':comment, 'shell':os.environ.get('SHELL', '/bin/sh')}) - os.chmod(filename, PERMISSIONS) - return - - -def initialize(args): - for filename, comment in GLOBAL_HOOKS: - make_hook(os.path.join('$WORKON_HOME', filename), comment) - return - -def pre_mkvirtualenv(args): - envname=args[0] - for filename, comment in LOCAL_HOOKS: - make_hook(os.path.join('$WORKON_HOME', envname, 'bin', filename), comment) - return - diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index a991567..fd087cc 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -8,6 +8,7 @@ import logging import os +import stat import subprocess import pkg_resources @@ -41,9 +42,83 @@ def run_global(script_name, *args): return +PERMISSIONS = stat.S_IRWXU | stat.S_IRWXG | stat.S_IROTH | stat.S_IXOTH + + +GLOBAL_HOOKS = [ + # initialize + ("initialize", + "This hook is run during the startup phase when loading virtualenvwrapper.sh."), + + # mkvirtualenv + ("premkvirtualenv", + "This hook is run after a new virtualenv is created and before it is activated."), + ("postmkvirtualenv", + "This hook is run after a new virtualenv is activated."), + + # rmvirtualenv + ("prermvirtualenv", + "This hook is run before a virtualenv is deleted."), + ("postrmvirtualenv", + "This hook is run after a virtualenv is deleted."), + + # deactivate + ("predeactivate", + "This hook is run before every virtualenv is deactivated."), + ("postdeactivate", + "This hook is run after every virtualenv is deactivated."), + + # activate + ("preactivate", + "This hook is run before every virtualenv is activated."), + ("postactivate", + "This hook is run after every virtualenv is activated."), + ] + + +LOCAL_HOOKS = [ + # deactivate + ("predeactivate", + "This hook is run before this virtualenv is deactivated."), + ("postdeactivate", + "This hook is run after this virtualenv is deactivated."), + + # activate + ("preactivate", + "This hook is run before this virtualenv is activated."), + ("postactivate", + "This hook is run after this virtualenv is activated."), + ] + + +def make_hook(filename, comment): + """Create a hook script. + + :param filename: The name of the file to write. + :param comment: The comment to insert into the file. + """ + filename = os.path.expanduser(os.path.expandvars(filename)) + if not os.path.exists(filename): + log.info('Creating %s', filename) + with open(filename, 'wt') as f: + f.write("""#!%(shell)s +# %(comment)s + +""" % {'comment':comment, 'shell':os.environ.get('SHELL', '/bin/sh')}) + os.chmod(filename, PERMISSIONS) + return + + # HOOKS + +def initialize(args): + for filename, comment in GLOBAL_HOOKS: + make_hook(os.path.join('$WORKON_HOME', filename), comment) + return + + def initialize_source(args): return """ # @@ -54,6 +129,9 @@ def initialize_source(args): def pre_mkvirtualenv(args): log.debug('pre_mkvirtualenv %s', str(args)) + envname=args[0] + for filename, comment in LOCAL_HOOKS: + make_hook(os.path.join('$WORKON_HOME', envname, 'bin', filename), comment) run_global('premkvirtualenv', *args) return From 4b914291da4584660d6c0e424b1d6c7cacb69293 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 4 Apr 2010 09:22:17 -0400 Subject: [PATCH 171/947] update extension entry point docs --- docs/source/developers.rst | 17 -- docs/source/plugins.rst | 316 ++++++++++++++++++++++++++++++++++++- docs/source/scripts.rst | 43 ++--- 3 files changed, 331 insertions(+), 45 deletions(-) diff --git a/docs/source/developers.rst b/docs/source/developers.rst index 9d396cd..bffbbac 100644 --- a/docs/source/developers.rst +++ b/docs/source/developers.rst @@ -63,20 +63,3 @@ The test suite for virtualenvwrapper uses `shunit2 `_. To run the tests under bash, sh, and zsh, use ``make test``. To add new tests, modify or create an appropriate script in the ``tests`` directory. - -.. _developers-extensions: - -Creating Extension Plugins -========================== - -virtualenvwrapper adds several hook points you can use to modify its -behavior. End-users can provide simple shell scripts (see -:ref:`hook-scripts`). Extensions can also be implemented in Python by -using the ``setuptools`` style *entry points*. - -Types of Hooks --------------- - -Existing Hook Points --------------------- - diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index 71e7bdc..c87852c 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -4,16 +4,318 @@ Extension Plugins =================== -virtualenvwrapper adds several hook points you can use to modify its -behavior. End-users can provide simple shell scripts (see -:ref:`hook-scripts`). Extensions can also be implemented in Python by -using the ``setuptools`` style *entry points*. +virtualenvwrapper adds several extension points for modifying its +behavior. End-users can use shell scripts or other programs for +personal customization (see :ref:`scripts`). Extensions can also be +implemented in Python by using Distribute_ *entry points*, making +it possible to share common behaviors between systems. -Types of Hooks --------------- +Defining an Extension +===================== + +.. note:: + + Virtualenvwrapper is delivered with a plugin for creating and + running the user customization scripts. The examples below are + taken from the implementation of that plugin. + +Code Organization +----------------- + +The Python package for ``virtualenvwrapper`` is a *namespace package*. +That means multiple libraries can install code into the package, even +if they are not distributed together or installed into the same +directory. Extensions can (optionally) use the ``virtualenvwrapper`` +namespace by setting up their source tree like: + +* virtualenvwrapper/ + + * __init__.py + * user_scripts.py + +And placing the following code in the ``__init__.py``:: + + """virtualenvwrapper module + """ + + __import__('pkg_resources').declare_namespace(__name__) -Existing Hook Points +This isn't required, so if you would prefer to use a different +namespace that will work, too. + +Extension API +------------- + +After the package is established, the next step is to create a module +to hold the extension code. For example, +``virtualenvwrapper/user_scripts.py``. The module should contain the +actual extension entry points. Supporting code can be included, or +imported from elsewhere using standard Python code organization +techniques. + +The API is the same for every extension point. Each uses a Python +function that takes a single argument, a list of string arguments +passed to the hook loader on the command line. The contents of the +argument list are defined for each extension point below (see +:ref:`plugins-extension-points`). + +:: + + def function_name(args): + # args is a list of strings passed to the hook loader + +Extension Invocation -------------------- +Plugins can attach to each hook in two different ways. The default is +to have an extension function run and do some work directly. For +example, the ``initialize()`` hook for the user scripts plugin makes +sure the scripts exist every time ``virtualenvwrapper.sh`` is loaded. + +:: + + def initialize(args): + for filename, comment in GLOBAL_HOOKS: + make_hook(os.path.join('$WORKON_HOME', filename), comment) + return + +.. _plugins-user-env: + +Modifying the User Environment +------------------------------ + +There are cases where the extension needs to update the user's +environment (e.g., changing the current working directory or setting +environment variables). Modifications to the user environment must be +made within the user's current shell, and cannot be run in a separate +process. Extensions can define hook functions to return the text of +the shell statements to be executed. These *source* hooks are run +after the regular hooks with the same name, and should not do any work +of their own. + +The ``initialize_source()`` hook for the user scripts plugin looks for +a global initialize script and causes it to be run in the current +shell process. + +:: + + def initialize_source(args): + return """ + # + # Run user-provided scripts + # + [ -f "$WORKON_HOME/initialize" ] && source "$WORKON_HOME/initialize" + """ + +.. warning:: + + Because the extension is modifying the user's working shell, care + must be taken not to corrupt the environment by overwriting + existing variable values unexpectedly. Avoid creating temporary + variables where possible, and use unique names where necessary. + Prefixing variables with the extension name is a good way to + manage the namespace. For example, instead of ``temp_file`` use + ``user_scripts_temp_file``. Use ``unset`` to release temporary + variable names when they are no longer needed. + +.. warning:: + + virtualenvwrapper works under several shells with slightly + different syntax (bash, sh, zsh, ksh). Take this portability into + account when defining source hooks. Sticking to the simplest + possible syntax usually avoids problems, but there may be cases + where examining the ``SHELL`` environment variable to generate + different syntax for each case is the only way to achieve the + desired result. + +Registering Entry Points +------------------------ + +The functions defined in the plugin need to be registered as *entry +points* in order for virtualenvwrapper's hook loader to find them. +Distribute_ entry points are configured in the ``setup.py`` for your +package by mapping the entry point name to the function in the package +that implements it. + +This partial copy of virtualenvwrapper's ``setup.py`` illustrates how +the ``initialize()`` and ``initialize_source()`` entry points are +configured. + +:: + + # Bootstrap installation of Distribute + import distribute_setup + distribute_setup.use_setuptools() + + from setuptools import setup + + setup( + name = 'virtualenvwrapper', + version = '2.0', + + description = 'Enhancements to virtualenv', + + # ... details omitted ... + + entry_points = { + 'virtualenvwrapper.initialize': [ + 'user_scripts = virtualenvwrapper.user_scripts:initialize', + ], + 'virtualenvwrapper.initialize_source': [ + 'user_scripts = virtualenvwrapper.user_scripts:initialize_source', + ], + + # ... details omitted ... + }, + ) + +The ``entry_points`` argument to ``setup()`` is a dictionary mapping +the entry point *group names* to lists of entry point specifiers. A +different group name is defined by virtualenvwrapper for each +extension point (see :ref:`plugins-extension-points`). + +The entry point specifiers are strings with the syntax ``name = +package.module:function``. By convention, the *name* of each entry +point is the plugin name, but that is not required (the names are not +used). + +The Hook Loader +--------------- + +Extensions are run through a command line application implemented in +``virtualenvwrapper.hook_loader``. Since ``virtualenvwrapper.sh`` is +the primary caller and users do not typically need to run the app +directly, no separate script is installed. Instead, to run the +application, use the ``-m`` option to the interpreter:: + + $ python -m virtualenvwrapper.hook_loader -h + Usage: virtualenvwrapper.hook_loader [options] [] + + Manage hooks for virtualenvwrapper + + Options: + -h, --help show this help message and exit + -s, --source Print the shell commands to be run in the current shell + -v, --verbose Show more information on the console + -q, --quiet Show less information on the console + Logging ------- + +The hook loader configures logging so that messages are written to +``$WORKON_HOME/hook.log``. Messages are also written to stdout, +depending on the verbosity flag. The default is for messages at info +or higher levels to be written to stdout, and debug or higher to go to +the log file. Using logging in this way provides a convenient +mechanism for users to control the verbosity of extensions. + +To use logging from within your extension, simply instantiate a logger +and call its ``info()``, ``debug()`` and other methods with the +messages. + +:: + + import logging + log = logging.getLogger(__name__) + + def pre_mkvirtualenv(args): + log.debug('pre_mkvirtualenv %s', str(args)) + # ... + +.. _plugins-extension-points: + +Extension Points +================ + +The extension point names for native plugins are different from the +user customization scripts. The pattern is +``virtualenvwrapper.(pre|post)_event[_source]``. The *event* is the +action taken by the user or virtualenvwrapper that triggers the +extension. ``(pre|post)`` is the prefix indicating whether to call +the extension before or after the event. The suffix ``_source`` is +added for extensions that return shell code instead of taking action +directly (see :ref:`plugins-user-env`). + +.. _plugins-initialize: + +initialize +---------- + +The ``virtualenvwrapper.initialize`` hooks are run each time +``virtualenvwrapper.sh`` is loaded into the user's environment. + +.. _plugins-pre_mkvirtualenv: + +pre_mkvirtualenv +---------------- + +The ``virtualenvwrapper.pre_mkvirtualenv`` hooks are run after the +virtual environment is created, but before the new environment is +activated. The current working directory for when the hook is run is +``$WORKON_HOME`` and the name of the new environment is passed as an +argument. + +.. _plugins-post_mkvirtualenv: + +post_mkvirtualenv +----------------- + +The ``virtualenvwrapper.post_mkvirtualenv`` hooks are run after a new +virtual environment is created and activated. ``$VIRTUAL_ENV`` is set +to point to the new environment. + +.. _plugins-pre_activate: + +pre_activate +------------ + +The ``virtualenvwrapper.pre_activate`` hooks are run just before an +environment is enabled. The environment name is passed as the first +argument. + +.. _plugins-post_activate: + +post_activate +------------- + +The ``virtualenvwrapper.post_activate`` hooks are run just after an +environment is enabled. ``$VIRTUAL_ENV`` is set to point to the +current environment. + +.. _plugins-pre_deactivate: + +pre_deactivate +-------------- + +The ``virtualenvwrapper.pre_deactivate`` hooks are run just before an +environment is disabled. ``$VIRTUAL_ENV`` is set to point to the +current environment. + +.. _plugins-post_deactivate: + +post_deactivate +--------------- + +The ``virtualenvwrapper.post_deactivate`` hooks are run just after an +environment is disabled. The name of the environment just deactivated +is passed as the first argument. + +.. _plugins-pre_rmvirtualenv: + +pre_rmvirtualenv +---------------- + +The ``virtualenvwrapper.pre_rmvirtualenv`` hooks are run just before +an environment is deleted. The name of the environment being deleted +is passed as the first argument. + +.. _plugins-post_rmvirtualenv: + +post_rmvirtualenv +----------------- + +The ``virtualenvwrapper.post_rmvirtualenv`` hooks are run just after +an environment is deleted. The name of the environment being deleted +is passed as the first argument. + +.. _Distribute: http://packages.python.org/distribute/ diff --git a/docs/source/scripts.rst b/docs/source/scripts.rst index 0a036b5..746d56e 100644 --- a/docs/source/scripts.rst +++ b/docs/source/scripts.rst @@ -1,16 +1,17 @@ -.. _hooks-scripts: +.. _scripts: -Per-User Hook Scripts -===================== +======================== + Per-User Customization +======================== The end-user customization scripts are either *sourced* (allowing them to modify your shell environment) or *run* as an external program at the appropriate trigger time. -.. _hooks-scripts-initialize: +.. _scripts-initialize: initialize ----------- +========== :Global/Local: global :Argument(s): None @@ -20,10 +21,10 @@ initialize is loaded into your environment. Use it to adjust global settings when virtualenvwrapper is enabled. -.. _hooks-scripts-premkvirtualenv: +.. _scripts-premkvirtualenv: premkvirtualenv ---------------- +=============== :Global/Local: global :Argument(s): name of new environment @@ -35,10 +36,10 @@ is switched to point to the new env. The current working directory for the script is ``$WORKON_HOME`` and the name of the new environment is passed as an argument to the script. -.. _hooks-scripts-postmkvirtualenv: +.. _scripts-postmkvirtualenv: postmkvirtualenv ----------------- +================ :Global/Local: global :Argument(s): none @@ -47,10 +48,10 @@ postmkvirtualenv ``$WORKON_HOME/postmkvirtualenv`` is sourced after the new environment is created and activated. -.. _hooks-scripts-preactivate: +.. _scripts-preactivate: preactivate ------------ +=========== :Global/Local: global, local :Argument(s): environment name @@ -64,10 +65,10 @@ The local ``$VIRTUAL_ENV/bin/preactivate`` hook is run before the new environment is enabled. The environment name is passed as the first argument. -.. _hooks-scripts-postactivate: +.. _scripts-postactivate: postactivate ------------- +============ :Global/Local: global, local :Argument(s): none @@ -98,10 +99,10 @@ containing the PyMOTW source. cd $pymotw_root PATH=$pymotw_root/bin:$PATH -.. _hooks-scripts-predeactivate: +.. _scripts-predeactivate: predeactivate -------------- +============= :Global/Local: local, global :Argument(s): none @@ -116,10 +117,10 @@ The global ``$WORKON_HOME/predeactivate`` script is sourced before the current environment is deactivated. ``$VIRTUAL_ENV`` refers to the old environment at the time the script runs. -.. _hooks-scripts-postdeactivate: +.. _scripts-postdeactivate: postdeactivate --------------- +============== :Global/Local: local, global :Argument(s): none @@ -130,10 +131,10 @@ current environment is deactivated, and can be used to disable or clear settings in your environment. The path to the environment just deactivated is available in ``$VIRTUALENVWRAPPER_LAST_VIRTUALENV``. -.. _hooks-scripts-prermvirtualenv: +.. _scripts-prermvirtualenv: prermvirtualenv ---------------- +=============== :Global/Local: global :Argument(s): environment name @@ -143,10 +144,10 @@ The ``$WORKON_HOME/prermvirtualenv`` script is run as an external program before the environment is removed. The full path to the environment directory is passed as an argument to the script. -.. _hooks-scripts-postrmvirtualenv: +.. _scripts-postrmvirtualenv: postrmvirtualenv ----------------- +================ :Global/Local: global :Argument(s): environment name From e54cf3f77badbbf3694ca16b12596934b00cc853 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 4 Apr 2010 09:36:49 -0400 Subject: [PATCH 172/947] more doc cleanup --- README.rst | 10 +++-- docs/source/command_ref.rst | 85 +++++++++++++++++++++++-------------- docs/source/index.rst | 12 ++++-- docs/source/plugins.rst | 2 +- 4 files changed, 68 insertions(+), 41 deletions(-) diff --git a/README.rst b/README.rst index 232b894..11f5ea1 100644 --- a/README.rst +++ b/README.rst @@ -23,6 +23,10 @@ Features 4. Tab completion for commands that take a virtual environment as argument. +5. User-configurable hooks for all operations. + +6. Plugin system for more creating sharable extensions. + Rich Leland has created a short `screencast `__ showing off the features of virtualenvwrapper. @@ -34,15 +38,15 @@ Quick Setup 1. Create a directory to hold all of the virtual environments. The default is ``$HOME/.virtualenvs``. -2. Add two lines to your shell startup script (``.bashrc``, - ``.bash_profile``, etc.) to set the location where the virtual +2. Add two lines to your shell startup file (``.bashrc``, + ``.profile``, etc.) to set the location where the virtual environments should live and the location of the script installed with this package:: export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh -3. Run: ``source ~/.bashrc`` +3. Reload the startup file (e.g., run: ``source ~/.bashrc``). 4. Run: ``workon`` 5. A list of environments, empty, is printed. 6. Run: ``mkvirtualenv temp`` diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index e83d48e..93def56 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -24,8 +24,8 @@ Syntax:: .. seealso:: - * :ref:`hooks-scripts-premkvirtualenv` - * :ref:`hooks-scripts-postmkvirtualenv` + * :ref:`scripts-premkvirtualenv` + * :ref:`scripts-postmkvirtualenv` rmvirtualenv ------------ @@ -38,8 +38,8 @@ Syntax:: .. seealso:: - * :ref:`hooks-scripts-prermvirtualenv` - * :ref:`hooks-scripts-postrmvirtualenv` + * :ref:`scripts-prermvirtualenv` + * :ref:`scripts-postrmvirtualenv` cpvirtualenv ------------ @@ -55,6 +55,10 @@ Syntax:: The environment created by the copy operation is made `relocatable `__. +================================== +Controlling the Active Environment +================================== + workon ------ @@ -69,10 +73,10 @@ is printed to stdout. .. seealso:: - * :ref:`hooks-scripts-predeactivate` - * :ref:`hooks-scripts-postdeactivate` - * :ref:`hooks-scripts-preactivate` - * :ref:`hooks-scripts-postactivate` + * :ref:`scripts-predeactivate` + * :ref:`scripts-postdeactivate` + * :ref:`scripts-preactivate` + * :ref:`scripts-postactivate` deactivate ---------- @@ -91,8 +95,8 @@ Syntax:: .. seealso:: - * :ref:`hooks-scripts-predeactivate` - * :ref:`hooks-scripts-postdeactivate` + * :ref:`scripts-predeactivate` + * :ref:`scripts-postdeactivate` ================================== Quickly Navigating to a virtualenv @@ -104,6 +108,12 @@ currently-active virtualenv. cdvirtualenv ------------ +Change the current working directory to ``$VIRTUAL_ENV``. + +Syntax:: + + cdvirtualenv [subdir] + Calling ``cdvirtualenv`` changes the current working directory to the top of the virtualenv (``$VIRTUAL_ENV``). An optional argument is appended to the path, allowing navigation directly into a @@ -124,6 +134,13 @@ subdirectory. cdsitepackages -------------- +Change the current working directory to the ``site-packages`` for +``$VIRTUAL_ENV``. + +Syntax:: + + cdsitepackages [subdir] + Because the exact path to the site-packages directory in the virtualenv depends on the version of Python, ``cdsitepackages`` is provided as a shortcut for ``cdvirtualenv @@ -132,6 +149,7 @@ allowed, to specify a directory hierarchy within the ``site-packages`` directory to change into. :: + $ workon pymotw $ echo $VIRTUAL_ENV /Users/dhellmann/.virtualenvs/pymotw @@ -139,22 +157,20 @@ directory to change into. $ pwd /Users/dhellmann/.virtualenvs/pymotw/lib/python2.6/site-packages/PyMOTW/bisect +lssitepackages +-------------- + +Calling ``lssitepackages`` shows the content of the ``site-packages`` +directory of the currently-active virtualenv. + +Syntax:: + + lssitepackages + =============== Path Management =============== -Sometimes it is desirable to share installed packages that are not in -the system ``site-pacakges`` directory and which you do not want to -install in each virtualenv. In this case, you *could* symlink the -source into the environment ``site-packages`` directory, but it is -also easy to add extra directories to the PYTHONPATH by including them -in a .pth file inside ``site-packages`` using ``add2virtualenv``. - -1. Check out the source for a big project, such as Django. -2. Run: ``add2virtualenv path_to_source``. -3. Run: ``add2virtualenv``. -4. A usage message and list of current "extra" paths is printed. - add2virtualenv -------------- @@ -165,17 +181,20 @@ Syntax:: add2virtualenv directory1 directory2 ... -Path management for packages outside of the virtual env. Based on a -contribution from James Bennett and Jannis Leidel. - -This will be done by placing the directory names in a path file named -``virtualenv_path_extensions.pth`` inside the virtualenv's -site-packages directory; if this file does not exist, it will be -created first. +Sometimes it is desirable to share installed packages that are not in +the system ``site-pacakges`` directory and which should not be +installed in each virtualenv. One possible solution is to symlink the +source into the environment ``site-packages`` directory, but it is +also easy to add extra directories to the PYTHONPATH by including them +in a ``.pth`` file inside ``site-packages`` using ``add2virtualenv``. +1. Check out the source for a big project, such as Django. +2. Run: ``add2virtualenv path_to_source``. +3. Run: ``add2virtualenv``. +4. A usage message and list of current "extra" paths is printed. -lssitepackages --------------- +The directory names are added to a path file named +``virtualenv_path_extensions.pth`` inside the site-packages directory +for the environment. -Calling ``lssitepackages`` shows the content of the ``site-packages`` -directory of the currently-active virtualenv. +*Based on a contribution from James Bennett and Jannis Leidel.* diff --git a/docs/source/index.rst b/docs/source/index.rst index e2f354d..effa8d2 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -24,7 +24,9 @@ Features 3. Use a single command to switch between environments. 4. Tab completion for commands that take a virtual environment as argument. -5. User-configurable hooks for all operations. +5. User-configurable hooks for all operations (see :ref:`scripts`). +6. Plugin system for more creating sharable extensions (see + :ref:`plugins`). =========== Quick Setup @@ -33,13 +35,15 @@ Quick Setup 1. Create a directory to hold all of the virtual environments. The default is ``$HOME/.virtualenvs``. -2. Add two lines to your .bashrc to set the location where the virtual environments should - live and the location of the script installed with this package:: +2. Add two lines to your shell startup file (``.bashrc``, + ``.profile``, etc.) to set the location where the virtual + environments should live and the location of the script installed + with this package:: export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh -3. Run: ``source ~/.bashrc`` +3. Reload the startup file (e.g., run: ``source ~/.bashrc``). 4. Run: ``workon`` 5. A list of environments, empty, is printed. 6. Run: ``mkvirtualenv temp`` diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index c87852c..129f4a9 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -1,4 +1,4 @@ -.. _developers-extensions: +.. _plugins: =================== Extension Plugins From a37242f73a56469716b2ed8546c315005d677f4e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 4 Apr 2010 10:08:32 -0400 Subject: [PATCH 173/947] more doc cleanup --- docs/source/extensions.rst | 4 +- docs/source/plugins.rst | 83 +++++++++++++++++++++++--------------- 2 files changed, 53 insertions(+), 34 deletions(-) diff --git a/docs/source/extensions.rst b/docs/source/extensions.rst index d176bdb..5d9e06d 100644 --- a/docs/source/extensions.rst +++ b/docs/source/extensions.rst @@ -2,6 +2,8 @@ Existing Extensions ===================== -make_hooks +.. _extensions-user_scripts: user_scripts +============ + diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index 129f4a9..91364a4 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -16,8 +16,9 @@ Defining an Extension .. note:: Virtualenvwrapper is delivered with a plugin for creating and - running the user customization scripts. The examples below are - taken from the implementation of that plugin. + running the user customization scripts + (:ref:`extensions-user_scripts`). The examples below are taken from + the implementation of that plugin. Code Organization ----------------- @@ -40,8 +41,10 @@ And placing the following code in the ``__init__.py``:: __import__('pkg_resources').declare_namespace(__name__) -This isn't required, so if you would prefer to use a different -namespace that will work, too. +.. note:: + + Extensions can be loaded from any package, so using the + ``virtualenvwrapper`` namespace is not required. Extension API ------------- @@ -54,23 +57,24 @@ imported from elsewhere using standard Python code organization techniques. The API is the same for every extension point. Each uses a Python -function that takes a single argument, a list of string arguments -passed to the hook loader on the command line. The contents of the -argument list are defined for each extension point below (see -:ref:`plugins-extension-points`). +function that takes a single argument, a list of strings passed to the +hook loader on the command line. :: def function_name(args): # args is a list of strings passed to the hook loader +The contents of the argument list are defined for each extension point +below (see :ref:`plugins-extension-points`). + Extension Invocation -------------------- Plugins can attach to each hook in two different ways. The default is -to have an extension function run and do some work directly. For -example, the ``initialize()`` hook for the user scripts plugin makes -sure the scripts exist every time ``virtualenvwrapper.sh`` is loaded. +to have a function run and do some work directly. For example, the +``initialize()`` function for the user scripts plugin creates default +user scripts when ``virtualenvwrapper.sh`` is loaded. :: @@ -88,10 +92,10 @@ There are cases where the extension needs to update the user's environment (e.g., changing the current working directory or setting environment variables). Modifications to the user environment must be made within the user's current shell, and cannot be run in a separate -process. Extensions can define hook functions to return the text of -the shell statements to be executed. These *source* hooks are run -after the regular hooks with the same name, and should not do any work -of their own. +process. To have code run in the user's shell process, extensions can +define hook functions to return the text of the shell statements to be +executed. These *source* hooks are run after the regular hooks with +the same name, and should not do any work of their own. The ``initialize_source()`` hook for the user scripts plugin looks for a global initialize script and causes it to be run in the current @@ -112,11 +116,11 @@ shell process. Because the extension is modifying the user's working shell, care must be taken not to corrupt the environment by overwriting existing variable values unexpectedly. Avoid creating temporary - variables where possible, and use unique names where necessary. - Prefixing variables with the extension name is a good way to - manage the namespace. For example, instead of ``temp_file`` use - ``user_scripts_temp_file``. Use ``unset`` to release temporary - variable names when they are no longer needed. + variables where possible, and use unique names where variables + cannot be avoided. Prefixing variables with the extension name is + a good way to manage the namespace. For example, instead of + ``temp_file`` use ``user_scripts_temp_file``. Use ``unset`` to + release temporary variable names when they are no longer needed. .. warning:: @@ -183,8 +187,8 @@ The Hook Loader --------------- Extensions are run through a command line application implemented in -``virtualenvwrapper.hook_loader``. Since ``virtualenvwrapper.sh`` is -the primary caller and users do not typically need to run the app +``virtualenvwrapper.hook_loader``. Because ``virtualenvwrapper.sh`` +is the primary caller and users do not typically need to run the app directly, no separate script is installed. Instead, to run the application, use the ``-m`` option to the interpreter:: @@ -199,13 +203,21 @@ application, use the ``-m`` option to the interpreter:: -v, --verbose Show more information on the console -q, --quiet Show less information on the console +To run the extensions for the initialize hook:: + + $ python -m virtualenvwrapper.hook_loader -v initialize + +To get the shell commands for the initialize hook:: + + $ python -m virtualenvwrapper.hook_loader --source initialize + Logging ------- The hook loader configures logging so that messages are written to -``$WORKON_HOME/hook.log``. Messages are also written to stdout, -depending on the verbosity flag. The default is for messages at info -or higher levels to be written to stdout, and debug or higher to go to +``$WORKON_HOME/hook.log``. Messages also may be written to stderr, +depending on the verbosity flag. The default is for messages at *info* +or higher levels to be written to stderr, and *debug* or higher to go to the log file. Using logging in this way provides a convenient mechanism for users to control the verbosity of extensions. @@ -222,19 +234,24 @@ messages. log.debug('pre_mkvirtualenv %s', str(args)) # ... +.. seealso:: + + * `Standard library documentation for logging `__ + * `PyMOTW for logging `__ + .. _plugins-extension-points: Extension Points ================ -The extension point names for native plugins are different from the -user customization scripts. The pattern is -``virtualenvwrapper.(pre|post)_event[_source]``. The *event* is the -action taken by the user or virtualenvwrapper that triggers the -extension. ``(pre|post)`` is the prefix indicating whether to call -the extension before or after the event. The suffix ``_source`` is -added for extensions that return shell code instead of taking action -directly (see :ref:`plugins-user-env`). +The extension point names for native plugins follow a naming +convention with several parts: +``virtualenvwrapper.(pre|post)_[_source]``. The ** is +the action taken by the user or virtualenvwrapper that triggers the +extension. ``(pre|post)`` indicates whether to call the extension +before or after the event. The suffix ``_source`` is added for +extensions that return shell code instead of taking action directly +(see :ref:`plugins-user-env`). .. _plugins-initialize: From d6ade8ae3f53e93d1460da484cf83250af40968e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 4 Apr 2010 10:08:58 -0400 Subject: [PATCH 174/947] remove rudundant 'source' from cli --- virtualenvwrapper.sh | 4 +--- virtualenvwrapper/hook_loader.py | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 9dfc26e..006ae7b 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -76,10 +76,8 @@ function virtualenvwrapper_run_hook () { # First anything that runs directly from the plugin "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION "$@" # Now anything that wants to run inside this shell - hook_name="$1" - shift # get rid of hook name "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION \ - --source "${hook_name}_source" "$@" >>$TMPDIR/$$.hook + --source "$@" >>$TMPDIR/$$.hook source $TMPDIR/$$.hook rm -f $TMPDIR/$$.hook } diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index debbbeb..1bd2d69 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -62,6 +62,8 @@ def main(): if not args: parser.error('Please specify the hook to run') hook = args[0] + if options.sourcing: + hook += '_source' for ep in pkg_resources.iter_entry_points('virtualenvwrapper.%s' % hook): plugin = ep.load() From 1d31f6d3fb6d6292eaa10fe420fff2601d982f64 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 4 Apr 2010 10:11:11 -0400 Subject: [PATCH 175/947] doc restructuring --- docs/source/plugins.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index 91364a4..b8f99eb 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -71,6 +71,9 @@ below (see :ref:`plugins-extension-points`). Extension Invocation -------------------- +Direct Action +~~~~~~~~~~~~~ + Plugins can attach to each hook in two different ways. The default is to have a function run and do some work directly. For example, the ``initialize()`` function for the user scripts plugin creates default @@ -86,7 +89,7 @@ user scripts when ``virtualenvwrapper.sh`` is loaded. .. _plugins-user-env: Modifying the User Environment ------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There are cases where the extension needs to update the user's environment (e.g., changing the current working directory or setting From 02f05b648d1606cc6d2857e9ce35af0d1cc5dd6b Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 4 Apr 2010 10:17:17 -0400 Subject: [PATCH 176/947] even more doc cleanup --- docs/source/developers.rst | 8 ++++---- docs/source/extensions.rst | 3 +++ docs/source/index.rst | 2 +- docs/source/plugins.rst | 12 ++++++------ 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/docs/source/developers.rst b/docs/source/developers.rst index bffbbac..a74b7dd 100644 --- a/docs/source/developers.rst +++ b/docs/source/developers.rst @@ -2,9 +2,9 @@ For Developers ############## -If you would like to contribute, these instructions should help you -get started. Patches, bug reports, and feature requests are all -welcome through the `BitBucket site +If you would like to contribute to virtualenvwrapper directly, these +instructions should help you get started. Patches, bug reports, and +feature requests are all welcome through the `BitBucket site `_. Contributions in the form of patches or pull requests are easier to integrate and will receive priority attention. @@ -14,7 +14,7 @@ Building Documentation The documentation for virtualenvwrapper is written in reStructuredText and converted to HTML using Sphinx. The build itself is driven by -Paver. You will need the following packages in order to build the +make. You will need the following packages in order to build the docs: - Sphinx diff --git a/docs/source/extensions.rst b/docs/source/extensions.rst index 5d9e06d..407ade7 100644 --- a/docs/source/extensions.rst +++ b/docs/source/extensions.rst @@ -7,3 +7,6 @@ user_scripts ============ +The ``user_scripts`` extension is delivered with virtualenvwrapper and +enabled by default. It implements the user customization script +features described in :ref:`scripts`. diff --git a/docs/source/index.rst b/docs/source/index.rst index effa8d2..d545bff 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -70,9 +70,9 @@ Details command_ref hooks tips - history developers extensions + history .. _references: diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index b8f99eb..4faa2ea 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -4,11 +4,11 @@ Extension Plugins =================== -virtualenvwrapper adds several extension points for modifying its -behavior. End-users can use shell scripts or other programs for -personal customization (see :ref:`scripts`). Extensions can also be -implemented in Python by using Distribute_ *entry points*, making -it possible to share common behaviors between systems. +virtualenvwrapper includes several ways to modify its behavior. +End-users can use shell scripts or other programs for personal +customization (see :ref:`scripts`). Extensions can also be +implemented in Python by using Distribute_ *entry points*, making it +possible to share common behaviors between systems. Defining an Extension ===================== @@ -34,7 +34,7 @@ namespace by setting up their source tree like: * __init__.py * user_scripts.py -And placing the following code in the ``__init__.py``:: +And placing the following code in ``__init__.py``:: """virtualenvwrapper module """ From 279e798871058b0e8f32eece73b4fd6618c918b7 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 4 Apr 2010 10:21:30 -0400 Subject: [PATCH 177/947] status update --- venv.org | 195 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 133 insertions(+), 62 deletions(-) diff --git a/venv.org b/venv.org index 4e8928d..9883d0a 100644 --- a/venv.org +++ b/venv.org @@ -1,66 +1,137 @@ # Org-mode notes and task list -* TODO convert to distribute for packaging [1/2] - - get rid of newvenvw and virtualenvwrapper virtualenvs and re-create - - [X] pavement.py to setup.py - - [ ] sphinx conf.py needs to get version from setup.py somehow - - [ ] separate rules for making website - - [ ] installwebsite - - [ ] register - - [ ] test for installation - -* plugin system for hooks - - http://bitbucket.org/dhellmann/virtualenvwrapper/issue/28/ - - use Distribute/setuptools entry points - - namespace package `virtualenvwrapper` to hold plugins I write, but - not required for other authors - - bump version to 2, since the user script implementation is moving - and this is a major update +* 2.0 +** DONE convert to distribute for packaging [7/7] + CLOSED: [2010-04-01 Thu 08:24] + - get rid of newvenvw and virtualenvwrapper virtualenvs and re-create + - [X] pavement.py to setup.py + - [X] sphinx conf.py needs to get version from setup.py somehow + - [X] separate rules for making website + - [X] installwebsite + - [X] register + - [X] test for installation + - [X] rename virtualenvwrapper_bashrc to virtualenvwrapperrc + + +** DONE review virtualenv template feature + SCHEDULED: <2010-04-02 Fri> CLOSED: [2010-04-04 Sun 10:20] + - http://bitbucket.org/dhellmann/virtualenvwrapper/issue/28/environment-templates + +** plugin system for hooks + - http://bitbucket.org/dhellmann/virtualenvwrapper/issue/28/ + - use Distribute/setuptools entry points + - [X] namespace package `virtualenvwrapper` to hold plugins I write, but + not required for other authors + - [X] bump version to 2, since the user script implementation is moving + and this is a major update + +*** DONE cli app to run the hooks + CLOSED: [2010-04-03 Sat 07:31] + + +*** DONE "user script" plugin implementation + CLOSED: [2010-04-03 Sat 07:29] + - uses pkg_resources to get contents of hook scripts out of + python package and run them + - [X] move all/most existing hook execution here + - [X] handle both global & local hooks + +*** DONE how does cli app handle the "sourced" hook scripts + CLOSED: [2010-04-03 Sat 07:33] + - ability to `cd` into a specific directory, for example + - separate plugin points for "foo_run_hook" and + "foo_source_hook", handled differently by the calling script + - run hooks are executed first (implement in any language) + - source hooks are dumped to text files and then sourced + (implement in shell language) + + +*** DONE expose each hook point as an entry point function [6/6] + CLOSED: [2010-04-03 Sat 07:34] + - [X] initialize + - during load of virtualenvwrapper.sh + - [X] mkvirtualenv [2/2] + - [X] pre + - [X] post + - [X] requirements + - automatically install packages based on requirements file + given to pip + - separate hook, or let a package just use postmkvirtualenv? + - if provide as a separate hook, run /before/ postmkvirtualenv + - let the postmkvirtualenv hook handle this as needed + - [X] activate [2/2] + - [X] pre + - [X] post + - [X] deactivate [2/2] + - [X] pre + - [X] post + - [X] rmvirtualenv [2/2] + - [X] pre + - [X] post + + +*** DONE documentation for how to publish your own hooks [6/6] + CLOSED: [2010-04-04 Sun 10:19] + - user script implementation as example, since it will implement + every hook point + - [X] change setuptools to distribute + - [X] initialize + - [X] mkvirtualenv [2/2] + - [X] pre + - [X] post + - [X] activate [2/2] + - [X] pre + - [X] post + - [X] deactivate [2/2] + - [X] pre + - [X] post + - [X] rmvirtualenv [2/2] + - [X] pre + - [X] post + + +*** DONE update documentation for user scripts + CLOSED: [2010-04-04 Sun 07:36] + - [X] make sure they are all included + - [X] table for each + - [X] global hook? + - [X] local hook? + - [X] argument(s) + - [X] sourced or run? + + +*** DONE documentation of existing extensions + CLOSED: [2010-04-04 Sun 10:19] + + +* TODO emacs desktop mode hooks + - release as separate project + +* 2.1 + +** TODO check if plugin enabled per-environment + - convenience function to check $VIRTUAL_ENV/.wrapperrc to see if a + plugin is enabled + - each plugin must do this itself + - convenience function for plugin to enable itself during + postmkvirtualenv hook (probably based on user interaction) + + +** TODO load plugin settings + - convenience function to load plugin settings from + $VIRTUAL_ENV/.wrapperrc + ** TODO how to specify execution order between plugin providers? - - plugins could provide a "phase" function for sorting - - return an integer, let the plugin author community sort out the - ranges - - alphabetical by plugin name - - undefined - -** TODO "user script" plugin implementation - - uses pkg_resources to get contents of hook scripts out of - python package and run them - - move all/most existing hook execution here - - handles both global & local hooks - -** TODO cli app to run the hooks - -** TODO how does cli app handle the "sourced" hook scripts - - ability to `cd` into a specific directory, for example - - separate plugin points for "foo_run_hook" and - "foo_source_hook", handled differently by the calling script - - run hooks are executed first (implement in any language) - - source hooks are dumped to text files and then sourced - (implement in shell language) - -** TODO expose each hook point as an entry point function [0/5] - - [ ] requirements - - automatically install packages based on requirements file - given to pip - - separate hook, or let a package just use postmkvirtualenv? - - if provide as a separate hook, run /before/ postmkvirtualenv - - [ ] mkvirtualenv [0/2] - - [ ] pre - - [ ] post - - [ ] activate [0/2] - - [ ] pre - - [ ] post - - [ ] deactivate [0/2] - - [ ] pre - - [ ] post - - [ ] rmvirtualenv [0/2] - - [ ] pre - - [ ] post - -** TODO documentation for how to publish your own hooks - - -* TODO add pre/post hooks for cpvirtualenv - - add new ones or just invoke existing hooks? + - options + - plugins could provide a "phase" function for sorting + - return an integer, let the plugin author community sort out the + ranges + - alphabetical by plugin name + - undefined + - left as undefined for now + + + +** TODO add pre/post hooks for cpvirtualenv + - add new ones or just invoke existing hooks? From 1d58dabe5ab9d918048d0753aa86d70c0e029c22 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 4 Apr 2010 10:48:41 -0400 Subject: [PATCH 178/947] add help to Makefile --- Makefile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0537f3b..3c1b987 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,16 @@ # Get the version of the app. This is used in the doc build. export VERSION=$(shell python setup.py --version) -# Default target is to build the source distribution. +# Default target is to show help +help: + @echo "sdist - Source distribution" + @echo "html - HTML documentation" + @echo "register - register a new release on PyPI" + @echo "website - build web version of docs" + @echo "installwebsite - deploy web version of docs" + @echo "develop - install development version" + + .PHONY: sdist sdist: html python setup.py sdist From 47aa40acab836796869117bf1a9ee50ca7e70b06 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 4 Apr 2010 15:18:45 -0400 Subject: [PATCH 179/947] include more motivational background --- docs/source/plugins.rst | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index 4faa2ea..88f968a 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -1,14 +1,32 @@ .. _plugins: -=================== - Extension Plugins -=================== - -virtualenvwrapper includes several ways to modify its behavior. -End-users can use shell scripts or other programs for personal +=========================== +Extending Virtualenvwrapper +=========================== + +Customizing one's development environment is a practice adopted from +other tool-based jobs in which long experience leads to home-grown and +unique solutions to persistent annoyances. Carpenters build jigs, +software developers write shell scripts. virtualenvwrapper continues +the tradition of encouraging a craftsman to modify his tools to work +the way he wants, rather than the other way around. + +Use the hooks provided to eliminate repetitive manual operations and +streamline your development workflow. For example, the pre_activate +and post_activate hooks can trigger an IDE to load a project file to +reload files from the last editing session, manage time-tracking +records, or start and stop development versions of an application +server. The initialize hook can be used to add entirely new commands +and hooks to virtualenvwrapper. And the pre_mkvirtualenv and +post_mkvirtualenv hooks give you an opportunity to install basic +requirements into each new development environment, initialize a +source code control repository, or otherwise set up a new project. + +There are two ways to attach your code so that virtualenvwrapper will +run it: End-users can use shell scripts or other programs for personal customization (see :ref:`scripts`). Extensions can also be implemented in Python by using Distribute_ *entry points*, making it -possible to share common behaviors between systems. +possible to share common behaviors between systems and developers. Defining an Extension ===================== @@ -262,7 +280,9 @@ initialize ---------- The ``virtualenvwrapper.initialize`` hooks are run each time -``virtualenvwrapper.sh`` is loaded into the user's environment. +``virtualenvwrapper.sh`` is loaded into the user's environment. The +initialize hook can be used to install templates for configuration +files or otherwise prepare the system for proper plugin operation. .. _plugins-pre_mkvirtualenv: @@ -338,4 +358,5 @@ The ``virtualenvwrapper.post_rmvirtualenv`` hooks are run just after an environment is deleted. The name of the environment being deleted is passed as the first argument. + .. _Distribute: http://packages.python.org/distribute/ From 5fadbfae3c8c76454ea552117617795cd9c67b80 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 5 Apr 2010 09:33:50 -0400 Subject: [PATCH 180/947] add namespace package declaration --- docs/source/plugins.rst | 9 ++++++++- setup.py | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index 88f968a..20302c1 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -181,6 +181,8 @@ configured. description = 'Enhancements to virtualenv', # ... details omitted ... + + namespace_packages = [ 'virtualenvwrapper' ], entry_points = { 'virtualenvwrapper.initialize': [ @@ -193,7 +195,7 @@ configured. # ... details omitted ... }, ) - + The ``entry_points`` argument to ``setup()`` is a dictionary mapping the entry point *group names* to lists of entry point specifiers. A different group name is defined by virtualenvwrapper for each @@ -204,6 +206,11 @@ package.module:function``. By convention, the *name* of each entry point is the plugin name, but that is not required (the names are not used). +.. seealso:: + + * `namespace packages `__ + * `Extensible Applications and Frameworks `__ + The Hook Loader --------------- diff --git a/setup.py b/setup.py index 902fe27..d21c6be 100644 --- a/setup.py +++ b/setup.py @@ -136,9 +136,11 @@ def find_package_data( ], provides=['virtualenvwrapper', + 'virtualenvwrapper.user_scripts', ], requires=['virtualenv'], + namespace_packages = [ 'virtualenvwrapper' ], packages = find_packages(), include_package_data = True, # Scan the input for package information From b44af28333f1b0518eb37f156edc1b5948c71a37 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 6 Apr 2010 19:08:38 -0400 Subject: [PATCH 181/947] move todo list out of hg repo --- venv.org | 137 ------------------------------------------------------- 1 file changed, 137 deletions(-) delete mode 100644 venv.org diff --git a/venv.org b/venv.org deleted file mode 100644 index 9883d0a..0000000 --- a/venv.org +++ /dev/null @@ -1,137 +0,0 @@ -# Org-mode notes and task list - -* 2.0 -** DONE convert to distribute for packaging [7/7] - CLOSED: [2010-04-01 Thu 08:24] - - get rid of newvenvw and virtualenvwrapper virtualenvs and re-create - - [X] pavement.py to setup.py - - [X] sphinx conf.py needs to get version from setup.py somehow - - [X] separate rules for making website - - [X] installwebsite - - [X] register - - [X] test for installation - - [X] rename virtualenvwrapper_bashrc to virtualenvwrapperrc - - -** DONE review virtualenv template feature - SCHEDULED: <2010-04-02 Fri> CLOSED: [2010-04-04 Sun 10:20] - - http://bitbucket.org/dhellmann/virtualenvwrapper/issue/28/environment-templates - -** plugin system for hooks - - http://bitbucket.org/dhellmann/virtualenvwrapper/issue/28/ - - use Distribute/setuptools entry points - - [X] namespace package `virtualenvwrapper` to hold plugins I write, but - not required for other authors - - [X] bump version to 2, since the user script implementation is moving - and this is a major update - -*** DONE cli app to run the hooks - CLOSED: [2010-04-03 Sat 07:31] - - -*** DONE "user script" plugin implementation - CLOSED: [2010-04-03 Sat 07:29] - - uses pkg_resources to get contents of hook scripts out of - python package and run them - - [X] move all/most existing hook execution here - - [X] handle both global & local hooks - -*** DONE how does cli app handle the "sourced" hook scripts - CLOSED: [2010-04-03 Sat 07:33] - - ability to `cd` into a specific directory, for example - - separate plugin points for "foo_run_hook" and - "foo_source_hook", handled differently by the calling script - - run hooks are executed first (implement in any language) - - source hooks are dumped to text files and then sourced - (implement in shell language) - - -*** DONE expose each hook point as an entry point function [6/6] - CLOSED: [2010-04-03 Sat 07:34] - - [X] initialize - - during load of virtualenvwrapper.sh - - [X] mkvirtualenv [2/2] - - [X] pre - - [X] post - - [X] requirements - - automatically install packages based on requirements file - given to pip - - separate hook, or let a package just use postmkvirtualenv? - - if provide as a separate hook, run /before/ postmkvirtualenv - - let the postmkvirtualenv hook handle this as needed - - [X] activate [2/2] - - [X] pre - - [X] post - - [X] deactivate [2/2] - - [X] pre - - [X] post - - [X] rmvirtualenv [2/2] - - [X] pre - - [X] post - - -*** DONE documentation for how to publish your own hooks [6/6] - CLOSED: [2010-04-04 Sun 10:19] - - user script implementation as example, since it will implement - every hook point - - [X] change setuptools to distribute - - [X] initialize - - [X] mkvirtualenv [2/2] - - [X] pre - - [X] post - - [X] activate [2/2] - - [X] pre - - [X] post - - [X] deactivate [2/2] - - [X] pre - - [X] post - - [X] rmvirtualenv [2/2] - - [X] pre - - [X] post - - -*** DONE update documentation for user scripts - CLOSED: [2010-04-04 Sun 07:36] - - [X] make sure they are all included - - [X] table for each - - [X] global hook? - - [X] local hook? - - [X] argument(s) - - [X] sourced or run? - - -*** DONE documentation of existing extensions - CLOSED: [2010-04-04 Sun 10:19] - - -* TODO emacs desktop mode hooks - - release as separate project - -* 2.1 - -** TODO check if plugin enabled per-environment - - convenience function to check $VIRTUAL_ENV/.wrapperrc to see if a - plugin is enabled - - each plugin must do this itself - - convenience function for plugin to enable itself during - postmkvirtualenv hook (probably based on user interaction) - - -** TODO load plugin settings - - convenience function to load plugin settings from - $VIRTUAL_ENV/.wrapperrc - - -** TODO how to specify execution order between plugin providers? - - options - - plugins could provide a "phase" function for sorting - - return an integer, let the plugin author community sort out the - ranges - - alphabetical by plugin name - - undefined - - left as undefined for now - - - -** TODO add pre/post hooks for cpvirtualenv - - add new ones or just invoke existing hooks? From 0cf37b3cd11a0418a0f3266b8cc7e7baa390034a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 6 Apr 2010 19:08:46 -0400 Subject: [PATCH 182/947] Added tag 2.0 for changeset 485e1999adf0 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 8e79c99..8b8ad6d 100644 --- a/.hgtags +++ b/.hgtags @@ -44,3 +44,4 @@ f318697791416cf0897091718d542e8045854233 1.24.2 3edf5f22481587608f8c172f8758014446a2d888 1.27 3edf5f22481587608f8c172f8758014446a2d888 1.27 d64869519c2e0553303cfeeb0918271564c72beb 1.27 +485e1999adf0d388340aec42bae4d87f93b8da92 2.0 From 418aa8fda7e37c28998b9845bc8b9ac8000ee19e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 6 Apr 2010 19:09:46 -0400 Subject: [PATCH 183/947] fix install dir for web docs --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3c1b987..0051c51 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ website: docs/sphinx/web/templates/base.html (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/web" BUILDDIR="website") installwebsite: website - (cd docs/website/html && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper2/) + (cd docs/website/html && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper/) # Register the new version on pypi .PHONY: register From 00944e87bd9cc684e91cdcebf5491d7cd603648f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 6 Apr 2010 19:09:51 -0400 Subject: [PATCH 184/947] Added tag 2.0 for changeset 54713c4552c2 --- .hgtags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.hgtags b/.hgtags index 8b8ad6d..25a914a 100644 --- a/.hgtags +++ b/.hgtags @@ -45,3 +45,5 @@ f318697791416cf0897091718d542e8045854233 1.24.2 3edf5f22481587608f8c172f8758014446a2d888 1.27 d64869519c2e0553303cfeeb0918271564c72beb 1.27 485e1999adf0d388340aec42bae4d87f93b8da92 2.0 +485e1999adf0d388340aec42bae4d87f93b8da92 2.0 +54713c4552c2bcf0155071c87cfca84ed1ea5f6e 2.0 From dcafdf865ac403f42179b880736b7699d624eac7 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 6 Apr 2010 20:21:39 -0400 Subject: [PATCH 185/947] save draft of email for announcing new releases on python-announce --- announce.rst | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 announce.rst diff --git a/announce.rst b/announce.rst new file mode 100644 index 0000000..0a3100b --- /dev/null +++ b/announce.rst @@ -0,0 +1,50 @@ +What is virtualenvwrapper +========================= + +virtualenvwrapper_ is a set of extensions to Ian Bicking's virtualenv_ +tool. The extensions include wrappers for creating and deleting +virtual environments and otherwise managing your development workflow, +making it easier to work on more than one project at a time without +introducing conflicts in their dependencies. + +What's New in 2.0 +================= + +This new version uses a significantly rewritten version of the +hook/callback subsystem to make it easier to share extensions. For +example, released at the same time is virtualenvwrapper-emacs-desktop_, +a plugin to switch emacs project files when you switch virtualenvs. + +Existing user scripts should continue to work as-written. Any failures +are probably a bug, so please report them on the bitbucket +tracker. Documentation for the new plugin system is available in the +virtualenvwrapper docs_. + +I also took this opportunity to change the name of the shell script +containing most of the virtualenvwrapper functionality from +virtualenvwrapper_bashrc to virtualenvwrapper.sh. This reflects the +fact that several shells other than bash are supported (bash, sh, ksh, +and zsh are all reported to work). You'll want to update your shell +startup file after upgrading to 2.0. + +The work to create the plugin system was triggered by a couple of +recent feature requests for environment templates and for a new +command to create a sub-shell instead of simply changing the settings +of the current shell. The new, more powerful, plugin capabilities will +make it easier to develop these and similar features. + +I'm looking forward to seeing what the community comes up with. I +especially want someone to write a plugin to start a copy of a +development server for a Django project if one is found in a +virtualenv. You'll get bonus points if it opens the home page of the +server in a web browser. + + + +.. _virtualenv: http://pypi.python.org/pypi/virtualenv + +.. _virtualenvwrapper: http://www.doughellmann.com/projects/virtualenvwrapper/ + +.. _virtualenvwrapper-emacs-desktop: http://www.doughellmann.com/projects/virtualenvwrapper-emacs-desktop/ + +.. _docs: http://www.doughellmann.com/docs/virtualenvwrapper/ From e7c0534e72ffe03102044ca80cb8a8349e342b86 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 7 Apr 2010 09:26:39 -0400 Subject: [PATCH 186/947] fix #29 by checking TMPDIR and using a default if no value is found --- tests/test_tmpdir.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++ virtualenvwrapper.sh | 16 ++++++++++++--- 2 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 tests/test_tmpdir.sh diff --git a/tests/test_tmpdir.sh b/tests/test_tmpdir.sh new file mode 100644 index 0000000..d62a84f --- /dev/null +++ b/tests/test_tmpdir.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +#set -x + +test_dir=$(dirname $0) +#source "$test_dir/../virtualenvwrapper.sh" + +export SCRATCH_DIR="${TMPDIR:-/tmp}/test_scratch_dir" + +oneTimeSetUp() { + rm -rf "$SCRATCH_DIR" + mkdir -p "$SCRATCH_DIR" +} + +oneTimeTearDown() { + rm -rf "$SCRATCH_DIR" +} + +setUp () { + echo + unset VIRTUALENVWRAPPER_TMPDIR +} + +test_unset_tmpdir () { + old_tmpdir="$TMPDIR" + unset TMPDIR + source "$test_dir/../virtualenvwrapper.sh" + export TMPDIR="$old_tmpdir" + assertSame "$VIRTUALENVWRAPPER_TMPDIR" "/tmp" +} + +test_set_tmpdir () { + old_tmpdir="$TMPDIR" + export TMPDIR="$SCRATCH_DIR" + source "$test_dir/../virtualenvwrapper.sh" + export TMPDIR="$old_tmpdir" + assertSame "$VIRTUALENVWRAPPER_TMPDIR" "$SCRATCH_DIR" +} + +test_set_virtualenvwrapper_tmpdir () { + VIRTUALENVWRAPPER_TMPDIR="$SCRATCH_DIR" + source "$test_dir/../virtualenvwrapper.sh" + assertSame "$VIRTUALENVWRAPPER_TMPDIR" "$SCRATCH_DIR" +} + +. "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 006ae7b..97a8489 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -59,6 +59,16 @@ VIRTUALENVWRAPPER_PYTHON="$(which python)" WORKON_HOME=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os; print os.path.abspath(os.path.expandvars(os.path.expanduser(\"$WORKON_HOME\")))") export WORKON_HOME +# Make sure we have a location for temporary files +if [ "$VIRTUALENVWRAPPER_TMPDIR" = "" ] +then + VIRTUALENVWRAPPER_TMPDIR="$TMPDIR" + if [ "$VIRTUALENVWRAPPER_TMPDIR" = "" ] + then + VIRTUALENVWRAPPER_TMPDIR="/tmp" + fi +fi + # Verify that the WORKON_HOME directory exists function virtualenvwrapper_verify_workon_home () { if [ ! -d "$WORKON_HOME" ] @@ -77,9 +87,9 @@ function virtualenvwrapper_run_hook () { "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION "$@" # Now anything that wants to run inside this shell "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION \ - --source "$@" >>$TMPDIR/$$.hook - source $TMPDIR/$$.hook - rm -f $TMPDIR/$$.hook + --source "$@" >>$VIRTUALENVWRAPPER_TMPDIR/$$.hook + source $VIRTUALENVWRAPPER_TMPDIR/$$.hook + rm -f $VIRTUALENVWRAPPER_TMPDIR/$$.hook } # Set up virtualenvwrapper properly From 8017b0be6a69cb5d5f8907671db653d62284b105 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 7 Apr 2010 09:32:51 -0400 Subject: [PATCH 187/947] add documentation about temp files --- README.rst | 29 ++++++------------------- docs/source/index.rst | 50 ++++++++++++++++++++++++++++++------------- 2 files changed, 42 insertions(+), 37 deletions(-) diff --git a/README.rst b/README.rst index 11f5ea1..f91574b 100644 --- a/README.rst +++ b/README.rst @@ -31,28 +31,13 @@ Rich Leland has created a short `screencast `__ showing off the features of virtualenvwrapper. -=========== -Quick Setup -=========== - -1. Create a directory to hold all of the virtual environments. The default is - ``$HOME/.virtualenvs``. - -2. Add two lines to your shell startup file (``.bashrc``, - ``.profile``, etc.) to set the location where the virtual - environments should live and the location of the script installed - with this package:: - - export WORKON_HOME=$HOME/.virtualenvs - source /usr/local/bin/virtualenvwrapper.sh - -3. Reload the startup file (e.g., run: ``source ~/.bashrc``). -4. Run: ``workon`` -5. A list of environments, empty, is printed. -6. Run: ``mkvirtualenv temp`` -7. A new environment, ``temp`` is created and activated. -8. Run: ``workon`` -9. This time, the ``temp`` environment is included. +============ +Installation +============ + +See the `project documentation +`__ for +installation and setup instructions. Upgrading from 1.x ================== diff --git a/docs/source/index.rst b/docs/source/index.rst index d545bff..82f7998 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -28,28 +28,48 @@ Features 6. Plugin system for more creating sharable extensions (see :ref:`plugins`). -=========== -Quick Setup +============ +Installation +============ + +WORKON_HOME =========== -1. Create a directory to hold all of the virtual environments. The default is - ``$HOME/.virtualenvs``. +The variable ``WORKON_HOME`` tells virtualenvwrapper where to place +your virtual environments. The default is ``$HOME/.virtualenvs``. +This directory must be created before using any virtualenvwrapper +commands. -2. Add two lines to your shell startup file (``.bashrc``, - ``.profile``, etc.) to set the location where the virtual - environments should live and the location of the script installed - with this package:: +Shell Startup File +================== + +Add two lines to your shell startup file (``.bashrc``, ``.profile``, +etc.) to set the location where the virtual environments should live +and the location of the script installed with this package:: export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh -3. Reload the startup file (e.g., run: ``source ~/.bashrc``). -4. Run: ``workon`` -5. A list of environments, empty, is printed. -6. Run: ``mkvirtualenv temp`` -7. A new environment, ``temp`` is created and activated. -8. Run: ``workon`` -9. This time, the ``temp`` environment is included. +After editing it, reload the startup file (e.g., run: ``source +~/.bashrc``). + +Quick-Start +=========== + +1. Run: ``workon`` +2. A list of environments, empty, is printed. +3. Run: ``mkvirtualenv temp`` +4. A new environment, ``temp`` is created and activated. +5. Run: ``workon`` +6. This time, the ``temp`` environment is included. + +Temporary Files +=============== + +virtualenvwrapper creates temporary files in ``$TMPDIR``. If the +variable is not set, it uses ``/tmp``. To change the location of +temporary files just for virtualenvwrapper, set +``VIRTUALENVWRAPPER_TMPDIR``. Upgrading from 1.x ================== From af4d5b5db23a575672a47c7ddfdc4eae4b5ac624 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 7 Apr 2010 09:54:09 -0400 Subject: [PATCH 188/947] update version and history --- docs/source/history.rst | 5 +++++ setup.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index e12e668..28a1e59 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -2,6 +2,11 @@ Release History =============== +2.0.1 + + - Fixed issue #29, to use a default value for ``TMPDIR`` if it is + not set in the user's shell environment. + 2.0 - Rewrote hook management using Distribute_ entry points to make it diff --git a/setup.py b/setup.py index d21c6be..e1cf263 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' -VERSION = '2.0' +VERSION = '2.0.1' # Bootstrap installation of Distribute import distribute_setup From 3b499d0ea1eca0315d1548a4bed351ff835d72b0 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 7 Apr 2010 09:54:12 -0400 Subject: [PATCH 189/947] Added tag 2.0.1 for changeset 91e1124c6831 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 25a914a..e736fdd 100644 --- a/.hgtags +++ b/.hgtags @@ -47,3 +47,4 @@ d64869519c2e0553303cfeeb0918271564c72beb 1.27 485e1999adf0d388340aec42bae4d87f93b8da92 2.0 485e1999adf0d388340aec42bae4d87f93b8da92 2.0 54713c4552c2bcf0155071c87cfca84ed1ea5f6e 2.0 +91e1124c68315f8cdc6578c4f72e3ed9c44e1fca 2.0.1 From b19a83c8a67d95eae113490bac0cf638c2c0b386 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 7 Apr 2010 18:36:52 -0400 Subject: [PATCH 190/947] sort ignore lines and add build directory --- .hgignore | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.hgignore b/.hgignore index 9da8d34..1b0d117 100644 --- a/.hgignore +++ b/.hgignore @@ -1,18 +1,19 @@ syntax: glob -distribute*.egg -distribute*.tar.gz +*.pyc README.html -virtualenvwrapper.egg-info -trace.txt +build dist +distribute*.egg +distribute*.tar.gz docs/build docs/website -*.pyc sphinx/web/templates/base.html tests/catch_output tests/testpackage/build tests/testpackage/dist tests/testpackage/testpackage.egg-info +trace.txt +virtualenvwrapper.egg-info virtualenvwrapper/docs syntax: re From 66c02efb4f525d7fce4a15178ea492749430e9d7 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 7 Apr 2010 19:02:19 -0400 Subject: [PATCH 191/947] fix #32 by removing use of 'with' ; add tests for python 2.6 and 2.5 --- Makefile | 34 +++++++++++++++++++++++++------ tests/test.sh | 3 ++- tests/test_add2virtualenv.sh | 2 +- tests/test_cd.sh | 2 +- tests/test_cp.sh | 2 +- tests/test_ls.sh | 2 +- tests/test_rmvirtualenv.sh | 2 +- tests/test_tmpdir.sh | 1 - virtualenvwrapper.sh | 5 ++++- virtualenvwrapper/user_scripts.py | 5 ++++- 10 files changed, 43 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 0051c51..c6863d2 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,15 @@ # Get the version of the app. This is used in the doc build. export VERSION=$(shell python setup.py --version) +# The main version of Python supported. +PRIMARY_PYTHON_VERSION=2.6 + +# The test-quick pattern changes the definition of +# this variable to only run against a single version of python. +ifeq ($(SUPPORTED_PYTHON_VERSIONS),) +SUPPORTED_PYTHON_VERSIONS=2.5 2.6 +endif + # Default target is to show help help: @echo "sdist - Source distribution" @@ -44,7 +53,7 @@ docs/sphinx/web/templates/base.html: ~/Devel/doughellmann/doughellmann/templates TEST_SCRIPTS=$(wildcard tests/test*.sh) .PHONY: develop test test-bash test-sh test-zsh test-loop test-install -test: develop test-bash test-sh test-zsh test-install +test: test-bash test-sh test-zsh test-install develop: python setup.py develop @@ -58,13 +67,26 @@ test-sh: test-zsh: TEST_SHELL="zsh -o shwordsplit" $(MAKE) test-loop +# For each supported version of Python, +# - Create a new virtualenv in a temporary directory. +# - Install virtualenvwrapper into the new virtualenv +# - Run each test script in tests test-loop: - @for test_script in $(wildcard tests/test*.sh) ; do \ - echo '********************************************************************************' ; \ - echo "Running $$test_script with $(TEST_SHELL)" ; \ - SHUNIT_PARENT=$$test_script $(TEST_SHELL) $$test_script || exit 1 ; \ - echo ; \ + for py_ver in $(SUPPORTED_PYTHON_VERSIONS) ; do \ + (cd $$TMPDIR/ && rm -rf virtualenvwrapper-test-env \ + && virtualenv -p /Library/Frameworks/Python.framework/Versions/$$py_ver/bin/python$$py_ver --no-site-packages virtualenvwrapper-test-env) \ + || exit 1 ; \ + $$TMPDIR/virtualenvwrapper-test-env/bin/python setup.py install || exit 1 ; \ + for test_script in $(wildcard tests/test*.sh) ; do \ + echo '********************************************************************************' ; \ + echo "Running $$test_script with $(TEST_SHELL) under Python $$py_ver" ; \ + VIRTUALENVWRAPPER_PYTHON=$$TMPDIR/virtualenvwrapper-test-env/bin/python SHUNIT_PARENT=$$test_script $(TEST_SHELL) $$test_script || exit 1 ; \ + echo ; \ + done \ done +test-quick: + SUPPORTED_PYTHON_VERSIONS=$(PRIMARY_PYTHON_VERSION) $(MAKE) test-bash + test-install: bash ./tests/manual_test_install.sh `pwd`/dist "$(VERSION)" \ No newline at end of file diff --git a/tests/test.sh b/tests/test.sh index 0dc0591..4c1c589 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -3,13 +3,14 @@ #set -x test_dir=$(dirname $0) -source "$test_dir/../virtualenvwrapper.sh" export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" + echo $PYTHONPATH } oneTimeTearDown() { diff --git a/tests/test_add2virtualenv.sh b/tests/test_add2virtualenv.sh index 43d3ca1..efba604 100644 --- a/tests/test_add2virtualenv.sh +++ b/tests/test_add2virtualenv.sh @@ -3,13 +3,13 @@ #set -x test_dir=$(dirname $0) -source "$test_dir/../virtualenvwrapper.sh" export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" } oneTimeTearDown() { diff --git a/tests/test_cd.sh b/tests/test_cd.sh index a6b5f0d..2db427d 100644 --- a/tests/test_cd.sh +++ b/tests/test_cd.sh @@ -3,13 +3,13 @@ #set -x test_dir=$(dirname $0) -source "$test_dir/../virtualenvwrapper.sh" export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" } oneTimeTearDown() { diff --git a/tests/test_cp.sh b/tests/test_cp.sh index 06e23a4..abdc99e 100644 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -3,13 +3,13 @@ #set -x test_dir=$(dirname $0) -source "$test_dir/../virtualenvwrapper.sh" export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" setUp () { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" echo rm -f "$test_dir/catch_output" } diff --git a/tests/test_ls.sh b/tests/test_ls.sh index b28e1f3..0352d73 100644 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -3,13 +3,13 @@ #set -x test_dir=$(dirname $0) -source "$test_dir/../virtualenvwrapper.sh" export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" } oneTimeTearDown() { diff --git a/tests/test_rmvirtualenv.sh b/tests/test_rmvirtualenv.sh index 44cbd02..d1b4921 100644 --- a/tests/test_rmvirtualenv.sh +++ b/tests/test_rmvirtualenv.sh @@ -3,13 +3,13 @@ #set -x test_dir=$(dirname $0) -source "$test_dir/../virtualenvwrapper.sh" export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" } oneTimeTearDown() { diff --git a/tests/test_tmpdir.sh b/tests/test_tmpdir.sh index d62a84f..b8652cc 100644 --- a/tests/test_tmpdir.sh +++ b/tests/test_tmpdir.sh @@ -3,7 +3,6 @@ #set -x test_dir=$(dirname $0) -#source "$test_dir/../virtualenvwrapper.sh" export SCRATCH_DIR="${TMPDIR:-/tmp}/test_scratch_dir" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 97a8489..824a5b3 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -52,7 +52,10 @@ then fi # Locate the global Python where virtualenvwrapper is installed. -VIRTUALENVWRAPPER_PYTHON="$(which python)" +if [ "$VIRTUALENVWRAPPER_PYTHON" = "" ] +then + VIRTUALENVWRAPPER_PYTHON="$(which python)" +fi # Normalize the directory name in case it includes # relative path components. diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index fd087cc..911374c 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -100,11 +100,14 @@ def make_hook(filename, comment): filename = os.path.expanduser(os.path.expandvars(filename)) if not os.path.exists(filename): log.info('Creating %s', filename) - with open(filename, 'wt') as f: + f = open(filename, 'wt') + try: f.write("""#!%(shell)s # %(comment)s """ % {'comment':comment, 'shell':os.environ.get('SHELL', '/bin/sh')}) + finally: + f.close() os.chmod(filename, PERMISSIONS) return From 94a817dea9962f3898b173329a881535cc5c6bee Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 7 Apr 2010 19:03:01 -0400 Subject: [PATCH 192/947] update version and history --- docs/source/history.rst | 5 +++++ setup.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index 28a1e59..c24eb33 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -2,6 +2,11 @@ Release History =============== +2.0.2 + + - Fixed issue #32, making virtualenvwrapper.user_scripts compatible + with Python 2.5 again. + 2.0.1 - Fixed issue #29, to use a default value for ``TMPDIR`` if it is diff --git a/setup.py b/setup.py index e1cf263..1ad326c 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' -VERSION = '2.0.1' +VERSION = '2.0.2' # Bootstrap installation of Distribute import distribute_setup From ba0b2824a8419136a921c20e7ef0482bfdc14fe3 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 7 Apr 2010 19:03:10 -0400 Subject: [PATCH 193/947] Added tag 2.0.2 for changeset 6a51a81454ae --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index e736fdd..7b4b921 100644 --- a/.hgtags +++ b/.hgtags @@ -48,3 +48,4 @@ d64869519c2e0553303cfeeb0918271564c72beb 1.27 485e1999adf0d388340aec42bae4d87f93b8da92 2.0 54713c4552c2bcf0155071c87cfca84ed1ea5f6e 2.0 91e1124c68315f8cdc6578c4f72e3ed9c44e1fca 2.0.1 +6a51a81454ae9dde5d923668ad5f034b3467fe11 2.0.2 From 6ee31a30754503537ac4396b0805d39b0140e5ac Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 7 Apr 2010 19:06:44 -0400 Subject: [PATCH 194/947] copy dist file to desktop after building --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index c6863d2..e870058 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,9 @@ help: .PHONY: sdist sdist: html + rm -f dist/*.gz python setup.py sdist + cp -v dist/*.gz ~/Desktop # Documentation .PHONY: html From da08f8a40c3ef38547d5ab36f146dd504384b025 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 7 Apr 2010 19:49:13 -0400 Subject: [PATCH 195/947] add support for ksh (fixes #25) --- Makefile | 17 ++++++++++------- docs/source/history.rst | 4 ++++ tests/test_cd.sh | 12 ++++++------ virtualenvwrapper.sh | 36 ++++++++++++++++++------------------ 4 files changed, 38 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index e870058..8426ef1 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,8 @@ ifeq ($(SUPPORTED_PYTHON_VERSIONS),) SUPPORTED_PYTHON_VERSIONS=2.5 2.6 endif +SUPPORTED_SHELLS=bash sh ksh zsh + # Default target is to show help help: @echo "sdist - Source distribution" @@ -54,17 +56,17 @@ docs/sphinx/web/templates/base.html: ~/Devel/doughellmann/doughellmann/templates # Testing TEST_SCRIPTS=$(wildcard tests/test*.sh) -.PHONY: develop test test-bash test-sh test-zsh test-loop test-install -test: test-bash test-sh test-zsh test-install +test: + for name in $(SUPPORTED_SHELLS) ; do \ + $(MAKE) test-$$name || exit 1 ; \ + done + $(MAKE) test-install develop: python setup.py develop -test-bash: - TEST_SHELL=bash $(MAKE) test-loop - -test-sh: - TEST_SHELL=sh $(MAKE) test-loop +test-%: + TEST_SHELL=$(subst test-,,$@) $(MAKE) test-loop test-zsh: TEST_SHELL="zsh -o shwordsplit" $(MAKE) test-loop @@ -80,6 +82,7 @@ test-loop: || exit 1 ; \ $$TMPDIR/virtualenvwrapper-test-env/bin/python setup.py install || exit 1 ; \ for test_script in $(wildcard tests/test*.sh) ; do \ + echo ; \ echo '********************************************************************************' ; \ echo "Running $$test_script with $(TEST_SHELL) under Python $$py_ver" ; \ VIRTUALENVWRAPPER_PYTHON=$$TMPDIR/virtualenvwrapper-test-env/bin/python SHUNIT_PARENT=$$test_script $(TEST_SHELL) $$test_script || exit 1 ; \ diff --git a/docs/source/history.rst b/docs/source/history.rst index c24eb33..5e83441 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -2,6 +2,10 @@ Release History =============== +Dev + + - Add support for ksh. + 2.0.2 - Fixed issue #32, making virtualenvwrapper.user_scripts compatible diff --git a/tests/test_cd.sh b/tests/test_cd.sh index 2db427d..2e9de2e 100644 --- a/tests/test_cd.sh +++ b/tests/test_cd.sh @@ -22,31 +22,31 @@ setUp () { } test_cdvirtual() { - pushd "$(pwd)" >/dev/null + start_dir="$(pwd)" cdvirtualenv assertSame "$VIRTUAL_ENV" "$(pwd)" cdvirtualenv bin assertSame "$VIRTUAL_ENV/bin" "$(pwd)" - popd >/dev/null + cd "$(start_dir)" } test_cdsitepackages () { - pushd "$(pwd)" >/dev/null + start_dir="$(pwd)" cdsitepackages pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" assertSame "$sitepackages" "$(pwd)" - popd >/dev/null + cd "$(start_dir)" } test_cdsitepackages_with_arg () { - pushd "$(pwd)" >/dev/null + start_dir="$(pwd)" pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) sitepackage_subdir="$VIRTUAL_ENV/lib/python${pyvers}/site-packages/subdir" mkdir -p "${sitepackage_subdir}" cdsitepackages subdir assertSame "$sitepackage_subdir" "$(pwd)" - popd >/dev/null + cd "$(start_dir)" } test_cdvirtualenv_no_workon_home () { diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 824a5b3..927ad68 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -73,7 +73,7 @@ then fi # Verify that the WORKON_HOME directory exists -function virtualenvwrapper_verify_workon_home () { +virtualenvwrapper_verify_workon_home () { if [ ! -d "$WORKON_HOME" ] then [ "$1" != "-q" ] && echo "ERROR: Virtual environments directory '$WORKON_HOME' does not exist. Create it or set WORKON_HOME to an existing directory." >&2 @@ -85,7 +85,7 @@ function virtualenvwrapper_verify_workon_home () { #HOOK_VERBOSE_OPTION="-v" # Run the hooks -function virtualenvwrapper_run_hook () { +virtualenvwrapper_run_hook () { # First anything that runs directly from the plugin "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION "$@" # Now anything that wants to run inside this shell @@ -96,7 +96,7 @@ function virtualenvwrapper_run_hook () { } # Set up virtualenvwrapper properly -function virtualenvwrapper_initialize () { +virtualenvwrapper_initialize () { virtualenvwrapper_verify_workon_home -q || return 1 virtualenvwrapper_run_hook "initialize" } @@ -104,7 +104,7 @@ function virtualenvwrapper_initialize () { virtualenvwrapper_initialize # Verify that virtualenv is installed and visible -function virtualenvwrapper_verify_virtualenv () { +virtualenvwrapper_verify_virtualenv () { venv=$(which virtualenv | grep -v "not found") if [ "$venv" = "" ] then @@ -120,7 +120,7 @@ function virtualenvwrapper_verify_virtualenv () { } # Verify that the requested environment exists -function virtualenvwrapper_verify_workon_environment () { +virtualenvwrapper_verify_workon_environment () { typeset env_name="$1" if [ ! -d "$WORKON_HOME/$env_name" ] then @@ -131,7 +131,7 @@ function virtualenvwrapper_verify_workon_environment () { } # Verify that the active environment exists -function virtualenvwrapper_verify_active_environment () { +virtualenvwrapper_verify_active_environment () { if [ ! -n "${VIRTUAL_ENV}" ] || [ ! -d "${VIRTUAL_ENV}" ] then echo "ERROR: no virtualenv active, or active virtualenv is missing" >&2 @@ -145,7 +145,7 @@ function virtualenvwrapper_verify_active_environment () { # Usage: mkvirtualenv [options] ENVNAME # (where the options are passed directly to virtualenv) # -function mkvirtualenv () { +mkvirtualenv () { eval "envname=\$$#" virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_virtualenv || return 1 @@ -163,7 +163,7 @@ function mkvirtualenv () { } # Remove an environment, in the WORKON_HOME. -function rmvirtualenv () { +rmvirtualenv () { typeset env_name="$1" virtualenvwrapper_verify_workon_home || return 1 if [ "$env_name" = "" ] @@ -184,7 +184,7 @@ function rmvirtualenv () { } # List the available environments. -function virtualenvwrapper_show_workon_options () { +virtualenvwrapper_show_workon_options () { virtualenvwrapper_verify_workon_home || return 1 # NOTE: DO NOT use ls here because colorized versions spew control characters # into the output list. @@ -197,7 +197,7 @@ function virtualenvwrapper_show_workon_options () { # # Usage: workon [environment_name] # -function workon () { +workon () { typeset env_name="$1" if [ "$env_name" = "" ] then @@ -232,7 +232,7 @@ function workon () { virtualenvwrapper_saved_deactivate=$(typeset -f deactivate) # Replace the deactivate() function with a wrapper. - eval 'function deactivate () { + eval 'deactivate () { # Call the local hook before the global so we can undo # any settings made by the local postactivate first. virtualenvwrapper_run_hook "pre_deactivate" @@ -288,12 +288,12 @@ elif [ -n "$ZSH_VERSION" ] ; then fi # Prints the Python version string for the current interpreter. -function virtualenvwrapper_get_python_version () { +virtualenvwrapper_get_python_version () { python -c 'import sys; print ".".join(str(p) for p in sys.version_info[:2])' } # Prints the path to the site-packages directory for the current environment. -function virtualenvwrapper_get_site_packages_dir () { +virtualenvwrapper_get_site_packages_dir () { echo "$VIRTUAL_ENV/lib/python`virtualenvwrapper_get_python_version`/site-packages" } @@ -308,7 +308,7 @@ function virtualenvwrapper_get_site_packages_dir () { # "virtualenv_path_extensions.pth" inside the virtualenv's # site-packages directory; if this file does not exist, it will be # created first. -function add2virtualenv () { +add2virtualenv () { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 @@ -350,7 +350,7 @@ function add2virtualenv () { # Does a ``cd`` to the site-packages directory of the currently-active # virtualenv. -function cdsitepackages () { +cdsitepackages () { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 site_packages="`virtualenvwrapper_get_site_packages_dir`" @@ -358,7 +358,7 @@ function cdsitepackages () { } # Does a ``cd`` to the root of the currently-active virtualenv. -function cdvirtualenv () { +cdvirtualenv () { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 cd $VIRTUAL_ENV/$1 @@ -366,7 +366,7 @@ function cdvirtualenv () { # Shows the content of the site-packages directory of the currently-active # virtualenv -function lssitepackages () { +lssitepackages () { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 site_packages="`virtualenvwrapper_get_site_packages_dir`" @@ -382,7 +382,7 @@ function lssitepackages () { } # Duplicate the named virtualenv to make a new one. -function cpvirtualenv() { +cpvirtualenv() { typeset env_name="$1" if [ "$env_name" = "" ] From 3b1ba2abb721e8b5e3dbfc53a658d8b986962e1f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 7 Apr 2010 19:50:30 -0400 Subject: [PATCH 196/947] add attribution for research work for ksh port --- docs/source/history.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index 5e83441..d6d4a01 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -4,7 +4,8 @@ Release History Dev - - Add support for ksh. + - Add support for ksh. Thanks to Doug Latornell for doing the + research on what needed to be changed. 2.0.2 From 733d8271c53e24f2a6cb018bb73acec60f8509fe Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 7 Apr 2010 20:11:29 -0400 Subject: [PATCH 197/947] update contributing info --- README.rst | 13 +++++++++++++ docs/source/developers.rst | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/README.rst b/README.rst index f91574b..1f3f384 100644 --- a/README.rst +++ b/README.rst @@ -48,6 +48,17 @@ supported. In your startup file, change ``source /usr/local/bin/virtualenvwrapper_bashrc`` to ``source /usr/local/bin/virtualenvwrapper.sh``. +============ +Contributing +============ + +Before contributing new features to virtualenvwrapper core, consider +whether they should be implemented as an extension instead. + +Refer to the `developers docs +`__ +for tips on contributing patches. + ======= License ======= @@ -69,3 +80,5 @@ CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +.. _BitBucket: http://bitbucket.org/dhellmann/virtualenvwrapper/overview/ diff --git a/docs/source/developers.rst b/docs/source/developers.rst index a74b7dd..266863d 100644 --- a/docs/source/developers.rst +++ b/docs/source/developers.rst @@ -9,6 +9,11 @@ feature requests are all welcome through the `BitBucket site in the form of patches or pull requests are easier to integrate and will receive priority attention. +.. note:: + + Before contributing new features to virtualenvwrapper core, please + consider whether they should be implemented as an extension instead. + Building Documentation ====================== From eb5beeb1be519a74dea3aa18592911fd1dabae99 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 9 Apr 2010 07:54:44 -0400 Subject: [PATCH 198/947] use tempfile to create temporary files instead of the process id so the filenames are less predictable --- docs/source/history.rst | 1 + virtualenvwrapper.sh | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index d6d4a01..b5ebf81 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -6,6 +6,7 @@ Dev - Add support for ksh. Thanks to Doug Latornell for doing the research on what needed to be changed. + - Switch to ``tempfile`` command for creating temporary hook files. 2.0.2 diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 927ad68..e6b676a 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -89,10 +89,11 @@ virtualenvwrapper_run_hook () { # First anything that runs directly from the plugin "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION "$@" # Now anything that wants to run inside this shell + hook_script=$(tempfile --directory "$VIRTUALENVWRAPPER_TMPDIR") "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION \ - --source "$@" >>$VIRTUALENVWRAPPER_TMPDIR/$$.hook - source $VIRTUALENVWRAPPER_TMPDIR/$$.hook - rm -f $VIRTUALENVWRAPPER_TMPDIR/$$.hook + --source "$@" >>"$hook_script" + source "$hook_script" + rm -f "$hook_script" } # Set up virtualenvwrapper properly From 3b5fdc27aadb305824d08f2bce6dd17fb331c4d6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 11 Apr 2010 11:42:56 -0400 Subject: [PATCH 199/947] fix #33 with improved installation instructions and a better error message --- docs/source/history.rst | 3 +++ docs/source/index.rst | 21 +++++++++++++++++++++ tests/test.sh | 10 ++++++++++ virtualenvwrapper.sh | 15 +++++++++++++-- 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index b5ebf81..3d30296 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -7,6 +7,9 @@ Dev - Add support for ksh. Thanks to Doug Latornell for doing the research on what needed to be changed. - Switch to ``tempfile`` command for creating temporary hook files. + - Test import of virtualenvwrapper.hook_loader on startup and report + the error in a way that should help the user figure out how to fix + it. 2.0.2 diff --git a/docs/source/index.rst b/docs/source/index.rst index 82f7998..ed7ddac 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -53,6 +53,27 @@ and the location of the script installed with this package:: After editing it, reload the startup file (e.g., run: ``source ~/.bashrc``). +Python Interpreter and $PATH +============================ + +During startup, ``virtualenvwrapper.sh`` finds the first ``python`` on +the ``$PATH`` and remembers it to use later. This eliminates any +conflict as the ``$PATH`` changes, enabling interpreters inside +virtual environments where virtualenvwrapper is not installed. +Because of this behavior, it is important for the ``$PATH`` to be set +**before** sourcing ``virtualenvwrapper.sh``. For example:: + + export PATH=/usr/local/bin:$PATH + source /usr/local/bin/virtualenvwrapper.sh + +To override the ``$PATH`` search, set the variable +``VIRTUALENVWRAPPER_PYTHON`` to the full path of the interpreter to +use (also **before** sourcing ``virtualenvwrapper.sh``). For +example:: + + export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python + source /usr/local/bin/virtualenvwrapper.sh + Quick-Start =========== diff --git a/tests/test.sh b/tests/test.sh index 4c1c589..575a4e0 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -63,5 +63,15 @@ test_get_python_version() { assertSame "$expected" "$actual" } +test_python_interpreter_set_incorrectly() { + return_to="$(pwd)" + cd "$WORKON_HOME" + mkvirtualenv --no-site-packages no_wrappers + output=`VIRTUALENVWRAPPER_PYTHON=$VIRTUAL_ENV/bin/python $SHELL $return_to/virtualenvwrapper.sh 2>&1` + assertTrue "Unexpected message: $output" "echo \"$output\" | grep 'Could not find Python module virtualenvwrapper.hook_loader'" + assertFalse "Failed to detect invalid Python location" "VIRTUALENVWRAPPER_PYTHON=$VIRTUAL_ENV/bin/python $SHELL $return_to/virtualenvwrapper.sh >/dev/null 2>&1" + cd "$return_to" + deactivate +} . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index e6b676a..28c69ae 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -99,11 +99,17 @@ virtualenvwrapper_run_hook () { # Set up virtualenvwrapper properly virtualenvwrapper_initialize () { virtualenvwrapper_verify_workon_home -q || return 1 + # Test for the virtualenvwrapper package we need so we can report + # an installation problem. + "$VIRTUALENVWRAPPER_PYTHON" -c "import virtualenvwrapper.hook_loader" >/dev/null 2>&1 + if [ $? -ne 0 ] + then + echo "virtualenvwrapper.sh: Could not find Python module virtualenvwrapper.hook_loader using VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON. Is the PATH set properly?" 1>&2 + return 1 + fi virtualenvwrapper_run_hook "initialize" } -virtualenvwrapper_initialize - # Verify that virtualenv is installed and visible virtualenvwrapper_verify_virtualenv () { venv=$(which virtualenv | grep -v "not found") @@ -426,3 +432,8 @@ cpvirtualenv() { echo "Created $new_env virtualenv" workon "$new_env" } + +# +# Invoke the initialization hooks +# +virtualenvwrapper_initialize From 62f0fe6174dfcede662631bf2e2ded359b6b15a0 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 11 Apr 2010 11:54:28 -0400 Subject: [PATCH 200/947] Update docs for mkvirtualenv to fix #30 --- docs/source/command_ref.rst | 5 ++++- docs/source/history.rst | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 93def56..131b219 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -11,6 +11,8 @@ All of the commands below are to be used on the Terminal command line. Managing Environments ===================== +.. _command-mkvirtualenv: + mkvirtualenv ------------ @@ -20,7 +22,8 @@ Syntax:: mkvirtualenv [options] ENVNAME -(any options are passed directly to ``virtualenv``) +All command line options are passed directly to ``virtualenv``. The +new environment is automatically activated after being initialized. .. seealso:: diff --git a/docs/source/history.rst b/docs/source/history.rst index 3d30296..1e73da7 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -9,7 +9,10 @@ Dev - Switch to ``tempfile`` command for creating temporary hook files. - Test import of virtualenvwrapper.hook_loader on startup and report the error in a way that should help the user figure out how to fix - it. + it (issue #33). + - Update :ref:`command-mkvirtualenv` documentation to include the + fact that a new environment is activated immediately after it is + created (issue #30). 2.0.2 From eb8948dcfdcb8b9da10493d6b58f71d9cd5fef55 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 12 Apr 2010 10:44:48 -0400 Subject: [PATCH 201/947] add hooks for cpvirtualenv; make deactivate work better under ksh --- docs/source/command_ref.rst | 9 ++++++++ docs/source/history.rst | 2 ++ docs/source/scripts.rst | 28 +++++++++++++++++++++++ setup.py | 7 ++++++ tests/test_cd.sh | 6 ++--- tests/test_cp.sh | 38 ++++++++++++++++++++++++++----- virtualenvwrapper.sh | 34 ++++++++++++++++++++------- virtualenvwrapper/user_scripts.py | 17 ++++++++++++++ 8 files changed, 124 insertions(+), 17 deletions(-) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 131b219..3692662 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -44,6 +44,8 @@ Syntax:: * :ref:`scripts-prermvirtualenv` * :ref:`scripts-postrmvirtualenv` +.. _command-cpvirtualenv: + cpvirtualenv ------------ @@ -58,6 +60,13 @@ Syntax:: The environment created by the copy operation is made `relocatable `__. +.. seealso:: + + * :ref:`scripts-precpvirtualenv` + * :ref:`scripts-postcpvirtualenv` + * :ref:`scripts-premkvirtualenv` + * :ref:`scripts-postmkvirtualenv` + ================================== Controlling the Active Environment ================================== diff --git a/docs/source/history.rst b/docs/source/history.rst index 1e73da7..c370fec 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -13,6 +13,8 @@ Dev - Update :ref:`command-mkvirtualenv` documentation to include the fact that a new environment is activated immediately after it is created (issue #30). + - Added hooks around :ref:`command-cpvirtualenv`. + - Made deactivation more robust, especially under ksh. 2.0.2 diff --git a/docs/source/scripts.rst b/docs/source/scripts.rst index 746d56e..122f9eb 100644 --- a/docs/source/scripts.rst +++ b/docs/source/scripts.rst @@ -48,6 +48,34 @@ postmkvirtualenv ``$WORKON_HOME/postmkvirtualenv`` is sourced after the new environment is created and activated. +.. _scripts-precpvirtualenv: + +precpvirtualenv +=============== + + :Global/Local: global + :Argument(s): name of original environment, name of new environment + :Sourced/Run: run + +``$WORKON_HOME/precpvirtualenv`` is run as an external program after +the source environment is duplicated and made relocatable, but before +the ``premkvirtualenv`` hook is run or the current environment is +switched to point to the new env. The current working directory for +the script is ``$WORKON_HOME`` and the names of the source and new +environments are passed as arguments to the script. + +.. _scripts-postcpvirtualenv: + +postcpvirtualenv +================ + + :Global/Local: global + :Argument(s): none + :Sourced/Run: sourced + +``$WORKON_HOME/postcpvirtualenv`` is sourced after the new environment +is created and activated. + .. _scripts-preactivate: preactivate diff --git a/setup.py b/setup.py index 1ad326c..9ed720c 100644 --- a/setup.py +++ b/setup.py @@ -167,6 +167,13 @@ def find_package_data( 'user_scripts = virtualenvwrapper.user_scripts:post_mkvirtualenv_source', ], + 'virtualenvwrapper.pre_cpvirtualenv': [ + 'user_scripts = virtualenvwrapper.user_scripts:pre_cpvirtualenv', + ], + 'virtualenvwrapper.post_cpvirtualenv_source': [ + 'user_scripts = virtualenvwrapper.user_scripts:post_cpvirtualenv_source', + ], + 'virtualenvwrapper.pre_rmvirtualenv': [ 'user_scripts = virtualenvwrapper.user_scripts:pre_rmvirtualenv', ], diff --git a/tests/test_cd.sh b/tests/test_cd.sh index 2e9de2e..24985d1 100644 --- a/tests/test_cd.sh +++ b/tests/test_cd.sh @@ -27,7 +27,7 @@ test_cdvirtual() { assertSame "$VIRTUAL_ENV" "$(pwd)" cdvirtualenv bin assertSame "$VIRTUAL_ENV/bin" "$(pwd)" - cd "$(start_dir)" + cd "$start_dir" } test_cdsitepackages () { @@ -36,7 +36,7 @@ test_cdsitepackages () { pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" assertSame "$sitepackages" "$(pwd)" - cd "$(start_dir)" + cd "$start_dir" } test_cdsitepackages_with_arg () { @@ -46,7 +46,7 @@ test_cdsitepackages_with_arg () { mkdir -p "${sitepackage_subdir}" cdsitepackages subdir assertSame "$sitepackage_subdir" "$(pwd)" - cd "$(start_dir)" + cd "$start_dir" } test_cdvirtualenv_no_workon_home () { diff --git a/tests/test_cp.sh b/tests/test_cp.sh index abdc99e..aeb033c 100644 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -10,22 +10,20 @@ setUp () { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" source "$test_dir/../virtualenvwrapper.sh" - echo rm -f "$test_dir/catch_output" + echo } tearDown() { rm -rf "$WORKON_HOME" } - test_cpvirtualenv () { mkvirtualenv "source" - (cd tests/testpackage && python setup.py install) + (cd tests/testpackage && python setup.py install) >/dev/null 2>&1 cpvirtualenv "source" "destination" - deactivate + assertSame "destination" $(basename "$VIRTUAL_ENV") rmvirtualenv "source" - workon "destination" testscript="$(which testscript.py)" assertTrue "Environment test script not found in path" "[ $WORKON_HOME/destination/bin/testscript.py -ef $testscript ]" testscriptcontent="$(cat $testscript)" @@ -36,7 +34,7 @@ test_cpvirtualenv () { test_cprelocatablevirtualenv () { mkvirtualenv "source" - (cd tests/testpackage && python setup.py install) + (cd tests/testpackage && python setup.py install) >/dev/null 2>&1 assertTrue "virtualenv --relocatable \"$WORKON_HOME/source\"" cpvirtualenv "source" "destination" testscript="$(which testscript.py)" @@ -50,5 +48,33 @@ test_cp_notexists () { assertSame "$out" "virtualenvthatdoesntexist virtualenv doesn't exist" } +test_hooks () { + mkvirtualenv "source" + + export pre_test_dir=$(cd "$test_dir"; pwd) + echo "echo GLOBAL premkvirtualenv \`pwd\` \"\$@\" >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" + chmod +x "$WORKON_HOME/premkvirtualenv" + echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" + echo "#!/bin/sh" > "$WORKON_HOME/precpvirtualenv" + echo "echo GLOBAL precpvirtualenv \`pwd\` \"\$@\" >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/precpvirtualenv" + chmod +x "$WORKON_HOME/precpvirtualenv" + echo "#!/bin/sh" > "$WORKON_HOME/postcpvirtualenv" + echo "echo GLOBAL postcpvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postcpvirtualenv" + + cpvirtualenv "source" "destination" + + output=$(cat "$test_dir/catch_output") + + expected="GLOBAL precpvirtualenv $WORKON_HOME source destination +GLOBAL premkvirtualenv $WORKON_HOME destination +GLOBAL postmkvirtualenv +GLOBAL postcpvirtualenv" + + assertSame "$expected" "$output" + rm -f "$WORKON_HOME/premkvirtualenv" + rm -f "$WORKON_HOME/postmkvirtualenv" + deactivate +} + . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 28c69ae..cb8558e 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -229,17 +229,26 @@ workon () { if [ $? -eq 0 ] then deactivate + unset -f deactivate >/dev/null 2>&1 fi virtualenvwrapper_run_hook "pre_activate" "$env_name" source "$activate" - # Save the deactivate function from virtualenv - virtualenvwrapper_saved_deactivate=$(typeset -f deactivate) + # Save the deactivate function from virtualenv under a different name + virtualenvwrapper_original_deactivate=`typeset -f deactivate | sed 's/deactivate/virtualenv_deactivate/g'` + eval "$virtualenvwrapper_original_deactivate" + unset -f deactivate >/dev/null 2>&1 +# virtualenvwrapper_saved_deactivate=$(tempfile --directory "$VIRTUALENVWRAPPER_TMPDIR") +# $(typeset -f deactivate | sed 's/deactivate/original_deactivate/g' > $virtualenvwrapper_saved_deactivate) +# echo "original_deactivate" >> $virtualenvwrapper_saved_deactivate +# echo "SAVED: \"$virtualenvwrapper_saved_deactivate\"" +# cat $virtualenvwrapper_saved_deactivate # Replace the deactivate() function with a wrapper. eval 'deactivate () { + # Call the local hook before the global so we can undo # any settings made by the local postactivate first. virtualenvwrapper_run_hook "pre_deactivate" @@ -247,13 +256,16 @@ workon () { env_postdeactivate_hook="$VIRTUAL_ENV/bin/postdeactivate" old_env=$(basename "$VIRTUAL_ENV") - # Restore the original definition of deactivate - eval "$virtualenvwrapper_saved_deactivate" - - # Instead of recursing, this calls the now restored original function. - deactivate + # Call the original function. + #source "$virtualenvwrapper_saved_deactivate" + #rm -f "$virtualenvwrapper_saved_deactivate" + virtualenv_deactivate virtualenvwrapper_run_hook "post_deactivate" "$old_env" + + # Remove this function + unset -f deactivate + }' virtualenvwrapper_run_hook "post_activate" @@ -429,8 +441,14 @@ cpvirtualenv() { virtualenv "$target_env" --relocatable sed "s/VIRTUAL_ENV\(.*\)$env_name/VIRTUAL_ENV\1$new_env/g" < "$source_env/bin/activate" > "$target_env/bin/activate" - echo "Created $new_env virtualenv" + + (cd "$WORKON_HOME" && + virtualenvwrapper_run_hook "pre_cpvirtualenv" "$env_name" "$new_env" && + virtualenvwrapper_run_hook "pre_mkvirtualenv" "$new_env" + ) workon "$new_env" + virtualenvwrapper_run_hook "post_mkvirtualenv" + virtualenvwrapper_run_hook "post_cpvirtualenv" } # diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 911374c..17c693e 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -147,6 +147,23 @@ def post_mkvirtualenv_source(args): [ -f "$WORKON_HOME/postmkvirtualenv" ] && source "$WORKON_HOME/postmkvirtualenv" """ +def pre_cpvirtualenv(args): + log.debug('pre_cpvirtualenv %s', str(args)) + envname=args[0] + for filename, comment in LOCAL_HOOKS: + make_hook(os.path.join('$WORKON_HOME', envname, 'bin', filename), comment) + run_global('precpvirtualenv', *args) + return + + +def post_cpvirtualenv_source(args): + return """ +# +# Run user-provided scripts +# +[ -f "$WORKON_HOME/postcpvirtualenv" ] && source "$WORKON_HOME/postcpvirtualenv" +""" + def pre_rmvirtualenv(args): log.debug('pre_rmvirtualenv') From 3525bc798057c69bf1a9bb83560cd407c51de579 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 12 Apr 2010 20:16:32 -0400 Subject: [PATCH 202/947] fix #34 by using python's tempfile module instead of a shell command --- tests/test_tempfile.sh | 42 +++++++++++++++++++++++++++++++++++++++ tests/test_tmpdir.sh | 45 ------------------------------------------ virtualenvwrapper.sh | 24 +++++++++++----------- 3 files changed, 54 insertions(+), 57 deletions(-) create mode 100644 tests/test_tempfile.sh delete mode 100644 tests/test_tmpdir.sh diff --git a/tests/test_tempfile.sh b/tests/test_tempfile.sh new file mode 100644 index 0000000..c2f812e --- /dev/null +++ b/tests/test_tempfile.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +#set -x + +test_dir=$(dirname $0) + +export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" + echo $PYTHONPATH +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +test_tempfile () { + filename=$(virtualenvwrapper_tempfile) + rm -f $filename + assertSame "$TMPDIR" "$(dirname $filename)/" + assertTrue "echo $filename | grep virtualenvwrapper" +} + +test_no_python () { + old=$VIRTUALENVWRAPPER_PYTHON + VIRTUALENVWRAPPER_PYTHON=false + filename=$(virtualenvwrapper_tempfile) + VIRTUALENVWRAPPER_PYTHON=$old + rm -f $filename + assertSame "$TMPDIR" "$(dirname $filename)/" + assertTrue "echo $filename | grep virtualenvwrapper.$$" +} + +. "$test_dir/shunit2" diff --git a/tests/test_tmpdir.sh b/tests/test_tmpdir.sh deleted file mode 100644 index b8652cc..0000000 --- a/tests/test_tmpdir.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh - -#set -x - -test_dir=$(dirname $0) - -export SCRATCH_DIR="${TMPDIR:-/tmp}/test_scratch_dir" - -oneTimeSetUp() { - rm -rf "$SCRATCH_DIR" - mkdir -p "$SCRATCH_DIR" -} - -oneTimeTearDown() { - rm -rf "$SCRATCH_DIR" -} - -setUp () { - echo - unset VIRTUALENVWRAPPER_TMPDIR -} - -test_unset_tmpdir () { - old_tmpdir="$TMPDIR" - unset TMPDIR - source "$test_dir/../virtualenvwrapper.sh" - export TMPDIR="$old_tmpdir" - assertSame "$VIRTUALENVWRAPPER_TMPDIR" "/tmp" -} - -test_set_tmpdir () { - old_tmpdir="$TMPDIR" - export TMPDIR="$SCRATCH_DIR" - source "$test_dir/../virtualenvwrapper.sh" - export TMPDIR="$old_tmpdir" - assertSame "$VIRTUALENVWRAPPER_TMPDIR" "$SCRATCH_DIR" -} - -test_set_virtualenvwrapper_tmpdir () { - VIRTUALENVWRAPPER_TMPDIR="$SCRATCH_DIR" - source "$test_dir/../virtualenvwrapper.sh" - assertSame "$VIRTUALENVWRAPPER_TMPDIR" "$SCRATCH_DIR" -} - -. "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index cb8558e..5416959 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -62,16 +62,6 @@ fi WORKON_HOME=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os; print os.path.abspath(os.path.expandvars(os.path.expanduser(\"$WORKON_HOME\")))") export WORKON_HOME -# Make sure we have a location for temporary files -if [ "$VIRTUALENVWRAPPER_TMPDIR" = "" ] -then - VIRTUALENVWRAPPER_TMPDIR="$TMPDIR" - if [ "$VIRTUALENVWRAPPER_TMPDIR" = "" ] - then - VIRTUALENVWRAPPER_TMPDIR="/tmp" - fi -fi - # Verify that the WORKON_HOME directory exists virtualenvwrapper_verify_workon_home () { if [ ! -d "$WORKON_HOME" ] @@ -84,12 +74,22 @@ virtualenvwrapper_verify_workon_home () { #HOOK_VERBOSE_OPTION="-v" +# Use Python's tempfile module to create a temporary file +# with a unique and not-likely-to-be-predictable name. +virtualenvwrapper_tempfile () { + $VIRTUALENVWRAPPER_PYTHON -c "import tempfile; print tempfile.NamedTemporaryFile(prefix='virtualenvwrapper.').name" + if [ $? -ne 0 ] + then + echo "${TMPDIR:-/tmp}/virtualenvwrapper.$$" + fi +} + # Run the hooks virtualenvwrapper_run_hook () { # First anything that runs directly from the plugin "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION "$@" # Now anything that wants to run inside this shell - hook_script=$(tempfile --directory "$VIRTUALENVWRAPPER_TMPDIR") + hook_script=$(virtualenvwrapper_tempfile) "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION \ --source "$@" >>"$hook_script" source "$hook_script" @@ -240,7 +240,7 @@ workon () { virtualenvwrapper_original_deactivate=`typeset -f deactivate | sed 's/deactivate/virtualenv_deactivate/g'` eval "$virtualenvwrapper_original_deactivate" unset -f deactivate >/dev/null 2>&1 -# virtualenvwrapper_saved_deactivate=$(tempfile --directory "$VIRTUALENVWRAPPER_TMPDIR") +# virtualenvwrapper_saved_deactivate=$(virtualenvwrapper_tempfile) # $(typeset -f deactivate | sed 's/deactivate/original_deactivate/g' > $virtualenvwrapper_saved_deactivate) # echo "original_deactivate" >> $virtualenvwrapper_saved_deactivate # echo "SAVED: \"$virtualenvwrapper_saved_deactivate\"" From 8a5ecfd64d9513ceaa27d244e0193ec13d037324 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 15 Apr 2010 08:24:49 -0400 Subject: [PATCH 203/947] include a date value in the filename --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 5416959..2c02dc5 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -80,7 +80,7 @@ virtualenvwrapper_tempfile () { $VIRTUALENVWRAPPER_PYTHON -c "import tempfile; print tempfile.NamedTemporaryFile(prefix='virtualenvwrapper.').name" if [ $? -ne 0 ] then - echo "${TMPDIR:-/tmp}/virtualenvwrapper.$$" + echo "${TMPDIR:-/tmp}/virtualenvwrapper.$$.`date +%s`" fi } From ea0f52616cb47100ac85f0516470ef27b559a8cf Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 15 Apr 2010 21:50:09 -0400 Subject: [PATCH 204/947] support nondescructive argument to deactivate --HG-- rename : README.rst => README.txt --- README.rst => README.txt | 0 docs/source/history.rst | 3 ++- setup.py | 2 +- tests/test_cp.sh | 5 ++++- virtualenvwrapper.sh | 17 +++++++---------- 5 files changed, 14 insertions(+), 13 deletions(-) rename README.rst => README.txt (100%) diff --git a/README.rst b/README.txt similarity index 100% rename from README.rst rename to README.txt diff --git a/docs/source/history.rst b/docs/source/history.rst index c370fec..e75ab65 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -6,7 +6,6 @@ Dev - Add support for ksh. Thanks to Doug Latornell for doing the research on what needed to be changed. - - Switch to ``tempfile`` command for creating temporary hook files. - Test import of virtualenvwrapper.hook_loader on startup and report the error in a way that should help the user figure out how to fix it (issue #33). @@ -15,6 +14,8 @@ Dev created (issue #30). - Added hooks around :ref:`command-cpvirtualenv`. - Made deactivation more robust, especially under ksh. + - Use Python's ``tempfile`` module for creating temporary filenames + safely and portably. 2.0.2 diff --git a/setup.py b/setup.py index 9ed720c..a076b10 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ import sys try: - long_description = open('README.rst', 'rt').read() + long_description = open('README.txt', 'rt').read() except IOError: long_description = '' diff --git a/tests/test_cp.sh b/tests/test_cp.sh index aeb033c..c46d93d 100644 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -15,6 +15,10 @@ setUp () { } tearDown() { + if type deactivate >/dev/null 2>&1 + then + deactivate + fi rm -rf "$WORKON_HOME" } @@ -73,7 +77,6 @@ GLOBAL postcpvirtualenv" assertSame "$expected" "$output" rm -f "$WORKON_HOME/premkvirtualenv" rm -f "$WORKON_HOME/postmkvirtualenv" - deactivate } . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 2c02dc5..c3127d9 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -240,11 +240,6 @@ workon () { virtualenvwrapper_original_deactivate=`typeset -f deactivate | sed 's/deactivate/virtualenv_deactivate/g'` eval "$virtualenvwrapper_original_deactivate" unset -f deactivate >/dev/null 2>&1 -# virtualenvwrapper_saved_deactivate=$(virtualenvwrapper_tempfile) -# $(typeset -f deactivate | sed 's/deactivate/original_deactivate/g' > $virtualenvwrapper_saved_deactivate) -# echo "original_deactivate" >> $virtualenvwrapper_saved_deactivate -# echo "SAVED: \"$virtualenvwrapper_saved_deactivate\"" -# cat $virtualenvwrapper_saved_deactivate # Replace the deactivate() function with a wrapper. eval 'deactivate () { @@ -257,14 +252,16 @@ workon () { old_env=$(basename "$VIRTUAL_ENV") # Call the original function. - #source "$virtualenvwrapper_saved_deactivate" - #rm -f "$virtualenvwrapper_saved_deactivate" - virtualenv_deactivate + virtualenv_deactivate $1 virtualenvwrapper_run_hook "post_deactivate" "$old_env" - # Remove this function - unset -f deactivate + if [ ! "$1" = "nondestructive" ] + then + # Remove this function + unset -f virtualenv_deactivate + unset -f deactivate + fi }' From c017813cfa3224d8149d633e7584f6efac5ae208 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 15 Apr 2010 22:08:55 -0400 Subject: [PATCH 205/947] handle empty workon_home dir properly --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index c3127d9..da23459 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -196,7 +196,7 @@ virtualenvwrapper_show_workon_options () { # NOTE: DO NOT use ls here because colorized versions spew control characters # into the output list. # echo seems a little faster than find, even with -depth 3. - (cd "$WORKON_HOME"; for f in */bin/activate; do echo $f; done) 2>/dev/null | sed 's|^\./||' | sed 's|/bin/activate||' | sort + (cd "$WORKON_HOME"; for f in */bin/activate; do echo $f; done) 2>/dev/null | sed 's|^\./||' | sed 's|/bin/activate||' | sort | egrep -v '^\*$' # (cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort } From b987b03748b3f9d64d286a4b178420761dc66114 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 15 Apr 2010 22:09:07 -0400 Subject: [PATCH 206/947] update docs with examples --- docs/source/command_ref.rst | 145 ++++++++++++++++++++++++++++++++---- docs/source/history.rst | 3 + 2 files changed, 133 insertions(+), 15 deletions(-) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 3692662..2c1fd01 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -25,6 +25,19 @@ Syntax:: All command line options are passed directly to ``virtualenv``. The new environment is automatically activated after being initialized. +:: + + $ workon + $ mkvirtualenv mynewenv + New python executable in mynewenv/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (mynewenv)$ workon + mynewenv + (mynewenv)$ + .. seealso:: * :ref:`scripts-premkvirtualenv` @@ -39,6 +52,16 @@ Syntax:: rmvirtualenv ENVNAME +You must use :ref:`command-deactivate` before removing the current +environment. + +:: + + (mynewenv)$ deactivate + $ rmvirtualenv mynewenv + $ workon + $ + .. seealso:: * :ref:`scripts-prermvirtualenv` @@ -60,6 +83,28 @@ Syntax:: The environment created by the copy operation is made `relocatable `__. +:: + + $ workon + $ mkvirtualenv source + New python executable in source/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (source)$ cpvirtualenv source dest + Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/easy_install relative + Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/easy_install-2.6 relative + Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/pip relative + Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/postactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) + Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/postdeactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) + Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/preactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) + Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/predeactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) + (dest)$ workon + dest + source + (dest)$ + .. seealso:: * :ref:`scripts-precpvirtualenv` @@ -83,6 +128,33 @@ Syntax:: If no ``environment_name`` is given the list of available environments is printed to stdout. +:: + + $ workon + $ mkvirtualenv env1 + New python executable in env1/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (env1)$ mkvirtualenv env2 + New python executable in env2/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (env2)$ workon + env1 + env2 + (env2)$ workon env1 + (env1)$ echo $VIRTUAL_ENV + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 + (env1)$ workon env2 + (env2)$ echo $VIRTUAL_ENV + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env2 + (env2)$ + + .. seealso:: * :ref:`scripts-predeactivate` @@ -90,6 +162,8 @@ is printed to stdout. * :ref:`scripts-preactivate` * :ref:`scripts-postactivate` +.. _command-deactivate: + deactivate ---------- @@ -105,6 +179,24 @@ Syntax:: This command is actually part of virtualenv, but is wrapped to provide before and after hooks, just as workon does for activate. +:: + + $ workon + $ echo $VIRTUAL_ENV + + $ mkvirtualenv env1 + New python executable in env1/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (env1)$ echo $VIRTUAL_ENV + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 + (env1)$ deactivate + $ echo $VIRTUAL_ENV + + $ + .. seealso:: * :ref:`scripts-predeactivate` @@ -133,15 +225,20 @@ subdirectory. :: - $ workon pymotw - $ echo $VIRTUAL_ENV - /Users/dhellmann/.virtualenvs/pymotw - $ cdvirtualenv - $ pwd - /Users/dhellmann/.virtualenvs/pymotw - $ cdvirtualenv bin - $ pwd - /Users/dhellmann/.virtualenvs/pymotw/bin + $ mkvirtualenv env1 + New python executable in env1/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (env1)$ echo $VIRTUAL_ENV + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 + (env1)$ cdvirtualenv + (env1)$ pwd + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 + (env1)$ cdvirtualenv bin + (env1)$ pwd + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1/bin cdsitepackages -------------- @@ -162,12 +259,17 @@ directory to change into. :: - $ workon pymotw - $ echo $VIRTUAL_ENV - /Users/dhellmann/.virtualenvs/pymotw - $ cdsitepackages PyMOTW/bisect/ - $ pwd - /Users/dhellmann/.virtualenvs/pymotw/lib/python2.6/site-packages/PyMOTW/bisect + $ mkvirtualenv env1 + New python executable in env1/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (env1)$ echo $VIRTUAL_ENV + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 + (env1)$ cdsitepackages PyMOTW/bisect/ + (env1)$ pwd + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1/lib/python2.6/site-packages/PyMOTW/bisect lssitepackages -------------- @@ -179,6 +281,19 @@ Syntax:: lssitepackages +:: + + $ mkvirtualenv env1 + New python executable in env1/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (env1)$ $ workon env1 + (env1)$ lssitepackages + distribute-0.6.10-py2.6.egg pip-0.6.3-py2.6.egg + easy-install.pth setuptools.pth + =============== Path Management =============== diff --git a/docs/source/history.rst b/docs/source/history.rst index e75ab65..49ae4cc 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -16,6 +16,9 @@ Dev - Made deactivation more robust, especially under ksh. - Use Python's ``tempfile`` module for creating temporary filenames safely and portably. + - Fix a problem with ``virtualenvwrapper_show_workon_options`` that + caused it to show ``*`` as the name of a virtualenv when no + environments had yet been created. 2.0.2 From 6f6b11c78148b211a824c7baa106b6ddb95904ed Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 16 Apr 2010 17:24:46 -0400 Subject: [PATCH 207/947] add -n and -l options to hook loader --- docs/source/history.rst | 4 ++++ virtualenvwrapper/hook_loader.py | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/docs/source/history.rst b/docs/source/history.rst index 49ae4cc..a304bfa 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -19,6 +19,10 @@ Dev - Fix a problem with ``virtualenvwrapper_show_workon_options`` that caused it to show ``*`` as the name of a virtualenv when no environments had yet been created. + - Change the hook loader so it can be told to run only a set of + named hooks. + - Add support for listing the available hooks, to be used in help + output of commands like virtualenvwrapper.project's mkproject. 2.0.2 diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 1bd2d69..55c4936 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -6,6 +6,7 @@ """Load hooks for virtualenvwrapper. """ +import inspect import logging import optparse import os @@ -24,6 +25,12 @@ def main(): dest='sourcing', default=False, ) + parser.add_option('-l', '--list', + help='Print a list of the plugins available for the given hook', + action='store_true', + default=False, + dest='listing', + ) parser.add_option('-v', '--verbose', help='Show more information on the console', action='store_const', @@ -37,6 +44,12 @@ def main(): const=0, dest='verbose_level', ) + parser.add_option('-n', '--name', + help='Only run the hook from the named plugin', + action='append', + dest='names', + default=[], + ) parser.disable_interspersed_args() # stop when we hit an option without an '-' options, args = parser.parse_args() @@ -66,7 +79,12 @@ def main(): hook += '_source' for ep in pkg_resources.iter_entry_points('virtualenvwrapper.%s' % hook): + if options.names and ep.name not in options.names: + continue plugin = ep.load() + if options.listing: + print ' {0:10} -- {1}'.format(ep.name, inspect.getdoc(plugin) or '') + continue if options.sourcing: # Show the shell commands so they can # be run in the calling shell. From fb9026018bf09880dc14a6cded741fbf747dc029 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 17 Apr 2010 16:11:51 -0400 Subject: [PATCH 208/947] add references to new extensions --- docs/source/extensions.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/source/extensions.rst b/docs/source/extensions.rst index c035869..95ab5c8 100644 --- a/docs/source/extensions.rst +++ b/docs/source/extensions.rst @@ -7,6 +7,24 @@ virtualenvwrapper. .. _extensions-user_scripts: +project +======= + +The project_ extension adds development directory management with +templates to virtualenvwrapper. + +bitbucket +--------- + +The bitbucket_ extension creates a project working directory and +automatically clones the repository from BitBucket. Requires +project_. + +.. _project: http://www.doughellmann.com/projects/virtualenvwrapper.project/ + +.. _bitbucket: http://www.doughellmann.com/projects/virtualenvwrapper.bitbucket/ + + user_scripts ============ From a5edf2270312fc72c3a35f294629bbf8f887911c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 17 Apr 2010 19:55:42 -0400 Subject: [PATCH 209/947] doc updates --- docs/source/command_ref.rst | 2 + docs/source/extensions.rst | 14 ++- docs/source/index.rst | 203 ++++++++++++++++++++++++------------ docs/source/install.rst | 72 +++++++++++++ docs/source/plugins.rst | 88 ++++++++++++---- 5 files changed, 287 insertions(+), 92 deletions(-) create mode 100644 docs/source/install.rst diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 2c1fd01..03826d1 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -1,6 +1,8 @@ .. Quick reference documentation for virtualenvwrapper command line functions Originally contributed Thursday, May 28, 2009 by Steve Steiner (ssteinerX@gmail.com) +.. _command: + ################# Command Reference ################# diff --git a/docs/source/extensions.rst b/docs/source/extensions.rst index 95ab5c8..cf0f461 100644 --- a/docs/source/extensions.rst +++ b/docs/source/extensions.rst @@ -16,7 +16,7 @@ templates to virtualenvwrapper. bitbucket --------- -The bitbucket_ extension creates a project working directory and +The bitbucket_ project template creates a working directory and automatically clones the repository from BitBucket. Requires project_. @@ -24,6 +24,18 @@ project_. .. _bitbucket: http://www.doughellmann.com/projects/virtualenvwrapper.bitbucket/ +emacs-desktop +============= + +Emacs desktop-mode_ lets you save the state of emacs (open buffers, +kill rings, buffer positions, etc.) between sessions. It can also be +used as a project file similar to other IDEs. The emacs-desktop_ +plugin adds a trigger to save the current desktop file and load a new +one when activating a new virtualenv using ``workon``. + +.. _desktop-mode: http://www.emacswiki.org/emacs/DeskTop + +.. _emacs-desktop: http://www.doughellmann.com/projects/virtualenvwrapper-emacs-desktop/ user_scripts ============ diff --git a/docs/source/index.rst b/docs/source/index.rst index ed7ddac..c760cf1 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -29,77 +29,141 @@ Features :ref:`plugins`). ============ -Installation +Introduction ============ -WORKON_HOME -=========== - -The variable ``WORKON_HOME`` tells virtualenvwrapper where to place -your virtual environments. The default is ``$HOME/.virtualenvs``. -This directory must be created before using any virtualenvwrapper -commands. - -Shell Startup File -================== - -Add two lines to your shell startup file (``.bashrc``, ``.profile``, -etc.) to set the location where the virtual environments should live -and the location of the script installed with this package:: - - export WORKON_HOME=$HOME/.virtualenvs - source /usr/local/bin/virtualenvwrapper.sh - -After editing it, reload the startup file (e.g., run: ``source -~/.bashrc``). - -Python Interpreter and $PATH -============================ - -During startup, ``virtualenvwrapper.sh`` finds the first ``python`` on -the ``$PATH`` and remembers it to use later. This eliminates any -conflict as the ``$PATH`` changes, enabling interpreters inside -virtual environments where virtualenvwrapper is not installed. -Because of this behavior, it is important for the ``$PATH`` to be set -**before** sourcing ``virtualenvwrapper.sh``. For example:: - - export PATH=/usr/local/bin:$PATH - source /usr/local/bin/virtualenvwrapper.sh - -To override the ``$PATH`` search, set the variable -``VIRTUALENVWRAPPER_PYTHON`` to the full path of the interpreter to -use (also **before** sourcing ``virtualenvwrapper.sh``). For -example:: - - export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python - source /usr/local/bin/virtualenvwrapper.sh - -Quick-Start -=========== - -1. Run: ``workon`` -2. A list of environments, empty, is printed. -3. Run: ``mkvirtualenv temp`` -4. A new environment, ``temp`` is created and activated. -5. Run: ``workon`` -6. This time, the ``temp`` environment is included. - -Temporary Files -=============== - -virtualenvwrapper creates temporary files in ``$TMPDIR``. If the -variable is not set, it uses ``/tmp``. To change the location of -temporary files just for virtualenvwrapper, set -``VIRTUALENVWRAPPER_TMPDIR``. - -Upgrading from 1.x -================== - -The shell script containing the wrapper functions has been renamed in -the 2.x series to reflect the fact that shells other than bash are -supported. In your startup file, change ``source -/usr/local/bin/virtualenvwrapper_bashrc`` to ``source -/usr/local/bin/virtualenvwrapper.sh``. +The best way to explain the features virtualenvwrapper gives you is to +show it in use. + +First, some initialization steps. Most of this only needs to be done +one time. You will want to add the command to ``source +/usr/local/bin/virtualenvwrapper.sh`` to your shell startup file, +changing the path to virtualenvwrapper.sh depending on where it was +installed by pip. + +:: + + $ pip install virtualenvwrapper + ... + $ export WORKON_HOME=~/Envs + $ mkdir -p $WORKON_HOME + $ source /usr/local/bin/virtualenvwrapper.sh + $ mkvirtualenv env1 + Installing + distribute.......................................... + .................................................... + .................................................... + ...............................done. + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/predeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/postdeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/preactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/postactivate New python executable in env1/bin/python + (env1)$ ls $WORKON_HOME + env1 hook.log + +Now we can install some software into the environment. + +:: + + (env1)$ pip install django + Downloading/unpacking django + Downloading Django-1.1.1.tar.gz (5.6Mb): 5.6Mb downloaded + Running setup.py egg_info for package django + Installing collected packages: django + Running setup.py install for django + changing mode of build/scripts-2.6/django-admin.py from 644 to 755 + changing mode of /Users/dhellmann/Envs/env1/bin/django-admin.py to 755 + Successfully installed django + +We can see the new package with ``lssitepackages``:: + + (env1)$ lssitepackages + Django-1.1.1-py2.6.egg-info easy-install.pth + distribute-0.6.10-py2.6.egg pip-0.6.3-py2.6.egg + django setuptools.pth + +Of course we are not limited to a single virtualenv:: + + (env1)$ ls $WORKON_HOME + env1 hook.log + (env1)$ mkvirtualenv env2 + Installing distribute............................... + .................................................... + .................................................... + ........... ...............................done. + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/predeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/postdeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/preactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/postactivate New python executable in env2/bin/python + (env2)$ ls $WORKON_HOME + env1 env2 hook.log + +Switch between environments with ``workon``:: + + (env2)$ workon env1 + (env1)$ echo $VIRTUAL_ENV + /Users/dhellmann/Envs/env1 + (env1)$ + +The ``workon`` command also includes tab completion for the +environment names, and invokes customization scripts as an environment +is activated or deactivated (see :ref:`scripts`). + +:: + + (env1)$ echo 'cd $VIRTUAL_ENV' >> $WORKON_HOME/postactivate + (env1)$ workon env2 + (env2)$ pwd + /Users/dhellmann/Envs/env2 + +:ref:`scripts-postmkvirtualenv` is run when a new environment is +created, letting you automatically install commonly-used tools. + +:: + + (env2)$ echo 'pip install sphinx' >> $WORKON_HOME/postmkvirtualenv + (env3)$ mkvirtualenv env3 + New python executable in env3/bin/python + Installing distribute............................... + .................................................... + .................................................... + ........... ...............................done. + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/predeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/postdeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/preactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/postactivate + Downloading/unpacking sphinx + Downloading Sphinx-0.6.5.tar.gz (972Kb): 972Kb downloaded + Running setup.py egg_info for package sphinx + no previously-included directories found matching 'doc/_build' + Downloading/unpacking Pygments>=0.8 (from sphinx) + Downloading Pygments-1.3.1.tar.gz (1.1Mb): 1.1Mb downloaded + Running setup.py egg_info for package Pygments + Downloading/unpacking Jinja2>=2.1 (from sphinx) + Downloading Jinja2-2.4.tar.gz (688Kb): 688Kb downloaded + Running setup.py egg_info for package Jinja2 + warning: no previously-included files matching '*' found under directory 'docs/_build/doctrees' + Downloading/unpacking docutils>=0.4 (from sphinx) + Downloading docutils-0.6.tar.gz (1.4Mb): 1.4Mb downloaded + Running setup.py egg_info for package docutils + Installing collected packages: docutils, Jinja2, Pygments, sphinx + Running setup.py install for docutils + Running setup.py install for Jinja2 + Running setup.py install for Pygments + Running setup.py install for sphinx + no previously-included directories found matching 'doc/_build' + Installing sphinx-build script to /Users/dhellmann/Envs/env3/bin + Installing sphinx-quickstart script to /Users/dhellmann/Envs/env3/bin + Installing sphinx-autogen script to /Users/dhellmann/Envs/env3/bin + Successfully installed docutils Jinja2 Pygments sphinx (env3)$ + (venv3)$ which sphinx-build + /Users/dhellmann/Envs/env3/bin/sphinx-build + +Through a combination of the existing functions defined by the core +package (see :ref:`command`), third-party plugins (see +:ref:`plugins`), and user-defined scripts (see :ref:`scripts`) +virtualenvwrapper gives you a wide variety of opportunities to +automate repetitive operations. ======= Details @@ -108,6 +172,7 @@ Details .. toctree:: :maxdepth: 2 + install command_ref hooks tips diff --git a/docs/source/install.rst b/docs/source/install.rst new file mode 100644 index 0000000..0cd4dbe --- /dev/null +++ b/docs/source/install.rst @@ -0,0 +1,72 @@ +============ +Installation +============ + +WORKON_HOME +=========== + +The variable ``WORKON_HOME`` tells virtualenvwrapper where to place +your virtual environments. The default is ``$HOME/.virtualenvs``. +This directory must be created before using any virtualenvwrapper +commands. + +Shell Startup File +================== + +Add two lines to your shell startup file (``.bashrc``, ``.profile``, +etc.) to set the location where the virtual environments should live +and the location of the script installed with this package:: + + export WORKON_HOME=$HOME/.virtualenvs + source /usr/local/bin/virtualenvwrapper.sh + +After editing it, reload the startup file (e.g., run: ``source +~/.bashrc``). + +Python Interpreter and $PATH +============================ + +During startup, ``virtualenvwrapper.sh`` finds the first ``python`` on +the ``$PATH`` and remembers it to use later. This eliminates any +conflict as the ``$PATH`` changes, enabling interpreters inside +virtual environments where virtualenvwrapper is not installed. +Because of this behavior, it is important for the ``$PATH`` to be set +**before** sourcing ``virtualenvwrapper.sh``. For example:: + + export PATH=/usr/local/bin:$PATH + source /usr/local/bin/virtualenvwrapper.sh + +To override the ``$PATH`` search, set the variable +``VIRTUALENVWRAPPER_PYTHON`` to the full path of the interpreter to +use (also **before** sourcing ``virtualenvwrapper.sh``). For +example:: + + export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python + source /usr/local/bin/virtualenvwrapper.sh + +Quick-Start +=========== + +1. Run: ``workon`` +2. A list of environments, empty, is printed. +3. Run: ``mkvirtualenv temp`` +4. A new environment, ``temp`` is created and activated. +5. Run: ``workon`` +6. This time, the ``temp`` environment is included. + +Temporary Files +=============== + +virtualenvwrapper creates temporary files in ``$TMPDIR``. If the +variable is not set, it uses ``/tmp``. To change the location of +temporary files just for virtualenvwrapper, set +``VIRTUALENVWRAPPER_TMPDIR``. + +Upgrading from 1.x +================== + +The shell script containing the wrapper functions has been renamed in +the 2.x series to reflect the fact that shells other than bash are +supported. In your startup file, change ``source +/usr/local/bin/virtualenvwrapper_bashrc`` to ``source +/usr/local/bin/virtualenvwrapper.sh``. diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index 20302c1..50e4a0a 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -4,23 +4,26 @@ Extending Virtualenvwrapper =========================== -Customizing one's development environment is a practice adopted from -other tool-based jobs in which long experience leads to home-grown and -unique solutions to persistent annoyances. Carpenters build jigs, -software developers write shell scripts. virtualenvwrapper continues -the tradition of encouraging a craftsman to modify his tools to work -the way he wants, rather than the other way around. +Long experience with home-grown solutions for customizing a +development environment has proven how valuable it can be to have the +ability to automate common tasks and eliminate persistent annoyances. +Carpenters build jigs, software developers write shell scripts. +virtualenvwrapper continues the tradition of encouraging a craftsman +to modify their tools to work the way they want, rather than the other +way around. Use the hooks provided to eliminate repetitive manual operations and -streamline your development workflow. For example, the pre_activate -and post_activate hooks can trigger an IDE to load a project file to -reload files from the last editing session, manage time-tracking -records, or start and stop development versions of an application -server. The initialize hook can be used to add entirely new commands -and hooks to virtualenvwrapper. And the pre_mkvirtualenv and -post_mkvirtualenv hooks give you an opportunity to install basic -requirements into each new development environment, initialize a -source code control repository, or otherwise set up a new project. +streamline your development workflow. For example, set up the +:ref:`plugins-pre_activate` and :ref:`plugins-post_activate` hooks to +trigger an IDE to load a project file to reload files from the last +editing session, manage time-tracking records, or start and stop +development versions of an application server. Use the +:ref:`plugins-initialize` hook to add entirely new commands and hooks +to virtualenvwrapper. And the :ref:`plugins-pre_mkvirtualenv` and +:ref:`plugins-post_mkvirtualenv` hooks give you an opportunity to +install basic requirements into each new development environment, +initialize a source code control repository, or otherwise set up a new +project. There are two ways to attach your code so that virtualenvwrapper will run it: End-users can use shell scripts or other programs for personal @@ -222,15 +225,20 @@ application, use the ``-m`` option to the interpreter:: $ python -m virtualenvwrapper.hook_loader -h Usage: virtualenvwrapper.hook_loader [options] [] - + Manage hooks for virtualenvwrapper - + Options: - -h, --help show this help message and exit - -s, --source Print the shell commands to be run in the current shell - -v, --verbose Show more information on the console - -q, --quiet Show less information on the console - + -h, --help show this help message and exit + -s, --source Print the shell commands to be run in the current + shell + -l, --list Print a list of the plugins available for the given + hook + -v, --verbose Show more information on the console + -q, --quiet Show less information on the console + -n NAMES, --name=NAMES + Only run the hook from the named plugin + To run the extensions for the initialize hook:: $ python -m virtualenvwrapper.hook_loader -v initialize @@ -239,6 +247,15 @@ To get the shell commands for the initialize hook:: $ python -m virtualenvwrapper.hook_loader --source initialize +In practice, rather than invoking the hook loader directly it is more +convenient to use the shell function, ``virtualenvwrapper_run_hook`` +to run the hooks in both modes.:: + + $ virtualenvwrapper_run_hook initialize + +All of the arguments given to shell function are passed directly to +the hook loader. + Logging ------- @@ -365,5 +382,32 @@ The ``virtualenvwrapper.post_rmvirtualenv`` hooks are run just after an environment is deleted. The name of the environment being deleted is passed as the first argument. +Adding New Extension Points +=========================== + +Plugins that define new operations can also define new extension +points. No setup needs to be done to allow the hook loader to find +the extensions; documenting the names and adding calls to +``virtualenvwrapper_run_hook`` is sufficient to cause them to be +invoked. + +The hook loader assumes all extension point names start with +``virtualenvwrapper.`` and new plugins will want to use their own +namespace qualifier to append to that. For example, the project_ +extension defines new events around creating project directories (pre +and post). These are called +``virtualenvwrapper.project.pre_mkproject`` and +``virtualenvwrapper.project.post_mkproject``. These are invoked +with:: + + virtualenvwrapper_run_hook project.pre_mkproject $project_name + +and:: + + virtualenvwrapper_run_hook project.post_mkproject + +respectively. .. _Distribute: http://packages.python.org/distribute/ + +.. _project: http://www.doughellmann.com/projects/virtualenvwrapper.project/ From a4c71f25d8a4e6970f74eec205645057d8e21f87 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 17 Apr 2010 21:01:11 -0400 Subject: [PATCH 210/947] fix mkvirtualenv -h --- docs/source/history.rst | 1 + docs/source/install.rst | 15 +++++++++++++++ virtualenvwrapper.sh | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index a304bfa..aa15633 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -23,6 +23,7 @@ Dev named hooks. - Add support for listing the available hooks, to be used in help output of commands like virtualenvwrapper.project's mkproject. + - Fix mkvirtualenv -h option behavior. 2.0.2 diff --git a/docs/source/install.rst b/docs/source/install.rst index 0cd4dbe..b0450fa 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -2,6 +2,17 @@ Installation ============ +Basic Installation +================== + +virtualenvwrapper should be installed using pip_:: + + $ pip install virtualenvwrapper + +You will want to install it into the global Python site-packages area, +along with virtualenv. You may need administrative privileges to do +that. + WORKON_HOME =========== @@ -10,6 +21,8 @@ your virtual environments. The default is ``$HOME/.virtualenvs``. This directory must be created before using any virtualenvwrapper commands. +.. _install-shell-config: + Shell Startup File ================== @@ -70,3 +83,5 @@ the 2.x series to reflect the fact that shells other than bash are supported. In your startup file, change ``source /usr/local/bin/virtualenvwrapper_bashrc`` to ``source /usr/local/bin/virtualenvwrapper.sh``. + +.. _pip: http://pypi.python.org/pypi/pip diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index da23459..6c16b68 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -158,7 +158,7 @@ mkvirtualenv () { virtualenvwrapper_verify_virtualenv || return 1 (cd "$WORKON_HOME" && virtualenv "$@" && - virtualenvwrapper_run_hook "pre_mkvirtualenv" "$envname" + [ -d "$WORKON_HOME/$envname" ] && virtualenvwrapper_run_hook "pre_mkvirtualenv" "$envname" ) # If they passed a help option or got an error from virtualenv, # the environment won't exist. Use that to tell whether From 75b2a626560cfa44b61560d0ddab22a3d55d2b81 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 18 Apr 2010 09:44:09 -0400 Subject: [PATCH 211/947] do not include html docs inside virtualenvwrapper dir to avoid conflicts with other packages using that namespace --- MANIFEST.in | 4 ++-- Makefile | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index eadfcfd..85a36ab 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,5 @@ include setup.py include distribute_setup.py include tests/* -recursive-include virtualenvwrapper *.html *.txt *.css *.js *.png -recursive-include docs *.rst +recursive-include docs *.rst *.py *.html *.css *.js *.png *.txt + diff --git a/Makefile b/Makefile index 8426ef1..5df41df 100644 --- a/Makefile +++ b/Makefile @@ -31,9 +31,7 @@ sdist: html # Documentation .PHONY: html html: - rm -rf virtualenvwrapper/docs (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/pkg") - cp -r docs/build/html virtualenvwrapper/docs # Website copy of documentation .PHONY: website From 3c6c68632f846e5e92937365e30611cbf1cd0e4c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 18 Apr 2010 10:25:55 -0400 Subject: [PATCH 212/947] do not include website html in sdist --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 5df41df..9c8899e 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,7 @@ help: .PHONY: sdist sdist: html rm -f dist/*.gz + rm -rf docs/website python setup.py sdist cp -v dist/*.gz ~/Desktop From 68b1d107c245a65ebff4c73333d0555d0f9cef17 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 18 Apr 2010 10:26:08 -0400 Subject: [PATCH 213/947] rotate log file when it grows too big --- docs/source/history.rst | 2 ++ virtualenvwrapper/hook_loader.py | 21 +++++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index aa15633..4df879e 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -24,6 +24,8 @@ Dev - Add support for listing the available hooks, to be used in help output of commands like virtualenvwrapper.project's mkproject. - Fix mkvirtualenv -h option behavior. + - Change logging so the $WORKON_HOME/hook.log file rotates after + 10KiB. 2.0.2 diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 55c4936..688ddd2 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -8,6 +8,7 @@ import inspect import logging +import logging.handlers import optparse import os @@ -53,12 +54,20 @@ def main(): parser.disable_interspersed_args() # stop when we hit an option without an '-' options, args = parser.parse_args() - # Set up logging to a file and to the console - logging.basicConfig( - filename=os.path.expandvars(os.path.join('$WORKON_HOME', 'hook.log')), - level=logging.DEBUG, - format='%(asctime)s %(levelname)s %(name)s %(message)s', + root_logger = logging.getLogger('') + + # Set up logging to a file + root_logger.setLevel(logging.DEBUG) + file_handler = logging.handlers.RotatingFileHandler( + os.path.expandvars(os.path.join('$WORKON_HOME', 'hook.log')), + maxBytes=10240, + backupCount=1, ) + formatter = logging.Formatter('%(asctime)s %(levelname)s %(name)s %(message)s') + file_handler.setFormatter(formatter) + root_logger.addHandler(file_handler) + + # Send higher-level messages to the console, too console = logging.StreamHandler() console_level = [ logging.WARNING, logging.INFO, @@ -67,7 +76,7 @@ def main(): console.setLevel(console_level) formatter = logging.Formatter('%(name)s %(message)s') console.setFormatter(formatter) - logging.getLogger('').addHandler(console) + root_logger.addHandler(console) #logging.getLogger(__name__).debug('cli args %s', args) From e412d442132e0c439041ba40d8969498140ba77d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 18 Apr 2010 10:28:04 -0400 Subject: [PATCH 214/947] bump version --- docs/source/history.rst | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index 4df879e..0636f95 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -2,7 +2,7 @@ Release History =============== -Dev +2.1 - Add support for ksh. Thanks to Doug Latornell for doing the research on what needed to be changed. diff --git a/setup.py b/setup.py index a076b10..3e67b94 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' -VERSION = '2.0.2' +VERSION = '2.1' # Bootstrap installation of Distribute import distribute_setup From 64179a291dafac5b5eca83c803d4514772656f6e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 18 Apr 2010 10:28:06 -0400 Subject: [PATCH 215/947] Added tag 2.1 for changeset 241df6c36860 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 7b4b921..7089e1a 100644 --- a/.hgtags +++ b/.hgtags @@ -49,3 +49,4 @@ d64869519c2e0553303cfeeb0918271564c72beb 1.27 54713c4552c2bcf0155071c87cfca84ed1ea5f6e 2.0 91e1124c68315f8cdc6578c4f72e3ed9c44e1fca 2.0.1 6a51a81454ae9dde5d923668ad5f034b3467fe11 2.0.2 +241df6c36860c13fae5468881457a27840ee9d72 2.1 From 986bd1ff92a8eb4c6b28219ca9864170bd33c1b6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 18 Apr 2010 10:35:33 -0400 Subject: [PATCH 216/947] add emacs directive to readme --- README.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.txt b/README.txt index 1f3f384..3cca3d5 100644 --- a/README.txt +++ b/README.txt @@ -1,3 +1,5 @@ +.. -*- mode: rst -*- + ################# virtualenvwrapper ################# From e72ff253102ced2a242ad06f68d50e3924040053 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 18 Apr 2010 10:59:53 -0400 Subject: [PATCH 217/947] update announcement for 2.1 --- announce.rst | 61 +++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/announce.rst b/announce.rst index 0a3100b..79e3289 100644 --- a/announce.rst +++ b/announce.rst @@ -7,37 +7,36 @@ virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. -What's New in 2.0 +What's New in 2.1 ================= -This new version uses a significantly rewritten version of the -hook/callback subsystem to make it easier to share extensions. For -example, released at the same time is virtualenvwrapper-emacs-desktop_, -a plugin to switch emacs project files when you switch virtualenvs. - -Existing user scripts should continue to work as-written. Any failures -are probably a bug, so please report them on the bitbucket -tracker. Documentation for the new plugin system is available in the -virtualenvwrapper docs_. - -I also took this opportunity to change the name of the shell script -containing most of the virtualenvwrapper functionality from -virtualenvwrapper_bashrc to virtualenvwrapper.sh. This reflects the -fact that several shells other than bash are supported (bash, sh, ksh, -and zsh are all reported to work). You'll want to update your shell -startup file after upgrading to 2.0. - -The work to create the plugin system was triggered by a couple of -recent feature requests for environment templates and for a new -command to create a sub-shell instead of simply changing the settings -of the current shell. The new, more powerful, plugin capabilities will -make it easier to develop these and similar features. - -I'm looking forward to seeing what the community comes up with. I -especially want someone to write a plugin to start a copy of a -development server for a Django project if one is found in a -virtualenv. You'll get bonus points if it opens the home page of the -server in a web browser. +The primary purpose of this release is a set of enhancements to +support virtualenvwrapper.project_, a new extension to manage project +work directories with templates. 2.1 also includes several smaller +changes and bug fixes. + +- Add support for ksh. Thanks to Doug Latornell for doing the + research on what needed to be changed. +- Test import of virtualenvwrapper.hook_loader on startup and report + the error in a way that should help the user figure out how to fix + it (issue #33). +- Update mkvirtualenv documentation to include the + fact that a new environment is activated immediately after it is + created (issue #30). +- Added hooks around cpvirtualenv. +- Made deactivation more robust, especially under ksh. +- Use Python's ``tempfile`` module for creating temporary filenames + safely and portably. +- Fix a problem with ``virtualenvwrapper_show_workon_options`` that + caused it to show ``*`` as the name of a virtualenv when no + environments had yet been created. +- Change the hook loader so it can be told to run only a set of + named hooks. +- Add support for listing the available hooks, to be used in help + output of commands like virtualenvwrapper.project's mkproject. +- Fix mkvirtualenv -h option behavior. +- Change logging so the $WORKON_HOME/hook.log file rotates after + 10KiB. @@ -45,6 +44,4 @@ server in a web browser. .. _virtualenvwrapper: http://www.doughellmann.com/projects/virtualenvwrapper/ -.. _virtualenvwrapper-emacs-desktop: http://www.doughellmann.com/projects/virtualenvwrapper-emacs-desktop/ - -.. _docs: http://www.doughellmann.com/docs/virtualenvwrapper/ +.. _virtualenvwrapper.project: http://www.doughellmann.com/projects/virtualenvwrapper.project/ From 44d2a9e9d44f5e04215a026936c7356788e654d8 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Mon, 19 Apr 2010 16:19:32 -0300 Subject: [PATCH 218/947] fixed the right bug :) --- docs/source/scripts.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/scripts.rst b/docs/source/scripts.rst index 122f9eb..02fa798 100644 --- a/docs/source/scripts.rst +++ b/docs/source/scripts.rst @@ -15,7 +15,7 @@ initialize :Global/Local: global :Argument(s): None - :Sourced/Run: run + :Sourced/Run: sourced ``$WORKON_HOME/initialize`` is sourced when ``virtualenvwrapper.sh`` is loaded into your environment. Use it to adjust global settings From 31a3d119f0286bae681f115f27a93e5b4f9e14d8 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 20 Apr 2010 00:01:17 -0300 Subject: [PATCH 219/947] index.rst translated to spanish --HG-- rename : docs/source/index.rst => docs/es/source/index.rst --- docs/es/source/index.rst | 218 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 218 insertions(+) create mode 100644 docs/es/source/index.rst diff --git a/docs/es/source/index.rst b/docs/es/source/index.rst new file mode 100644 index 0000000..8a93d24 --- /dev/null +++ b/docs/es/source/index.rst @@ -0,0 +1,218 @@ +.. virtualenvwrapper documentation master file, created by + sphinx-quickstart on Thu May 28 22:35:13 2009. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +########################### +virtualenvwrapper |release| +########################### + +virtualenvwrapper es un conjunto de extensiones de la herramienta de Ian +Bicking `virtualenv `_. Las extensiones +incluyen funciones para la creación y eliminación de entornos virtuales y por otro +lado administración de tu rutina de desarrollo, haciendo fácil trabajar en más +de un proyecto al mismo tiempo sin introducir conflictos entre sus dependencias. + +=============== +Características +=============== + +1. Organiza todos tus entornos virtuales en un sólo lugar +2. Funciones para administrar tus entornor virtuales (crear, eliminar, copiar). +3. Usa un sólo comando para cambiar entre los entornos. +4. Completa con tab los comandos que toman un entorno virtual como argumento. +5. Ganchos configurables para todas las operaciones (ver :ref:`scripts`). +6. Sistema de plugins para la creación de extensiones compartibles (ver +:ref:`plugins`). + +============ +Introducción +============ + +La mejor forma de explicar las características que virtualenvwrapper brinda es +mostrar éste en uso. + +Primero, algunos pasos de inicialización. La mayoría de esto sólo necesita ser +hecho una sóla vez. Vas a querer agregar el comando ``source +/usr/local/bin/virtualenvwrapper.sh`` al archivo de inicio de shell, cambiando +el path hacia virtualenvwrapper.sh dependiendo en dónde haya sido instalado por +pip. + +:: + + $ pip install virtualenvwrapper + ... + $ export WORKON_HOME=~/Envs + $ mkdir -p $WORKON_HOME + $ source /usr/local/bin/virtualenvwrapper.sh + $ mkvirtualenv env1 + Installing + distribute.......................................... + .................................................... + .................................................... + ...............................done. + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/predeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/postdeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/preactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/postactivate New python executable in env1/bin/python + (env1)$ ls $WORKON_HOME + env1 hook.log + +Ahora podemos instalar algún software dentro del entorno. + +:: + + (env1)$ pip install django + Downloading/unpacking django + Downloading Django-1.1.1.tar.gz (5.6Mb): 5.6Mb downloaded + Running setup.py egg_info for package django + Installing collected packages: django + Running setup.py install for django + changing mode of build/scripts-2.6/django-admin.py from 644 to 755 + changing mode of /Users/dhellmann/Envs/env1/bin/django-admin.py to 755 + Successfully installed django + +Podemos ver el nuevo paquete instalado con ``lssitepackages``:: + + (env1)$ lssitepackages + Django-1.1.1-py2.6.egg-info easy-install.pth + distribute-0.6.10-py2.6.egg pip-0.6.3-py2.6.egg + django setuptools.pth + +Por supuesto que no estamos limitados a un sólo virtualenv:: + + (env1)$ ls $WORKON_HOME + env1 hook.log + (env1)$ mkvirtualenv env2 + Installing distribute............................... + .................................................... + .................................................... + ........... ...............................done. + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/predeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/postdeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/preactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/postactivate New python executable in env2/bin/python + (env2)$ ls $WORKON_HOME + env1 env2 hook.log + +Cambiar entre entornos con ``workon``:: + + (env2)$ workon env1 + (env1)$ echo $VIRTUAL_ENV + /Users/dhellmann/Envs/env1 + (env1)$ + +El comando ``workon`` también incluye la completación con tab para los nombres +de los entornos, e invoca a los scripts customizados cuando un entorno es +activado o desactivado (ver :ref:`scripts`). + +:: + + (env1)$ echo 'cd $VIRTUAL_ENV' >> $WORKON_HOME/postactivate + (env1)$ workon env2 + (env2)$ pwd + /Users/dhellmann/Envs/env2 + +:ref:`scripts-postmkvirtualenv` es ejecutado cuando un nuevo entorno es creado, +dejándote instalar automáticamente herramientas comunmente utilizadas. + +:: + + (env2)$ echo 'pip install sphinx' >> $WORKON_HOME/postmkvirtualenv + (env3)$ mkvirtualenv env3 + New python executable in env3/bin/python + Installing distribute............................... + .................................................... + .................................................... + ........... ...............................done. + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/predeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/postdeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/preactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/postactivate + Downloading/unpacking sphinx + Downloading Sphinx-0.6.5.tar.gz (972Kb): 972Kb downloaded + Running setup.py egg_info for package sphinx + no previously-included directories found matching 'doc/_build' + Downloading/unpacking Pygments>=0.8 (from sphinx) + Downloading Pygments-1.3.1.tar.gz (1.1Mb): 1.1Mb downloaded + Running setup.py egg_info for package Pygments + Downloading/unpacking Jinja2>=2.1 (from sphinx) + Downloading Jinja2-2.4.tar.gz (688Kb): 688Kb downloaded + Running setup.py egg_info for package Jinja2 + warning: no previously-included files matching '*' found under directory 'docs/_build/doctrees' + Downloading/unpacking docutils>=0.4 (from sphinx) + Downloading docutils-0.6.tar.gz (1.4Mb): 1.4Mb downloaded + Running setup.py egg_info for package docutils + Installing collected packages: docutils, Jinja2, Pygments, sphinx + Running setup.py install for docutils + Running setup.py install for Jinja2 + Running setup.py install for Pygments + Running setup.py install for sphinx + no previously-included directories found matching 'doc/_build' + Installing sphinx-build script to /Users/dhellmann/Envs/env3/bin + Installing sphinx-quickstart script to /Users/dhellmann/Envs/env3/bin + Installing sphinx-autogen script to /Users/dhellmann/Envs/env3/bin + Successfully installed docutils Jinja2 Pygments sphinx (env3)$ + (venv3)$ which sphinx-build + /Users/dhellmann/Envs/env3/bin/sphinx-build + +A través de una combinación de funciones existentes definidas por el "core" +package (see :ref:`command`), plugins de terceros (see +:ref:`plugins`), y scripts definidos por el usuario (see :ref:`scripts`) +virtualenvwrapper brinda una amplia variedad de oportunidades para automatizar +tareas repetitivas. + +======== +Detalles +======== + +.. toctree:: + :maxdepth: 2 + + install + command_ref + hooks + tips + developers + extensions + history + +.. _references: + +=========== +Referencias +=========== + +`virtualenv `_, de Ian +Bicking, es un pre-requisito para usar estas extensiones. + +Para más detalles, referirse a la columna que escribí para la revista de +python (Python Magazine) en Mayo de 2008: `virtualenvwrapper | And Now For Something +Completely Different +`_. + +Rich Leland ha grabado un pequeño `screencast +`__ +mostrando las características de virtualenvwrapper. + +======== +Licencia +======== + +Copyright Doug Hellmann, All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Doug Hellmann not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. From 5809e3e0fe1b866257d5da0110d0e36430b59b54 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 20 Apr 2010 11:53:11 -0300 Subject: [PATCH 220/947] added the translation for install.rst --HG-- rename : docs/source/install.rst => docs/es/source/install.rst --- docs/es/source/install.rst | 85 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 docs/es/source/install.rst diff --git a/docs/es/source/install.rst b/docs/es/source/install.rst new file mode 100644 index 0000000..a189651 --- /dev/null +++ b/docs/es/source/install.rst @@ -0,0 +1,85 @@ +=========== +Instalación +=========== + +Instalación básica +================== + +virtualenvwrapper debe se instalado usando pip_:: + + $ pip install virtualenvwrapper + +Querrás instalarlo dentro del site-packages global de Python, junto con +virtualenv. Quizás necesites privilegios de administrador para hacer esto. + +WORKON_HOME +=========== + +La variable ``WORKON_HOME`` le indica a virtualenvwrapper cuál es el lugar de +tus entornos virtuales. El default es ``$HOME/.virtualenvs``. +Este directorio debe ser creado antes de usar cualquier comando de +virtualenvwrapper. + +.. _install-shell-config: + +Archivo de inicio del shell +=========================== + +Agrega estas dos líneas a tu archivo de inicio del shell (``.bashrc``, ``.profile``, +etc.) para configurar la ubicación dónde se van a guardar los entornos virtuales +y los scripts instalados con este paquete:: + + export WORKON_HOME=$HOME/.virtualenvs + source /usr/local/bin/virtualenvwrapper.sh + +Despues de editar este, recarga el archivo de inicio (e.g., ejecuta: ``source +~/.bashrc``). + +Intérprete de Python y $PATH +============================ + +Durante el inicio, ``virtualenvwrapper.sh`` busca el primer ``python`` en la +variable ``$PATH`` y recuerda éste para su posterior uso. Esto elimina cualquier +conflicto con los cambios en ``$PATH``, permitiendo intérpretes dentro de +entornos en los cuales virtualenvwrapper no está instalado. Debido a este +comportamiento, es importante configurar la variable ``$PATH`` **antes** de +hacer la inclusión de ``virtualenvwrapper.sh`` (mediante ``source``). Por +ejemplo:: + + export PATH=/usr/local/bin:$PATH + source /usr/local/bin/virtualenvwrapper.sh + +Para reemplazar la búsqueda en ``$PATH``, se puede configurar la variable +``VIRTUALENVWRAPPER_PYTHON`` hacia la ruta absoluta del intérprete a usar +(también **antes** de incluir ``virtualenvwrapper.sh``). Por ejemplo:: + + export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python + source /usr/local/bin/virtualenvwrapper.sh + +Inicio rápido +============= + +1. Ejecuta: ``workon`` +2. Una lista de entornos, vacía, es impresa. +3. Ejecuta: ``mkvirtualenv temp`` +4. Un nuevo entorno, ``temp`` es creado y activado. +5. Ejecuta: ``workon`` +6. Esta vez, el entorno ``temp`` es incluido. + +Archivos temporales +=================== + +virtualenvwrapper crea archivos temporales en ``$TMPDIR``. Si la variable no +está configuradad, este usa ``/tmp``. Para cambiar la ubicación de los archivos +temporales sólo para virtualenvwrapper, configura ``VIRTUALENVWRAPPER_TMPDIR``. + +Actualizar desde 1.x +==================== + +El script de shell que contiene las funciones ha sido renombrado en la serie +2.x para reflejar el hecho de que otros shell además de bash son soportados. En +tu archivo de inicio del shell, cambia ``source +/usr/local/bin/virtualenvwrapper_bashrc`` por ``source +/usr/local/bin/virtualenvwrapper.sh``. + +.. _pip: http://pypi.python.org/pypi/pip From d407cada88aa5886777f2677d01bba6944433966 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 20 Apr 2010 13:52:00 -0300 Subject: [PATCH 221/947] added some translated topics --HG-- rename : docs/es/source/index.rst => docs/source/es/index.rst rename : docs/es/source/install.rst => docs/source/es/install.rst --- docs/source/es/command_ref.rst | 327 ++++++++++++++++++++++ docs/{es/source => source/es}/index.rst | 0 docs/{es/source => source/es}/install.rst | 0 3 files changed, 327 insertions(+) create mode 100644 docs/source/es/command_ref.rst rename docs/{es/source => source/es}/index.rst (100%) rename docs/{es/source => source/es}/install.rst (100%) diff --git a/docs/source/es/command_ref.rst b/docs/source/es/command_ref.rst new file mode 100644 index 0000000..c05013c --- /dev/null +++ b/docs/source/es/command_ref.rst @@ -0,0 +1,327 @@ +.. Quick reference documentation for virtualenvwrapper command line functions + Originally contributed Thursday, May 28, 2009 by Steve Steiner (ssteinerX@gmail.com) + +.. _command: + +###################### +Referencia de comandos +###################### + +Todos los comandos a continuación son para ser utilizados en una Terminal de +línea de comandos. + +==================== +Administrar entornos +==================== + +.. _command-mkvirtualenv: + +mkvirtualenv +------------ + +Crea un nuevo entorno, dentro de WORKON_HOME. + +Sintaxis:: + + mkvirtualenv [options] ENVNAME + +Todas las opciones de línea de comandos son pasados diréctamente a +``virtualenv``. El nuevo entorno es automáticamente activado luego de su +inicialización. + +:: + + $ workon + $ mkvirtualenv mynewenv + New python executable in mynewenv/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (mynewenv)$ workon + mynewenv + (mynewenv)$ + +.. seealso:: + + * :ref:`scripts-premkvirtualenv` + * :ref:`scripts-postmkvirtualenv` + +rmvirtualenv +------------ + +Elimina un entorno, dentro de WORKON_HOME. + +Sintaxis:: + + rmvirtualenv ENVNAME + +Debes usar :ref:`command-deactivate` antes de eliminar el entorno actual. + +:: + + (mynewenv)$ deactivate + $ rmvirtualenv mynewenv + $ workon + $ + +.. seealso:: + + * :ref:`scripts-prermvirtualenv` + * :ref:`scripts-postrmvirtualenv` + +.. _command-cpvirtualenv: + +cpvirtualenv +------------ + +Duplica un entorno, dentro de WORKON_HOME. + +Syntax:: + + cpvirtualenv ENVNAME TARGETENVNAME + +.. note:: + + El entorno creado por la operación de copia es hecho `reubicable + `__. + +:: + + $ workon + $ mkvirtualenv source + New python executable in source/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (source)$ cpvirtualenv source dest + Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/easy_install relative + Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/easy_install-2.6 relative + Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/pip relative + Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/postactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) + Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/postdeactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) + Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/preactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) + Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/predeactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) + (dest)$ workon + dest + source + (dest)$ + +.. seealso:: + + * :ref:`scripts-precpvirtualenv` + * :ref:`scripts-postcpvirtualenv` + * :ref:`scripts-premkvirtualenv` + * :ref:`scripts-postmkvirtualenv` + +============================== +Controlar los entornos activos +============================== + +workon +------ + +Lista o cambia el entorno de trabajo actual + +Sintaxis:: + + workon [environment_name] + +Si no se especifica el ``environment_name`` la lista de entornos disponibles es +impresa en la salida estándar. + +:: + + $ workon + $ mkvirtualenv env1 + New python executable in env1/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (env1)$ mkvirtualenv env2 + New python executable in env2/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (env2)$ workon + env1 + env2 + (env2)$ workon env1 + (env1)$ echo $VIRTUAL_ENV + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 + (env1)$ workon env2 + (env2)$ echo $VIRTUAL_ENV + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env2 + (env2)$ + + +.. seealso:: + + * :ref:`scripts-predeactivate` + * :ref:`scripts-postdeactivate` + * :ref:`scripts-preactivate` + * :ref:`scripts-postactivate` + +.. _command-deactivate: + +deactivate +---------- + +Cambia de un entorno virtual a la versión instalada de Python en el sistema. + +Sintaxis:: + + deactivate + +.. note:: + + Este comando es actualmente parte de virtualenv, pero es encapsulado para + proveer ganchos antes y después, al igual que workon hace para activate. + +:: + + $ workon + $ echo $VIRTUAL_ENV + + $ mkvirtualenv env1 + New python executable in env1/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (env1)$ echo $VIRTUAL_ENV + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 + (env1)$ deactivate + $ echo $VIRTUAL_ENV + + $ + +.. seealso:: + + * :ref:`scripts-predeactivate` + * :ref:`scripts-postdeactivate` + +====================================== +Rápida navegación dentro de virtualenv +====================================== + +Existen dos funciones que proveen atajos para navegar dentro del virtualenv +actualmente activado. + +cdvirtualenv +------------ + +Cambia el directorio de trabajo actual hacia ``$VIRTUAL_ENV``. + +Sintaxis:: + + cdvirtualenv [subdir] + +Al llamar ``cdvirtualenv`` se cambia el directorio de trabajo actual hacia la +sima de virtualenv (``$VIRTUAL_ENV``). Un argumento adicional es agregado a la +ruta, permitiendo navegar diréctamente dentro de un subdirectorio. + +:: + + $ mkvirtualenv env1 + New python executable in env1/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (env1)$ echo $VIRTUAL_ENV + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 + (env1)$ cdvirtualenv + (env1)$ pwd + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 + (env1)$ cdvirtualenv bin + (env1)$ pwd + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1/bin + +cdsitepackages +-------------- + +Cambia el directorio de trabajo actual al ``site-packages`` del +``$VIRTUAL_ENV``. + +Sintaxis:: + + cdsitepackages [subdir] + +Debido a que la ruta exacta hacia el directorio site-packages dentro del +virtualenv depende de la versión de Python, ``cdsitepackages`` es provisto como +un atajo para ``cdvirtualenv lib/python${pyvers}/site-packages``. Un argumento +opcional también está permitido, para especificar un directorio heredado dentro +del directorio ``site-packages`` y así ingresar a este. + +:: + + $ mkvirtualenv env1 + New python executable in env1/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (env1)$ echo $VIRTUAL_ENV + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 + (env1)$ cdsitepackages PyMOTW/bisect/ + (env1)$ pwd + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1/lib/python2.6/site-packages/PyMOTW/bisect + +lssitepackages +-------------- + +``lssitepackages`` muestra el contenido del directorio ``site-packages`` +del entorno actualmente activado. + +Sintaxis:: + + lssitepackages + +:: + + $ mkvirtualenv env1 + New python executable in env1/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (env1)$ $ workon env1 + (env1)$ lssitepackages + distribute-0.6.10-py2.6.egg pip-0.6.3-py2.6.egg + easy-install.pth setuptools.pth + +======================= +Administración de rutas +======================= + +add2virtualenv +-------------- + +Agrega los directorios especificados al path de Python para el entorno virtual +actualmente activo. + +Sintaxis:: + + add2virtualenv directory1 directory2 ... + +A veces esto es conveniente compartir paquetes instalados que no están en el +directorio ``site-pacakges`` del sistema y no deben ser instalados en cada +entorno virtual. Una posible solución es crear enláces simbólicos (*symlinks*) +hacia el código dentro del directorio ``site-packages`` del entorno, pero +también es fácil agregar a la variable PYTHONPATH directorios extras que están +incluídos en los archivos ``.pth`` dentro de ``site-packages`` usando ``add2virtualenv``. + +1. Descarga (*check out*) el código de un proyecto grande, como Django. +2. Ejecuta: ``add2virtualenv path_to_source``. +3. Ejecuta: ``add2virtualenv``. +4. Un mensaje de uso y una lista de las rutas "extras" actuales es impreso. + +Los nombres de los directorios son agregados a un archivo llamado +``virtualenv_path_extensions.pth`` dentro del directorio site-packages de este +entorno. + +*Basado en una contribución de James Bennett y Jannis Leidel.* diff --git a/docs/es/source/index.rst b/docs/source/es/index.rst similarity index 100% rename from docs/es/source/index.rst rename to docs/source/es/index.rst diff --git a/docs/es/source/install.rst b/docs/source/es/install.rst similarity index 100% rename from docs/es/source/install.rst rename to docs/source/es/install.rst From d7248734a94444dca84db603ece815caa622a8e6 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 20 Apr 2010 14:06:52 -0300 Subject: [PATCH 222/947] translations in the index page --- docs/source/index.rst | 1 + docs/source/translations.rst | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 docs/source/translations.rst diff --git a/docs/source/index.rst b/docs/source/index.rst index c760cf1..6a28ad3 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -179,6 +179,7 @@ Details developers extensions history + translations .. _references: diff --git a/docs/source/translations.rst b/docs/source/translations.rst new file mode 100644 index 0000000..30921e3 --- /dev/null +++ b/docs/source/translations.rst @@ -0,0 +1,6 @@ +.. toctree:: + :maxdepth: 2 + + install + command_ref + hooks From c16a2e38bb890942f6dfb61f971058e1c87b7262 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 20 Apr 2010 14:07:01 -0300 Subject: [PATCH 223/947] hooks translated --HG-- rename : docs/source/hooks.rst => docs/source/es/hooks.rst --- docs/source/es/hooks.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 docs/source/es/hooks.rst diff --git a/docs/source/es/hooks.rst b/docs/source/es/hooks.rst new file mode 100644 index 0000000..307e488 --- /dev/null +++ b/docs/source/es/hooks.rst @@ -0,0 +1,13 @@ +============================= + Customiar Virtualenvwrapper +============================= + +virtualenvwrapper agrega varios ganchos que puedes usar para cambiar tus +configuraciones, el entorno del shell, u otras configuraciones al crear, +eliminar o cambiar entre entornos. Estos ganchos son expuestos en dos formas: + +.. toctree:: + :maxdepth: 1 + + scripts + plugins From 97a104f71e7faaa5c69f7f0b40a2a0869e3d37e2 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 20 Apr 2010 15:22:39 -0300 Subject: [PATCH 224/947] start to translate plugins.rst --HG-- rename : docs/source/plugins.rst => docs/source/es/plugins.rst --- docs/source/es/plugins.rst | 412 +++++++++++++++++++++++++++++++++++++ 1 file changed, 412 insertions(+) create mode 100644 docs/source/es/plugins.rst diff --git a/docs/source/es/plugins.rst b/docs/source/es/plugins.rst new file mode 100644 index 0000000..aec7d13 --- /dev/null +++ b/docs/source/es/plugins.rst @@ -0,0 +1,412 @@ +.. _plugins: + +========================== +Extender Virtualenvwrapper +========================== + +Una gran experiencia con soluciones caseras para customizar un entorno de +desarrollo ha demostrado cuán valioso puede ser tener la capacidad de +automatizar tareas comunes y elminar molestias persistentes. Carpinteros +construyen plantillas de guía, desarrolladores de software escriben scripts de +shell. virtualenvwrapper continúa la tradición de animar a un artesano a +modificar sus herramientas para trabajar de la manera que ellos quieran, en vez +de al revés. + +Usa los ganchos provistos para eliminar operaciones manuales repetitivas y hacer +más simple tu flujo de desarrollo. Por ejemplo, configura los ganchos +:ref:`plugins-pre_activate` y :ref:`plugins-post_activate` para provocar que un +IDE cargue un proyecto o recargue los archivos desde la última sesión de +edición, administra el logueo de horas, o inicia y detiene versiones de +desarrollo de un servidor de aplicaciones. Usa el gancho +:ref:`plugins-initialize` para agregar nuevos comandos y ganchos a +virtualenvwrapper. Los ganchos :ref:`plugins-pre_mkvirtualenv` y +:ref:`plugins-post_mkvirtualenv` te brindan la oportunidad de instalar +requerimientos básicos dentro de cada nuevo entorno de desarrollo, inicializar +el repositorio de control de versiones para el código, o por otro lado +configurar un nuevo proyecto. + +Existen dos maneras para adjuntar tu código para que virtualenvwrapper lo +ejecute: los usuarios finales pueden usar scrips the shell o otros programas +para la customización personal (ver :ref:`scripts`). Las extensiones también +pueden ser implementadas en Python usando *entry points* con Distribute_ , + +Defining an Extension +===================== + +.. note:: + + Virtualenvwrapper is delivered with a plugin for creating and + running the user customization scripts + (:ref:`extensions-user_scripts`). The examples below are taken from + the implementation of that plugin. + +Code Organization +----------------- + +The Python package for ``virtualenvwrapper`` is a *namespace package*. +That means multiple libraries can install code into the package, even +if they are not distributed together or installed into the same +directory. Extensions can (optionally) use the ``virtualenvwrapper`` +namespace by setting up their source tree like: + +* virtualenvwrapper/ + + * __init__.py + * user_scripts.py + +And placing the following code in ``__init__.py``:: + + """virtualenvwrapper module + """ + + __import__('pkg_resources').declare_namespace(__name__) + +.. note:: + + Extensions can be loaded from any package, so using the + ``virtualenvwrapper`` namespace is not required. + +Extension API +------------- + +After the package is established, the next step is to create a module +to hold the extension code. For example, +``virtualenvwrapper/user_scripts.py``. The module should contain the +actual extension entry points. Supporting code can be included, or +imported from elsewhere using standard Python code organization +techniques. + +The API is the same for every extension point. Each uses a Python +function that takes a single argument, a list of strings passed to the +hook loader on the command line. + +:: + + def function_name(args): + # args is a list of strings passed to the hook loader + +The contents of the argument list are defined for each extension point +below (see :ref:`plugins-extension-points`). + +Extension Invocation +-------------------- + +Direct Action +~~~~~~~~~~~~~ + +Plugins can attach to each hook in two different ways. The default is +to have a function run and do some work directly. For example, the +``initialize()`` function for the user scripts plugin creates default +user scripts when ``virtualenvwrapper.sh`` is loaded. + +:: + + def initialize(args): + for filename, comment in GLOBAL_HOOKS: + make_hook(os.path.join('$WORKON_HOME', filename), comment) + return + +.. _plugins-user-env: + +Modifying the User Environment +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +There are cases where the extension needs to update the user's +environment (e.g., changing the current working directory or setting +environment variables). Modifications to the user environment must be +made within the user's current shell, and cannot be run in a separate +process. To have code run in the user's shell process, extensions can +define hook functions to return the text of the shell statements to be +executed. These *source* hooks are run after the regular hooks with +the same name, and should not do any work of their own. + +The ``initialize_source()`` hook for the user scripts plugin looks for +a global initialize script and causes it to be run in the current +shell process. + +:: + + def initialize_source(args): + return """ + # + # Run user-provided scripts + # + [ -f "$WORKON_HOME/initialize" ] && source "$WORKON_HOME/initialize" + """ + +.. warning:: + + Because the extension is modifying the user's working shell, care + must be taken not to corrupt the environment by overwriting + existing variable values unexpectedly. Avoid creating temporary + variables where possible, and use unique names where variables + cannot be avoided. Prefixing variables with the extension name is + a good way to manage the namespace. For example, instead of + ``temp_file`` use ``user_scripts_temp_file``. Use ``unset`` to + release temporary variable names when they are no longer needed. + +.. warning:: + + virtualenvwrapper works under several shells with slightly + different syntax (bash, sh, zsh, ksh). Take this portability into + account when defining source hooks. Sticking to the simplest + possible syntax usually avoids problems, but there may be cases + where examining the ``SHELL`` environment variable to generate + different syntax for each case is the only way to achieve the + desired result. + +Registering Entry Points +------------------------ + +The functions defined in the plugin need to be registered as *entry +points* in order for virtualenvwrapper's hook loader to find them. +Distribute_ entry points are configured in the ``setup.py`` for your +package by mapping the entry point name to the function in the package +that implements it. + +This partial copy of virtualenvwrapper's ``setup.py`` illustrates how +the ``initialize()`` and ``initialize_source()`` entry points are +configured. + +:: + + # Bootstrap installation of Distribute + import distribute_setup + distribute_setup.use_setuptools() + + from setuptools import setup + + setup( + name = 'virtualenvwrapper', + version = '2.0', + + description = 'Enhancements to virtualenv', + + # ... details omitted ... + + namespace_packages = [ 'virtualenvwrapper' ], + + entry_points = { + 'virtualenvwrapper.initialize': [ + 'user_scripts = virtualenvwrapper.user_scripts:initialize', + ], + 'virtualenvwrapper.initialize_source': [ + 'user_scripts = virtualenvwrapper.user_scripts:initialize_source', + ], + + # ... details omitted ... + }, + ) + +The ``entry_points`` argument to ``setup()`` is a dictionary mapping +the entry point *group names* to lists of entry point specifiers. A +different group name is defined by virtualenvwrapper for each +extension point (see :ref:`plugins-extension-points`). + +The entry point specifiers are strings with the syntax ``name = +package.module:function``. By convention, the *name* of each entry +point is the plugin name, but that is not required (the names are not +used). + +.. seealso:: + + * `namespace packages `__ + * `Extensible Applications and Frameworks `__ + +The Hook Loader +--------------- + +Extensions are run through a command line application implemented in +``virtualenvwrapper.hook_loader``. Because ``virtualenvwrapper.sh`` +is the primary caller and users do not typically need to run the app +directly, no separate script is installed. Instead, to run the +application, use the ``-m`` option to the interpreter:: + + $ python -m virtualenvwrapper.hook_loader -h + Usage: virtualenvwrapper.hook_loader [options] [] + + Manage hooks for virtualenvwrapper + + Options: + -h, --help show this help message and exit + -s, --source Print the shell commands to be run in the current + shell + -l, --list Print a list of the plugins available for the given + hook + -v, --verbose Show more information on the console + -q, --quiet Show less information on the console + -n NAMES, --name=NAMES + Only run the hook from the named plugin + +To run the extensions for the initialize hook:: + + $ python -m virtualenvwrapper.hook_loader -v initialize + +To get the shell commands for the initialize hook:: + + $ python -m virtualenvwrapper.hook_loader --source initialize + +In practice, rather than invoking the hook loader directly it is more +convenient to use the shell function, ``virtualenvwrapper_run_hook`` +to run the hooks in both modes.:: + + $ virtualenvwrapper_run_hook initialize + +All of the arguments given to shell function are passed directly to +the hook loader. + +Logging +------- + +The hook loader configures logging so that messages are written to +``$WORKON_HOME/hook.log``. Messages also may be written to stderr, +depending on the verbosity flag. The default is for messages at *info* +or higher levels to be written to stderr, and *debug* or higher to go to +the log file. Using logging in this way provides a convenient +mechanism for users to control the verbosity of extensions. + +To use logging from within your extension, simply instantiate a logger +and call its ``info()``, ``debug()`` and other methods with the +messages. + +:: + + import logging + log = logging.getLogger(__name__) + + def pre_mkvirtualenv(args): + log.debug('pre_mkvirtualenv %s', str(args)) + # ... + +.. seealso:: + + * `Standard library documentation for logging `__ + * `PyMOTW for logging `__ + +.. _plugins-extension-points: + +Extension Points +================ + +The extension point names for native plugins follow a naming +convention with several parts: +``virtualenvwrapper.(pre|post)_[_source]``. The ** is +the action taken by the user or virtualenvwrapper that triggers the +extension. ``(pre|post)`` indicates whether to call the extension +before or after the event. The suffix ``_source`` is added for +extensions that return shell code instead of taking action directly +(see :ref:`plugins-user-env`). + +.. _plugins-initialize: + +initialize +---------- + +The ``virtualenvwrapper.initialize`` hooks are run each time +``virtualenvwrapper.sh`` is loaded into the user's environment. The +initialize hook can be used to install templates for configuration +files or otherwise prepare the system for proper plugin operation. + +.. _plugins-pre_mkvirtualenv: + +pre_mkvirtualenv +---------------- + +The ``virtualenvwrapper.pre_mkvirtualenv`` hooks are run after the +virtual environment is created, but before the new environment is +activated. The current working directory for when the hook is run is +``$WORKON_HOME`` and the name of the new environment is passed as an +argument. + +.. _plugins-post_mkvirtualenv: + +post_mkvirtualenv +----------------- + +The ``virtualenvwrapper.post_mkvirtualenv`` hooks are run after a new +virtual environment is created and activated. ``$VIRTUAL_ENV`` is set +to point to the new environment. + +.. _plugins-pre_activate: + +pre_activate +------------ + +The ``virtualenvwrapper.pre_activate`` hooks are run just before an +environment is enabled. The environment name is passed as the first +argument. + +.. _plugins-post_activate: + +post_activate +------------- + +The ``virtualenvwrapper.post_activate`` hooks are run just after an +environment is enabled. ``$VIRTUAL_ENV`` is set to point to the +current environment. + +.. _plugins-pre_deactivate: + +pre_deactivate +-------------- + +The ``virtualenvwrapper.pre_deactivate`` hooks are run just before an +environment is disabled. ``$VIRTUAL_ENV`` is set to point to the +current environment. + +.. _plugins-post_deactivate: + +post_deactivate +--------------- + +The ``virtualenvwrapper.post_deactivate`` hooks are run just after an +environment is disabled. The name of the environment just deactivated +is passed as the first argument. + +.. _plugins-pre_rmvirtualenv: + +pre_rmvirtualenv +---------------- + +The ``virtualenvwrapper.pre_rmvirtualenv`` hooks are run just before +an environment is deleted. The name of the environment being deleted +is passed as the first argument. + +.. _plugins-post_rmvirtualenv: + +post_rmvirtualenv +----------------- + +The ``virtualenvwrapper.post_rmvirtualenv`` hooks are run just after +an environment is deleted. The name of the environment being deleted +is passed as the first argument. + +Adding New Extension Points +=========================== + +Plugins that define new operations can also define new extension +points. No setup needs to be done to allow the hook loader to find +the extensions; documenting the names and adding calls to +``virtualenvwrapper_run_hook`` is sufficient to cause them to be +invoked. + +The hook loader assumes all extension point names start with +``virtualenvwrapper.`` and new plugins will want to use their own +namespace qualifier to append to that. For example, the project_ +extension defines new events around creating project directories (pre +and post). These are called +``virtualenvwrapper.project.pre_mkproject`` and +``virtualenvwrapper.project.post_mkproject``. These are invoked +with:: + + virtualenvwrapper_run_hook project.pre_mkproject $project_name + +and:: + + virtualenvwrapper_run_hook project.post_mkproject + +respectively. + +.. _Distribute: http://packages.python.org/distribute/ + +.. _project: http://www.doughellmann.com/projects/virtualenvwrapper.project/ From cd15ef8739b040424119813d4cc174e68d86a296 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 20 Apr 2010 15:48:26 -0300 Subject: [PATCH 225/947] starting with "Defining an Extension" --- docs/source/es/plugins.rst | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/docs/source/es/plugins.rst b/docs/source/es/plugins.rst index aec7d13..599855d 100644 --- a/docs/source/es/plugins.rst +++ b/docs/source/es/plugins.rst @@ -30,31 +30,30 @@ ejecute: los usuarios finales pueden usar scrips the shell o otros programas para la customización personal (ver :ref:`scripts`). Las extensiones también pueden ser implementadas en Python usando *entry points* con Distribute_ , -Defining an Extension +Definir una extensión ===================== .. note:: - Virtualenvwrapper is delivered with a plugin for creating and - running the user customization scripts - (:ref:`extensions-user_scripts`). The examples below are taken from - the implementation of that plugin. + Virtualenvwrapper es distribuido con un plugin para la creación y ejecución de + los scripts de customización de los usuarios (:ref:`extensions-user_scripts`). + Los ejemplos siguientes han sido tomados de la implementación de ese plugin. -Code Organization ------------------ +Organización del código +----------------------- -The Python package for ``virtualenvwrapper`` is a *namespace package*. -That means multiple libraries can install code into the package, even -if they are not distributed together or installed into the same -directory. Extensions can (optionally) use the ``virtualenvwrapper`` -namespace by setting up their source tree like: +El paquete Python para ``virtualenvwrapper`` es un *namespace package*. +Eso signific que multiples librerías pueden instalar código dentro del paquete, +incluso si ellas no son ditribuidas juntas o instaladas dentro del mismo +directorio. Las extensiones pueden (opcionalmente) usar el namespace de +``virtualenvwrapper`` configurando su estructura de directorios así: * virtualenvwrapper/ * __init__.py * user_scripts.py -And placing the following code in ``__init__.py``:: +Y agregando el siguiente código dentro de ``__init__.py``:: """virtualenvwrapper module """ @@ -63,8 +62,8 @@ And placing the following code in ``__init__.py``:: .. note:: - Extensions can be loaded from any package, so using the - ``virtualenvwrapper`` namespace is not required. + Las extensiones pueden ser cargadas desde cualquier paquete, así que usar el + espacio de nombres de ``virtualenvwrapper`` no es requerido. Extension API ------------- From a7bb6da609ba3dd3683980e38a2467c5182d0420 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 20 Apr 2010 17:31:48 -0400 Subject: [PATCH 226/947] Fix typo found by humitos. --- docs/source/command_ref.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 03826d1..13958f7 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -208,7 +208,7 @@ Syntax:: Quickly Navigating to a virtualenv ================================== -There are two functions to provide shortcuts to navigate into the the +There are two functions to provide shortcuts to navigate into the currently-active virtualenv. cdvirtualenv From d3c7e1fdc5b51ee115e4042486cb140a4fd438ee Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 20 Apr 2010 20:59:46 -0300 Subject: [PATCH 227/947] continue plugins.rst translation --- docs/source/es/plugins.rst | 72 ++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/docs/source/es/plugins.rst b/docs/source/es/plugins.rst index 599855d..50f499d 100644 --- a/docs/source/es/plugins.rst +++ b/docs/source/es/plugins.rst @@ -68,35 +68,38 @@ Y agregando el siguiente código dentro de ``__init__.py``:: Extension API ------------- -After the package is established, the next step is to create a module -to hold the extension code. For example, -``virtualenvwrapper/user_scripts.py``. The module should contain the -actual extension entry points. Supporting code can be included, or -imported from elsewhere using standard Python code organization -techniques. +Después de que el paquete está establecido, el siguiente paso es crear un módulo +para alojar el código de la extensión. Por ejemplo, +``virtualenvwrapper/user_scripts.py``. El módulo debe contener la extensión +actual a los *entry points*. Soporte de código puede ser incluído, o importado +desde algún lugar usando la técnica de organización de código estándar de +Python. -The API is the same for every extension point. Each uses a Python -function that takes a single argument, a list of strings passed to the -hook loader on the command line. +FIXME: I don't like the last paragraph + +La API es la misma para todos los puntos de extensión. Cada uno usa una función +de Python que toma un sólo argumento, una lista de string pasada al script que +carga los ganchos en la línea de comandos. :: def function_name(args): # args is a list of strings passed to the hook loader -The contents of the argument list are defined for each extension point -below (see :ref:`plugins-extension-points`). +El contenido de la lista de argumentos está definida para cada punto de +extensión a continuación (ver :ref:`plugins-extension-points`). -Extension Invocation --------------------- +Invocación de la extensión +-------------------------- -Direct Action -~~~~~~~~~~~~~ +Acción directa +~~~~~~~~~~~~~~ -Plugins can attach to each hook in two different ways. The default is -to have a function run and do some work directly. For example, the -``initialize()`` function for the user scripts plugin creates default -user scripts when ``virtualenvwrapper.sh`` is loaded. +Los plugins pueden ser colgados a cada uno de los ganchos de dos formas +diferentes. La estándar es tener una función y hacer algún trabajo diréctamente. +Por ejemplo, la función ``initialize()`` para el pluging de los scripts de +usuarios crea scripts de usuarios por default cuando ``virtualenvwrapper.sh`` es +cargada. :: @@ -107,21 +110,22 @@ user scripts when ``virtualenvwrapper.sh`` is loaded. .. _plugins-user-env: -Modifying the User Environment -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -There are cases where the extension needs to update the user's -environment (e.g., changing the current working directory or setting -environment variables). Modifications to the user environment must be -made within the user's current shell, and cannot be run in a separate -process. To have code run in the user's shell process, extensions can -define hook functions to return the text of the shell statements to be -executed. These *source* hooks are run after the regular hooks with -the same name, and should not do any work of their own. - -The ``initialize_source()`` hook for the user scripts plugin looks for -a global initialize script and causes it to be run in the current -shell process. +Modificar el entorno de usuario +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Hay casos en dónde la extensión necesita actualizar el entorno del usuario (por +ejemplo, cambiar el directorio de trabajo actual o configurar variables de +entorno). Las modificaciones al entorno del usuario deben ser hechas dentro del +shell actual del usuario, y no pueden ser ejecutadas en un proceso separado. +Para tener código ejecutado en un proceso shell del usuario, las extensiones +pueden definir funciones gancho y retornar el texto de los comandos de shell +a ser ejecutados. Estos ganchos *fuente* son ejecutados después de los ganchos +comunes con el mismo nombre, y no deben hacer ningún trabajo por ellos mismos. + + +El gancho ``initialize_source()`` para el plugin de scripts de usuarios busca +un script ``initializa`` global y causa que este sea ejecutado en el proceso de +shell actual. :: From ca7ac92121877be5294ea2aa2dab95808e8ad6f5 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 20 Apr 2010 21:06:29 -0300 Subject: [PATCH 228/947] typo fixed --- docs/source/es/hooks.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/es/hooks.rst b/docs/source/es/hooks.rst index 307e488..6deea4c 100644 --- a/docs/source/es/hooks.rst +++ b/docs/source/es/hooks.rst @@ -1,6 +1,6 @@ -============================= - Customiar Virtualenvwrapper -============================= +============================== + Customizar Virtualenvwrapper +============================== virtualenvwrapper agrega varios ganchos que puedes usar para cambiar tus configuraciones, el entorno del shell, u otras configuraciones al crear, From 01f2278657e5924e56d4966dd46fae0fab13766d Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 20 Apr 2010 21:20:13 -0300 Subject: [PATCH 229/947] developers.rst translated --HG-- rename : docs/source/developers.rst => docs/source/es/developers.rst --- docs/source/es/developers.rst | 69 +++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 docs/source/es/developers.rst diff --git a/docs/source/es/developers.rst b/docs/source/es/developers.rst new file mode 100644 index 0000000..40a53fc --- /dev/null +++ b/docs/source/es/developers.rst @@ -0,0 +1,69 @@ +#################### +Para desarrolladores +#################### + +Si quieres contribuir con virtualenvwrapper directamente, estas instrucciones +deberían ayudarte a empezar. Parches, reporte de bugs, y propuestas de +características son todas bienvenidas a través del `sitio de BitBucket +`_. Contribuciones en la +forma de parches o solicitud de pull son fáciles de integrar y recibirán +prioridad en la atención. + +.. note:: + + Antes de contribuir con nuevas características al *core* de virtualenvwrapper, + por favor considera, en vez, si no debe ser implementada como una extensión. + +Construir la documentación +========================== + +La documentación para virtualenvwrapper está escrita en reStructuredText y +convertida a HTML usando Sphinx. La propia construcción es impulsada por make. +Necesitas los siguientes paquetes para construir la documentación: + +- Sphinx +- docutils + +Una vez que todas las herramientas están instaladas dentro de un virtualen +usando pip, ejecuta ``make html`` para generar la versión de HTML de la +documentación:: + + $ make html + rm -rf virtualenvwrapper/docs + (cd docs && make html SPHINXOPTS="-c sphinx/pkg") + sphinx-build -b html -d build/doctrees -c sphinx/pkg source build/html + Running Sphinx v0.6.4 + loading pickled environment... done + building [html]: targets for 2 source files that are out of date + updating environment: 0 added, 2 changed, 0 removed + reading sources... [ 50%] command_ref + reading sources... [100%] developers + + looking for now-outdated files... none found + pickling environment... done + checking consistency... done + preparing documents... done + writing output... [ 33%] command_ref + writing output... [ 66%] developers + writing output... [100%] index + + writing additional files... search + copying static files... WARNING: static directory '/Users/dhellmann/Devel/virtualenvwrapper/plugins/docs/sphinx/pkg/static' does not exist + done + dumping search index... done + dumping object inventory... done + build succeeded, 1 warning. + + Build finished. The HTML pages are in build/html. + cp -r docs/build/html virtualenvwrapper/docs + +La versión de publicación de la documentación termina dentro de +``./virtualenvwrapper/docs`` + +Ejecutar tests +============== + +La suite de test para virtualenvwrapper usa `shunit2 +`_. Para ejecutar los tests en bash, sh, y zsh, +usa ``make test``. + From 66d0bde8808d4971f91e1ba8ce3d5bd0385c5835 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 20 Apr 2010 21:05:04 -0400 Subject: [PATCH 230/947] put the base template in the repository --- .hgignore | 1 - Makefile | 7 +- docs/sphinx/web/templates/base.html | 155 ++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+), 6 deletions(-) create mode 100644 docs/sphinx/web/templates/base.html diff --git a/.hgignore b/.hgignore index 1b0d117..9a97f53 100644 --- a/.hgignore +++ b/.hgignore @@ -7,7 +7,6 @@ distribute*.egg distribute*.tar.gz docs/build docs/website -sphinx/web/templates/base.html tests/catch_output tests/testpackage/build tests/testpackage/dist diff --git a/Makefile b/Makefile index 9c8899e..ceb4654 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,8 @@ html: # Website copy of documentation .PHONY: website -website: docs/sphinx/web/templates/base.html +website: + [ ~/Devel/doughellmann/doughellmann/templates/base.html -nt docs/sphinx/web/templates/base.html ] && (echo "Updating base.html" ; cp ~/Devel/doughellmann/doughellmann/templates/base.html docs/sphinx/web/templates/base.html) || exit 0 rm -rf docs/website (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/web" BUILDDIR="website") @@ -48,10 +49,6 @@ installwebsite: website register: python setup.py register -# Copy the base template from my website build directory -docs/sphinx/web/templates/base.html: ~/Devel/doughellmann/doughellmann/templates/base.html - cp $< $@ - # Testing TEST_SCRIPTS=$(wildcard tests/test*.sh) diff --git a/docs/sphinx/web/templates/base.html b/docs/sphinx/web/templates/base.html new file mode 100644 index 0000000..3f590e9 --- /dev/null +++ b/docs/sphinx/web/templates/base.html @@ -0,0 +1,155 @@ + + + + + {% block title %}Doug Hellmann{% endblock %} +{% block head_before_css %} +{% endblock %} + +{% block head_after_css %} +{% endblock %} +{% block head %} +{% endblock %} + + + + +
+ + + + + + + +
+{% block content %} +{% block relbar1 %}{% endblock %} + +

Welcome to Leaves.

+

Welcome to Leaves, a static, 3 column layout made with your usual CSS and XHTML. It is able to correctly accommodate any font size increases or shrinkages (Is that a word?). It seems to work fine in Firefox, Opera, Internet Explorer and Safari. It's more minimal than other designs, because I think images (drop shadows, giant header images) are being obsessively over used these days. I think it detracts from the content and shoves way too much information to a viewer all at the same time, so here you go: Leaves, a minimalist design. Feel free to massacre or change the design to your liking. Well, I guess it's time for some more Latin. If you want me to create a custom design for you, feel free to drop me a line anytime at web@smallpark.org

+ +{% block relbar2 %}{% endblock %} +{% endblock %} + +{% block addthis %} +
Bookmark and Share
+{% endblock %} + +{% block comments %} + + +{% endblock %} +
+ + + + + +
+ + + + + + + From b523e113b11e89ec12091bf5501cdf86680ba09f Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 20 Apr 2010 22:09:32 -0300 Subject: [PATCH 231/947] Makefile modified to build "es" documentation --- Makefile | 4 +++- docs/Makefile | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9c8899e..cd8a10b 100644 --- a/Makefile +++ b/Makefile @@ -33,12 +33,14 @@ sdist: html .PHONY: html html: (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/pkg") + (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/pkg" LANGUAGE="es") # Website copy of documentation .PHONY: website website: docs/sphinx/web/templates/base.html rm -rf docs/website (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/web" BUILDDIR="website") + (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/web" BUILDDIR="website" LANGUAGE="es") installwebsite: website (cd docs/website/html && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper/) @@ -93,4 +95,4 @@ test-quick: SUPPORTED_PYTHON_VERSIONS=$(PRIMARY_PYTHON_VERSION) $(MAKE) test-bash test-install: - bash ./tests/manual_test_install.sh `pwd`/dist "$(VERSION)" \ No newline at end of file + bash ./tests/manual_test_install.sh `pwd`/dist "$(VERSION)" diff --git a/docs/Makefile b/docs/Makefile index af893ed..608bb54 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -10,7 +10,9 @@ BUILDDIR = build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source +# If doc language is English you don't need to set this variable +LANGUAGE = +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source/$(LANGUAGE) .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest From deee5dbc4d2669dcea7b6ac38d69f695c8faefb9 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 21 Apr 2010 13:58:58 -0300 Subject: [PATCH 232/947] reorder the documents files in docs/LANGUAGE folders and modify the rules in the Makefile to build the documentation --HG-- rename : docs/source/command_ref.rst => docs/en/command_ref.rst rename : docs/source/developers.rst => docs/en/developers.rst rename : docs/source/extensions.rst => docs/en/extensions.rst rename : docs/source/history.rst => docs/en/history.rst rename : docs/source/hooks.rst => docs/en/hooks.rst rename : docs/source/index.rst => docs/en/index.rst rename : docs/source/install.rst => docs/en/install.rst rename : docs/source/plugins.rst => docs/en/plugins.rst rename : docs/source/scripts.rst => docs/en/scripts.rst rename : docs/source/tips.rst => docs/en/tips.rst rename : docs/source/translations.rst => docs/en/translations.rst rename : docs/source/es/command_ref.rst => docs/es/command_ref.rst rename : docs/source/es/developers.rst => docs/es/developers.rst rename : docs/source/es/hooks.rst => docs/es/hooks.rst rename : docs/source/es/index.rst => docs/es/index.rst rename : docs/source/es/install.rst => docs/es/install.rst rename : docs/source/es/plugins.rst => docs/es/plugins.rst --- docs/Makefile | 9 +++++---- docs/{source => en}/command_ref.rst | 0 docs/{source => en}/developers.rst | 0 docs/{source => en}/extensions.rst | 0 docs/{source => en}/history.rst | 0 docs/{source => en}/hooks.rst | 0 docs/{source => en}/index.rst | 0 docs/{source => en}/install.rst | 0 docs/{source => en}/plugins.rst | 0 docs/{source => en}/scripts.rst | 0 docs/{source => en}/tips.rst | 0 docs/{source => en}/translations.rst | 0 docs/{source => }/es/command_ref.rst | 0 docs/{source => }/es/developers.rst | 0 docs/{source => }/es/hooks.rst | 0 docs/{source => }/es/index.rst | 0 docs/{source => }/es/install.rst | 0 docs/{source => }/es/plugins.rst | 0 18 files changed, 5 insertions(+), 4 deletions(-) rename docs/{source => en}/command_ref.rst (100%) rename docs/{source => en}/developers.rst (100%) rename docs/{source => en}/extensions.rst (100%) rename docs/{source => en}/history.rst (100%) rename docs/{source => en}/hooks.rst (100%) rename docs/{source => en}/index.rst (100%) rename docs/{source => en}/install.rst (100%) rename docs/{source => en}/plugins.rst (100%) rename docs/{source => en}/scripts.rst (100%) rename docs/{source => en}/tips.rst (100%) rename docs/{source => en}/translations.rst (100%) rename docs/{source => }/es/command_ref.rst (100%) rename docs/{source => }/es/developers.rst (100%) rename docs/{source => }/es/hooks.rst (100%) rename docs/{source => }/es/index.rst (100%) rename docs/{source => }/es/install.rst (100%) rename docs/{source => }/es/plugins.rst (100%) diff --git a/docs/Makefile b/docs/Makefile index 608bb54..1de19bd 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,18 +1,19 @@ # Makefile for Sphinx documentation # +# If doc language is English you don't need to set this variable +LANGUAGE = en + # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = -BUILDDIR = build +BUILDDIR = build/$(LANGUAGE) # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter -# If doc language is English you don't need to set this variable -LANGUAGE = -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source/$(LANGUAGE) +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(LANGUAGE) .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest diff --git a/docs/source/command_ref.rst b/docs/en/command_ref.rst similarity index 100% rename from docs/source/command_ref.rst rename to docs/en/command_ref.rst diff --git a/docs/source/developers.rst b/docs/en/developers.rst similarity index 100% rename from docs/source/developers.rst rename to docs/en/developers.rst diff --git a/docs/source/extensions.rst b/docs/en/extensions.rst similarity index 100% rename from docs/source/extensions.rst rename to docs/en/extensions.rst diff --git a/docs/source/history.rst b/docs/en/history.rst similarity index 100% rename from docs/source/history.rst rename to docs/en/history.rst diff --git a/docs/source/hooks.rst b/docs/en/hooks.rst similarity index 100% rename from docs/source/hooks.rst rename to docs/en/hooks.rst diff --git a/docs/source/index.rst b/docs/en/index.rst similarity index 100% rename from docs/source/index.rst rename to docs/en/index.rst diff --git a/docs/source/install.rst b/docs/en/install.rst similarity index 100% rename from docs/source/install.rst rename to docs/en/install.rst diff --git a/docs/source/plugins.rst b/docs/en/plugins.rst similarity index 100% rename from docs/source/plugins.rst rename to docs/en/plugins.rst diff --git a/docs/source/scripts.rst b/docs/en/scripts.rst similarity index 100% rename from docs/source/scripts.rst rename to docs/en/scripts.rst diff --git a/docs/source/tips.rst b/docs/en/tips.rst similarity index 100% rename from docs/source/tips.rst rename to docs/en/tips.rst diff --git a/docs/source/translations.rst b/docs/en/translations.rst similarity index 100% rename from docs/source/translations.rst rename to docs/en/translations.rst diff --git a/docs/source/es/command_ref.rst b/docs/es/command_ref.rst similarity index 100% rename from docs/source/es/command_ref.rst rename to docs/es/command_ref.rst diff --git a/docs/source/es/developers.rst b/docs/es/developers.rst similarity index 100% rename from docs/source/es/developers.rst rename to docs/es/developers.rst diff --git a/docs/source/es/hooks.rst b/docs/es/hooks.rst similarity index 100% rename from docs/source/es/hooks.rst rename to docs/es/hooks.rst diff --git a/docs/source/es/index.rst b/docs/es/index.rst similarity index 100% rename from docs/source/es/index.rst rename to docs/es/index.rst diff --git a/docs/source/es/install.rst b/docs/es/install.rst similarity index 100% rename from docs/source/es/install.rst rename to docs/es/install.rst diff --git a/docs/source/es/plugins.rst b/docs/es/plugins.rst similarity index 100% rename from docs/source/es/plugins.rst rename to docs/es/plugins.rst From 619d0503ecc495a34b3953a30b24f72038ce240d Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 21 Apr 2010 14:05:14 -0300 Subject: [PATCH 233/947] fix the Makefile to generate the website documentation for 'en' and 'es' languages --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index d4d7fb8..4500a0c 100644 --- a/Makefile +++ b/Makefile @@ -40,11 +40,12 @@ html: website: [ ~/Devel/doughellmann/doughellmann/templates/base.html -nt docs/sphinx/web/templates/base.html ] && (echo "Updating base.html" ; cp ~/Devel/doughellmann/doughellmann/templates/base.html docs/sphinx/web/templates/base.html) || exit 0 rm -rf docs/website - (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/web" BUILDDIR="website") - (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/web" BUILDDIR="website" LANGUAGE="es") + (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/web" BUILDDIR="website/en") + (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/web" BUILDDIR="website/es" LANGUAGE="es") installwebsite: website - (cd docs/website/html && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper/) + (cd docs/website/en/html && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper/) + (cd docs/website/es/html && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper/es/) # Register the new version on pypi .PHONY: register From a6828c0987bfc2d31ab1eb21119583bbc992adee Mon Sep 17 00:00:00 2001 From: humitos Date: Wed, 21 Apr 2010 14:27:03 -0300 Subject: [PATCH 234/947] typo fixed on english documentation --- docs/en/tips.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/tips.rst b/docs/en/tips.rst index 6113987..2398548 100644 --- a/docs/en/tips.rst +++ b/docs/en/tips.rst @@ -84,7 +84,7 @@ Automatically Run workon When Entering a Directory `Justin Lily posted `__ -about about some code he added to his shell environment to look at the +about some code he added to his shell environment to look at the directory each time he runs ``cd``. If it finds a ``.venv`` file, it activates the environment named within. On leaving that directory, the current virtualenv is automatically deactivated. From 9a715f8cede5f4c6999046b5debaafaedfb79beb Mon Sep 17 00:00:00 2001 From: humitos Date: Wed, 21 Apr 2010 14:28:54 -0300 Subject: [PATCH 235/947] rst markup fixed --- docs/en/tips.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/tips.rst b/docs/en/tips.rst index 2398548..4b77f57 100644 --- a/docs/en/tips.rst +++ b/docs/en/tips.rst @@ -98,7 +98,7 @@ Installing Common Tools Automatically in New Environments Via `rizumu `__: -I have this postmkvirtualenv to install the get a basic setup. +I have this ``postmkvirtualenv`` to install the get a basic setup. :: From 4dfe8b33e188d946e90babf660603e56eebdd30b Mon Sep 17 00:00:00 2001 From: humitos Date: Wed, 21 Apr 2010 17:16:44 -0300 Subject: [PATCH 236/947] tips.rst translated --HG-- rename : docs/en/tips.rst => docs/es/tips.rst --- docs/es/tips.rst | 156 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 docs/es/tips.rst diff --git a/docs/es/tips.rst b/docs/es/tips.rst new file mode 100644 index 0000000..9a5d89f --- /dev/null +++ b/docs/es/tips.rst @@ -0,0 +1,156 @@ +.. _tips-and-tricks: + +=================== + Consejos y Trucos +=================== + +Esta es una lista de contribuciones de usuarios para hacer virtualenv y +virtualenvwrapper incluso más útil. Si tienes tips para compartir, envíame un +email o deja un comentario en `esta entrada de mi blog +`__ +y lo agregaré aquí. + +Prompt zsh +========== + +De `Nat `_: + +Usando zsh, agregué algunas líneas a ``$WORKON_HOME/post(de)activate`` para +mostrar el virtualenv activo en el lado derecho de la pantalla en vez de a la +izquierda. + +En ``postactivate``:: + + PS1="$_OLD_VIRTUAL_PS1" + _OLD_RPROMPT="$RPROMPT" + RPROMPT="%{${fg_bold[white]}%}(env: %{${fg[green]}%}`basename \"$VIRTUAL_ENV\"`%{${fg_bold[white]}%})%{${reset_color}%} $RPROMPT" + +Agrega en ``postdeactivate``:: + + RPROMPT="$_OLD_RPROMPT" + +Ajusta los colores de acuerdo a tu gusto personal o a tu entorno. + +Actualizar las entradas de ``$PATH`` cacheadas +============================================== + +De `Nat `_: + +También agregué el comando 'rehas' a ``$WORKON_HOME/postactivate`` y +``$WORKON_HOME/postdeactivate`` porque estaba teniendo algunos problemas +con zsh ya que no actualizaba los paths inmediatamente. + +Atar el soporte para virtualenv de pip +====================================== + +Vía http://becomingguru.com/: + +Agrega esto al script de login de tu shell para indicarle a pip que use el mismo +directorio para virtualenv que para virtualenwrapper:: + + export PIP_VIRTUALENV_BASE=$WORKON_HOME + +y Vía Nat: + +además de lo que dijo becomingguru, esta línea es clave:: + + export PIP_RESPECT_VIRTUALENV=true + +Eso hace que pip detecte un virtualenv activo e instale dentro de este, sin +pasar el parámetro -E. + +Crear los directorio para trabajar en el proyecto +================================================= + +Vía `James `_: + +En el script ``postmkvirtualenv`` tengo lo siguiente para crear un directorio +basado en el nombre del proyecto, agregar ese directorio la path de python y +luego ingresar a este:: + + proj_name=$(echo $VIRTUAL_ENV|awk -F'/' '{print $NF}') + mkdir $HOME/projects/$proj_name + add2virtualenv $HOME/projects/$proj_name + cd $HOME/projects/$proj_name + + +En el script ``postactivate`` tengo configurado para que automáticamente ingrese +a este directorio cuando uso el comando workon:: + + proj_name=$(echo $VIRTUAL_ENV|awk -F'/' '{print $NF}') + cd ~/projects/$proj_name + +Ejecutar automáticamente workon cuando se ingresa a un directorio +================================================================= + +`Justin Lily escribió un post +`__ +sobre algún código que agrego a su entorno de shell para buscar en el directorio +cada vez que se ejecuta ``cd``. Si este encuentra un archivo llamado ``.venv``, +activa el entorno nombrado dentro. Una vez que se deja el directorio, el +virtualenv actual es automáticamente desactivado. + +`Harry Marr `__ +escribió una función similar que funciona con `repositorios git +`__. + +Instalar herramientas comunes automáticmante en nuevos entornos +=============================================================== + +Vía `rizumu `__: + +Tengo esto en postmkvirtualenv para instalar una configuración básica. + +:: + + $ cat postmkvirtualenv + #!/usr/bin/env bash + curl -O http://python-distribute.org/distribute_setup.p... />python distribute_setup.py + rm distribute_setup.py + easy_install pip==dev + pip install Mercurial + +Además, tengo un archivo de requerimiento de pip para instalar mis herramientas +de desarrollo. + +:: + + $ cat developer_requirements.txt + ipdb + ipython + pastescript + nose + http://douglatornell.ca/software/python/Nosy-1.0.tar.gz + coverage + sphinx + grin + pyflakes + pep8 + +Entonces, cada proyecto tiene su propio archivo de requerimientos para cosas +como PIL, psycopg2, django-apps, numpy, etc. + +Cambiar el comportamiento por default de ``cd`` +=============================================== + +Vía `mae `__: + +Esto se supone que es ejecutado después de workon, es como un gancho +``postactivate``. Basicamente sobreescribe ``cd`` para saber sobre VENV +entonces en vez de hacer ``cd`` para ir a ``~`` irá al root del venv, creo que +es muy práctico y no puedo vivir más sin esto. Si le pasas un path +apropiado entonces hará lo correcto. + +:: + + cd () { + if (( $# == 0 )) + then + builtin cd $VIRTUAL_ENV + else + builtin cd "$@" + fi + } + + cd + From 41a42cfaeebd9cd5884232aae584a4cda8775c18 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 21 Apr 2010 17:33:53 -0300 Subject: [PATCH 237/947] extensions.rst translated --HG-- rename : docs/en/extensions.rst => docs/es/extensions.rst --- docs/es/extensions.rst | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 docs/es/extensions.rst diff --git a/docs/es/extensions.rst b/docs/es/extensions.rst new file mode 100644 index 0000000..3646149 --- /dev/null +++ b/docs/es/extensions.rst @@ -0,0 +1,45 @@ +======================== + Extensiones existentes +======================== + +Debajo se listan algunas de las extensiones disponibles para usar con +virtualenvwrapper. + +.. _extensions-user_scripts: + +project +======= + +La extensión project_ agrega la gestión del desarrollo de directorios con +plantillas para virtualenvwrapper. + +bitbucket +--------- + +La plantilla de proyecto bitbucket_ crea un directorio de trabajo y +automáticamente clona el repositorio desde BitBucket. Requiere project_ + +.. _project: http://www.doughellmann.com/projects/virtualenvwrapper.project/ + +.. _bitbucket: http://www.doughellmann.com/projects/virtualenvwrapper.bitbucket/ + +emacs-desktop +============= + +Emacs desktop-mode_ te permite guardar el estado de emacs (buffers abiertos, +posiciones de buffers, etc.) entre sesiones. También puede ser usado como un +archivo de proyecto similar a otros IDEs. El plugin emacs-desktop_ agrega +un disparador para guardar el archivo de proyect actual y cargar uno nuevo +cuando se active un nuevo entorno usando ``workon``. + +.. _desktop-mode: http://www.emacswiki.org/emacs/DeskTop + +.. _emacs-desktop: http://www.doughellmann.com/projects/virtualenvwrapper-emacs-desktop/ + +user_scripts +============ + +La extensión ``user_scripts`` es distribuida con virtualenvwrapper y está +habilitada por default. Implmenta la característica de script de customización +de usuarios descrita en :ref:`scripts`. + From 8c57e7bd6c122594f7ac16e3c778391be36259d5 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 21 Apr 2010 17:35:39 -0300 Subject: [PATCH 238/947] I don't think that we need to translate the ChangeLog --HG-- rename : docs/en/history.rst => docs/es/history.rst --- docs/es/history.rst | 184 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 docs/es/history.rst diff --git a/docs/es/history.rst b/docs/es/history.rst new file mode 100644 index 0000000..0636f95 --- /dev/null +++ b/docs/es/history.rst @@ -0,0 +1,184 @@ +=============== +Release History +=============== + +2.1 + + - Add support for ksh. Thanks to Doug Latornell for doing the + research on what needed to be changed. + - Test import of virtualenvwrapper.hook_loader on startup and report + the error in a way that should help the user figure out how to fix + it (issue #33). + - Update :ref:`command-mkvirtualenv` documentation to include the + fact that a new environment is activated immediately after it is + created (issue #30). + - Added hooks around :ref:`command-cpvirtualenv`. + - Made deactivation more robust, especially under ksh. + - Use Python's ``tempfile`` module for creating temporary filenames + safely and portably. + - Fix a problem with ``virtualenvwrapper_show_workon_options`` that + caused it to show ``*`` as the name of a virtualenv when no + environments had yet been created. + - Change the hook loader so it can be told to run only a set of + named hooks. + - Add support for listing the available hooks, to be used in help + output of commands like virtualenvwrapper.project's mkproject. + - Fix mkvirtualenv -h option behavior. + - Change logging so the $WORKON_HOME/hook.log file rotates after + 10KiB. + +2.0.2 + + - Fixed issue #32, making virtualenvwrapper.user_scripts compatible + with Python 2.5 again. + +2.0.1 + + - Fixed issue #29, to use a default value for ``TMPDIR`` if it is + not set in the user's shell environment. + +2.0 + + - Rewrote hook management using Distribute_ entry points to make it + easier to share extensions. + +.. _Distribute: http://packages.python.org/distribute/ + +1.27 + + - Added cpvirtualenv command [Thomas Desvenain] + +1.26 + + - Fix a problem with error messages showing up during init for users + with the wrappers installed site-wide but who are not actually + using them. See issue #26. + - Split up the tests into multiple files. + - Run all tests with all supported shells. + +1.25 + + - Merged in changes to cdsitepackages from William McVey. It now + takes an argument and supports tab-completion for directories + within site-packages. + +1.24.2 + + - Add user provided :ref:`tips-and-tricks` section. + - Add link to Rich Leland's screencast to :ref:`references` section. + +1.24.1 + + - Add license text to the header of the script. + +1.24 + + - Resolve a bug with the preactivate hook not being run properly. + Refer to issue #21 for complete details. + +1.23 + + - Resolve a bug with the postmkvirtualenv hook not being run + properly. Refer to issues #19 and #20 for complete details. + +1.22 + + - Automatically create any missing hook scripts as stubs with + comments to expose the feature in case users are not aware of it. + +1.21 + + - Better protection of ``$WORKON_HOME`` does not exist when the wrapper script is sourced. + +1.20 + + - Incorporate lssitepackages feature from Sander Smits. + - Refactor some of the functions that were using copy-and-paste code to build path names. + - Add a few tests. + +1.19 + + - Fix problem with add2virtualenv and relative paths. Thanks to Doug Latornell for the bug report James Bennett for the suggested fix. + +1.18.1 + + - Incorporate patch from Sascha Brossmann to fix a issue #15. Directory normalization was causing ``WORKON_HOME`` to appear to be a missing directory if there were control characters in the output of ``pwd``. + +1.18 + + - Remove warning during installation if sphinxcontrib.paverutils is not installed. (#10) + - Added some basic developer information to the documentation. + - Added documentation for deactivate command. + +1.17 + + - Added documentation updates provided by Steve Steiner. + +1.16 + + - Merged in changes to ``cdvirtualenv`` from wam and added tests and docs. + - Merged in changes to make error messages go to stderr, also provided by wam. + +1.15 + - Better error handling in mkvirtualenv. + - Remove bogus VIRTUALENV_WRAPPER_BIN variable. + +1.14 + - Wrap the virtualenv version of deactivate() with one that lets us invoke + the predeactivate hooks. + - Fix virtualenvwrapper_show_workon_options for colorized versions of ls and + write myself a note so I don't break it again later. + - Convert test.sh to use true tests with `shunit2 `_ + +1.13 + - Fix issue #5 by correctly handling symlinks and limiting the list of envs to things + that look like they can be activated. + +1.12 + - Check return value of virtualenvwrapper_verify_workon_home everywhere, thanks to + Jeff Forcier for pointing out the errors. + - Fix instructions at top of README, pointed out by Matthew Scott. + - Add cdvirtualenv and cdsitepackages, contributed by James Bennett. + - Enhance test.sh. + +1.11 + - Optimize virtualenvwrapper_show_workon_options. + - Add global postactivate hook. + +1.10 + - Pull in fix for colorized ls from Jeff Forcier (b42a25f7b74a). + +1.9 + - Add more hooks for operations to run before and after creating or deleting environments based on changes from Chris Hasenpflug. + +1.8.1 + - Corrected a problem with change to mkvirtualenv that lead to release 1.8 by using an alternate fix proposed by James in comments on release 1.4. + +1.8 + - Fix for processing the argument list in mkvirtualenv from jorgevargas (BitBucket issue #1) + +1.7 + - Move to bitbucket.org for hosting + - clean up TODO list and svn keywords + - add license section below + +1.6.1 + + - More zsh support (fixes to rmvirtualenv) from Byron Clark. + +1.6 + + - Add completion support for zsh, courtesy of Ted Leung. + +1.5 + + - Fix some issues with spaces in directory or env names. They still don't really work with virtualenv, though. + - Added documentation for the postactivate and predeactivate scripts. + +1.4 + + - Includes a new .pth management function based on work contributed by James Bennett and Jannis Leidel. + +1.3.x + + - Includes a fix for a nasty bug in rmvirtualenv identified by John Shimek. From 42b840a16ce9be4f0514040e251f1ef1841c8521 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 21 Apr 2010 17:36:29 -0300 Subject: [PATCH 239/947] remove old version of translations.rst, we don't need this file anymore --- docs/en/translations.rst | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 docs/en/translations.rst diff --git a/docs/en/translations.rst b/docs/en/translations.rst deleted file mode 100644 index 30921e3..0000000 --- a/docs/en/translations.rst +++ /dev/null @@ -1,6 +0,0 @@ -.. toctree:: - :maxdepth: 2 - - install - command_ref - hooks From fa1752a4b7b89a1ea4ef4cec16fb928ac61c9d1f Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 21 Apr 2010 17:58:02 -0300 Subject: [PATCH 240/947] scripts.rst tranlated to spanish --HG-- rename : docs/en/scripts.rst => docs/es/scripts.rst --- docs/es/scripts.rst | 185 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 docs/es/scripts.rst diff --git a/docs/es/scripts.rst b/docs/es/scripts.rst new file mode 100644 index 0000000..df3c210 --- /dev/null +++ b/docs/es/scripts.rst @@ -0,0 +1,185 @@ +.. _scripts: + +============================= + Customizaciones por usuario +============================= + +Los scripts de customización de usuarios finales son *incluidos* uno por uno +(permitiendoles modificar su entorno de shell) o *ejecutados* como un programa externo +en el momento apropiado. + +.. _scripts-initialize: + +initialize +========== + + :Global/Local: global + :Argumento(s): ninguno + :Incluído/Ejecutado: incluído + +``$WORKON_HOME/initialize`` is incluído cuando ``virtualenvwrapper.sh`` +es cargado dentro de tu entorno. Usa este para ajustar configuraciones globales +cuando virtualenvwrapper es habilitado. + +.. _scripts-premkvirtualenv: + +premkvirtualenv +=============== + + :Global/Local: global + :Argumento(s): nombre de un nuevo virtualenv + :Incluído/Ejecutado: run + +``$WORKON_HOME/premkvirtualenv`` es ejecutado como un programa externo luego que +de un entorno virtual es creado pero antes de que el entorno actual sea cambiado +para apuntar al nuevo entorno. El directorio de trabajo actual para este script +es ``$WORKON_HOME`` y el nombre del nuevo entorno es pasado como argumento al +script. + +.. _scripts-postmkvirtualenv: + +postmkvirtualenv +================ + + :Global/Local: global + :Argumento(s): ninguno + :Incluído/Ejecutado: incluído + +``$WORKON_HOME/postmkvirtualenv`` es incluído después de que un nuevo entorno es +creado y activado. + +.. _scripts-precpvirtualenv: + +precpvirtualenv +=============== + + :Global/Local: global + :Argumento(s): nombre del entorno origianl, nombre del nuevo entorno + :Incluído/Ejecutado: ejecutado + +``$WORKON_HOME/precpvirtualenv`` es ejecutado como un programa externo luego de +que un entorno es duplicado y hecho reubicable, pero antes de que +``premkvirtualenv`` sea ejecutado o se haya cambiado al nuevo entorno creado. El +directorio de trabajo actual para este script es ``$WORKON_HOME`` y los nombres +del entorno original y el nuevo son pasados como argumento al script. + +.. _scripts-postcpvirtualenv: + +postcpvirtualenv +================ + + :Global/Local: global + :Argumento(s): ninguno + :Incluído/Ejecutado: incluído + +``$WORKON_HOME/postcpvirtualenv`` es incluído luego de que un nuevo entorno es +creado y activado. + +.. _scripts-preactivate: + +preactivate +=========== + + :Global/Local: global, local + :Argumento(s): nombre de entorno + :Incluído/Ejecutado: ejecutado + +El script global ``$WORKON_HOME/preactivate`` es ejecutado antes de que el nuevo +entorno sea habilitado. El nombre de entorno es pasado como primer argumento. + +El gancho ``$VIRTUAL_ENV/bin/preactivate`` es ejecutado antes de que el nuevo +entorno sea habilitado. El nombre del entorno es pasado como primer argumento. + +.. _scripts-postactivate: + +postactivate +============ + + :Global/Local: global, local + :Argumento(s): ninguno + :Incluído/Ejecutado: incluído + + +El script global ``$WORKON_HOME/postactivate`` es incluído luego de que el nuevo +entorno sea habilitado. ``$VIRTUAL_ENV`` hace referencia al nuevo entorno al +momento en el que se ejecuta el script. + +Este script de ejemplo añade un espacio entre el nombre del entorno virtual y la +tu variable PS1 haciendo uso de ``_OLD_VIRTUAL_PS1``. + +:: + + PS1="(`basename \"$VIRTUAL_ENV\"`) $_OLD_VIRTUAL_PS1" + +El script local ``$VIRTUAL_ENV/bin/postactivate`` es incluído luego de que el +nuevo entorno es habilitado. ``$VIRTUAL_ENV`` hace referencia al nuevo entorno +al momento en el que el script es ejecutado. + +Este script de ejemplo para el entorno PyMOTW cambia el directorio de trabajo +actual y la referencia de la variable PATH hacia el árbol que +contiene el código de PyMOTW. + +:: + + pymotw_root=/Users/dhellmann/Documents/PyMOTW + cd $pymotw_root + PATH=$pymotw_root/bin:$PATH + +.. _scripts-predeactivate: + +predeactivate +============= + + :Global/Local: local, global + :Argumento(s): ninguno + :Incluído/Ejecutado: incluído + +El script local ``$VIRTUAL_ENV/bin/predeactivate`` es incluído antes de que el entorno +actual sea desactivado, y puede ser usado para deshabilitar o limpiar +configuraciones en tu entorno. ``$VIRTUAL_ENV`` hace referencia al entorno viejo +al momento de ejecutar este script. + +El script global ``$WORKON_HOME/predeactivate`` es incluído antes de que el +entorno actual sea desactivado. ``$VIRTUAL_ENV`` hace referencia al entorno viejo +al momento de ejecutar este script. + +.. _scripts-postdeactivate: + +postdeactivate +============== + + :Global/Local: local, global + :Argumento(s): ninguno + :Incluído/Ejecutado: incluído + +El script ``$VIRTUAL_ENV/bin/postdeactivate`` es incluído luego de que el +entorno actual sea desactivado, y puede ser usado para deshabilitar o limpiar +configuraciones en tu entorno. El path hacia el entorno que recientemente se ha +desactivado está disponible en ``$VIRTUALENVWRAPPER_LAST_VIRTUALENV``. + +.. _scripts-prermvirtualenv: + +prermvirtualenv +=============== + + :Global/Local: global + :Argumento(s): nombre de entorno + :Incluído/Ejecutado: ejecutad + +EL script ``$WORKON_HOME/prermvirtualenv`` es ejecutado como un programa externo +antes de que el entorno sea eliminado. El path absoluto hacia el entorno es +pasado como arguemnto al script. + +.. _scripts-postrmvirtualenv: + +postrmvirtualenv +================ + + :Global/Local: global + :Argumento(s): nombre de entorno + :Incluído/Ejecutado: ejecutado + +El script ``$WORKON_HOME/postrmvirtualenv`` es ejecuato como un programa externo +luego de que el entorno sea eliminado. El path absoluto hacia el directorio del +entorno es pasado como argumento al script. + From 275d72f9d83263654e443fbfc015e9a09ed7f35e Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 21 Apr 2010 18:02:14 -0300 Subject: [PATCH 241/947] remove translation from the toctree --- docs/en/index.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/en/index.rst b/docs/en/index.rst index 6a28ad3..c760cf1 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -179,7 +179,6 @@ Details developers extensions history - translations .. _references: From ee5da1c4a916094491bd013191c72ffd9cd8e810 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 21 Apr 2010 18:03:31 -0300 Subject: [PATCH 242/947] markup fixed --- docs/es/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/es/index.rst b/docs/es/index.rst index 8a93d24..5f588bb 100644 --- a/docs/es/index.rst +++ b/docs/es/index.rst @@ -23,7 +23,7 @@ Características 4. Completa con tab los comandos que toman un entorno virtual como argumento. 5. Ganchos configurables para todas las operaciones (ver :ref:`scripts`). 6. Sistema de plugins para la creación de extensiones compartibles (ver -:ref:`plugins`). + :ref:`plugins`). ============ Introducción From ed5200df5f93bf09a725647eb320c707040743a5 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 21 Apr 2010 18:05:23 -0300 Subject: [PATCH 243/947] remove the option that copy the static files: we don't have file to copy and it generate a WARNING in the sphinx compilation --- docs/sphinx/pkg/conf.py | 2 +- docs/sphinx/web/conf.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/pkg/conf.py b/docs/sphinx/pkg/conf.py index 1045433..a587a81 100644 --- a/docs/sphinx/pkg/conf.py +++ b/docs/sphinx/pkg/conf.py @@ -120,7 +120,7 @@ # 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, # 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, # using the given strftime format. diff --git a/docs/sphinx/web/conf.py b/docs/sphinx/web/conf.py index 7634fdc..6faf447 100644 --- a/docs/sphinx/web/conf.py +++ b/docs/sphinx/web/conf.py @@ -120,7 +120,7 @@ # 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, # 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, # using the given strftime format. From 15fa779228ff55adb53dadf9e1855e777b8c8bee Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Thu, 22 Apr 2010 10:00:52 -0300 Subject: [PATCH 244/947] continue the translation of plugins.rst --- docs/es/plugins.rst | 47 +++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/docs/es/plugins.rst b/docs/es/plugins.rst index 50f499d..58770ce 100644 --- a/docs/es/plugins.rst +++ b/docs/es/plugins.rst @@ -150,26 +150,24 @@ shell actual. .. warning:: - virtualenvwrapper works under several shells with slightly - different syntax (bash, sh, zsh, ksh). Take this portability into - account when defining source hooks. Sticking to the simplest - possible syntax usually avoids problems, but there may be cases - where examining the ``SHELL`` environment variable to generate - different syntax for each case is the only way to achieve the - desired result. + virtualenvwrapper funciona en varios shells con una sintaxis ligeramente + diferente (bash, sh, zsh, ksh). Ten en cuenta esta portabilidad cuando + definas ganchos incluídos (*sourced hooks*). Mantener la sintaxis lo más simple + posible evitará problemas comunes, pero quizás haya casos donde + examinar la varible de entorno ``SHELL`` y generar diferente sintaxis + para cada caso sea la única manera de alcanzar el resultado desedo. -Registering Entry Points ------------------------- +Registrar puntos de entrada +--------------------------- -The functions defined in the plugin need to be registered as *entry -points* in order for virtualenvwrapper's hook loader to find them. -Distribute_ entry points are configured in the ``setup.py`` for your -package by mapping the entry point name to the function in the package -that implements it. +Las funciones definidas en el plugin necesitan ser registradas como *puntos de +entrada* para que el cargador de ganchos de virtualenvwrapper los encuentre. +Los puntos de entrada de Distribute_ se configuran en el ``setup.py`` de tu +paquete coincidiendo el nombre del punto de entrada con la función en el paquete +que lo implementa. -This partial copy of virtualenvwrapper's ``setup.py`` illustrates how -the ``initialize()`` and ``initialize_source()`` entry points are -configured. +Una copia parcial del ``setup.py`` de virtualenvwrapper ilustra cómo los puntos +de entrada ``initialize()`` y ``initialize_source()`` son configurados. :: @@ -201,15 +199,14 @@ configured. }, ) -The ``entry_points`` argument to ``setup()`` is a dictionary mapping -the entry point *group names* to lists of entry point specifiers. A -different group name is defined by virtualenvwrapper for each -extension point (see :ref:`plugins-extension-points`). +El argumento ``entry_points`` de ``setup()`` es un diccionario que mapea los +*grupos de nombre* de puntos de entrada a listas de puntos de entrada +específicos. Un nombre de grupo diferente es definido por virtualenvwrapper por +cada punto de extensión (ver :ref:`plugins-extension-points`). -The entry point specifiers are strings with the syntax ``name = -package.module:function``. By convention, the *name* of each entry -point is the plugin name, but that is not required (the names are not -used). +Los identificadores de puntos de entrada son strings con la sintaxis ``name = +package.module:function``. Por convención, el *nombre* de cada punto de entrada +es el nombre del plugin, pero esto no es requerido (los nombres no son usados). .. seealso:: From c1a13372338f825a4001c0f44365065401468a70 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Sat, 24 Apr 2010 13:26:17 -0300 Subject: [PATCH 245/947] continue the translation --- docs/es/plugins.rst | 59 +++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/docs/es/plugins.rst b/docs/es/plugins.rst index 58770ce..c1017e2 100644 --- a/docs/es/plugins.rst +++ b/docs/es/plugins.rst @@ -213,8 +213,13 @@ es el nombre del plugin, pero esto no es requerido (los nombres no son usados). * `namespace packages `__ * `Extensible Applications and Frameworks `__ -The Hook Loader ---------------- +El cargador de ganchos +---------------------- + +Las extenciones son ejecutadas mediante una aplicación de líneas de comando +implementada en ``virtualenvwrapper.hook_loader``. Debido a que ``virtualenvwrapper.sh`` + + Extensions are run through a command line application implemented in ``virtualenvwrapper.hook_loader``. Because ``virtualenvwrapper.sh`` @@ -237,37 +242,36 @@ application, use the ``-m`` option to the interpreter:: -q, --quiet Show less information on the console -n NAMES, --name=NAMES Only run the hook from the named plugin - -To run the extensions for the initialize hook:: + +Para ejecutar las extensiones para el gancho *initialize*:: $ python -m virtualenvwrapper.hook_loader -v initialize -To get the shell commands for the initialize hook:: +Para obtener los comandos de shell para el gancho *initialize*:: $ python -m virtualenvwrapper.hook_loader --source initialize -In practice, rather than invoking the hook loader directly it is more -convenient to use the shell function, ``virtualenvwrapper_run_hook`` -to run the hooks in both modes.:: +En la práctica, en vez de invocar al cargador de ganchos directamente es +conveniente usar la función de shell, ``virtualenvwrapper_run_hook`` para +ejecutar los ganchos en ambos modos.:: $ virtualenvwrapper_run_hook initialize -All of the arguments given to shell function are passed directly to -the hook loader. +Todos los argumentos pasados a la función de shell son pasados directamente al +cargador de ganchos. -Logging -------- +Registro (*Logging*) +-------------------- -The hook loader configures logging so that messages are written to -``$WORKON_HOME/hook.log``. Messages also may be written to stderr, -depending on the verbosity flag. The default is for messages at *info* -or higher levels to be written to stderr, and *debug* or higher to go to -the log file. Using logging in this way provides a convenient -mechanism for users to control the verbosity of extensions. +El cargador de ganchos configura el registro para que los mensajes sean escritos +en ``$WORKON_HOME/hook.log``. Los mensajes quizás sean escritos en stderr, +dependiendo de la flash verbose. Por default los mensajes con un nivel mayor o +igual a *info* se escriben en stderr, y los de nivel *debug* o mayor van al +archivo de registro. Usar el registro de esta forma provee un mecanismo +conveniente para que los usuarios controlen la verbosidad de las extensiones. -To use logging from within your extension, simply instantiate a logger -and call its ``info()``, ``debug()`` and other methods with the -messages. +Para usar el registro en tu extensión, simplemente instancia un registro y llama +a sus métodos ``info()``, ``debug()`` y otros métodos de mensajería. :: @@ -285,8 +289,17 @@ messages. .. _plugins-extension-points: -Extension Points -================ +Puntos de extensión +=================== + +Los nombres de los puntos de extensión para los plugins nativos siguen una +convensión con varias partes: +``virtualenvwrapper.(pre|post)_[_source]``. ** es la acción tomada +por el usuario o virtualenvwrapper que provoca la extensión. ``(pre|post)`` +indica si llamar a la extensión antes o después de un evento. El sufijo ``_source`` +es agregado para las extensiones que retornan código shell en vez de tomar una +acción directamente (ver :ref:`plugins-user-env`). + The extension point names for native plugins follow a naming convention with several parts: From b5aabf1d6d5b100522636863aa08f2f4668b6f11 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Sat, 24 Apr 2010 13:52:13 -0300 Subject: [PATCH 246/947] almost done for plugins.rst --- docs/es/plugins.rst | 103 +++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 58 deletions(-) diff --git a/docs/es/plugins.rst b/docs/es/plugins.rst index c1017e2..340607b 100644 --- a/docs/es/plugins.rst +++ b/docs/es/plugins.rst @@ -296,129 +296,116 @@ Los nombres de los puntos de extensión para los plugins nativos siguen una convensión con varias partes: ``virtualenvwrapper.(pre|post)_[_source]``. ** es la acción tomada por el usuario o virtualenvwrapper que provoca la extensión. ``(pre|post)`` -indica si llamar a la extensión antes o después de un evento. El sufijo ``_source`` +indica si llama a la extensión antes o después de un evento. El sufijo ``_source`` es agregado para las extensiones que retornan código shell en vez de tomar una acción directamente (ver :ref:`plugins-user-env`). - -The extension point names for native plugins follow a naming -convention with several parts: -``virtualenvwrapper.(pre|post)_[_source]``. The ** is -the action taken by the user or virtualenvwrapper that triggers the -extension. ``(pre|post)`` indicates whether to call the extension -before or after the event. The suffix ``_source`` is added for -extensions that return shell code instead of taking action directly -(see :ref:`plugins-user-env`). - .. _plugins-initialize: initialize ---------- -The ``virtualenvwrapper.initialize`` hooks are run each time -``virtualenvwrapper.sh`` is loaded into the user's environment. The -initialize hook can be used to install templates for configuration -files or otherwise prepare the system for proper plugin operation. +Los ganchos ``virtualenvwrapper.initialize`` son ejecutados cada vez que +``virtualenvwrapper.sh`` es cargado en el entorno del usuario. El gancho +*initialize* puede ser usado para instalar plantillas para configurar archivos o +preparar el sistema para una operación correcta del plugin. .. _plugins-pre_mkvirtualenv: pre_mkvirtualenv ---------------- -The ``virtualenvwrapper.pre_mkvirtualenv`` hooks are run after the -virtual environment is created, but before the new environment is -activated. The current working directory for when the hook is run is -``$WORKON_HOME`` and the name of the new environment is passed as an -argument. +Los ganchos ``virtualenvwrapper.pre_mkvirtualenv`` son ejecutados después de que +el entorno es creado, pero antes de que el nuevo entorno sea activado. El +directorio de trabajo actual para cuando el gancho es ejecutado es ``$WORKON_HOME`` +y el nombre del nuevo entorno es pasado como un argumento. .. _plugins-post_mkvirtualenv: post_mkvirtualenv ----------------- -The ``virtualenvwrapper.post_mkvirtualenv`` hooks are run after a new -virtual environment is created and activated. ``$VIRTUAL_ENV`` is set -to point to the new environment. +Los ganchos ``virtualenvwrapper.post_mkvirtualenv`` son ejecutado después de que +un nuevo entorno sea creado y activado. ``$VIRTUAL_ENV`` es configurado para +apuntar al nuevo entorno. .. _plugins-pre_activate: pre_activate ------------ -The ``virtualenvwrapper.pre_activate`` hooks are run just before an -environment is enabled. The environment name is passed as the first -argument. +Los ganchos ``virtualenvwrapper.pre_activate`` son ejecutados justo antes +de que un entorno sea activado. El nombre del entorno es pasado como +primer argumento. .. _plugins-post_activate: post_activate ------------- -The ``virtualenvwrapper.post_activate`` hooks are run just after an -environment is enabled. ``$VIRTUAL_ENV`` is set to point to the -current environment. + +Los ganchos ``virtualenvwrapper.post_activate`` son ejecutados justo después +de que un entorno sea activado. ``$VIRTUAL_ENV`` apunta al entorno actual. .. _plugins-pre_deactivate: pre_deactivate -------------- -The ``virtualenvwrapper.pre_deactivate`` hooks are run just before an -environment is disabled. ``$VIRTUAL_ENV`` is set to point to the -current environment. +Los ganchos ``virtualenvwrapper.pre_deactivate`` son ejecutados justo antes de +que un entorno sea desactivado. ``$VIRTUAL_ENV`` apunta al entorno actual. .. _plugins-post_deactivate: post_deactivate --------------- -The ``virtualenvwrapper.post_deactivate`` hooks are run just after an -environment is disabled. The name of the environment just deactivated -is passed as the first argument. +Los ganchos ``virtualenvwrapper.post_deactivate`` son ejecutados justo después +de que un entorno sea desactivado. El nombre del entorno recién desactivado es +pasado como primer argumento. .. _plugins-pre_rmvirtualenv: pre_rmvirtualenv ---------------- -The ``virtualenvwrapper.pre_rmvirtualenv`` hooks are run just before -an environment is deleted. The name of the environment being deleted -is passed as the first argument. +Los ganchos ``virtualenvwrapper.pre_rmvirtualenv`` son ejecutados justo antes +de que un entorno sea eliminado. El nombre del entorno eliminado es pasado +como primer argumento. .. _plugins-post_rmvirtualenv: post_rmvirtualenv ----------------- -The ``virtualenvwrapper.post_rmvirtualenv`` hooks are run just after -an environment is deleted. The name of the environment being deleted -is passed as the first argument. +Los ganchos ``virtualenvwrapper.post_rmvirtualenv`` son ejecutados justo después +de que un entorno haya sido eliminado. El nombre del entorno eliminado es pasado +como primer argumento. -Adding New Extension Points -=========================== -Plugins that define new operations can also define new extension -points. No setup needs to be done to allow the hook loader to find -the extensions; documenting the names and adding calls to -``virtualenvwrapper_run_hook`` is sufficient to cause them to be -invoked. +Agregar nuevos puntos de extensión +================================== -The hook loader assumes all extension point names start with -``virtualenvwrapper.`` and new plugins will want to use their own -namespace qualifier to append to that. For example, the project_ -extension defines new events around creating project directories (pre -and post). These are called -``virtualenvwrapper.project.pre_mkproject`` and -``virtualenvwrapper.project.post_mkproject``. These are invoked -with:: +Los plugins que definen nuevas operaciones pueden también definir nuevos puntos +de extensión. No es necesario hacer ninguna configuración para permitir que el +cargador de ganchos encuentre las extensiones; documentar los nombres y agregar +llamadas a ``virtualenvwrapper_run_hook`` es suficiente para causar que ellos se +invoquen. + +El cargador de ganchos asume que todos los nombres de puntos de extensión +comienzan con ``virtualenvwrapper.`` y los nuevos plugins querrán usar su +propio espacio de nombres para agregar. Por ejemplo, la extensión project_ +define nuevos eventos para crear directorios del proyecto (pre y post). Esas son +llamadas a ``virtualenvwrapper.project.pre_mkproject`` y +``virtualenvwrapper.project.post_mkproject``. Estas son invocadas con:: virtualenvwrapper_run_hook project.pre_mkproject $project_name -and:: +y:: virtualenvwrapper_run_hook project.post_mkproject -respectively. +respectivamente. .. _Distribute: http://packages.python.org/distribute/ From d17d2dd57f1d9c9cf6b480a60957bef742478f07 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Sat, 24 Apr 2010 14:03:53 -0300 Subject: [PATCH 247/947] another paragraph --- docs/es/plugins.rst | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/docs/es/plugins.rst b/docs/es/plugins.rst index 340607b..0cd2c94 100644 --- a/docs/es/plugins.rst +++ b/docs/es/plugins.rst @@ -139,14 +139,13 @@ shell actual. .. warning:: - Because the extension is modifying the user's working shell, care - must be taken not to corrupt the environment by overwriting - existing variable values unexpectedly. Avoid creating temporary - variables where possible, and use unique names where variables - cannot be avoided. Prefixing variables with the extension name is - a good way to manage the namespace. For example, instead of - ``temp_file`` use ``user_scripts_temp_file``. Use ``unset`` to - release temporary variable names when they are no longer needed. + Como las extensiones están modificando el shell de trabajo del usuario, se + debe tener mucho cuidado de corromper el entorno sobreescribiendo variables + con valores inesperados. Evita crear variables temporales cuando sea + posible. Poner prefijos a las variables con el nombre de la extensión es una + buena forma de manejar espacios de nombres. Por ejemplo, en vez de + ``temp_file`` usa ``user_scripts_temp_file``. Usa ``unset`` para liberar + nombres de variables temporales cuando no sean más necesarias. .. warning:: @@ -217,8 +216,8 @@ El cargador de ganchos ---------------------- Las extenciones son ejecutadas mediante una aplicación de líneas de comando -implementada en ``virtualenvwrapper.hook_loader``. Debido a que ``virtualenvwrapper.sh`` - +implementada en ``virtualenvwrapper.hook_loader``. Como ``virtualenvwrapper.sh`` +es Extensions are run through a command line application implemented in From 26cc5fa647a89ab25b78f10732165f500e698e2b Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Sat, 24 Apr 2010 14:14:01 -0300 Subject: [PATCH 248/947] aspell for command_ref --- docs/es/command_ref.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/es/command_ref.rst b/docs/es/command_ref.rst index c05013c..94960ae 100644 --- a/docs/es/command_ref.rst +++ b/docs/es/command_ref.rst @@ -25,7 +25,7 @@ Sintaxis:: mkvirtualenv [options] ENVNAME -Todas las opciones de línea de comandos son pasados diréctamente a +Todas las opciones de línea de comandos son pasados directamente a ``virtualenv``. El nuevo entorno es automáticamente activado luego de su inicialización. @@ -77,7 +77,7 @@ cpvirtualenv Duplica un entorno, dentro de WORKON_HOME. -Syntax:: +Sintaxis:: cpvirtualenv ENVNAME TARGETENVNAME @@ -179,7 +179,7 @@ Sintaxis:: .. note:: Este comando es actualmente parte de virtualenv, pero es encapsulado para - proveer ganchos antes y después, al igual que workon hace para activate. + proveer ganchos antes y después, al igual que workon hace para *activate*. :: @@ -222,7 +222,7 @@ Sintaxis:: Al llamar ``cdvirtualenv`` se cambia el directorio de trabajo actual hacia la sima de virtualenv (``$VIRTUAL_ENV``). Un argumento adicional es agregado a la -ruta, permitiendo navegar diréctamente dentro de un subdirectorio. +ruta, permitiendo navegar directamente dentro de un subdirectorio. :: @@ -310,10 +310,10 @@ Sintaxis:: A veces esto es conveniente compartir paquetes instalados que no están en el directorio ``site-pacakges`` del sistema y no deben ser instalados en cada -entorno virtual. Una posible solución es crear enláces simbólicos (*symlinks*) +entorno virtual. Una posible solución es crear enlaces simbólicos (*symlinks*) hacia el código dentro del directorio ``site-packages`` del entorno, pero también es fácil agregar a la variable PYTHONPATH directorios extras que están -incluídos en los archivos ``.pth`` dentro de ``site-packages`` usando ``add2virtualenv``. +incluidos en los archivos ``.pth`` dentro de ``site-packages`` usando ``add2virtualenv``. 1. Descarga (*check out*) el código de un proyecto grande, como Django. 2. Ejecuta: ``add2virtualenv path_to_source``. From 11498b463dcef8dbb8971d63fe34d163a0c53034 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Sat, 24 Apr 2010 14:15:51 -0300 Subject: [PATCH 249/947] aspell for developers --- docs/es/developers.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/es/developers.rst b/docs/es/developers.rst index 40a53fc..03cf739 100644 --- a/docs/es/developers.rst +++ b/docs/es/developers.rst @@ -6,7 +6,7 @@ Si quieres contribuir con virtualenvwrapper directamente, estas instrucciones deberían ayudarte a empezar. Parches, reporte de bugs, y propuestas de características son todas bienvenidas a través del `sitio de BitBucket `_. Contribuciones en la -forma de parches o solicitud de pull son fáciles de integrar y recibirán +forma de parches o solicitud de *pull* son fáciles de integrar y recibirán prioridad en la atención. .. note:: @@ -24,7 +24,7 @@ Necesitas los siguientes paquetes para construir la documentación: - Sphinx - docutils -Una vez que todas las herramientas están instaladas dentro de un virtualen +Una vez que todas las herramientas están instaladas dentro de un virtualenv usando pip, ejecuta ``make html`` para generar la versión de HTML de la documentación:: From 12f7f87a729e6e593ba4bbd006d820344295d3c0 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Sat, 24 Apr 2010 14:17:38 -0300 Subject: [PATCH 250/947] aspell for extensions --- docs/es/extensions.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/es/extensions.rst b/docs/es/extensions.rst index 3646149..56924f7 100644 --- a/docs/es/extensions.rst +++ b/docs/es/extensions.rst @@ -29,7 +29,7 @@ emacs-desktop Emacs desktop-mode_ te permite guardar el estado de emacs (buffers abiertos, posiciones de buffers, etc.) entre sesiones. También puede ser usado como un archivo de proyecto similar a otros IDEs. El plugin emacs-desktop_ agrega -un disparador para guardar el archivo de proyect actual y cargar uno nuevo +un disparador para guardar el archivo de proyecto actual y cargar uno nuevo cuando se active un nuevo entorno usando ``workon``. .. _desktop-mode: http://www.emacswiki.org/emacs/DeskTop @@ -40,6 +40,6 @@ user_scripts ============ La extensión ``user_scripts`` es distribuida con virtualenvwrapper y está -habilitada por default. Implmenta la característica de script de customización +habilitada por default. Implementa la característica de script de personalización de usuarios descrita en :ref:`scripts`. From 1816db68fce3b148a5c1ca1a1cd742f182ad02d5 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Sat, 24 Apr 2010 15:51:13 -0300 Subject: [PATCH 251/947] aspell to hooks --- docs/es/hooks.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/es/hooks.rst b/docs/es/hooks.rst index 6deea4c..04830b8 100644 --- a/docs/es/hooks.rst +++ b/docs/es/hooks.rst @@ -1,5 +1,5 @@ ============================== - Customizar Virtualenvwrapper + Personalizar Virtualenvwrapper ============================== virtualenvwrapper agrega varios ganchos que puedes usar para cambiar tus From 6bf34a9bb36878493839f9691cd193ac84c16122 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Sat, 24 Apr 2010 15:59:54 -0300 Subject: [PATCH 252/947] aspell to index --- docs/es/index.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/es/index.rst b/docs/es/index.rst index 5f588bb..213a32c 100644 --- a/docs/es/index.rst +++ b/docs/es/index.rst @@ -18,9 +18,9 @@ Características =============== 1. Organiza todos tus entornos virtuales en un sólo lugar -2. Funciones para administrar tus entornor virtuales (crear, eliminar, copiar). +2. Funciones para administrar tus entornos virtuales (crear, eliminar, copiar). 3. Usa un sólo comando para cambiar entre los entornos. -4. Completa con tab los comandos que toman un entorno virtual como argumento. +4. Completa con Tab los comandos que toman un entorno virtual como argumento. 5. Ganchos configurables para todas las operaciones (ver :ref:`scripts`). 6. Sistema de plugins para la creación de extensiones compartibles (ver :ref:`plugins`). @@ -33,7 +33,7 @@ La mejor forma de explicar las características que virtualenvwrapper brinda es mostrar éste en uso. Primero, algunos pasos de inicialización. La mayoría de esto sólo necesita ser -hecho una sóla vez. Vas a querer agregar el comando ``source +hecho una sola vez. Vas a querer agregar el comando ``source /usr/local/bin/virtualenvwrapper.sh`` al archivo de inicio de shell, cambiando el path hacia virtualenvwrapper.sh dependiendo en dónde haya sido instalado por pip. @@ -102,8 +102,8 @@ Cambiar entre entornos con ``workon``:: /Users/dhellmann/Envs/env1 (env1)$ -El comando ``workon`` también incluye la completación con tab para los nombres -de los entornos, e invoca a los scripts customizados cuando un entorno es +El comando ``workon`` también incluye la opción de completar con Tab los nombres +de los entornos, e invoca a los scripts personalizados cuando un entorno es activado o desactivado (ver :ref:`scripts`). :: @@ -114,7 +114,7 @@ activado o desactivado (ver :ref:`scripts`). /Users/dhellmann/Envs/env2 :ref:`scripts-postmkvirtualenv` es ejecutado cuando un nuevo entorno es creado, -dejándote instalar automáticamente herramientas comunmente utilizadas. +dejándote instalar automáticamente herramientas comúnmente utilizadas. :: @@ -157,8 +157,8 @@ dejándote instalar automáticamente herramientas comunmente utilizadas. /Users/dhellmann/Envs/env3/bin/sphinx-build A través de una combinación de funciones existentes definidas por el "core" -package (see :ref:`command`), plugins de terceros (see -:ref:`plugins`), y scripts definidos por el usuario (see :ref:`scripts`) +package (ver :ref:`command`), plugins de terceros (ver +:ref:`plugins`), y scripts definidos por el usuario (ver :ref:`scripts`) virtualenvwrapper brinda una amplia variedad de oportunidades para automatizar tareas repetitivas. From 7a56930bfaa0c2f2007be2c7d42aaf4445a5989f Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Sat, 24 Apr 2010 16:02:01 -0300 Subject: [PATCH 253/947] aspell to install --- docs/es/install.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/es/install.rst b/docs/es/install.rst index a189651..f358bcf 100644 --- a/docs/es/install.rst +++ b/docs/es/install.rst @@ -32,7 +32,7 @@ y los scripts instalados con este paquete:: export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh -Despues de editar este, recarga el archivo de inicio (e.g., ejecuta: ``source +Después de editar este, recarga el archivo de inicio (e.g., ejecuta: ``source ~/.bashrc``). Intérprete de Python y $PATH @@ -70,7 +70,7 @@ Archivos temporales =================== virtualenvwrapper crea archivos temporales en ``$TMPDIR``. Si la variable no -está configuradad, este usa ``/tmp``. Para cambiar la ubicación de los archivos +está configurada, este usa ``/tmp``. Para cambiar la ubicación de los archivos temporales sólo para virtualenvwrapper, configura ``VIRTUALENVWRAPPER_TMPDIR``. Actualizar desde 1.x From eb5ddf9479659ad6a3a868046ea0dd31e1de1b2b Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Sat, 24 Apr 2010 16:06:11 -0300 Subject: [PATCH 254/947] aspell for script --- docs/es/scripts.rst | 50 ++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/docs/es/scripts.rst b/docs/es/scripts.rst index df3c210..a2f3e8a 100644 --- a/docs/es/scripts.rst +++ b/docs/es/scripts.rst @@ -1,11 +1,11 @@ .. _scripts: ============================= - Customizaciones por usuario + Personalizaciones por usuario ============================= -Los scripts de customización de usuarios finales son *incluidos* uno por uno -(permitiendoles modificar su entorno de shell) o *ejecutados* como un programa externo +Los scripts de personalización de usuarios finales son *incluidos* uno por uno +(permitiéndoles modificar su entorno de shell) o *ejecutados* como un programa externo en el momento apropiado. .. _scripts-initialize: @@ -15,9 +15,9 @@ initialize :Global/Local: global :Argumento(s): ninguno - :Incluído/Ejecutado: incluído + :Incluido/Ejecutado: incluido -``$WORKON_HOME/initialize`` is incluído cuando ``virtualenvwrapper.sh`` +``$WORKON_HOME/initialize`` es incluido cuando ``virtualenvwrapper.sh`` es cargado dentro de tu entorno. Usa este para ajustar configuraciones globales cuando virtualenvwrapper es habilitado. @@ -28,7 +28,7 @@ premkvirtualenv :Global/Local: global :Argumento(s): nombre de un nuevo virtualenv - :Incluído/Ejecutado: run + :Incluido/Ejecutado: ejecutado ``$WORKON_HOME/premkvirtualenv`` es ejecutado como un programa externo luego que de un entorno virtual es creado pero antes de que el entorno actual sea cambiado @@ -43,9 +43,9 @@ postmkvirtualenv :Global/Local: global :Argumento(s): ninguno - :Incluído/Ejecutado: incluído + :Incluido/Ejecutado: incluido -``$WORKON_HOME/postmkvirtualenv`` es incluído después de que un nuevo entorno es +``$WORKON_HOME/postmkvirtualenv`` es incluido después de que un nuevo entorno es creado y activado. .. _scripts-precpvirtualenv: @@ -54,8 +54,8 @@ precpvirtualenv =============== :Global/Local: global - :Argumento(s): nombre del entorno origianl, nombre del nuevo entorno - :Incluído/Ejecutado: ejecutado + :Argumento(s): nombre del entorno original, nombre del nuevo entorno + :Incluido/Ejecutado: ejecutado ``$WORKON_HOME/precpvirtualenv`` es ejecutado como un programa externo luego de que un entorno es duplicado y hecho reubicable, pero antes de que @@ -70,9 +70,9 @@ postcpvirtualenv :Global/Local: global :Argumento(s): ninguno - :Incluído/Ejecutado: incluído + :Incluido/Ejecutado: incluido -``$WORKON_HOME/postcpvirtualenv`` es incluído luego de que un nuevo entorno es +``$WORKON_HOME/postcpvirtualenv`` es incluido luego de que un nuevo entorno es creado y activado. .. _scripts-preactivate: @@ -82,7 +82,7 @@ preactivate :Global/Local: global, local :Argumento(s): nombre de entorno - :Incluído/Ejecutado: ejecutado + :Incluido/Ejecutado: ejecutado El script global ``$WORKON_HOME/preactivate`` es ejecutado antes de que el nuevo entorno sea habilitado. El nombre de entorno es pasado como primer argumento. @@ -97,10 +97,10 @@ postactivate :Global/Local: global, local :Argumento(s): ninguno - :Incluído/Ejecutado: incluído + :Incluido/Ejecutado: incluido -El script global ``$WORKON_HOME/postactivate`` es incluído luego de que el nuevo +El script global ``$WORKON_HOME/postactivate`` es incluido luego de que el nuevo entorno sea habilitado. ``$VIRTUAL_ENV`` hace referencia al nuevo entorno al momento en el que se ejecuta el script. @@ -111,7 +111,7 @@ tu variable PS1 haciendo uso de ``_OLD_VIRTUAL_PS1``. PS1="(`basename \"$VIRTUAL_ENV\"`) $_OLD_VIRTUAL_PS1" -El script local ``$VIRTUAL_ENV/bin/postactivate`` es incluído luego de que el +El script local ``$VIRTUAL_ENV/bin/postactivate`` es incluido luego de que el nuevo entorno es habilitado. ``$VIRTUAL_ENV`` hace referencia al nuevo entorno al momento en el que el script es ejecutado. @@ -132,14 +132,14 @@ predeactivate :Global/Local: local, global :Argumento(s): ninguno - :Incluído/Ejecutado: incluído + :Incluido/Ejecutado: incluido -El script local ``$VIRTUAL_ENV/bin/predeactivate`` es incluído antes de que el entorno +El script local ``$VIRTUAL_ENV/bin/predeactivate`` es incluido antes de que el entorno actual sea desactivado, y puede ser usado para deshabilitar o limpiar configuraciones en tu entorno. ``$VIRTUAL_ENV`` hace referencia al entorno viejo al momento de ejecutar este script. -El script global ``$WORKON_HOME/predeactivate`` es incluído antes de que el +El script global ``$WORKON_HOME/predeactivate`` es incluido antes de que el entorno actual sea desactivado. ``$VIRTUAL_ENV`` hace referencia al entorno viejo al momento de ejecutar este script. @@ -150,9 +150,9 @@ postdeactivate :Global/Local: local, global :Argumento(s): ninguno - :Incluído/Ejecutado: incluído + :Incluido/Ejecutado: incluido -El script ``$VIRTUAL_ENV/bin/postdeactivate`` es incluído luego de que el +El script ``$VIRTUAL_ENV/bin/postdeactivate`` es incluido luego de que el entorno actual sea desactivado, y puede ser usado para deshabilitar o limpiar configuraciones en tu entorno. El path hacia el entorno que recientemente se ha desactivado está disponible en ``$VIRTUALENVWRAPPER_LAST_VIRTUALENV``. @@ -164,11 +164,11 @@ prermvirtualenv :Global/Local: global :Argumento(s): nombre de entorno - :Incluído/Ejecutado: ejecutad + :Incluido/Ejecutado: ejecutado EL script ``$WORKON_HOME/prermvirtualenv`` es ejecutado como un programa externo antes de que el entorno sea eliminado. El path absoluto hacia el entorno es -pasado como arguemnto al script. +pasado como argumento al script. .. _scripts-postrmvirtualenv: @@ -177,9 +177,9 @@ postrmvirtualenv :Global/Local: global :Argumento(s): nombre de entorno - :Incluído/Ejecutado: ejecutado + :Incluido/Ejecutado: ejecutado -El script ``$WORKON_HOME/postrmvirtualenv`` es ejecuato como un programa externo +El script ``$WORKON_HOME/postrmvirtualenv`` es ejecutado como un programa externo luego de que el entorno sea eliminado. El path absoluto hacia el directorio del entorno es pasado como argumento al script. From 3a8c9dc6240d4b3fb4faa357252694a7ea26cd5d Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Sat, 24 Apr 2010 16:33:17 -0300 Subject: [PATCH 255/947] aspell to plugins and fix some paragraphs --- docs/es/plugins.rst | 47 ++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/docs/es/plugins.rst b/docs/es/plugins.rst index 0cd2c94..fca3be6 100644 --- a/docs/es/plugins.rst +++ b/docs/es/plugins.rst @@ -4,9 +4,9 @@ Extender Virtualenvwrapper ========================== -Una gran experiencia con soluciones caseras para customizar un entorno de +Una gran experiencia con soluciones caseras para personalizar un entorno de desarrollo ha demostrado cuán valioso puede ser tener la capacidad de -automatizar tareas comunes y elminar molestias persistentes. Carpinteros +automatizar tareas comunes y eliminar molestias persistentes. Carpinteros construyen plantillas de guía, desarrolladores de software escriben scripts de shell. virtualenvwrapper continúa la tradición de animar a un artesano a modificar sus herramientas para trabajar de la manera que ellos quieran, en vez @@ -26,9 +26,9 @@ el repositorio de control de versiones para el código, o por otro lado configurar un nuevo proyecto. Existen dos maneras para adjuntar tu código para que virtualenvwrapper lo -ejecute: los usuarios finales pueden usar scrips the shell o otros programas -para la customización personal (ver :ref:`scripts`). Las extensiones también -pueden ser implementadas en Python usando *entry points* con Distribute_ , +ejecute: los usuarios finales pueden usar scripts de shell o otros programas +para la personalización personal (ver :ref:`scripts`). Las extensiones también +pueden ser implementadas en Python usando *puntos de entrada* con Distribute_ , Definir una extensión ===================== @@ -36,15 +36,15 @@ Definir una extensión .. note:: Virtualenvwrapper es distribuido con un plugin para la creación y ejecución de - los scripts de customización de los usuarios (:ref:`extensions-user_scripts`). + los scripts de personalización de los usuarios (:ref:`extensions-user_scripts`). Los ejemplos siguientes han sido tomados de la implementación de ese plugin. Organización del código ----------------------- El paquete Python para ``virtualenvwrapper`` es un *namespace package*. -Eso signific que multiples librerías pueden instalar código dentro del paquete, -incluso si ellas no son ditribuidas juntas o instaladas dentro del mismo +Eso significa que múltiples librerías pueden instalar código dentro del paquete, +incluso si ellas no son distribuidas juntas o instaladas dentro del mismo directorio. Las extensiones pueden (opcionalmente) usar el namespace de ``virtualenvwrapper`` configurando su estructura de directorios así: @@ -65,20 +65,20 @@ Y agregando el siguiente código dentro de ``__init__.py``:: Las extensiones pueden ser cargadas desde cualquier paquete, así que usar el espacio de nombres de ``virtualenvwrapper`` no es requerido. -Extension API +Extensión API ------------- Después de que el paquete está establecido, el siguiente paso es crear un módulo para alojar el código de la extensión. Por ejemplo, ``virtualenvwrapper/user_scripts.py``. El módulo debe contener la extensión -actual a los *entry points*. Soporte de código puede ser incluído, o importado +actual a los *entry points*. Soporte de código puede ser incluido, o importado desde algún lugar usando la técnica de organización de código estándar de Python. FIXME: I don't like the last paragraph La API es la misma para todos los puntos de extensión. Cada uno usa una función -de Python que toma un sólo argumento, una lista de string pasada al script que +de Python que toma un sólo argumento, una lista de strings pasada al script que carga los ganchos en la línea de comandos. :: @@ -96,8 +96,8 @@ Acción directa ~~~~~~~~~~~~~~ Los plugins pueden ser colgados a cada uno de los ganchos de dos formas -diferentes. La estándar es tener una función y hacer algún trabajo diréctamente. -Por ejemplo, la función ``initialize()`` para el pluging de los scripts de +diferentes. La estándar es tener una función y hacer algún trabajo directamente. +Por ejemplo, la función ``initialize()`` para el plugin de los scripts de usuarios crea scripts de usuarios por default cuando ``virtualenvwrapper.sh`` es cargada. @@ -151,10 +151,10 @@ shell actual. virtualenvwrapper funciona en varios shells con una sintaxis ligeramente diferente (bash, sh, zsh, ksh). Ten en cuenta esta portabilidad cuando - definas ganchos incluídos (*sourced hooks*). Mantener la sintaxis lo más simple + definas ganchos incluidos (*sourced hooks*). Mantener la sintaxis lo más simple posible evitará problemas comunes, pero quizás haya casos donde - examinar la varible de entorno ``SHELL`` y generar diferente sintaxis - para cada caso sea la única manera de alcanzar el resultado desedo. + examinar la variable de entorno ``SHELL`` y generar diferente sintaxis + para cada caso sea la única manera de alcanzar el resultado deseado. Registrar puntos de entrada --------------------------- @@ -215,16 +215,11 @@ es el nombre del plugin, pero esto no es requerido (los nombres no son usados). El cargador de ganchos ---------------------- -Las extenciones son ejecutadas mediante una aplicación de líneas de comando +Las extensiones son ejecutadas mediante una aplicación de líneas de comando implementada en ``virtualenvwrapper.hook_loader``. Como ``virtualenvwrapper.sh`` -es - - -Extensions are run through a command line application implemented in -``virtualenvwrapper.hook_loader``. Because ``virtualenvwrapper.sh`` -is the primary caller and users do not typically need to run the app -directly, no separate script is installed. Instead, to run the -application, use the ``-m`` option to the interpreter:: +es invocado primero y los usuarios generalmente no necesitan ejecutar la +aplicación directamente, ningún otro script es instalado por separado. En vez, +para ejecutar la aplicación, usa la opción ``-m`` del intérprete:: $ python -m virtualenvwrapper.hook_loader -h Usage: virtualenvwrapper.hook_loader [options] [] @@ -292,7 +287,7 @@ Puntos de extensión =================== Los nombres de los puntos de extensión para los plugins nativos siguen una -convensión con varias partes: +convención con varias partes: ``virtualenvwrapper.(pre|post)_[_source]``. ** es la acción tomada por el usuario o virtualenvwrapper que provoca la extensión. ``(pre|post)`` indica si llama a la extensión antes o después de un evento. El sufijo ``_source`` From 3b43adbe520be28dd547c9c46469c7e63dc60126 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Sat, 24 Apr 2010 16:34:46 -0300 Subject: [PATCH 256/947] markup fix --- docs/es/hooks.rst | 4 ++-- docs/es/scripts.rst | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/es/hooks.rst b/docs/es/hooks.rst index 04830b8..10193fa 100644 --- a/docs/es/hooks.rst +++ b/docs/es/hooks.rst @@ -1,6 +1,6 @@ -============================== +================================ Personalizar Virtualenvwrapper -============================== +================================ virtualenvwrapper agrega varios ganchos que puedes usar para cambiar tus configuraciones, el entorno del shell, u otras configuraciones al crear, diff --git a/docs/es/scripts.rst b/docs/es/scripts.rst index a2f3e8a..ac3598f 100644 --- a/docs/es/scripts.rst +++ b/docs/es/scripts.rst @@ -1,8 +1,8 @@ .. _scripts: -============================= +=============================== Personalizaciones por usuario -============================= +=============================== Los scripts de personalización de usuarios finales son *incluidos* uno por uno (permitiéndoles modificar su entorno de shell) o *ejecutados* como un programa externo From 506512d86ffc3160cf854af1d33df03be703fc66 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Sat, 24 Apr 2010 16:47:39 -0300 Subject: [PATCH 257/947] index revision --- docs/es/index.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/es/index.rst b/docs/es/index.rst index 213a32c..1f2906f 100644 --- a/docs/es/index.rst +++ b/docs/es/index.rst @@ -17,7 +17,7 @@ de un proyecto al mismo tiempo sin introducir conflictos entre sus dependencias. Características =============== -1. Organiza todos tus entornos virtuales en un sólo lugar +1. Organiza todos tus entornos virtuales en un sólo lugar. 2. Funciones para administrar tus entornos virtuales (crear, eliminar, copiar). 3. Usa un sólo comando para cambiar entre los entornos. 4. Completa con Tab los comandos que toman un entorno virtual como argumento. @@ -30,7 +30,7 @@ Introducción ============ La mejor forma de explicar las características que virtualenvwrapper brinda es -mostrar éste en uso. +mostrarlo en acción. Primero, algunos pasos de inicialización. La mayoría de esto sólo necesita ser hecho una sola vez. Vas a querer agregar el comando ``source @@ -156,8 +156,8 @@ dejándote instalar automáticamente herramientas comúnmente utilizadas. (venv3)$ which sphinx-build /Users/dhellmann/Envs/env3/bin/sphinx-build -A través de una combinación de funciones existentes definidas por el "core" -package (ver :ref:`command`), plugins de terceros (ver +A través de una combinación de funciones existentes definidas por el *core* +del paquete (ver :ref:`command`), plugins de terceros (ver :ref:`plugins`), y scripts definidos por el usuario (ver :ref:`scripts`) virtualenvwrapper brinda una amplia variedad de oportunidades para automatizar tareas repetitivas. From 55933610fa924de20f41d08fb0cab0d9c03740c1 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Sat, 24 Apr 2010 17:00:32 -0300 Subject: [PATCH 258/947] first revision --- docs/es/command_ref.rst | 8 ++++---- docs/es/install.rst | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/es/command_ref.rst b/docs/es/command_ref.rst index 94960ae..0b8384d 100644 --- a/docs/es/command_ref.rst +++ b/docs/es/command_ref.rst @@ -7,8 +7,8 @@ Referencia de comandos ###################### -Todos los comandos a continuación son para ser utilizados en una Terminal de -línea de comandos. +Todos los comandos, mostrados a continuación, son para ser utilizados +en una Terminal de línea de comandos. ==================== Administrar entornos @@ -128,7 +128,7 @@ Sintaxis:: workon [environment_name] -Si no se especifica el ``environment_name`` la lista de entornos disponibles es +Si no se especifica el ``environment_name``, la lista de entornos disponibles es impresa en la salida estándar. :: @@ -308,7 +308,7 @@ Sintaxis:: add2virtualenv directory1 directory2 ... -A veces esto es conveniente compartir paquetes instalados que no están en el +A veces esto es útli para compartir paquetes instalados que no están en el directorio ``site-pacakges`` del sistema y no deben ser instalados en cada entorno virtual. Una posible solución es crear enlaces simbólicos (*symlinks*) hacia el código dentro del directorio ``site-packages`` del entorno, pero diff --git a/docs/es/install.rst b/docs/es/install.rst index f358bcf..9c3fd2a 100644 --- a/docs/es/install.rst +++ b/docs/es/install.rst @@ -5,7 +5,7 @@ Instalación Instalación básica ================== -virtualenvwrapper debe se instalado usando pip_:: +virtualenvwrapper debe ser instalado usando pip_:: $ pip install virtualenvwrapper @@ -32,7 +32,7 @@ y los scripts instalados con este paquete:: export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh -Después de editar este, recarga el archivo de inicio (e.g., ejecuta: ``source +Después de editar este, recarga el archivo de inicio (por ejemplo, ejecuta: ``source ~/.bashrc``). Intérprete de Python y $PATH @@ -77,7 +77,7 @@ Actualizar desde 1.x ==================== El script de shell que contiene las funciones ha sido renombrado en la serie -2.x para reflejar el hecho de que otros shell además de bash son soportados. En +2.x para reflejar el hecho de que otros shells, además de bash, son soportados. En tu archivo de inicio del shell, cambia ``source /usr/local/bin/virtualenvwrapper_bashrc`` por ``source /usr/local/bin/virtualenvwrapper.sh``. From f81c6fc87019e56a0596c4f6a1605f4fe9021dfe Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Sat, 24 Apr 2010 17:32:53 -0300 Subject: [PATCH 259/947] README translated --HG-- rename : README.txt => README.es.txt --- README.es.txt | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 README.es.txt diff --git a/README.es.txt b/README.es.txt new file mode 100644 index 0000000..55158cf --- /dev/null +++ b/README.es.txt @@ -0,0 +1,92 @@ +.. -*- mode: rst -*- + +################# +virtualenvwrapper +################# + +virtualenvwrapper es un conjunto de extensiones de la herramienta de Ian +Bicking `virtualenv `_. Las extensiones +incluyen funciones para la creación y eliminación de entornos virtuales y por otro +lado administración de tu rutina de desarrollo, haciendo fácil trabajar en más +de un proyecto al mismo tiempo sin introducir conflictos entre sus dependencias. + + + +virtualenvwrapper is a set of extensions to Ian Bicking's `virtualenv +`_ tool. The extensions include +wrappers for creating and deleting virtual environments and otherwise +managing your development workflow, making it easier to work on more +than one project at a time without introducing conflicts in their +dependencies. + +=============== +Características +=============== + +1. Organiza todos tus entornos virtuales en un sólo lugar. + +2. Funciones para administrar tus entornos virtuales (crear, eliminar, copiar). + +3. Usa un sólo comando para cambiar entre los entornos. + +4. Completa con Tab los comandos que toman un entorno virtual como argumento. + +5. Ganchos configurables para todas las operaciones. + +6. Sistema de plugins para la creación de extensiones compartibles. + +Rich Leland ha grabado un pequeño `screencast +`__ +mostrando las características de virtualenvwrapper. + + +=========== +Instalación +=========== + +Ve a la `documentación del proyecto `__ +para las instrucciones de instalación y configuración. + +Actualizar desde 1.x +==================== + +El script de shell que contiene las funciones ha sido renombrado en la serie +2.x para reflejar el hecho de que otros shells, además de bash, son soportados. En +tu archivo de inicio del shell, cambia ``source +/usr/local/bin/virtualenvwrapper_bashrc`` por ``source +/usr/local/bin/virtualenvwrapper.sh``. + +============== +Contribuciones +============== + +Antes de contribuir con nuevas características al *core* de virtualenvwrapper, +por favor considera, en vez, si no debe ser implementada como una extensión. + +Ve a la `documentación para desarrolladores +`__ +por trucos sobre parches. + +======== +Licencia +======== + +Copyright Doug Hellmann, All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Doug Hellmann not be used +in advertising or publicity pertaining to distribution of the software +without specific, written prior permission. + +DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + +.. _BitBucket: http://bitbucket.org/dhellmann/virtualenvwrapper/overview/ From 0116a64461587999cbd519b8bb2f3b20963d8b25 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Sat, 24 Apr 2010 17:34:19 -0300 Subject: [PATCH 260/947] english paragraph removed --- README.es.txt | 9 --------- 1 file changed, 9 deletions(-) diff --git a/README.es.txt b/README.es.txt index 55158cf..b9d9b24 100644 --- a/README.es.txt +++ b/README.es.txt @@ -10,15 +10,6 @@ incluyen funciones para la creación y eliminación de entornos virtuales y por lado administración de tu rutina de desarrollo, haciendo fácil trabajar en más de un proyecto al mismo tiempo sin introducir conflictos entre sus dependencias. - - -virtualenvwrapper is a set of extensions to Ian Bicking's `virtualenv -`_ tool. The extensions include -wrappers for creating and deleting virtual environments and otherwise -managing your development workflow, making it easier to work on more -than one project at a time without introducing conflicts in their -dependencies. - =============== Características =============== From e36d87690755c28795298f7943c45ef3701604cd Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Sat, 24 Apr 2010 17:55:04 -0300 Subject: [PATCH 261/947] announce translation --HG-- rename : announce.rst => announce.es.rst --- announce.es.rst | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 announce.es.rst diff --git a/announce.es.rst b/announce.es.rst new file mode 100644 index 0000000..345a902 --- /dev/null +++ b/announce.es.rst @@ -0,0 +1,45 @@ +¿Qué es virtualenvwrapper? +========================== + +virtualenvwrapper es un conjunto de extensiones de la herramienta de Ian +Bicking `virtualenv `_. Las extensiones +incluyen funciones para la creación y eliminación de entornos virtuales y por otro +lado administración de tu rutina de desarrollo, haciendo fácil trabajar en más +de un proyecto al mismo tiempo sin introducir conflictos entre sus dependencias. + + +¿Qué es lo nuevo en 2.1? +======================== + +El principal propósito de esta *release* es un conjunto de mejoras para soportar +virtualenvwrapper.project_, una nueva extensión para administrar los directorios +de trabajo para los proyectos con plantillas. 2.1 también incluye pequeños +cambios y corrección de bugs. + +- Agregado soporte para ksh. Gracias a Doug Latornell por hacer la investigación + sobre qué era necesario cambiar. +- Testeo de importación de virtualenvwrapper.hook_loader en el inicio que reporta + el error de manera que debería ayudar al usuario a resolver cómo solucionarlo + (ticket #33). +- Actualizada la documentación de mkvirtualenv para incluir el hecho de que un + nuevo entorno es activado inmediatamente luego de que es creado (ticket #30). +- Agregados ganchos alrededor cpvirtualenv. +- deactivation es más robusto, especialmente bajo ksh. +- Uso del módulo de Python ``tempfile`` para creación de archivos temporales + de forma segura y portable. +- Corregido un problema con ``virtualenvwrapper_show_workon_options`` que + causaba que este muestre ``*`` como el nombre de un virtualenv cuando no había + entornos creados todavía. +- Cambio en el cargador de ganchos para que pueda ejecutar sólo un conjunto de + ganchos nombrados. +- Agregado soporte para listar los ganchos disponibles, para ser usado en la + ayuda de los comandos como mkproject en virtualenvwrapper.project. +- Corregida la opción -h de mkvirtualenv. +- Cambiado el registro para que $WORKON_HOME/hook.log rote después de 10KiB. + + +.. _virtualenv: http://pypi.python.org/pypi/virtualenv + +.. _virtualenvwrapper: http://www.doughellmann.com/projects/virtualenvwrapper/ + +.. _virtualenvwrapper.project: http://www.doughellmann.com/projects/virtualenvwrapper.project/ From 3aff5201bc790bda9010a9f519d1c7d6778051b1 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Sat, 24 Apr 2010 17:57:43 -0300 Subject: [PATCH 262/947] added italic to deactivation --- announce.es.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/announce.es.rst b/announce.es.rst index 345a902..e9cec37 100644 --- a/announce.es.rst +++ b/announce.es.rst @@ -24,7 +24,7 @@ cambios y corrección de bugs. - Actualizada la documentación de mkvirtualenv para incluir el hecho de que un nuevo entorno es activado inmediatamente luego de que es creado (ticket #30). - Agregados ganchos alrededor cpvirtualenv. -- deactivation es más robusto, especialmente bajo ksh. +- *deactivation* es más robusto, especialmente bajo ksh. - Uso del módulo de Python ``tempfile`` para creación de archivos temporales de forma segura y portable. - Corregido un problema con ``virtualenvwrapper_show_workon_options`` que From 659748fc78fe24c0003aff6f882412ca3fc4b8e8 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 26 Apr 2010 09:59:56 -0400 Subject: [PATCH 263/947] another attempt to address #35 --- ChangeLog | 5 +++++ Makefile | 1 + tests/test_tempfile.sh | 8 ++++---- virtualenvwrapper.sh | 11 +++++++---- 4 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 ChangeLog diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..c67b4b9 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,5 @@ +2010-04-26 Doug Hellmann + + * virtualenvwrapper.sh (virtualenvwrapper_tempfile): Add a suffix + to the tempfile name so we know the tempfile module isn't going to + erase it. diff --git a/Makefile b/Makefile index ceb4654..b3a6bb0 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,7 @@ help: @echo "website - build web version of docs" @echo "installwebsite - deploy web version of docs" @echo "develop - install development version" + @echo "test - run the test suite" .PHONY: sdist diff --git a/tests/test_tempfile.sh b/tests/test_tempfile.sh index c2f812e..da53e67 100644 --- a/tests/test_tempfile.sh +++ b/tests/test_tempfile.sh @@ -23,7 +23,7 @@ setUp () { } test_tempfile () { - filename=$(virtualenvwrapper_tempfile) + filename=$(virtualenvwrapper_tempfile hook) rm -f $filename assertSame "$TMPDIR" "$(dirname $filename)/" assertTrue "echo $filename | grep virtualenvwrapper" @@ -32,11 +32,11 @@ test_tempfile () { test_no_python () { old=$VIRTUALENVWRAPPER_PYTHON VIRTUALENVWRAPPER_PYTHON=false - filename=$(virtualenvwrapper_tempfile) + filename=$(virtualenvwrapper_tempfile hook) VIRTUALENVWRAPPER_PYTHON=$old rm -f $filename - assertSame "$TMPDIR" "$(dirname $filename)/" - assertTrue "echo $filename | grep virtualenvwrapper.$$" + assertSame "TMPDIR and path not the same for $filename." "$TMPDIR" "$(dirname $filename)/" + assertTrue "virtualenvwrapper and pid not in filename." "echo $filename | grep virtualenvwrapper.$$" } . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 6c16b68..b8910c4 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -76,11 +76,14 @@ virtualenvwrapper_verify_workon_home () { # Use Python's tempfile module to create a temporary file # with a unique and not-likely-to-be-predictable name. +# Expects 1 argument, the suffix for the new file. virtualenvwrapper_tempfile () { - $VIRTUALENVWRAPPER_PYTHON -c "import tempfile; print tempfile.NamedTemporaryFile(prefix='virtualenvwrapper.').name" - if [ $? -ne 0 ] + typeset base=$("$VIRTUALENVWRAPPER_PYTHON" -c "import tempfile; print tempfile.NamedTemporaryFile(prefix='virtualenvwrapper.').name") + if [ -z "$base" ] then - echo "${TMPDIR:-/tmp}/virtualenvwrapper.$$.`date +%s`" + echo "${TMPDIR:-/tmp}/virtualenvwrapper.$$.`date +%s`.$1" + else + echo "$base.$1" fi } @@ -89,7 +92,7 @@ virtualenvwrapper_run_hook () { # First anything that runs directly from the plugin "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION "$@" # Now anything that wants to run inside this shell - hook_script=$(virtualenvwrapper_tempfile) + hook_script="$(virtualenvwrapper_tempfile hook)" "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION \ --source "$@" >>"$hook_script" source "$hook_script" From 7173ed02a14420cb89f021ee2417a0cebc5164fb Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 27 Apr 2010 08:21:32 -0400 Subject: [PATCH 264/947] shift output directory for html build so the sdist package looks nicer --- .hgignore | 1 + Makefile | 9 +++- docs/Makefile | 114 +++++++++++++++++++++++++------------------------- 3 files changed, 65 insertions(+), 59 deletions(-) diff --git a/.hgignore b/.hgignore index 9a97f53..d203a1e 100644 --- a/.hgignore +++ b/.hgignore @@ -6,6 +6,7 @@ dist distribute*.egg distribute*.tar.gz docs/build +docs/html docs/website tests/catch_output tests/testpackage/build diff --git a/Makefile b/Makefile index 7e0bd82..089bd7c 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ SUPPORTED_SHELLS=bash sh ksh zsh help: @echo "sdist - Source distribution" @echo "html - HTML documentation" + @echo "docclean - Remove documentation build files" @echo "register - register a new release on PyPI" @echo "website - build web version of docs" @echo "installwebsite - deploy web version of docs" @@ -33,15 +34,19 @@ sdist: html # Documentation .PHONY: html html: - (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/pkg") + (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/pkg" LANGUAGE="en") (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/pkg" LANGUAGE="es") +.PHONY: docclean +docclean: + rm -rf docs/build docs/html + # Website copy of documentation .PHONY: website website: [ ~/Devel/doughellmann/doughellmann/templates/base.html -nt docs/sphinx/web/templates/base.html ] && (echo "Updating base.html" ; cp ~/Devel/doughellmann/doughellmann/templates/base.html docs/sphinx/web/templates/base.html) || exit 0 rm -rf docs/website - (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/web" BUILDDIR="website/en") + (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/web" BUILDDIR="website/en" LANGUAGE="en") (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/web" BUILDDIR="website/es" LANGUAGE="es") installwebsite: website diff --git a/docs/Makefile b/docs/Makefile index 1de19bd..857f3d9 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -8,12 +8,12 @@ LANGUAGE = en SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = -BUILDDIR = build/$(LANGUAGE) +BUILDDIR = html/$(LANGUAGE) # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(LANGUAGE) +ALLSPHINXOPTS = -d build/$(LANGUAGE)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(LANGUAGE) .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest @@ -34,59 +34,59 @@ clean: -rm -rf $(BUILDDIR)/* html: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR) @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." - -dirhtml: - $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." - -pickle: - $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle - @echo - @echo "Build finished; now you can process the pickle files." - -json: - $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json - @echo - @echo "Build finished; now you can process the JSON files." - -htmlhelp: - $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp - @echo - @echo "Build finished; now you can run HTML Help Workshop with the" \ - ".hhp project file in $(BUILDDIR)/htmlhelp." - -qthelp: - $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp - @echo - @echo "Build finished; now you can run "qcollectiongenerator" with the" \ - ".qhcp project file in $(BUILDDIR)/qthelp, like this:" - @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/virtualenvwrapper.qhcp" - @echo "To view the help file:" - @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/virtualenvwrapper.qhc" - -latex: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo - @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." - @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ - "run these through (pdf)latex." - -changes: - $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes - @echo - @echo "The overview file is in $(BUILDDIR)/changes." - -linkcheck: - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck - @echo - @echo "Link check complete; look for any errors in the above output " \ - "or in $(BUILDDIR)/linkcheck/output.txt." - -doctest: - $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest - @echo "Testing of doctests in the sources finished, look at the " \ - "results in $(BUILDDIR)/doctest/output.txt." + @echo "Build finished. The HTML pages are in $(BUILDDIR)." + +# dirhtml: +# $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml +# @echo +# @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +# pickle: +# $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle +# @echo +# @echo "Build finished; now you can process the pickle files." + +# json: +# $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json +# @echo +# @echo "Build finished; now you can process the JSON files." + +# htmlhelp: +# $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp +# @echo +# @echo "Build finished; now you can run HTML Help Workshop with the" \ +# ".hhp project file in $(BUILDDIR)/htmlhelp." + +# qthelp: +# $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp +# @echo +# @echo "Build finished; now you can run "qcollectiongenerator" with the" \ +# ".qhcp project file in $(BUILDDIR)/qthelp, like this:" +# @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/virtualenvwrapper.qhcp" +# @echo "To view the help file:" +# @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/virtualenvwrapper.qhc" + +# latex: +# $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex +# @echo +# @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." +# @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ +# "run these through (pdf)latex." + +# changes: +# $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes +# @echo +# @echo "The overview file is in $(BUILDDIR)/changes." + +# linkcheck: +# $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck +# @echo +# @echo "Link check complete; look for any errors in the above output " \ +# "or in $(BUILDDIR)/linkcheck/output.txt." + +# doctest: +# $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest +# @echo "Testing of doctests in the sources finished, look at the " \ +# "results in $(BUILDDIR)/doctest/output.txt." From 43169488979969eb6ff879e66c85b9c32a83d3e4 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 27 Apr 2010 08:27:29 -0400 Subject: [PATCH 265/947] add link from english to spanish docs; update history --- Makefile | 4 ++-- docs/en/history.rst | 7 +++++++ docs/en/index.rst | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 089bd7c..884ebfb 100644 --- a/Makefile +++ b/Makefile @@ -50,8 +50,8 @@ website: (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/web" BUILDDIR="website/es" LANGUAGE="es") installwebsite: website - (cd docs/website/en/html && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper/) - (cd docs/website/es/html && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper/es/) + (cd docs/website/en && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper/) + (cd docs/website/es && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper/es/) # Register the new version on pypi .PHONY: register diff --git a/docs/en/history.rst b/docs/en/history.rst index 0636f95..0be9d81 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,13 @@ Release History =============== +Dev + + - Added `Spanish translation for the documentation + `__ via + Manuel Kaufmann's fork at + http://bitbucket.org/humitos/virtualenvwrapper-es-translation/ + 2.1 - Add support for ksh. Thanks to Doug Latornell for doing the diff --git a/docs/en/index.rst b/docs/en/index.rst index c760cf1..1bbade4 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -198,6 +198,9 @@ Rich Leland has created a short `screencast `__ showing off the features of virtualenvwrapper. +Manuel Kaufmann has `translated this documentation into Spanish +`__. + ======= License ======= From 3bb2835a9583c3e6a6b028d49f804b65d23b3616 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 27 Apr 2010 08:31:54 -0400 Subject: [PATCH 266/947] add attribution for Manuel --- docs/es/index.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/es/index.rst b/docs/es/index.rst index 1f2906f..3ed7fa1 100644 --- a/docs/es/index.rst +++ b/docs/es/index.rst @@ -216,3 +216,8 @@ CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +.. note:: + + Esta traducción fue preparada por `Manuel Kaufmann + `__. From fc98595e015a77cf101b0c5c8ed32fd84a703d56 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 27 Apr 2010 08:34:02 -0400 Subject: [PATCH 267/947] add link back to english docs --- docs/es/index.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/es/index.rst b/docs/es/index.rst index 3ed7fa1..d5af834 100644 --- a/docs/es/index.rst +++ b/docs/es/index.rst @@ -221,3 +221,9 @@ PERFORMANCE OF THIS SOFTWARE. Esta traducción fue preparada por `Manuel Kaufmann `__. + +.. seealso:: + + The original `English version + `__ of the + documentation. From db3b6a5893063a0c0916841ceaaa186458ee0de3 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 27 Apr 2010 08:38:59 -0400 Subject: [PATCH 268/947] link to Manuel's home page instead of just the translation --- docs/es/index.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/es/index.rst b/docs/es/index.rst index d5af834..c17b844 100644 --- a/docs/es/index.rst +++ b/docs/es/index.rst @@ -220,10 +220,13 @@ PERFORMANCE OF THIS SOFTWARE. .. note:: Esta traducción fue preparada por `Manuel Kaufmann - `__. + `__. .. seealso:: + `La traducción al español + `__ + The original `English version `__ of the documentation. From 404b5cf5c34c886e35d56e73749adda4e557fbbe Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 27 Apr 2010 08:40:49 -0400 Subject: [PATCH 269/947] fix formatting of seealso block --- docs/es/index.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/es/index.rst b/docs/es/index.rst index c17b844..c9045c9 100644 --- a/docs/es/index.rst +++ b/docs/es/index.rst @@ -224,9 +224,8 @@ PERFORMANCE OF THIS SOFTWARE. .. seealso:: - `La traducción al español - `__ + * `La traducción al español `__ - The original `English version - `__ of the - documentation. + * The original `English version + `__ of the + documentation. From b216a86bc9db491ff35ef8babba50e6c0132b29b Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 29 Apr 2010 21:04:16 -0400 Subject: [PATCH 270/947] fix #41 by using the cached python where the wrappers are installed --- ChangeLog | 8 ++++++++ docs/en/history.rst | 3 +++ virtualenvwrapper.sh | 5 ++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c67b4b9..cbfd0a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-04-29 Doug Hellmann + + * virtualenvwrapper.sh (virtualenvwrapper_get_python_version): Add + a comment about why we're using the $PATH python instead of the + one where the wrappers are installed. + (add2virtualenv): Use the install-tree python instead of the one + from $PATH. + 2010-04-26 Doug Hellmann * virtualenvwrapper.sh (virtualenvwrapper_tempfile): Add a suffix diff --git a/docs/en/history.rst b/docs/en/history.rst index 0be9d81..0a8c56d 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -8,6 +8,9 @@ Dev `__ via Manuel Kaufmann's fork at http://bitbucket.org/humitos/virtualenvwrapper-es-translation/ + - Fixed improper use of python from ``$PATH`` instead of the + location where the wrappers are installed. See `issue #41 + `__. 2.1 diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index b8910c4..e4286f1 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -308,6 +308,9 @@ fi # Prints the Python version string for the current interpreter. virtualenvwrapper_get_python_version () { + # Uses the Python from the virtualenv because we're trying to + # determine the version installed there so we can build + # up the path to the site-packages directory. python -c 'import sys; print ".".join(str(p) for p in sys.version_info[:2])' } @@ -357,7 +360,7 @@ add2virtualenv () { touch "$path_file" for pydir in "$@" do - absolute_path=$(python -c "import os; print os.path.abspath(\"$pydir\")") + absolute_path=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os; print os.path.abspath(\"$pydir\")") if [ "$absolute_path" != "$pydir" ] then echo "Warning: Converting \"$pydir\" to \"$absolute_path\"" 1>&2 From fd109f6861690068b341959b420eaadad2755fb6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 29 Apr 2010 22:53:50 -0400 Subject: [PATCH 271/947] fix #42 by quieting the errors/warnings --- ChangeLog | 7 +++++ docs/en/history.rst | 3 ++ tests/test_deactivate.sh | 60 ++++++++++++++++++++++++++++++++++++++++ tests/test_workon.sh | 35 ----------------------- virtualenvwrapper.sh | 4 +-- 5 files changed, 72 insertions(+), 37 deletions(-) create mode 100644 tests/test_deactivate.sh diff --git a/ChangeLog b/ChangeLog index cbfd0a4..2f4dc17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,17 @@ 2010-04-29 Doug Hellmann + * tests/test_workon.sh: Refactor deactivate tests into their own + script. + + * tests/test_deactivate.sh: Refactor deactivate tests into their + own script. + * virtualenvwrapper.sh (virtualenvwrapper_get_python_version): Add a comment about why we're using the $PATH python instead of the one where the wrappers are installed. (add2virtualenv): Use the install-tree python instead of the one from $PATH. + (deactivate): Ignore errors from redundant unset calls. 2010-04-26 Doug Hellmann diff --git a/docs/en/history.rst b/docs/en/history.rst index 0a8c56d..6ad9da7 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -11,6 +11,9 @@ Dev - Fixed improper use of python from ``$PATH`` instead of the location where the wrappers are installed. See `issue #41 `__. + - Quiet spurrious error/warning messages when deactivating a + virtualenv under zsh. See `issue #42 + `__. 2.1 diff --git a/tests/test_deactivate.sh b/tests/test_deactivate.sh new file mode 100644 index 0000000..b07c98e --- /dev/null +++ b/tests/test_deactivate.sh @@ -0,0 +1,60 @@ +#!/bin/sh + +#set -x + +test_dir=$(dirname $0) + +export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" + mkvirtualenv "env1" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +test_deactivate () { + workon env1 + assertNotNull "$VIRTUAL_ENV" + deactivate + assertNull "$VIRTUAL_ENV" + assertFalse virtualenvwrapper_verify_active_environment +} + +test_deactivate_hooks () { + workon env1 + + for t in pre post + do + echo "echo GLOBAL ${t}deactivate \$VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV >> $test_dir/catch_output" > "$WORKON_HOME/${t}deactivate" + echo "echo ENV ${t}deactivate \$VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV >> $test_dir/catch_output" > "$WORKON_HOME/env1/bin/${t}deactivate" + done + + touch "$test_dir/catch_output" + + deactivate + + output=$(cat "$test_dir/catch_output") + expected="ENV predeactivate +GLOBAL predeactivate +ENV postdeactivate $WORKON_HOME/env1 +GLOBAL postdeactivate $WORKON_HOME/env1" + assertSame "$expected" "$output" + + for t in pre post + do + rm -f "$WORKON_HOME/env1/bin/${t}activate" + rm -f "$WORKON_HOME/${t}activate" + done +} + +. "$test_dir/shunit2" diff --git a/tests/test_workon.sh b/tests/test_workon.sh index 4b4e62f..ca18c33 100644 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -57,41 +57,6 @@ ENV postactivate" done } -test_deactivate () { - workon env1 - assertNotNull "$VIRTUAL_ENV" - deactivate - assertNull "$VIRTUAL_ENV" - assertFalse virtualenvwrapper_verify_active_environment -} - -test_deactivate_hooks () { - workon env1 - - for t in pre post - do - echo "echo GLOBAL ${t}deactivate \$VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV >> $test_dir/catch_output" > "$WORKON_HOME/${t}deactivate" - echo "echo ENV ${t}deactivate \$VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV >> $test_dir/catch_output" > "$WORKON_HOME/env1/bin/${t}deactivate" - done - - touch "$test_dir/catch_output" - - deactivate - - output=$(cat "$test_dir/catch_output") - expected="ENV predeactivate -GLOBAL predeactivate -ENV postdeactivate $WORKON_HOME/env1 -GLOBAL postdeactivate $WORKON_HOME/env1" - assertSame "$expected" "$output" - - for t in pre post - do - rm -f "$WORKON_HOME/env1/bin/${t}activate" - rm -f "$WORKON_HOME/${t}activate" - done -} - test_virtualenvwrapper_show_workon_options () { mkdir "$WORKON_HOME/not_env" (cd "$WORKON_HOME"; ln -s env1 link_env) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index e4286f1..e9ec6b1 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -262,8 +262,8 @@ workon () { if [ ! "$1" = "nondestructive" ] then # Remove this function - unset -f virtualenv_deactivate - unset -f deactivate + unset -f virtualenv_deactivate >/dev/null 2>&1 + unset -f deactivate >/dev/null 2>&1 fi }' From a8a36b8c4a3b17519e247bc3e3babec58de7476f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 29 Apr 2010 22:55:43 -0400 Subject: [PATCH 272/947] setting up for a release --- docs/en/history.rst | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 6ad9da7..2579be6 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,7 +2,7 @@ Release History =============== -Dev +2.1.1 - Added `Spanish translation for the documentation `__ via diff --git a/setup.py b/setup.py index 3e67b94..63d040f 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' -VERSION = '2.1' +VERSION = '2.1.1' # Bootstrap installation of Distribute import distribute_setup From ffe290b26158ff3baa1cb64586cb7f5b8095acd8 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 29 Apr 2010 22:55:54 -0400 Subject: [PATCH 273/947] Added tag 2.1.1 for changeset 7540fc7d8e63 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 7089e1a..1ee9f1e 100644 --- a/.hgtags +++ b/.hgtags @@ -50,3 +50,4 @@ d64869519c2e0553303cfeeb0918271564c72beb 1.27 91e1124c68315f8cdc6578c4f72e3ed9c44e1fca 2.0.1 6a51a81454ae9dde5d923668ad5f034b3467fe11 2.0.2 241df6c36860c13fae5468881457a27840ee9d72 2.1 +7540fc7d8e63cafe6c3126e0855ed8c277b450cf 2.1.1 From 24c821d96c71b0c749cb04f585a7ad038fa342d7 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 2 May 2010 10:12:51 -0400 Subject: [PATCH 274/947] fix #43 by switching the way the hook loader is run --- ChangeLog | 5 +++++ Makefile | 20 ++++++++++++++------ docs/en/history.rst | 6 ++++++ virtualenvwrapper.sh | 4 ++-- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2f4dc17..d75afc2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-05-02 Doug Hellmann + + * virtualenvwrapper.sh (virtualenvwrapper_run_hook): Instead of + -m, use -c so hooks can be run under Python 2.4. + 2010-04-29 Doug Hellmann * tests/test_workon.sh: Refactor deactivate tests into their own diff --git a/Makefile b/Makefile index 884ebfb..3d85db9 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,18 @@ # Get the version of the app. This is used in the doc build. export VERSION=$(shell python setup.py --version) +# Locations of Python interpreter binaries +PYTHON26=/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 +PYTHON25=/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5 +PYTHON24=/Users/dhellmann/Devel/virtualenvwrapper/Python/2.4.6/bin/python2.4 + # The main version of Python supported. -PRIMARY_PYTHON_VERSION=2.6 +PRIMARY_PYTHON_VERSION=$(PYTHON26) # The test-quick pattern changes the definition of # this variable to only run against a single version of python. -ifeq ($(SUPPORTED_PYTHON_VERSIONS),) -SUPPORTED_PYTHON_VERSIONS=2.5 2.6 +ifeq ($(PYTHON_BINARIES),) +PYTHON_BINARIES=$(PRIMARY_PYHTON_VERSION) $(PYTHON25) $(PYTHON24) endif SUPPORTED_SHELLS=bash sh ksh zsh @@ -81,9 +86,9 @@ test-zsh: # - Install virtualenvwrapper into the new virtualenv # - Run each test script in tests test-loop: - for py_ver in $(SUPPORTED_PYTHON_VERSIONS) ; do \ + for py_bin in $(PYTHON_BINARIES) ; do \ (cd $$TMPDIR/ && rm -rf virtualenvwrapper-test-env \ - && virtualenv -p /Library/Frameworks/Python.framework/Versions/$$py_ver/bin/python$$py_ver --no-site-packages virtualenvwrapper-test-env) \ + && virtualenv -p $$py_bin --no-site-packages virtualenvwrapper-test-env) \ || exit 1 ; \ $$TMPDIR/virtualenvwrapper-test-env/bin/python setup.py install || exit 1 ; \ for test_script in $(wildcard tests/test*.sh) ; do \ @@ -96,7 +101,10 @@ test-loop: done test-quick: - SUPPORTED_PYTHON_VERSIONS=$(PRIMARY_PYTHON_VERSION) $(MAKE) test-bash + PYTHON_BINARIES=$(PRIMARY_PYTHON_VERSION) $(MAKE) test-bash + +test-24: + PYTHON_BINARIES=$(PYTHON24) $(MAKE) test-bash test-install: bash ./tests/manual_test_install.sh `pwd`/dist "$(VERSION)" diff --git a/docs/en/history.rst b/docs/en/history.rst index 2579be6..fb9fa8e 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,12 @@ Release History =============== +Dev + + - Switched hook loader execution to a form that works with Python + 2.4 to resolve `issue 43 + `__. + 2.1.1 - Added `Spanish translation for the documentation diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index e9ec6b1..e1e5fa5 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -90,10 +90,10 @@ virtualenvwrapper_tempfile () { # Run the hooks virtualenvwrapper_run_hook () { # First anything that runs directly from the plugin - "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION "$@" + "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' $HOOK_VERBOSE_OPTION "$@" # Now anything that wants to run inside this shell hook_script="$(virtualenvwrapper_tempfile hook)" - "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader $HOOK_VERBOSE_OPTION \ + "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' $HOOK_VERBOSE_OPTION \ --source "$@" >>"$hook_script" source "$hook_script" rm -f "$hook_script" From 38ea4a93bdb27783dbf06c89a9dd2bc0af6ed061 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 2 May 2010 10:51:12 -0400 Subject: [PATCH 275/947] fix #44 by updating the tests to run with python 2.7b1 --- Makefile | 18 ++++++++++++------ docs/en/history.rst | 2 ++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 3d85db9..1bf65d1 100644 --- a/Makefile +++ b/Makefile @@ -2,17 +2,15 @@ export VERSION=$(shell python setup.py --version) # Locations of Python interpreter binaries +PYTHON27=/Users/dhellmann/Devel/virtualenvwrapper/Python/2.7b1/bin/python2.7 PYTHON26=/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 PYTHON25=/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5 PYTHON24=/Users/dhellmann/Devel/virtualenvwrapper/Python/2.4.6/bin/python2.4 -# The main version of Python supported. -PRIMARY_PYTHON_VERSION=$(PYTHON26) - # The test-quick pattern changes the definition of # this variable to only run against a single version of python. ifeq ($(PYTHON_BINARIES),) -PYTHON_BINARIES=$(PRIMARY_PYHTON_VERSION) $(PYTHON25) $(PYTHON24) +PYTHON_BINARIES=$(PYTHON26) $(PYTHON27) $(PYTHON25) $(PYTHON24) endif SUPPORTED_SHELLS=bash sh ksh zsh @@ -100,11 +98,19 @@ test-loop: done \ done -test-quick: - PYTHON_BINARIES=$(PRIMARY_PYTHON_VERSION) $(MAKE) test-bash +test-quick: test-26 test-24: PYTHON_BINARIES=$(PYTHON24) $(MAKE) test-bash +test-25: + PYTHON_BINARIES=$(PYTHON25) $(MAKE) test-bash + +test-26: + PYTHON_BINARIES=$(PYTHON26) $(MAKE) test-bash + +test-27: + PYTHON_BINARIES=$(PYTHON27) $(MAKE) test-bash + test-install: bash ./tests/manual_test_install.sh `pwd`/dist "$(VERSION)" diff --git a/docs/en/history.rst b/docs/en/history.rst index fb9fa8e..8bd8775 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -7,6 +7,8 @@ Dev - Switched hook loader execution to a form that works with Python 2.4 to resolve `issue 43 `__. + - Tested under Python 2.7b1. See `issue 44 + `__. 2.1.1 From f7fa4cb6bcf22d2b43051b771d60b26a97afdbec Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 2 May 2010 11:35:01 -0400 Subject: [PATCH 276/947] show python version in test progress messages --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1bf65d1..3536633 100644 --- a/Makefile +++ b/Makefile @@ -92,7 +92,7 @@ test-loop: for test_script in $(wildcard tests/test*.sh) ; do \ echo ; \ echo '********************************************************************************' ; \ - echo "Running $$test_script with $(TEST_SHELL) under Python $$py_ver" ; \ + echo "Running $$test_script with $(TEST_SHELL) under Python $(basename $$py_bin)" ; \ VIRTUALENVWRAPPER_PYTHON=$$TMPDIR/virtualenvwrapper-test-env/bin/python SHUNIT_PARENT=$$test_script $(TEST_SHELL) $$test_script || exit 1 ; \ echo ; \ done \ From a5dfd5b6363eb10d8c2493384f83bae42a6fa8ed Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Mon, 3 May 2010 10:51:43 -0300 Subject: [PATCH 277/947] review for text added by Doug about the translation --- docs/es/index.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/es/index.rst b/docs/es/index.rst index c9045c9..c78197d 100644 --- a/docs/es/index.rst +++ b/docs/es/index.rst @@ -100,7 +100,7 @@ Cambiar entre entornos con ``workon``:: (env2)$ workon env1 (env1)$ echo $VIRTUAL_ENV /Users/dhellmann/Envs/env1 - (env1)$ + (env1)$ El comando ``workon`` también incluye la opción de completar con Tab los nombres de los entornos, e invoca a los scripts personalizados cuando un entorno es @@ -152,7 +152,7 @@ dejándote instalar automáticamente herramientas comúnmente utilizadas. Installing sphinx-build script to /Users/dhellmann/Envs/env3/bin Installing sphinx-quickstart script to /Users/dhellmann/Envs/env3/bin Installing sphinx-autogen script to /Users/dhellmann/Envs/env3/bin - Successfully installed docutils Jinja2 Pygments sphinx (env3)$ + Successfully installed docutils Jinja2 Pygments sphinx (env3)$ (venv3)$ which sphinx-build /Users/dhellmann/Envs/env3/bin/sphinx-build @@ -219,7 +219,7 @@ PERFORMANCE OF THIS SOFTWARE. .. note:: - Esta traducción fue preparada por `Manuel Kaufmann + Esta traducción fue realizada por `Manuel Kaufmann `__. .. seealso:: From 58cca4899ecbc642f8b2635373307725eb555f65 Mon Sep 17 00:00:00 2001 From: David Wolever Date: Mon, 3 May 2010 19:49:29 -0400 Subject: [PATCH 278/947] First pass at speeding things up by making fewer calls into Python. Needs review. --- virtualenvwrapper.sh | 56 ++++++++++++++++++-------------- virtualenvwrapper/hook_loader.py | 34 +++++++++++++++++-- 2 files changed, 62 insertions(+), 28 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index e1e5fa5..9b77b63 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -57,10 +57,25 @@ then VIRTUALENVWRAPPER_PYTHON="$(which python)" fi -# Normalize the directory name in case it includes -# relative path components. -WORKON_HOME=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os; print os.path.abspath(os.path.expandvars(os.path.expanduser(\"$WORKON_HOME\")))") -export WORKON_HOME +# If the path is relative, prefix it with $HOME +# (note: for compatibility) +if echo "$WORKON_HOME" | grep -e '^[^/~]' +then + export WORKON_HOME="$HOME/$WORKON_HOME" +fi + +# Only call on Python to fix the path if it looks like the +# path might contain stuff to expand. +# (it might be possible to do this in shell, but I don't know a +# cross-shell-safe way of doing it -wolever) +if echo "$WORKON_HOME" | grep -e "[$~]" +then + # This will normalize the path by: + # - Expanding variables (eg, $foo) + # - Converting ~s to complete paths (eg, ~/ to /home/brian/ and ~arthur to /home/arthur) + WORKON_HOME=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os; print os.path.expandvars(os.path.expanduser(\"$WORKON_HOME\"))") + export WORKON_HOME +fi # Verify that the WORKON_HOME directory exists virtualenvwrapper_verify_workon_home () { @@ -74,43 +89,34 @@ virtualenvwrapper_verify_workon_home () { #HOOK_VERBOSE_OPTION="-v" -# Use Python's tempfile module to create a temporary file -# with a unique and not-likely-to-be-predictable name. # Expects 1 argument, the suffix for the new file. virtualenvwrapper_tempfile () { - typeset base=$("$VIRTUALENVWRAPPER_PYTHON" -c "import tempfile; print tempfile.NamedTemporaryFile(prefix='virtualenvwrapper.').name") - if [ -z "$base" ] - then - echo "${TMPDIR:-/tmp}/virtualenvwrapper.$$.`date +%s`.$1" - else - echo "$base.$1" - fi + tempfile "virtualenvwrapper-XXXXXX-$1" } # Run the hooks virtualenvwrapper_run_hook () { - # First anything that runs directly from the plugin - "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' $HOOK_VERBOSE_OPTION "$@" - # Now anything that wants to run inside this shell hook_script="$(virtualenvwrapper_tempfile hook)" - "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' $HOOK_VERBOSE_OPTION \ - --source "$@" >>"$hook_script" - source "$hook_script" - rm -f "$hook_script" + "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' $HOOK_VERBOSE_OPTION --run-hook-and-write-source "$hook_script" "$@" + result=$? + + if [ $result -eq 0 ] + then + source "$hook_script" + fi + rm -f "$hook_script" > /dev/null 2>&1 + return $result } # Set up virtualenvwrapper properly virtualenvwrapper_initialize () { virtualenvwrapper_verify_workon_home -q || return 1 - # Test for the virtualenvwrapper package we need so we can report - # an installation problem. - "$VIRTUALENVWRAPPER_PYTHON" -c "import virtualenvwrapper.hook_loader" >/dev/null 2>&1 + virtualenvwrapper_run_hook "initialize" if [ $? -ne 0 ] then - echo "virtualenvwrapper.sh: Could not find Python module virtualenvwrapper.hook_loader using VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON. Is the PATH set properly?" 1>&2 + echo "virtualenvwrapper.sh: Python encountered a problem. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON and that PATH set properly." 1>&2 return 1 fi - virtualenvwrapper_run_hook "initialize" } # Verify that virtualenv is installed and visible diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 688ddd2..ca78784 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -11,6 +11,7 @@ import logging.handlers import optparse import os +import sys import pkg_resources @@ -20,6 +21,13 @@ def main(): prog='virtualenvwrapper.hook_loader', description='Manage hooks for virtualenvwrapper', ) + + parser.add_option('-S', '--run-hook-and-write-source', + help='Runs "hook" and runs "_source", writing the ' + + 'result to ', + dest='source_filename', + default=None, + ) parser.add_option('-s', '--source', help='Print the shell commands to be run in the current shell', action='store_true', @@ -84,9 +92,30 @@ def main(): if not args: parser.error('Please specify the hook to run') hook = args[0] + + if options.sourcing and options.source_filename: + parser.error('--source and --run-hook-and-write-source are mutually ' + + 'exclusive.') + if options.sourcing: hook += '_source' + run_hooks(hook, options, args) + + if options.source_filename: + options.sourcing = True + output = open(options.source_filename, "w") + try: + run_hooks(hook + '_source', options, args, output) + finally: + output.close() + + return 0 + +def run_hooks(hook, options, args, output=None): + if output is None: + output = sys.stdout + for ep in pkg_resources.iter_entry_points('virtualenvwrapper.%s' % hook): if options.names and ep.name not in options.names: continue @@ -99,12 +128,11 @@ def main(): # be run in the calling shell. contents = (plugin(args[1:]) or '').strip() if contents: - print contents - print + output.write(contents) + output.write("\n") else: # Just run the plugin ourselves plugin(args[1:]) - return 0 if __name__ == '__main__': main() From 4a3624e365fc94e9404ba319c29ba79e2b614827 Mon Sep 17 00:00:00 2001 From: David Wolever Date: Fri, 7 May 2010 22:07:31 -0400 Subject: [PATCH 279/947] Some cleanup after talking with dhellmann --- virtualenvwrapper.sh | 12 ++++++------ virtualenvwrapper/hook_loader.py | 15 +++++++-------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 9b77b63..d6c307c 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -59,7 +59,7 @@ fi # If the path is relative, prefix it with $HOME # (note: for compatibility) -if echo "$WORKON_HOME" | grep -e '^[^/~]' +if echo "$WORKON_HOME" | grep -e '^[^/~]' > /dev/null then export WORKON_HOME="$HOME/$WORKON_HOME" fi @@ -68,7 +68,7 @@ fi # path might contain stuff to expand. # (it might be possible to do this in shell, but I don't know a # cross-shell-safe way of doing it -wolever) -if echo "$WORKON_HOME" | grep -e "[$~]" +if echo "$WORKON_HOME" | grep -e "[$~]" > /dev/null then # This will normalize the path by: # - Expanding variables (eg, $foo) @@ -91,20 +91,20 @@ virtualenvwrapper_verify_workon_home () { # Expects 1 argument, the suffix for the new file. virtualenvwrapper_tempfile () { - tempfile "virtualenvwrapper-XXXXXX-$1" + mktemp "virtualenvwrapper-XXXXXX-$1" } # Run the hooks virtualenvwrapper_run_hook () { hook_script="$(virtualenvwrapper_tempfile hook)" - "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' $HOOK_VERBOSE_OPTION --run-hook-and-write-source "$hook_script" "$@" + "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' $HOOK_VERBOSE_OPTION --script "$hook_script" "$@" result=$? if [ $result -eq 0 ] then source "$hook_script" fi - rm -f "$hook_script" > /dev/null 2>&1 + rm -f "$hook_script" &> /dev/null return $result } @@ -424,7 +424,7 @@ cpvirtualenv() { echo "Please specify target virtualenv" return 1 fi - if echo "$WORKON_HOME" | grep -e "/$" + if echo "$WORKON_HOME" | grep -e "/$" > /dev/null then env_home="$WORKON_HOME" else diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index ca78784..7ab124f 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -22,10 +22,10 @@ def main(): description='Manage hooks for virtualenvwrapper', ) - parser.add_option('-S', '--run-hook-and-write-source', - help='Runs "hook" and runs "_source", writing the ' + + parser.add_option('-S', '--script', + help='Runs "hook" then "_source", writing the ' + 'result to ', - dest='source_filename', + dest='script_filename', default=None, ) parser.add_option('-s', '--source', @@ -93,18 +93,17 @@ def main(): parser.error('Please specify the hook to run') hook = args[0] - if options.sourcing and options.source_filename: - parser.error('--source and --run-hook-and-write-source are mutually ' + - 'exclusive.') + if options.sourcing and options.script_filename: + parser.error('--source and --script are mutually exclusive.') if options.sourcing: hook += '_source' run_hooks(hook, options, args) - if options.source_filename: + if options.script_filename: options.sourcing = True - output = open(options.source_filename, "w") + output = open(options.script_filename, "w") try: run_hooks(hook + '_source', options, args, output) finally: From c673ab46b3ade7601bd4e136ac54c54825c7dd8d Mon Sep 17 00:00:00 2001 From: David Wolever Date: Sat, 8 May 2010 15:17:26 -0400 Subject: [PATCH 280/947] Fixing a bug in the call to mktemp --- virtualenvwrapper.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index d6c307c..cd625ad 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -91,7 +91,8 @@ virtualenvwrapper_verify_workon_home () { # Expects 1 argument, the suffix for the new file. virtualenvwrapper_tempfile () { - mktemp "virtualenvwrapper-XXXXXX-$1" + # Note: the 'X's must come last + mktemp "virtualenvwrapper-$1-XXXXXX" } # Run the hooks From da7117a794a4baffc96d0c78feb41836c9580d0b Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 9 May 2010 10:58:07 -0400 Subject: [PATCH 281/947] fix tests; clean up contributed changes --- ChangeLog | 22 ++++++++++++++++++++++ Makefile | 8 +++++--- tests/test.sh | 7 +++++-- tests/test_cp.sh | 5 +++-- tests/test_mkvirtualenv.sh | 3 ++- tests/test_tempfile.sh | 12 +----------- virtualenvwrapper.sh | 35 ++++++++++++++++++----------------- 7 files changed, 56 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index d75afc2..88ab8be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2010-05-09 Doug Hellmann + + * virtualenvwrapper.sh: Tweak path normalization code so double + slashes are also removed from WORKON_HOME. Use typeset for local + variables. + (virtualenvwrapper_tempfile): Add -t option to mktemp so the new + files are always created in the user's temporary directory. + (virtualenvwrapper_run_hook): Add the hook name to the temporary + file name. + + * tests/test_tempfile.sh: Remove obsolete test. Fix assertions + for remaining test. + + * tests/test_mkvirtualenv.sh (test_hooks): Use pwd to convert + WORKON_HOME to the expected value. + + * tests/test.sh (test_python_interpreter_set_incorrectly): Rework + grep-based assertion to actually pass. + + * Makefile (test-bash test-ksh test-sh): Remove wildcard build + rule so test-quick target works. + 2010-05-02 Doug Hellmann * virtualenvwrapper.sh (virtualenvwrapper_run_hook): Instead of diff --git a/Makefile b/Makefile index 3536633..ef5ab81 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,7 @@ help: @echo "installwebsite - deploy web version of docs" @echo "develop - install development version" @echo "test - run the test suite" + @echo "test-quick - run the test suite for bash and one version of Python" .PHONY: sdist @@ -73,7 +74,7 @@ test: develop: python setup.py develop -test-%: +test-bash test-ksh test-sh: TEST_SHELL=$(subst test-,,$@) $(MAKE) test-loop test-zsh: @@ -89,16 +90,17 @@ test-loop: && virtualenv -p $$py_bin --no-site-packages virtualenvwrapper-test-env) \ || exit 1 ; \ $$TMPDIR/virtualenvwrapper-test-env/bin/python setup.py install || exit 1 ; \ - for test_script in $(wildcard tests/test*.sh) ; do \ + for test_script in tests/test*.sh ; do \ echo ; \ echo '********************************************************************************' ; \ echo "Running $$test_script with $(TEST_SHELL) under Python $(basename $$py_bin)" ; \ + echo ; \ VIRTUALENVWRAPPER_PYTHON=$$TMPDIR/virtualenvwrapper-test-env/bin/python SHUNIT_PARENT=$$test_script $(TEST_SHELL) $$test_script || exit 1 ; \ echo ; \ done \ done -test-quick: test-26 +test-quick:: test-26 test-24: PYTHON_BINARIES=$(PYTHON24) $(MAKE) test-bash diff --git a/tests/test.sh b/tests/test.sh index 575a4e0..02e5a6a 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -67,8 +67,11 @@ test_python_interpreter_set_incorrectly() { return_to="$(pwd)" cd "$WORKON_HOME" mkvirtualenv --no-site-packages no_wrappers - output=`VIRTUALENVWRAPPER_PYTHON=$VIRTUAL_ENV/bin/python $SHELL $return_to/virtualenvwrapper.sh 2>&1` - assertTrue "Unexpected message: $output" "echo \"$output\" | grep 'Could not find Python module virtualenvwrapper.hook_loader'" + expected="ImportError: No module named virtualenvwrapper.hook_loader" + output=$(VIRTUALENVWRAPPER_PYTHON=$VIRTUAL_ENV/bin/python $SHELL $return_to/virtualenvwrapper.sh 2>&1) + echo "$output" | grep "$expected" 2>&1 + found=$? + assertTrue "Expected \"$expected\", got: \"$output\"" "[ $found -eq 0 ]" assertFalse "Failed to detect invalid Python location" "VIRTUALENVWRAPPER_PYTHON=$VIRTUAL_ENV/bin/python $SHELL $return_to/virtualenvwrapper.sh >/dev/null 2>&1" cd "$return_to" deactivate diff --git a/tests/test_cp.sh b/tests/test_cp.sh index c46d93d..43771d0 100644 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -68,9 +68,10 @@ test_hooks () { cpvirtualenv "source" "destination" output=$(cat "$test_dir/catch_output") + workon_home_as_pwd=$(cd $WORKON_HOME; pwd) - expected="GLOBAL precpvirtualenv $WORKON_HOME source destination -GLOBAL premkvirtualenv $WORKON_HOME destination + expected="GLOBAL precpvirtualenv $workon_home_as_pwd source destination +GLOBAL premkvirtualenv $workon_home_as_pwd destination GLOBAL postmkvirtualenv GLOBAL postcpvirtualenv" diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index e0ca3cb..9ae510b 100644 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -43,7 +43,8 @@ test_hooks () { echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" mkvirtualenv "env3" output=$(cat "$test_dir/catch_output") - expected="GLOBAL premkvirtualenv $WORKON_HOME env3 + workon_home_as_pwd=$(cd $WORKON_HOME; pwd) + expected="GLOBAL premkvirtualenv $workon_home_as_pwd env3 GLOBAL postmkvirtualenv" assertSame "$expected" "$output" rm -f "$WORKON_HOME/premkvirtualenv" diff --git a/tests/test_tempfile.sh b/tests/test_tempfile.sh index da53e67..f0a63b1 100644 --- a/tests/test_tempfile.sh +++ b/tests/test_tempfile.sh @@ -25,18 +25,8 @@ setUp () { test_tempfile () { filename=$(virtualenvwrapper_tempfile hook) rm -f $filename - assertSame "$TMPDIR" "$(dirname $filename)/" - assertTrue "echo $filename | grep virtualenvwrapper" -} - -test_no_python () { - old=$VIRTUALENVWRAPPER_PYTHON - VIRTUALENVWRAPPER_PYTHON=false - filename=$(virtualenvwrapper_tempfile hook) - VIRTUALENVWRAPPER_PYTHON=$old - rm -f $filename assertSame "TMPDIR and path not the same for $filename." "$TMPDIR" "$(dirname $filename)/" - assertTrue "virtualenvwrapper and pid not in filename." "echo $filename | grep virtualenvwrapper.$$" + assertTrue "virtualenvwrapper-hook not in filename." "echo $filename | grep virtualenvwrapper-hook" } . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index cd625ad..edcc9bb 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -68,11 +68,12 @@ fi # path might contain stuff to expand. # (it might be possible to do this in shell, but I don't know a # cross-shell-safe way of doing it -wolever) -if echo "$WORKON_HOME" | grep -e "[$~]" > /dev/null +if echo "$WORKON_HOME" | egrep -e "([$~]|//)" >/dev/null then # This will normalize the path by: - # - Expanding variables (eg, $foo) - # - Converting ~s to complete paths (eg, ~/ to /home/brian/ and ~arthur to /home/arthur) + # - Removing extra slashes (e.g., when TMPDIR ends in a slash) + # - Expanding variables (e.g., $foo) + # - Converting ~s to complete paths (e.g., ~/ to /home/brian/ and ~arthur to /home/arthur) WORKON_HOME=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os; print os.path.expandvars(os.path.expanduser(\"$WORKON_HOME\"))") export WORKON_HOME fi @@ -81,7 +82,7 @@ fi virtualenvwrapper_verify_workon_home () { if [ ! -d "$WORKON_HOME" ] then - [ "$1" != "-q" ] && echo "ERROR: Virtual environments directory '$WORKON_HOME' does not exist. Create it or set WORKON_HOME to an existing directory." >&2 + [ "$1" != "-q" ] && echo "ERROR: Virtual environments directory '$WORKON_HOME' does not exist. Create it or set WORKON_HOME to an existing directory." 1>&2 return 1 fi return 0 @@ -92,12 +93,12 @@ virtualenvwrapper_verify_workon_home () { # Expects 1 argument, the suffix for the new file. virtualenvwrapper_tempfile () { # Note: the 'X's must come last - mktemp "virtualenvwrapper-$1-XXXXXX" + mktemp -t "virtualenvwrapper-$1-XXXXXX" } # Run the hooks virtualenvwrapper_run_hook () { - hook_script="$(virtualenvwrapper_tempfile hook)" + typeset hook_script="$(virtualenvwrapper_tempfile ${1}-hook)" "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' $HOOK_VERBOSE_OPTION --script "$hook_script" "$@" result=$? @@ -105,7 +106,7 @@ virtualenvwrapper_run_hook () { then source "$hook_script" fi - rm -f "$hook_script" &> /dev/null + rm -f "$hook_script" >/dev/null 2>&1 return $result } @@ -115,14 +116,14 @@ virtualenvwrapper_initialize () { virtualenvwrapper_run_hook "initialize" if [ $? -ne 0 ] then - echo "virtualenvwrapper.sh: Python encountered a problem. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON and that PATH set properly." 1>&2 + echo "virtualenvwrapper.sh: Python encountered a problem. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON and that PATH is set properly." 1>&2 return 1 fi } # Verify that virtualenv is installed and visible virtualenvwrapper_verify_virtualenv () { - venv=$(which virtualenv | grep -v "not found") + typeset venv=$(which virtualenv | grep -v "not found") if [ "$venv" = "" ] then echo "ERROR: virtualenvwrapper could not find virtualenv in your path" >&2 @@ -382,7 +383,7 @@ add2virtualenv () { cdsitepackages () { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 - site_packages="`virtualenvwrapper_get_site_packages_dir`" + typeset site_packages="`virtualenvwrapper_get_site_packages_dir`" cd "$site_packages"/$1 } @@ -398,7 +399,7 @@ cdvirtualenv () { lssitepackages () { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 - site_packages="`virtualenvwrapper_get_site_packages_dir`" + typeset site_packages="`virtualenvwrapper_get_site_packages_dir`" ls $@ $site_packages path_file="$site_packages/virtualenv_path_extensions.pth" @@ -427,12 +428,12 @@ cpvirtualenv() { fi if echo "$WORKON_HOME" | grep -e "/$" > /dev/null then - env_home="$WORKON_HOME" + typset env_home="$WORKON_HOME" else - env_home="$WORKON_HOME/" + typeset env_home="$WORKON_HOME/" fi - source_env="$env_home$env_name" - target_env="$env_home$new_env" + typeset source_env="$env_home$env_name" + typeset target_env="$env_home$new_env" if [ ! -e "$source_env" ] then @@ -442,12 +443,12 @@ cpvirtualenv() { cp -r "$source_env" "$target_env" for script in $( ls $target_env/bin/* ) - do + do newscript="$script-new" sed "s|$source_env|$target_env|g" < "$script" > "$newscript" mv "$newscript" "$script" chmod a+x "$script" - done + done virtualenv "$target_env" --relocatable sed "s/VIRTUAL_ENV\(.*\)$env_name/VIRTUAL_ENV\1$new_env/g" < "$source_env/bin/activate" > "$target_env/bin/activate" From 7a4ea5907d1e39f4cc0ade728fc37801916faef3 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 9 May 2010 11:01:50 -0400 Subject: [PATCH 282/947] update history with recent changes --- docs/en/history.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index 8bd8775..fc6ee9b 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -9,6 +9,8 @@ Dev `__. - Tested under Python 2.7b1. See `issue 44 `__. + - Incorporated performance improvements from David Wolever. See `issue 38 + `__. 2.1.1 From 252346b08536f6ff207af91ed399abe2b9ecbb8a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 9 May 2010 12:26:39 -0400 Subject: [PATCH 283/947] use the sphinxcontrib.bitbucket extension for links to the issues and changesets in history.rst --- docs/en/history.rst | 102 ++++++++++++++++++++++++---------------- docs/sphinx/pkg/conf.py | 4 +- docs/sphinx/web/conf.py | 4 +- 3 files changed, 68 insertions(+), 42 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index fc6ee9b..fd30b58 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -5,12 +5,10 @@ Release History Dev - Switched hook loader execution to a form that works with Python - 2.4 to resolve `issue 43 - `__. - - Tested under Python 2.7b1. See `issue 44 - `__. - - Incorporated performance improvements from David Wolever. See `issue 38 - `__. + 2.4 to resolve :bbissue:`43`. + - Tested under Python 2.7b1. See :bbissue:`44`. + - Incorporated performance improvements from David Wolever. See + :bbissue:`38`. 2.1.1 @@ -19,11 +17,9 @@ Dev Manuel Kaufmann's fork at http://bitbucket.org/humitos/virtualenvwrapper-es-translation/ - Fixed improper use of python from ``$PATH`` instead of the - location where the wrappers are installed. See `issue #41 - `__. + location where the wrappers are installed. See :bbissue:`41`. - Quiet spurrious error/warning messages when deactivating a - virtualenv under zsh. See `issue #42 - `__. + virtualenv under zsh. See :bbissue:`42`. 2.1 @@ -31,10 +27,10 @@ Dev research on what needed to be changed. - Test import of virtualenvwrapper.hook_loader on startup and report the error in a way that should help the user figure out how to fix - it (issue #33). + it (:bbissue:`33`). - Update :ref:`command-mkvirtualenv` documentation to include the fact that a new environment is activated immediately after it is - created (issue #30). + created (:bbissue:`30`). - Added hooks around :ref:`command-cpvirtualenv`. - Made deactivation more robust, especially under ksh. - Use Python's ``tempfile`` module for creating temporary filenames @@ -52,13 +48,13 @@ Dev 2.0.2 - - Fixed issue #32, making virtualenvwrapper.user_scripts compatible + - Fixed :bbissue:`32`, making virtualenvwrapper.user_scripts compatible with Python 2.5 again. 2.0.1 - - Fixed issue #29, to use a default value for ``TMPDIR`` if it is - not set in the user's shell environment. + - Fixed :bbissue:`29`, to use a default value for ``TMPDIR`` if it + is not set in the user's shell environment. 2.0 @@ -75,7 +71,7 @@ Dev - Fix a problem with error messages showing up during init for users with the wrappers installed site-wide but who are not actually - using them. See issue #26. + using them. See :bbissue:`26`. - Split up the tests into multiple files. - Run all tests with all supported shells. @@ -97,12 +93,13 @@ Dev 1.24 - Resolve a bug with the preactivate hook not being run properly. - Refer to issue #21 for complete details. + Refer to :bbissue:`21` for complete details. 1.23 - Resolve a bug with the postmkvirtualenv hook not being run - properly. Refer to issues #19 and #20 for complete details. + properly. Refer to :bbissue:`19` and :bbissue:`20` for complete + details. 1.22 @@ -111,25 +108,32 @@ Dev 1.21 - - Better protection of ``$WORKON_HOME`` does not exist when the wrapper script is sourced. + - Better protection of ``$WORKON_HOME`` does not exist when the + wrapper script is sourced. 1.20 - Incorporate lssitepackages feature from Sander Smits. - - Refactor some of the functions that were using copy-and-paste code to build path names. + - Refactor some of the functions that were using copy-and-paste code + to build path names. - Add a few tests. 1.19 - - Fix problem with add2virtualenv and relative paths. Thanks to Doug Latornell for the bug report James Bennett for the suggested fix. + - Fix problem with add2virtualenv and relative paths. Thanks to Doug + Latornell for the bug report James Bennett for the suggested fix. 1.18.1 - - Incorporate patch from Sascha Brossmann to fix a issue #15. Directory normalization was causing ``WORKON_HOME`` to appear to be a missing directory if there were control characters in the output of ``pwd``. + - Incorporate patch from Sascha Brossmann to fix a + :bbissue:`15`. Directory normalization was causing ``WORKON_HOME`` + to appear to be a missing directory if there were control + characters in the output of ``pwd``. 1.18 - - Remove warning during installation if sphinxcontrib.paverutils is not installed. (#10) + - Remove warning during installation if sphinxcontrib.paverutils is + not installed. (:bbissue:`10`) - Added some basic developer information to the documentation. - Added documentation for deactivate command. @@ -139,48 +143,64 @@ Dev 1.16 - - Merged in changes to ``cdvirtualenv`` from wam and added tests and docs. - - Merged in changes to make error messages go to stderr, also provided by wam. + - Merged in changes to ``cdvirtualenv`` from wam and added tests and + docs. + - Merged in changes to make error messages go to stderr, also + provided by wam. 1.15 - Better error handling in mkvirtualenv. - Remove bogus VIRTUALENV_WRAPPER_BIN variable. 1.14 - - Wrap the virtualenv version of deactivate() with one that lets us invoke - the predeactivate hooks. - - Fix virtualenvwrapper_show_workon_options for colorized versions of ls and - write myself a note so I don't break it again later. - - Convert test.sh to use true tests with `shunit2 `_ + - Wrap the virtualenv version of deactivate() with one that lets us + invoke the predeactivate hooks. + - Fix virtualenvwrapper_show_workon_options for colorized versions + of ls and write myself a note so I don't break it again later. + - Convert test.sh to use true tests with `shunit2 + `_ 1.13 - - Fix issue #5 by correctly handling symlinks and limiting the list of envs to things - that look like they can be activated. + + - Fix :bbissue:`5` by correctly handling symlinks and limiting the + list of envs to things that look like they can be activated. 1.12 - - Check return value of virtualenvwrapper_verify_workon_home everywhere, thanks to - Jeff Forcier for pointing out the errors. + + - Check return value of virtualenvwrapper_verify_workon_home + everywhere, thanks to Jeff Forcier for pointing out the errors. - Fix instructions at top of README, pointed out by Matthew Scott. - Add cdvirtualenv and cdsitepackages, contributed by James Bennett. - Enhance test.sh. 1.11 + - Optimize virtualenvwrapper_show_workon_options. - Add global postactivate hook. 1.10 - - Pull in fix for colorized ls from Jeff Forcier (b42a25f7b74a). + + - Pull in fix for colorized ls from Jeff Forcier + (:bbchangeset:`b42a25f7b74a`). 1.9 - - Add more hooks for operations to run before and after creating or deleting environments based on changes from Chris Hasenpflug. + + - Add more hooks for operations to run before and after creating or + deleting environments based on changes from Chris Hasenpflug. 1.8.1 - - Corrected a problem with change to mkvirtualenv that lead to release 1.8 by using an alternate fix proposed by James in comments on release 1.4. + + - Corrected a problem with change to mkvirtualenv that lead to + release 1.8 by using an alternate fix proposed by James in + comments on release 1.4. 1.8 - - Fix for processing the argument list in mkvirtualenv from jorgevargas (BitBucket issue #1) + + - Fix for processing the argument list in mkvirtualenv from + jorgevargas (:bbissue:`1`) 1.7 + - Move to bitbucket.org for hosting - clean up TODO list and svn keywords - add license section below @@ -195,12 +215,14 @@ Dev 1.5 - - Fix some issues with spaces in directory or env names. They still don't really work with virtualenv, though. + - Fix some issues with spaces in directory or env names. They still + don't really work with virtualenv, though. - Added documentation for the postactivate and predeactivate scripts. 1.4 - - Includes a new .pth management function based on work contributed by James Bennett and Jannis Leidel. + - Includes a new .pth management function based on work contributed + by James Bennett and Jannis Leidel. 1.3.x diff --git a/docs/sphinx/pkg/conf.py b/docs/sphinx/pkg/conf.py index a587a81..2686081 100644 --- a/docs/sphinx/pkg/conf.py +++ b/docs/sphinx/pkg/conf.py @@ -22,7 +22,9 @@ # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = [] +extensions = [ 'sphinxcontrib.bitbucket' ] + +bitbucket_project_url = 'http://bitbucket.org/dhellmann/virtualenvwrapper/' # Add any paths that contain templates here, relative to this directory. templates_path = ['templates'] diff --git a/docs/sphinx/web/conf.py b/docs/sphinx/web/conf.py index 6faf447..e03637a 100644 --- a/docs/sphinx/web/conf.py +++ b/docs/sphinx/web/conf.py @@ -22,7 +22,9 @@ # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = [] +extensions = [ 'sphinxcontrib.bitbucket' ] + +bitbucket_project_url = 'http://bitbucket.org/dhellmann/virtualenvwrapper/' # Add any paths that contain templates here, relative to this directory. templates_path = ['templates'] From a4bec83d4078196f8b6b29a3324316c4750fff40 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 9 May 2010 16:42:58 -0400 Subject: [PATCH 284/947] unify sphinx config files --HG-- rename : docs/sphinx/pkg/conf.py => docs/sphinx/conf.py --- Makefile | 8 +- docs/sphinx/{pkg => }/conf.py | 12 ++- docs/sphinx/web/conf.py | 196 ---------------------------------- 3 files changed, 14 insertions(+), 202 deletions(-) rename docs/sphinx/{pkg => }/conf.py (96%) delete mode 100644 docs/sphinx/web/conf.py diff --git a/Makefile b/Makefile index ef5ab81..175b78a 100644 --- a/Makefile +++ b/Makefile @@ -38,8 +38,8 @@ sdist: html # Documentation .PHONY: html html: - (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/pkg" LANGUAGE="en") - (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/pkg" LANGUAGE="es") + (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx" LANGUAGE="en") + (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx" LANGUAGE="es") .PHONY: docclean docclean: @@ -50,8 +50,8 @@ docclean: website: [ ~/Devel/doughellmann/doughellmann/templates/base.html -nt docs/sphinx/web/templates/base.html ] && (echo "Updating base.html" ; cp ~/Devel/doughellmann/doughellmann/templates/base.html docs/sphinx/web/templates/base.html) || exit 0 rm -rf docs/website - (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/web" BUILDDIR="website/en" LANGUAGE="en") - (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx/web" BUILDDIR="website/es" LANGUAGE="es") + (cd docs && $(MAKE) html BUILDING_WEB=1 SPHINXOPTS="-c sphinx" BUILDDIR="website/en" LANGUAGE="en") + (cd docs && $(MAKE) html BUILDING_WEB=1 SPHINXOPTS="-c sphinx" BUILDDIR="website/es" LANGUAGE="es") installwebsite: website (cd docs/website/en && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper/) diff --git a/docs/sphinx/pkg/conf.py b/docs/sphinx/conf.py similarity index 96% rename from docs/sphinx/pkg/conf.py rename to docs/sphinx/conf.py index 2686081..1bed798 100644 --- a/docs/sphinx/pkg/conf.py +++ b/docs/sphinx/conf.py @@ -13,6 +13,8 @@ import sys, os +building_web = int(os.environ.get('BUILDING_WEB', '0')) + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. @@ -27,7 +29,10 @@ bitbucket_project_url = 'http://bitbucket.org/dhellmann/virtualenvwrapper/' # Add any paths that contain templates here, relative to this directory. -templates_path = ['templates'] +if building_web: + templates_path = ['web/templates'] +else: + templates_path = ['pkg/templates'] # The suffix of source filenames. source_suffix = '.rst' @@ -93,7 +98,10 @@ # The theme to use for HTML and HTML Help pages. Major themes that come with # Sphinx are currently 'default' and 'sphinxdoc'. -html_theme = 'sphinxdoc' +if building_web: + html_theme = 'default' +else: + html_theme = 'sphinxdoc' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the diff --git a/docs/sphinx/web/conf.py b/docs/sphinx/web/conf.py deleted file mode 100644 index e03637a..0000000 --- a/docs/sphinx/web/conf.py +++ /dev/null @@ -1,196 +0,0 @@ -# -*- coding: utf-8 -*- -# -# virtualenvwrapper documentation build configuration file, created by -# sphinx-quickstart on Thu May 28 22:35:13 2009. -# -# This file is execfile()d with the current directory set to its containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys, os - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.append(os.path.abspath('.')) - -# -- General configuration ----------------------------------------------------- - -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = [ 'sphinxcontrib.bitbucket' ] - -bitbucket_project_url = 'http://bitbucket.org/dhellmann/virtualenvwrapper/' - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['templates'] - -# The suffix of source filenames. -source_suffix = '.rst' - -# The encoding of source files. -#source_encoding = 'utf-8' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'virtualenvwrapper' -copyright = u'2009, Doug Hellmann' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = os.environ['VERSION'] -# The full version, including alpha/beta/rc tags. -release = version - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -#language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -#today = '' -# Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' - -# List of documents that shouldn't be included in the build. -#unused_docs = [] - -# List of directories, relative to source directory, that shouldn't be searched -# for source files. -exclude_trees = ['_build'] - -# The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -#add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -#show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] - - -# -- Options for HTML output --------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. Major themes that come with -# Sphinx are currently 'default' and 'sphinxdoc'. -html_theme = 'default' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -#html_theme_options = {} - -# Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -#html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -#html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -#html_favicon = None - -# 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, -# so a file named "default.css" will overwrite the builtin "default.css". -#html_static_path = ['static'] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -#html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -#html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -#html_additional_pages = {} - -# If false, no module index is generated. -html_use_modindex = False - -# If false, no index is generated. -html_use_index = False - -# If true, the index is split into individual pages for each letter. -#html_split_index = False - -# If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -#html_use_opensearch = '' - -# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = '' - -# Output file base name for HTML help builder. -htmlhelp_basename = 'virtualenvwrapperdoc' - - -# -- Options for LaTeX output -------------------------------------------------- - -# The paper size ('letter' or 'a4'). -#latex_paper_size = 'letter' - -# The font size ('10pt', '11pt' or '12pt'). -#latex_font_size = '10pt' - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). -latex_documents = [ - ('index', 'virtualenvwrapper.tex', u'virtualenvwrapper Documentation', - u'Doug Hellmann', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -#latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -#latex_use_parts = False - -# Additional stuff for the LaTeX preamble. -#latex_preamble = '' - -# Documents to append as an appendix to all manuals. -#latex_appendices = [] - -# If false, no module index is generated. -#latex_use_modindex = True From 0f4544f72e93d4cc967321e6694b6c4b916fc5a9 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 9 May 2010 16:44:57 -0400 Subject: [PATCH 285/947] since we always use the same config dir, set it once --- Makefile | 8 ++++---- docs/Makefile | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 175b78a..e01b908 100644 --- a/Makefile +++ b/Makefile @@ -38,8 +38,8 @@ sdist: html # Documentation .PHONY: html html: - (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx" LANGUAGE="en") - (cd docs && $(MAKE) html SPHINXOPTS="-c sphinx" LANGUAGE="es") + (cd docs && $(MAKE) html LANGUAGE="en") + (cd docs && $(MAKE) html LANGUAGE="es") .PHONY: docclean docclean: @@ -50,8 +50,8 @@ docclean: website: [ ~/Devel/doughellmann/doughellmann/templates/base.html -nt docs/sphinx/web/templates/base.html ] && (echo "Updating base.html" ; cp ~/Devel/doughellmann/doughellmann/templates/base.html docs/sphinx/web/templates/base.html) || exit 0 rm -rf docs/website - (cd docs && $(MAKE) html BUILDING_WEB=1 SPHINXOPTS="-c sphinx" BUILDDIR="website/en" LANGUAGE="en") - (cd docs && $(MAKE) html BUILDING_WEB=1 SPHINXOPTS="-c sphinx" BUILDDIR="website/es" LANGUAGE="es") + (cd docs && $(MAKE) html BUILDING_WEB=1 BUILDDIR="website/en" LANGUAGE="en") + (cd docs && $(MAKE) html BUILDING_WEB=1 BUILDDIR="website/es" LANGUAGE="es") installwebsite: website (cd docs/website/en && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper/) diff --git a/docs/Makefile b/docs/Makefile index 857f3d9..50cb69f 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -5,7 +5,7 @@ LANGUAGE = en # You can set these variables from the command line. -SPHINXOPTS = +SPHINXOPTS = -c sphinx SPHINXBUILD = sphinx-build PAPER = BUILDDIR = html/$(LANGUAGE) From ea26ed6d39b3d0fcfd753bf0ce97d35219c37e3f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 16 May 2010 08:53:42 -0400 Subject: [PATCH 286/947] addresses ticket 35 by adding debugging instrumentation --- ChangeLog | 9 +++++++++ tests/test_tempfile.sh | 23 +++++++++++++++++++++++ virtualenvwrapper.sh | 12 +++++++++++- virtualenvwrapper/hook_loader.py | 5 +++++ 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 88ab8be..7493926 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2010-05-16 Doug Hellmann + + * virtualenvwrapper/hook_loader.py (main): Add more debug logging + to try to narrow down the tempfile issue (#35). + + * virtualenvwrapper.sh (virtualenvwrapper_run_hook): Add more + debugging error reporting to try to narrow down the tempfile + issue (#35). + 2010-05-09 Doug Hellmann * virtualenvwrapper.sh: Tweak path normalization code so double diff --git a/tests/test_tempfile.sh b/tests/test_tempfile.sh index f0a63b1..e47c9db 100644 --- a/tests/test_tempfile.sh +++ b/tests/test_tempfile.sh @@ -5,6 +5,7 @@ test_dir=$(dirname $0) export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" +export HOOK_VERBOSE_OPTION=-v oneTimeSetUp() { rm -rf "$WORKON_HOME" @@ -29,4 +30,26 @@ test_tempfile () { assertTrue "virtualenvwrapper-hook not in filename." "echo $filename | grep virtualenvwrapper-hook" } +test_no_such_tmpdir () { + old_tmpdir="$TMPDIR" + TMPDIR="$TMPDIR/does-not-exist" + virtualenvwrapper_run_hook "initialize" >/dev/null 2>&1 + RC=$? + assertSame "Unexpected exit code $RC" "1" "$RC" + TMPDIR="$old_tmpdir" +} + +test_tmpdir_not_writable () { + old_tmpdir="$TMPDIR" + TMPDIR="$TMPDIR/cannot-write" + mkdir "$TMPDIR" + chmod ugo-w "$TMPDIR" + virtualenvwrapper_run_hook "initialize" >/dev/null 2>&1 + RC=$? + assertSame "Unexpected exit code $RC" "1" "$RC" + chmod ugo+w "$TMPDIR" + rmdir "$TMPDIR" + TMPDIR="$old_tmpdir" +} + . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index edcc9bb..3f82100 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -99,11 +99,21 @@ virtualenvwrapper_tempfile () { # Run the hooks virtualenvwrapper_run_hook () { typeset hook_script="$(virtualenvwrapper_tempfile ${1}-hook)" + if [ -z "$hook_script" ] + then + echo "ERROR: Could not create temporary file name. Make sure TMPDIR is set." 1>&2 + return 1 + fi "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' $HOOK_VERBOSE_OPTION --script "$hook_script" "$@" result=$? if [ $result -eq 0 ] then + if [ ! -f "$hook_script" ] + then + echo "ERROR: virtualenvwrapper_run_hook could not find temporary file $hook_script" 1>&2 + return 2 + fi source "$hook_script" fi rm -f "$hook_script" >/dev/null 2>&1 @@ -116,7 +126,7 @@ virtualenvwrapper_initialize () { virtualenvwrapper_run_hook "initialize" if [ $? -ne 0 ] then - echo "virtualenvwrapper.sh: Python encountered a problem. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON and that PATH is set properly." 1>&2 + echo "virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON and that PATH is set properly." 1>&2 return 1 fi } diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 7ab124f..7ec1ef4 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -99,12 +99,17 @@ def main(): if options.sourcing: hook += '_source' + log = logging.getLogger(__name__) + + log.debug('Running %s hooks', hook) run_hooks(hook, options, args) if options.script_filename: + log.debug('Saving sourcable %s hooks to %s', hook, options.script_filename) options.sourcing = True output = open(options.script_filename, "w") try: + output.write('# %s\n' % hook) run_hooks(hook + '_source', options, args, output) finally: output.close() From 5105cef0a4b4f8c0d371df4308622d34e9bdc5f3 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 16 May 2010 08:55:12 -0400 Subject: [PATCH 287/947] mention changes to address ticket 35 in history --- docs/en/history.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index fd30b58..16d2dcc 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -9,6 +9,7 @@ Dev - Tested under Python 2.7b1. See :bbissue:`44`. - Incorporated performance improvements from David Wolever. See :bbissue:`38`. + - Added some debug instrumentation for :bbissue:`35`. 2.1.1 From 0b1d952a4e84a811a3e469a455ac9ba06fbb46ad Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 16 May 2010 12:32:18 -0400 Subject: [PATCH 288/947] changes to make the tests run on my linux host --- ChangeLog | 13 +++++++++++++ Makefile | 4 ++-- tests/test_cd.sh | 8 ++++++++ tests/test_tempfile.sh | 5 ++++- virtualenvwrapper/hook_loader.py | 1 + 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7493926..ed0c452 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,20 @@ 2010-05-16 Doug Hellmann + * Makefile (PYTHON26): Use which to find python2.6, the default + interpreter, so we can run the tests as "make test-quick" on other + hosts. + + * tests/test_tempfile.sh (test_tempfile): Normalize the paths so + we don't depend on the value of TMPDIR or behavior of dirname. + + * tests/test_cd.sh: Make sure the virtualenv from the caller does + not influence test behaviors by establishing our own virtualenv + locally. + * virtualenvwrapper/hook_loader.py (main): Add more debug logging to try to narrow down the tempfile issue (#35). + (run_hooks): Insert a comment into the output file to show which + hook we are running. * virtualenvwrapper.sh (virtualenvwrapper_run_hook): Add more debugging error reporting to try to narrow down the tempfile diff --git a/Makefile b/Makefile index e01b908..0e25798 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ export VERSION=$(shell python setup.py --version) # Locations of Python interpreter binaries PYTHON27=/Users/dhellmann/Devel/virtualenvwrapper/Python/2.7b1/bin/python2.7 -PYTHON26=/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 +PYTHON26=$(shell which python2.6) PYTHON25=/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5 PYTHON24=/Users/dhellmann/Devel/virtualenvwrapper/Python/2.4.6/bin/python2.4 @@ -95,7 +95,7 @@ test-loop: echo '********************************************************************************' ; \ echo "Running $$test_script with $(TEST_SHELL) under Python $(basename $$py_bin)" ; \ echo ; \ - VIRTUALENVWRAPPER_PYTHON=$$TMPDIR/virtualenvwrapper-test-env/bin/python SHUNIT_PARENT=$$test_script $(TEST_SHELL) $$test_script || exit 1 ; \ + HOOK_VERBOSE_OPTION=-v VIRTUALENVWRAPPER_PYTHON=$$TMPDIR/virtualenvwrapper-test-env/bin/python SHUNIT_PARENT=$$test_script $(TEST_SHELL) $$test_script || exit 1 ; \ echo ; \ done \ done diff --git a/tests/test_cd.sh b/tests/test_cd.sh index 24985d1..a10831a 100644 --- a/tests/test_cd.sh +++ b/tests/test_cd.sh @@ -9,7 +9,10 @@ export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" + unset VIRTUAL_ENV source "$test_dir/../virtualenvwrapper.sh" + mkvirtualenv cd-test + deactivate } oneTimeTearDown() { @@ -19,6 +22,11 @@ oneTimeTearDown() { setUp () { echo rm -f "$test_dir/catch_output" + workon cd-test +} + +tearDown () { + deactivate } test_cdvirtual() { diff --git a/tests/test_tempfile.sh b/tests/test_tempfile.sh index e47c9db..07895b2 100644 --- a/tests/test_tempfile.sh +++ b/tests/test_tempfile.sh @@ -25,8 +25,11 @@ setUp () { test_tempfile () { filename=$(virtualenvwrapper_tempfile hook) + assertTrue "Filename is empty" "[ ! -z \"$filename\" ]" rm -f $filename - assertSame "TMPDIR and path not the same for $filename." "$TMPDIR" "$(dirname $filename)/" + comparable_tmpdir=$(echo $TMPDIR | sed 's|/$||') + comparable_dirname=$(dirname $filename | sed 's|/$||') + assertSame "TMPDIR and path not the same for $filename" "$comparable_tmpdir" "$comparable_dirname" assertTrue "virtualenvwrapper-hook not in filename." "echo $filename | grep virtualenvwrapper-hook" } diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 7ec1ef4..0dc9725 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -132,6 +132,7 @@ def run_hooks(hook, options, args, output=None): # be run in the calling shell. contents = (plugin(args[1:]) or '').strip() if contents: + output.write('# %s\n' % ep.name) output.write(contents) output.write("\n") else: From f65a75f653380a5a259d1c7b1e4bb0523064b164 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 16 May 2010 14:35:16 -0400 Subject: [PATCH 289/947] more tempfile fixes --- ChangeLog | 4 ++++ tests/test_cp.sh | 2 ++ virtualenvwrapper.sh | 9 ++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ed0c452..e6e3dd1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2010-05-16 Doug Hellmann + * virtualenvwrapper.sh (virtualenvwrapper_tempfile): Set a default + suffix of "hook" and explicitly report when we detect an error + condition. + * Makefile (PYTHON26): Use which to find python2.6, the default interpreter, so we can run the tests as "make test-quick" on other hosts. diff --git a/tests/test_cp.sh b/tests/test_cp.sh index 43771d0..59c11a0 100644 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -6,6 +6,8 @@ test_dir=$(dirname $0) export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" +unset HOOK_VERBOSE_OPTION + setUp () { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 3f82100..ce1a490 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -93,7 +93,14 @@ virtualenvwrapper_verify_workon_home () { # Expects 1 argument, the suffix for the new file. virtualenvwrapper_tempfile () { # Note: the 'X's must come last - mktemp -t "virtualenvwrapper-$1-XXXXXX" + typeset suffix=${1:-hook} + mktemp -t "virtualenvwrapper-$suffix-XXXXXXXXXX" + if [ $? -ne 0 ] + then + echo "ERROR: virtualenvwrapper could not create a temporary file name." 1>&2 + return 1 + fi + return 0 } # Run the hooks From e7b0f469959718e73d72b7509483a882757ffb94 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 18 May 2010 09:31:34 -0400 Subject: [PATCH 290/947] add trap to remove temporary file, see #38 --- ChangeLog | 5 +++++ virtualenvwrapper.sh | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e6e3dd1..08c2689 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-05-18 Doug Hellmann + + * virtualenvwrapper.sh (virtualenvwrapper_tempfile): Use a trap to + ensure the temporary file is removed when we exit. + 2010-05-16 Doug Hellmann * virtualenvwrapper.sh (virtualenvwrapper_tempfile): Set a default diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index ce1a490..2949d68 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -94,12 +94,14 @@ virtualenvwrapper_verify_workon_home () { virtualenvwrapper_tempfile () { # Note: the 'X's must come last typeset suffix=${1:-hook} - mktemp -t "virtualenvwrapper-$suffix-XXXXXXXXXX" + typeset file="`mktemp -t virtualenvwrapper-$suffix-XXXXXXXXXX`" if [ $? -ne 0 ] then echo "ERROR: virtualenvwrapper could not create a temporary file name." 1>&2 return 1 fi + trap "rm '$file' >/dev/null 2>&1" EXIT + echo $file return 0 } From a6cd415a034d263347ac7899a17c9e6299b83c7f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 22 May 2010 11:22:19 -0400 Subject: [PATCH 291/947] more test refinements --- ChangeLog | 9 +++++++++ Makefile | 6 +++++- tests/test.sh | 4 ++-- tests/test_add2virtualenv.sh | 4 ++-- tests/test_cd.sh | 4 ++-- tests/test_cp.sh | 19 ++++++++++++------- tests/test_deactivate.sh | 4 ++-- tests/test_ls.sh | 4 ++-- tests/test_mkvirtualenv.sh | 5 +++-- tests/test_rmvirtualenv.sh | 4 ++-- tests/test_run_hook.sh | 4 ++-- tests/test_tempfile.sh | 5 +++-- tests/test_workon.sh | 14 +++++++++++--- 13 files changed, 57 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 08c2689..73a34f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2010-05-22 Doug Hellmann + + * tests/test_cp.sh: Clarify some of the tests by breaking up, + renaming, and rewriting some functions. + + * Makefile (PYTHON26): If we're in a virtualenv when the tests + start, use a hard-coded path to the binary to get the global + version. + 2010-05-18 Doug Hellmann * virtualenvwrapper.sh (virtualenvwrapper_tempfile): Use a trap to diff --git a/Makefile b/Makefile index 0e25798..db02a0e 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,11 @@ export VERSION=$(shell python setup.py --version) # Locations of Python interpreter binaries PYTHON27=/Users/dhellmann/Devel/virtualenvwrapper/Python/2.7b1/bin/python2.7 +ifeq ($VIRTUAL_ENV,) PYTHON26=$(shell which python2.6) +else +PYTHON26=/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 +endif PYTHON25=/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5 PYTHON24=/Users/dhellmann/Devel/virtualenvwrapper/Python/2.4.6/bin/python2.4 @@ -25,7 +29,7 @@ help: @echo "installwebsite - deploy web version of docs" @echo "develop - install development version" @echo "test - run the test suite" - @echo "test-quick - run the test suite for bash and one version of Python" + @echo "test-quick - run the test suite for bash and one version of Python ($(PYTHON26))" .PHONY: sdist diff --git a/tests/test.sh b/tests/test.sh index 02e5a6a..8644962 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -2,9 +2,9 @@ #set -x -test_dir=$(dirname $0) +test_dir=$(cd $(dirname $0) && pwd) -export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_add2virtualenv.sh b/tests/test_add2virtualenv.sh index efba604..4076a2f 100644 --- a/tests/test_add2virtualenv.sh +++ b/tests/test_add2virtualenv.sh @@ -2,9 +2,9 @@ #set -x -test_dir=$(dirname $0) +test_dir=$(cd $(dirname $0) && pwd) -export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_cd.sh b/tests/test_cd.sh index a10831a..cee9b67 100644 --- a/tests/test_cd.sh +++ b/tests/test_cd.sh @@ -2,9 +2,9 @@ #set -x -test_dir=$(dirname $0) +test_dir=$(cd $(dirname $0) && pwd) -export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_cp.sh b/tests/test_cp.sh index 59c11a0..a0a9f79 100644 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -2,9 +2,9 @@ #set -x -test_dir=$(dirname $0) +test_dir=$(cd $(dirname $0) && pwd) -export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" unset HOOK_VERBOSE_OPTION @@ -24,21 +24,26 @@ tearDown() { rm -rf "$WORKON_HOME" } -test_cpvirtualenv () { +test_new_env_activated () { mkvirtualenv "source" (cd tests/testpackage && python setup.py install) >/dev/null 2>&1 cpvirtualenv "source" "destination" - assertSame "destination" $(basename "$VIRTUAL_ENV") rmvirtualenv "source" testscript="$(which testscript.py)" assertTrue "Environment test script not found in path" "[ $WORKON_HOME/destination/bin/testscript.py -ef $testscript ]" testscriptcontent="$(cat $testscript)" - assertTrue "No cpvirtualenvtest in $/testscriptcontent" "echo $testscriptcontent | grep cpvirtualenvtest" + assertTrue "No cpvirtualenvtest in $testscriptcontent" "echo $testscriptcontent | grep cpvirtualenvtest" assertTrue virtualenvwrapper_verify_active_environment +} + +test_virtual_env_variable () { + mkvirtualenv "source" + cpvirtualenv "source" "destination" assertSame "Wrong virtualenv name" "destination" $(basename "$VIRTUAL_ENV") + assertTrue "$WORKON_HOME not in $VIRTUAL_ENV" "echo $VIRTUAL_ENV | grep -q $WORKON_HOME" } -test_cprelocatablevirtualenv () { +test_source_relocatable () { mkvirtualenv "source" (cd tests/testpackage && python setup.py install) >/dev/null 2>&1 assertTrue "virtualenv --relocatable \"$WORKON_HOME/source\"" @@ -49,7 +54,7 @@ test_cprelocatablevirtualenv () { assertSame "Wrong virtualenv name" "destination" $(basename "$VIRTUAL_ENV") } -test_cp_notexists () { +test_source_does_not_exist () { out="$(cpvirtualenv virtualenvthatdoesntexist foo)" assertSame "$out" "virtualenvthatdoesntexist virtualenv doesn't exist" } diff --git a/tests/test_deactivate.sh b/tests/test_deactivate.sh index b07c98e..aa3da19 100644 --- a/tests/test_deactivate.sh +++ b/tests/test_deactivate.sh @@ -2,9 +2,9 @@ #set -x -test_dir=$(dirname $0) +test_dir=$(cd $(dirname $0) && pwd) -export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_ls.sh b/tests/test_ls.sh index 0352d73..03731fa 100644 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -2,9 +2,9 @@ #set -x -test_dir=$(dirname $0) +test_dir=$(cd $(dirname $0) && pwd) -export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index 9ae510b..38d345f 100644 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -2,8 +2,9 @@ #set -x -test_dir=$(dirname $0) -export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" +test_dir=$(cd $(dirname $0) && pwd) + +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_rmvirtualenv.sh b/tests/test_rmvirtualenv.sh index d1b4921..20629d0 100644 --- a/tests/test_rmvirtualenv.sh +++ b/tests/test_rmvirtualenv.sh @@ -2,9 +2,9 @@ #set -x -test_dir=$(dirname $0) +test_dir=$(cd $(dirname $0) && pwd) -export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_run_hook.sh b/tests/test_run_hook.sh index 34b675e..b68f293 100644 --- a/tests/test_run_hook.sh +++ b/tests/test_run_hook.sh @@ -2,9 +2,9 @@ #set -x -export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" +test_dir=$(cd $(dirname $0) && pwd) -test_dir=$(dirname $0) +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_tempfile.sh b/tests/test_tempfile.sh index 07895b2..46619ff 100644 --- a/tests/test_tempfile.sh +++ b/tests/test_tempfile.sh @@ -2,9 +2,10 @@ #set -x -test_dir=$(dirname $0) +test_dir=$(cd $(dirname $0) && pwd) + +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" -export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" export HOOK_VERBOSE_OPTION=-v oneTimeSetUp() { diff --git a/tests/test_workon.sh b/tests/test_workon.sh index ca18c33..d759f33 100644 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -2,15 +2,17 @@ #set -x -test_dir=$(dirname $0) +test_dir=$(cd $(dirname $0) && pwd) -export WORKON_HOME="${TMPDIR:-/tmp}/WORKON_HOME" +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" source "$test_dir/../virtualenvwrapper.sh" mkvirtualenv "env1" + mkvirtualenv "env2" + deactivate >/dev/null 2>&1 } oneTimeTearDown() { @@ -22,6 +24,10 @@ setUp () { rm -f "$test_dir/catch_output" } +tearDown () { + deactivate >/dev/null 2>&1 +} + test_workon () { workon env1 assertTrue virtualenvwrapper_verify_active_environment @@ -31,8 +37,10 @@ test_workon () { test_workon_activate_hooks () { for t in pre post do + echo "#!/bin/bash" > "$WORKON_HOME/${t}activate" echo "echo GLOBAL ${t}activate >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/${t}activate" chmod +x "$WORKON_HOME/${t}activate" + echo "#!/bin/bash" > "$WORKON_HOME/env2/bin/${t}activate" echo "echo ENV ${t}activate >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/env1/bin/${t}activate" chmod +x "$WORKON_HOME/env1/bin/${t}activate" done @@ -61,7 +69,7 @@ test_virtualenvwrapper_show_workon_options () { mkdir "$WORKON_HOME/not_env" (cd "$WORKON_HOME"; ln -s env1 link_env) envs=$(virtualenvwrapper_show_workon_options | tr '\n' ' ') - assertSame "env1 link_env " "$envs" + assertSame "env1 env2 link_env " "$envs" rmdir "$WORKON_HOME/not_env" rm -f "$WORKON_HOME/link_env" } From 8913fb86b169fdd7c03813bbba37c3e928f786cf Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 22 May 2010 18:15:18 -0400 Subject: [PATCH 292/947] bump version number --- docs/en/history.rst | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 16d2dcc..88877f7 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,7 +2,7 @@ Release History =============== -Dev +2.2 - Switched hook loader execution to a form that works with Python 2.4 to resolve :bbissue:`43`. diff --git a/setup.py b/setup.py index 63d040f..ee9fd08 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' -VERSION = '2.1.1' +VERSION = '2.2' # Bootstrap installation of Distribute import distribute_setup From ffeb19ba6fde7ecb9e0904e8d3c5f3389eadda4c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 22 May 2010 18:15:24 -0400 Subject: [PATCH 293/947] Added tag 2.2 for changeset d5c5faecc92d --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 1ee9f1e..fc675f1 100644 --- a/.hgtags +++ b/.hgtags @@ -51,3 +51,4 @@ d64869519c2e0553303cfeeb0918271564c72beb 1.27 6a51a81454ae9dde5d923668ad5f034b3467fe11 2.0.2 241df6c36860c13fae5468881457a27840ee9d72 2.1 7540fc7d8e63cafe6c3126e0855ed8c277b450cf 2.1.1 +d5c5faecc92daef3d15510f0314d4d5e6c95e234 2.2 From 9be727995da4ae93d7e0f8de899194afb6122ee1 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 3 Jun 2010 21:49:04 -0400 Subject: [PATCH 294/947] address issue #46 by escaping the calls to which --- ChangeLog | 5 +++++ virtualenvwrapper.sh | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 73a34f2..35bfde4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-06-03 Doug Hellmann + + * virtualenvwrapper.sh: Escape the call to "which" so we don't use + an alias by accident. + 2010-05-22 Doug Hellmann * tests/test_cp.sh: Clarify some of the tests by breaking up, diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 2949d68..f411568 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -54,7 +54,7 @@ fi # Locate the global Python where virtualenvwrapper is installed. if [ "$VIRTUALENVWRAPPER_PYTHON" = "" ] then - VIRTUALENVWRAPPER_PYTHON="$(which python)" + VIRTUALENVWRAPPER_PYTHON="$(\which python)" fi # If the path is relative, prefix it with $HOME @@ -142,7 +142,7 @@ virtualenvwrapper_initialize () { # Verify that virtualenv is installed and visible virtualenvwrapper_verify_virtualenv () { - typeset venv=$(which virtualenv | grep -v "not found") + typeset venv=$(\which virtualenv | grep -v "not found") if [ "$venv" = "" ] then echo "ERROR: virtualenvwrapper could not find virtualenv in your path" >&2 From 0826e802099c74c8bac8bffc005f7c156193e752 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 3 Jun 2010 21:50:13 -0400 Subject: [PATCH 295/947] update history --- docs/en/history.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index 88877f7..338ae82 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,10 @@ Release History =============== +Dev + + - Escape ``which`` calls to avoid aliases. Resolves :bbissue:`46`. + 2.2 - Switched hook loader execution to a form that works with Python From be2aba34f9fab788f621f50cc0ab28183a759279 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 3 Jun 2010 22:02:13 -0400 Subject: [PATCH 296/947] address #37 with wording change in docs --- docs/en/developers.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/developers.rst b/docs/en/developers.rst index 266863d..0420975 100644 --- a/docs/en/developers.rst +++ b/docs/en/developers.rst @@ -66,5 +66,5 @@ Running Tests The test suite for virtualenvwrapper uses `shunit2 `_. To run the tests under bash, sh, -and zsh, use ``make test``. To add new tests, modify or create an -appropriate script in the ``tests`` directory. +and zsh, use ``make test``. In order to add new tests, you will need +to modify or create an appropriate script in the ``tests`` directory. From f02df7429d8a130763c1f7f8d1462c2973380d45 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 3 Jun 2010 22:29:42 -0400 Subject: [PATCH 297/947] ignore missing files in trap cleanup (see #38) --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index f411568..39274cf 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -100,7 +100,7 @@ virtualenvwrapper_tempfile () { echo "ERROR: virtualenvwrapper could not create a temporary file name." 1>&2 return 1 fi - trap "rm '$file' >/dev/null 2>&1" EXIT + trap "rm -f '$file' >/dev/null 2>&1" EXIT echo $file return 0 } From 38daba74768724fecd285c579a04e5f3b3687ed5 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 4 Jun 2010 08:27:07 -0400 Subject: [PATCH 298/947] add support and bug tracker link to readme and docs --- README.txt | 13 +++++++++++-- docs/en/index.rst | 11 +++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/README.txt b/README.txt index 3cca3d5..5a20e36 100644 --- a/README.txt +++ b/README.txt @@ -61,6 +61,17 @@ Refer to the `developers docs `__ for tips on contributing patches. +======= +Support +======= + +Join the `virtualenvwrapper Google Group +`__ to discuss +issues and features. + +Report bugs via the `bug tracker on BitBucket +`__. + ======= License ======= @@ -82,5 +93,3 @@ CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -.. _BitBucket: http://bitbucket.org/dhellmann/virtualenvwrapper/overview/ diff --git a/docs/en/index.rst b/docs/en/index.rst index 1bbade4..89fe28e 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -201,6 +201,17 @@ showing off the features of virtualenvwrapper. Manuel Kaufmann has `translated this documentation into Spanish `__. +======= +Support +======= + +Join the `virtualenvwrapper Google Group +`__ to discuss +issues and features. + +Report bugs via the `bug tracker on BitBucket +`__. + ======= License ======= From 9d39ffc4249411e164b643408ad6f63154fec035 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 15 Jun 2010 09:44:40 -0300 Subject: [PATCH 299/947] unset GREP_OPTIONS before to use grep --- virtualenvwrapper.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 39274cf..e646cc5 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -59,7 +59,7 @@ fi # If the path is relative, prefix it with $HOME # (note: for compatibility) -if echo "$WORKON_HOME" | grep -e '^[^/~]' > /dev/null +if echo "$WORKON_HOME" | (unset GREP_OPTIONS; grep -e '^[^/~]' > /dev/null) then export WORKON_HOME="$HOME/$WORKON_HOME" fi @@ -68,7 +68,7 @@ fi # path might contain stuff to expand. # (it might be possible to do this in shell, but I don't know a # cross-shell-safe way of doing it -wolever) -if echo "$WORKON_HOME" | egrep -e "([$~]|//)" >/dev/null +if echo "$WORKON_HOME" | (unset GREP_OPTIONS; egrep -e "([$~]|//)" >/dev/null) then # This will normalize the path by: # - Removing extra slashes (e.g., when TMPDIR ends in a slash) @@ -142,7 +142,7 @@ virtualenvwrapper_initialize () { # Verify that virtualenv is installed and visible virtualenvwrapper_verify_virtualenv () { - typeset venv=$(\which virtualenv | grep -v "not found") + typeset venv=$(\which virtualenv | (unset GREP_OPTIONS; grep -v "not found")) if [ "$venv" = "" ] then echo "ERROR: virtualenvwrapper could not find virtualenv in your path" >&2 @@ -226,7 +226,7 @@ virtualenvwrapper_show_workon_options () { # NOTE: DO NOT use ls here because colorized versions spew control characters # into the output list. # echo seems a little faster than find, even with -depth 3. - (cd "$WORKON_HOME"; for f in */bin/activate; do echo $f; done) 2>/dev/null | sed 's|^\./||' | sed 's|/bin/activate||' | sort | egrep -v '^\*$' + (cd "$WORKON_HOME"; for f in */bin/activate; do echo $f; done) 2>/dev/null | sed 's|^\./||' | sed 's|/bin/activate||' | sort | (unset GREP_OPTIONS; egrep -v '^\*$') # (cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort } @@ -445,7 +445,7 @@ cpvirtualenv() { echo "Please specify target virtualenv" return 1 fi - if echo "$WORKON_HOME" | grep -e "/$" > /dev/null + if echo "$WORKON_HOME" | (unset GREP_OPTIONS; grep -e "/$" > /dev/null) then typset env_home="$WORKON_HOME" else From 8eea540b8b82d91fdb8ee6127d307fa2882b0ddd Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 20 Jun 2010 11:57:15 -0400 Subject: [PATCH 300/947] add tests for GREP_OPTIONS problem (ref #51) --- docs/en/history.rst | 2 ++ tests/test.sh | 11 +++++++++++ tests/test_workon.sh | 11 +++++++++++ 3 files changed, 24 insertions(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index 338ae82..5467e62 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -5,6 +5,8 @@ Release History Dev - Escape ``which`` calls to avoid aliases. Resolves :bbissue:`46`. + - Integrate Manuel Kaufmann's patch to unset GREP_OPTIONS before + calling grep. Resolves :bbissue:`51`. 2.2 diff --git a/tests/test.sh b/tests/test.sh index 8644962..32d96f4 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -49,6 +49,17 @@ test_virtualenvwrapper_verify_workon_home_missing_dir() { WORKON_HOME="$old_home" } +test_virtualenvwrapper_verify_workon_home_missing_dir_grep_options() { + old_home="$WORKON_HOME" + WORKON_HOME="$WORKON_HOME/not_there" + # This should prevent the message from being found if it isn't + # unset correctly. + export GREP_OPTIONS="--count" + assertFalse "WORKON_HOME verified unexpectedly" virtualenvwrapper_verify_workon_home + WORKON_HOME="$old_home" + unset GREP_OPTIONS +} + test_virtualenvwrapper_verify_workon_home_missing_dir_quiet_init() { old_home="$WORKON_HOME" export WORKON_HOME="$WORKON_HOME/not_there" diff --git a/tests/test_workon.sh b/tests/test_workon.sh index d759f33..707e132 100644 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -74,6 +74,17 @@ test_virtualenvwrapper_show_workon_options () { rm -f "$WORKON_HOME/link_env" } +test_virtualenvwrapper_show_workon_options_grep_options () { + mkdir "$WORKON_HOME/not_env" + (cd "$WORKON_HOME"; ln -s env1 link_env) + export GREP_OPTIONS="--count" + envs=$(virtualenvwrapper_show_workon_options | tr '\n' ' ') + unset GREP_OPTIONS + assertSame "env1 env2 link_env " "$envs" + rmdir "$WORKON_HOME/not_env" + rm -f "$WORKON_HOME/link_env" +} + test_virtualenvwrapper_show_workon_options_no_envs () { old_home="$WORKON_HOME" export WORKON_HOME=${TMPDIR:-/tmp}/$$ From b4792afd5f97e32a63eede2b87b3b0ecd45da624 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 20 Jun 2010 12:07:46 -0400 Subject: [PATCH 301/947] escape dollar sign in regex to resolve #53 --- announce.rst | 37 ++++++------------------------------- docs/en/history.rst | 1 + virtualenvwrapper.sh | 2 +- 3 files changed, 8 insertions(+), 32 deletions(-) diff --git a/announce.rst b/announce.rst index 79e3289..e0940d6 100644 --- a/announce.rst +++ b/announce.rst @@ -7,41 +7,16 @@ virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. -What's New in 2.1 +What's New in 2.2.1 ================= -The primary purpose of this release is a set of enhancements to -support virtualenvwrapper.project_, a new extension to manage project -work directories with templates. 2.1 also includes several smaller -changes and bug fixes. - -- Add support for ksh. Thanks to Doug Latornell for doing the - research on what needed to be changed. -- Test import of virtualenvwrapper.hook_loader on startup and report - the error in a way that should help the user figure out how to fix - it (issue #33). -- Update mkvirtualenv documentation to include the - fact that a new environment is activated immediately after it is - created (issue #30). -- Added hooks around cpvirtualenv. -- Made deactivation more robust, especially under ksh. -- Use Python's ``tempfile`` module for creating temporary filenames - safely and portably. -- Fix a problem with ``virtualenvwrapper_show_workon_options`` that - caused it to show ``*`` as the name of a virtualenv when no - environments had yet been created. -- Change the hook loader so it can be told to run only a set of - named hooks. -- Add support for listing the available hooks, to be used in help - output of commands like virtualenvwrapper.project's mkproject. -- Fix mkvirtualenv -h option behavior. -- Change logging so the $WORKON_HOME/hook.log file rotates after - 10KiB. - +Version 2.2.1 is a bug-fix release: +- Escape ``which`` calls to avoid aliases. (#46) +- Integrate Manuel Kaufmann's patch to unset GREP_OPTIONS before + calling grep. (#51) +- Escape ``$`` in regex to resolve #53. .. _virtualenv: http://pypi.python.org/pypi/virtualenv .. _virtualenvwrapper: http://www.doughellmann.com/projects/virtualenvwrapper/ - -.. _virtualenvwrapper.project: http://www.doughellmann.com/projects/virtualenvwrapper.project/ diff --git a/docs/en/history.rst b/docs/en/history.rst index 5467e62..20ae657 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -7,6 +7,7 @@ Dev - Escape ``which`` calls to avoid aliases. Resolves :bbissue:`46`. - Integrate Manuel Kaufmann's patch to unset GREP_OPTIONS before calling grep. Resolves :bbissue:`51`. + - Escape ``$`` in regex to resolve :bbissue:`53`. 2.2 diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index e646cc5..ffd349f 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -68,7 +68,7 @@ fi # path might contain stuff to expand. # (it might be possible to do this in shell, but I don't know a # cross-shell-safe way of doing it -wolever) -if echo "$WORKON_HOME" | (unset GREP_OPTIONS; egrep -e "([$~]|//)" >/dev/null) +if echo "$WORKON_HOME" | (unset GREP_OPTIONS; egrep -e "([\$~]|//)" >/dev/null) then # This will normalize the path by: # - Removing extra slashes (e.g., when TMPDIR ends in a slash) From 753b0af18ddceff56bac09123eb0c90e16ae1ece Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 20 Jun 2010 12:36:12 -0400 Subject: [PATCH 302/947] convert path deriving code in startup of script to function so it is easier to test --- tests/test_derive_workon_home.sh | 47 +++++++++++++++++++++++++ virtualenvwrapper.sh | 59 ++++++++++++++++++-------------- 2 files changed, 80 insertions(+), 26 deletions(-) create mode 100644 tests/test_derive_workon_home.sh diff --git a/tests/test_derive_workon_home.sh b/tests/test_derive_workon_home.sh new file mode 100644 index 0000000..5cf06ec --- /dev/null +++ b/tests/test_derive_workon_home.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +#set -x + +test_dir=$(cd $(dirname $0) && pwd) + +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +TMP_WORKON_HOME="$WORKON_HOME" + +oneTimeSetUp() { + rm -rf "$TMP_WORKON_HOME" + mkdir -p "$TMP_WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" + echo $PYTHONPATH +} + +oneTimeTearDown() { + rm -rf "$TMP_WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" + WORKON_HOME="$TMP_WORKON_HOME" +} + +test_default() { + unset WORKON_HOME + assertSame "$HOME/.virtualenvs" "$(virtualenvwrapper_derive_workon_home)" +} + +test_includes_relative_path() { + WORKON_HOME="$WORKON_HOME/../$(basename $WORKON_HOME)" + assertSame "$WORKON_HOME" "$(virtualenvwrapper_derive_workon_home)" +} + +test_begins_relative_path() { + WORKON_HOME=".test-virtualenvs" + assertSame "$HOME/.test-virtualenvs" "$(virtualenvwrapper_derive_workon_home)" +} + +test_includes_tilde() { + WORKON_HOME="~/.test-virtualenvs" + assertSame "$HOME/.test-virtualenvs" "$(virtualenvwrapper_derive_workon_home)" +} + +. "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index ffd349f..5e47608 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -44,39 +44,45 @@ # 11. The virtual environment is activated. # -# Make sure there is a default value for WORKON_HOME. -# You can override this setting in your .bashrc. -if [ "$WORKON_HOME" = "" ] -then - export WORKON_HOME="$HOME/.virtualenvs" -fi - # Locate the global Python where virtualenvwrapper is installed. if [ "$VIRTUALENVWRAPPER_PYTHON" = "" ] then VIRTUALENVWRAPPER_PYTHON="$(\which python)" fi -# If the path is relative, prefix it with $HOME -# (note: for compatibility) -if echo "$WORKON_HOME" | (unset GREP_OPTIONS; grep -e '^[^/~]' > /dev/null) -then - export WORKON_HOME="$HOME/$WORKON_HOME" -fi +virtualenvwrapper_derive_workon_home() { + typeset workon_home_dir="$WORKON_HOME" -# Only call on Python to fix the path if it looks like the -# path might contain stuff to expand. -# (it might be possible to do this in shell, but I don't know a -# cross-shell-safe way of doing it -wolever) -if echo "$WORKON_HOME" | (unset GREP_OPTIONS; egrep -e "([\$~]|//)" >/dev/null) -then - # This will normalize the path by: - # - Removing extra slashes (e.g., when TMPDIR ends in a slash) - # - Expanding variables (e.g., $foo) - # - Converting ~s to complete paths (e.g., ~/ to /home/brian/ and ~arthur to /home/arthur) - WORKON_HOME=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os; print os.path.expandvars(os.path.expanduser(\"$WORKON_HOME\"))") - export WORKON_HOME -fi + # Make sure there is a default value for WORKON_HOME. + # You can override this setting in your .bashrc. + if [ "$workon_home_dir" = "" ] + then + workon_home_dir="$HOME/.virtualenvs" + fi + + # If the path is relative, prefix it with $HOME + # (note: for compatibility) + if echo "$workon_home_dir" | (unset GREP_OPTIONS; grep -e '^[^/~]' > /dev/null) + then + workon_home_dir="$HOME/$WORKON_HOME" + fi + + # Only call on Python to fix the path if it looks like the + # path might contain stuff to expand. + # (it might be possible to do this in shell, but I don't know a + # cross-shell-safe way of doing it -wolever) + if echo "$workon_home_dir" | (unset GREP_OPTIONS; egrep -e "([\$~]|//)" >/dev/null) + then + # This will normalize the path by: + # - Removing extra slashes (e.g., when TMPDIR ends in a slash) + # - Expanding variables (e.g., $foo) + # - Converting ~s to complete paths (e.g., ~/ to /home/brian/ and ~arthur to /home/arthur) + workon_home_dir=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os; print os.path.expandvars(os.path.expanduser(\"$workon_home_dir\"))") + fi + + echo "$workon_home_dir" + return 0 +} # Verify that the WORKON_HOME directory exists virtualenvwrapper_verify_workon_home () { @@ -131,6 +137,7 @@ virtualenvwrapper_run_hook () { # Set up virtualenvwrapper properly virtualenvwrapper_initialize () { + export WORKON_HOME=$(virtualenvwrapper_derive_workon_home) virtualenvwrapper_verify_workon_home -q || return 1 virtualenvwrapper_run_hook "initialize" if [ $? -ne 0 ] From bdde6dc3340558567671d8c78eef08720d30c569 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 20 Jun 2010 13:44:21 -0400 Subject: [PATCH 303/947] bump version to 2.2.1 --- docs/en/history.rst | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 20ae657..f53f2d3 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,7 +2,7 @@ Release History =============== -Dev +2.2.1 - Escape ``which`` calls to avoid aliases. Resolves :bbissue:`46`. - Integrate Manuel Kaufmann's patch to unset GREP_OPTIONS before diff --git a/setup.py b/setup.py index ee9fd08..2ddde33 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' -VERSION = '2.2' +VERSION = '2.2.1' # Bootstrap installation of Distribute import distribute_setup From 5ef7081390f738a50b981517b85ec18e4546de06 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 20 Jun 2010 13:44:26 -0400 Subject: [PATCH 304/947] Added tag 2.2.1 for changeset 66a89d019905 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index fc675f1..81890ac 100644 --- a/.hgtags +++ b/.hgtags @@ -52,3 +52,4 @@ d64869519c2e0553303cfeeb0918271564c72beb 1.27 241df6c36860c13fae5468881457a27840ee9d72 2.1 7540fc7d8e63cafe6c3126e0855ed8c277b450cf 2.1.1 d5c5faecc92daef3d15510f0314d4d5e6c95e234 2.2 +66a89d019905aa7b697b7ce69303201f50e1d4e7 2.2.1 From c5433fefff52d8623a61af46b91f44ce0b10c69e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 20 Jun 2010 14:54:42 -0400 Subject: [PATCH 305/947] fix #50 by escaping rm before calling it --- README.txt | 10 ++++++++++ docs/en/history.rst | 2 ++ docs/en/index.rst | 10 ++++++++++ tests/test_rmvirtualenv.sh | 10 ++++++++++ virtualenvwrapper.sh | 6 +++--- 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/README.txt b/README.txt index 5a20e36..d7f073d 100644 --- a/README.txt +++ b/README.txt @@ -72,6 +72,16 @@ issues and features. Report bugs via the `bug tracker on BitBucket `__. +Shell Aliases +============= + +Since virtualenvwrapper is largely a shell script, it uses shell +commands for a lot of its actions. If your environment makes heavy +use of shell aliases or other customizations, you may encounter +issues. Before reporting bugs in the bug tracker, please test +*without* your aliases enabled. If you can identify the alias causing +the problem, that will help make virtualenvwrapper more robust. + ======= License ======= diff --git a/docs/en/history.rst b/docs/en/history.rst index f53f2d3..e01e05e 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -8,6 +8,8 @@ Release History - Integrate Manuel Kaufmann's patch to unset GREP_OPTIONS before calling grep. Resolves :bbissue:`51`. - Escape ``$`` in regex to resolve :bbissue:`53`. + - Escape ``rm`` to avoid issues with aliases and resolve + :bbissue:`50`. 2.2 diff --git a/docs/en/index.rst b/docs/en/index.rst index 89fe28e..d43599a 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -212,6 +212,16 @@ issues and features. Report bugs via the `bug tracker on BitBucket `__. +Shell Aliases +============= + +Since virtualenvwrapper is largely a shell script, it uses shell +commands for a lot of its actions. If your environment makes heavy +use of shell aliases or other customizations, you may encounter +issues. Before reporting bugs in the bug tracker, please test +*without* your aliases enabled. If you can identify the alias causing +the problem, that will help make virtualenvwrapper more robust. + ======= License ======= diff --git a/tests/test_rmvirtualenv.sh b/tests/test_rmvirtualenv.sh index 20629d0..169af89 100644 --- a/tests/test_rmvirtualenv.sh +++ b/tests/test_rmvirtualenv.sh @@ -29,6 +29,16 @@ test_remove () { assertFalse "[ -d $WORKON_HOME/deleteme ]" } +test_rm_aliased () { + mkvirtualenv "deleteme" + deactivate + alias rm='rm -i' + set -x + rmvirtualenv "deleteme" + set +x + unalias rm +} + test_no_such_env () { assertFalse "[ -d $WORKON_HOME/deleteme ]" assertTrue "rmvirtualenv deleteme" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 5e47608..f0241b7 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -106,7 +106,7 @@ virtualenvwrapper_tempfile () { echo "ERROR: virtualenvwrapper could not create a temporary file name." 1>&2 return 1 fi - trap "rm -f '$file' >/dev/null 2>&1" EXIT + trap "\rm -f '$file' >/dev/null 2>&1" EXIT echo $file return 0 } @@ -131,7 +131,7 @@ virtualenvwrapper_run_hook () { fi source "$hook_script" fi - rm -f "$hook_script" >/dev/null 2>&1 + \rm -f "$hook_script" >/dev/null 2>&1 return $result } @@ -223,7 +223,7 @@ rmvirtualenv () { return 1 fi virtualenvwrapper_run_hook "pre_rmvirtualenv" "$env_name" - rm -rf "$env_dir" + \rm -rf "$env_dir" virtualenvwrapper_run_hook "post_rmvirtualenv" "$env_name" } From 8fb218e180c1e742e68a60f2a27f03867a3bac86 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 20 Jun 2010 15:01:12 -0400 Subject: [PATCH 306/947] Added tag 2.2.1 for changeset 87d60f20a715 --- .hgtags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.hgtags b/.hgtags index 81890ac..431588b 100644 --- a/.hgtags +++ b/.hgtags @@ -53,3 +53,5 @@ d64869519c2e0553303cfeeb0918271564c72beb 1.27 7540fc7d8e63cafe6c3126e0855ed8c277b450cf 2.1.1 d5c5faecc92daef3d15510f0314d4d5e6c95e234 2.2 66a89d019905aa7b697b7ce69303201f50e1d4e7 2.2.1 +66a89d019905aa7b697b7ce69303201f50e1d4e7 2.2.1 +87d60f20a715e5641e819d127cfdc31f8003c4f2 2.2.1 From 764d89106ff7835ba6992389060f600e3ef8ca16 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 27 Jun 2010 15:52:51 -0400 Subject: [PATCH 307/947] incorporate patch from fredpalmer to escape grep calls (fixes #57) --- virtualenvwrapper.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index f0241b7..bf82129 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -62,7 +62,7 @@ virtualenvwrapper_derive_workon_home() { # If the path is relative, prefix it with $HOME # (note: for compatibility) - if echo "$workon_home_dir" | (unset GREP_OPTIONS; grep -e '^[^/~]' > /dev/null) + if echo "$workon_home_dir" | (unset GREP_OPTIONS; \grep -e '^[^/~]' > /dev/null) then workon_home_dir="$HOME/$WORKON_HOME" fi @@ -71,7 +71,7 @@ virtualenvwrapper_derive_workon_home() { # path might contain stuff to expand. # (it might be possible to do this in shell, but I don't know a # cross-shell-safe way of doing it -wolever) - if echo "$workon_home_dir" | (unset GREP_OPTIONS; egrep -e "([\$~]|//)" >/dev/null) + if echo "$workon_home_dir" | (unset GREP_OPTIONS; \egrep -e "([\$~]|//)" >/dev/null) then # This will normalize the path by: # - Removing extra slashes (e.g., when TMPDIR ends in a slash) @@ -149,7 +149,7 @@ virtualenvwrapper_initialize () { # Verify that virtualenv is installed and visible virtualenvwrapper_verify_virtualenv () { - typeset venv=$(\which virtualenv | (unset GREP_OPTIONS; grep -v "not found")) + typeset venv=$(\which virtualenv | (unset GREP_OPTIONS; \grep -v "not found")) if [ "$venv" = "" ] then echo "ERROR: virtualenvwrapper could not find virtualenv in your path" >&2 @@ -233,7 +233,7 @@ virtualenvwrapper_show_workon_options () { # NOTE: DO NOT use ls here because colorized versions spew control characters # into the output list. # echo seems a little faster than find, even with -depth 3. - (cd "$WORKON_HOME"; for f in */bin/activate; do echo $f; done) 2>/dev/null | sed 's|^\./||' | sed 's|/bin/activate||' | sort | (unset GREP_OPTIONS; egrep -v '^\*$') + (cd "$WORKON_HOME"; for f in */bin/activate; do echo $f; done) 2>/dev/null | sed 's|^\./||' | sed 's|/bin/activate||' | sort | (unset GREP_OPTIONS; \egrep -v '^\*$') # (cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort } @@ -452,7 +452,7 @@ cpvirtualenv() { echo "Please specify target virtualenv" return 1 fi - if echo "$WORKON_HOME" | (unset GREP_OPTIONS; grep -e "/$" > /dev/null) + if echo "$WORKON_HOME" | (unset GREP_OPTIONS; \grep -e "/$" > /dev/null) then typset env_home="$WORKON_HOME" else From b956ae5f87bd8ee835229ec1f04fee947e0b3a55 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 27 Jun 2010 17:24:17 -0400 Subject: [PATCH 308/947] escape more commands (see #57) --- virtualenvwrapper.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index bf82129..7643be2 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -100,7 +100,7 @@ virtualenvwrapper_verify_workon_home () { virtualenvwrapper_tempfile () { # Note: the 'X's must come last typeset suffix=${1:-hook} - typeset file="`mktemp -t virtualenvwrapper-$suffix-XXXXXXXXXX`" + typeset file="`\mktemp -t virtualenvwrapper-$suffix-XXXXXXXXXX`" if [ $? -ne 0 ] then echo "ERROR: virtualenvwrapper could not create a temporary file name." 1>&2 @@ -233,7 +233,7 @@ virtualenvwrapper_show_workon_options () { # NOTE: DO NOT use ls here because colorized versions spew control characters # into the output list. # echo seems a little faster than find, even with -depth 3. - (cd "$WORKON_HOME"; for f in */bin/activate; do echo $f; done) 2>/dev/null | sed 's|^\./||' | sed 's|/bin/activate||' | sort | (unset GREP_OPTIONS; \egrep -v '^\*$') + (cd "$WORKON_HOME"; for f in */bin/activate; do echo $f; done) 2>/dev/null | \sed 's|^\./||' | \sed 's|/bin/activate||' | \sort | (unset GREP_OPTIONS; \egrep -v '^\*$') # (cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort } @@ -467,17 +467,17 @@ cpvirtualenv() { return 1 fi - cp -r "$source_env" "$target_env" - for script in $( ls $target_env/bin/* ) + \cp -r "$source_env" "$target_env" + for script in $( \ls $target_env/bin/* ) do newscript="$script-new" - sed "s|$source_env|$target_env|g" < "$script" > "$newscript" - mv "$newscript" "$script" - chmod a+x "$script" + \sed "s|$source_env|$target_env|g" < "$script" > "$newscript" + \mv "$newscript" "$script" + \chmod a+x "$script" done virtualenv "$target_env" --relocatable - sed "s/VIRTUAL_ENV\(.*\)$env_name/VIRTUAL_ENV\1$new_env/g" < "$source_env/bin/activate" > "$target_env/bin/activate" + \sed "s/VIRTUAL_ENV\(.*\)$env_name/VIRTUAL_ENV\1$new_env/g" < "$source_env/bin/activate" > "$target_env/bin/activate" (cd "$WORKON_HOME" && virtualenvwrapper_run_hook "pre_cpvirtualenv" "$env_name" "$new_env" && From f9d9fe22597a9abf1876ffe7ce1cf46bec1bce06 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 27 Jun 2010 17:26:32 -0400 Subject: [PATCH 309/947] update history with changes (see #57) --- docs/en/history.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index e01e05e..58afde5 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,11 @@ Release History =============== +Dev + + - Integrate Fred Palmer's patch to escape more shell commands to + avoid aliases. Resolves :bbissue:`57`. + 2.2.1 - Escape ``which`` calls to avoid aliases. Resolves :bbissue:`46`. From 201ed5886b3f24f76e8a7cc6d0e69f57cf3c3e12 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 27 Jun 2010 17:50:24 -0400 Subject: [PATCH 310/947] use single quotes around regex with $ (see #55) --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 7643be2..44cebf7 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -71,7 +71,7 @@ virtualenvwrapper_derive_workon_home() { # path might contain stuff to expand. # (it might be possible to do this in shell, but I don't know a # cross-shell-safe way of doing it -wolever) - if echo "$workon_home_dir" | (unset GREP_OPTIONS; \egrep -e "([\$~]|//)" >/dev/null) + if echo "$workon_home_dir" | (unset GREP_OPTIONS; \egrep -e '([\$~]|//)' >/dev/null) then # This will normalize the path by: # - Removing extra slashes (e.g., when TMPDIR ends in a slash) From e7c988ed8230a4f3482791e99faac85e1c8652bf Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 27 Jun 2010 17:58:04 -0400 Subject: [PATCH 311/947] check exit code of virtualenv before proceeding (fixes #56) --- tests/test_mkvirtualenv.sh | 6 ++++++ virtualenvwrapper.sh | 2 ++ 2 files changed, 8 insertions(+) diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index 38d345f..fc8f36d 100644 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -67,6 +67,12 @@ test_no_virtualenv () { assertSame "$RC" "1" } +test_no_args () { + mkvirtualenv 2>/dev/null 1>&2 + RC=$? + assertSame "2" "$RC" +} + test_no_workon_home () { old_home="$WORKON_HOME" export WORKON_HOME="$WORKON_HOME/not_there" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 44cebf7..e0198c8 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -197,6 +197,8 @@ mkvirtualenv () { virtualenv "$@" && [ -d "$WORKON_HOME/$envname" ] && virtualenvwrapper_run_hook "pre_mkvirtualenv" "$envname" ) + typeset RC=$? + [ $RC -ne 0 ] && return $RC # If they passed a help option or got an error from virtualenv, # the environment won't exist. Use that to tell whether # we should switch to the environment and run the hook. From 0742eff41227d526331ecfc5db343febb537d848 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 27 Jun 2010 18:04:03 -0400 Subject: [PATCH 312/947] bump version to 2.2.2 --- docs/en/history.rst | 4 +++- setup.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 58afde5..2d5c38e 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,10 +2,12 @@ Release History =============== -Dev +2.2.2 - Integrate Fred Palmer's patch to escape more shell commands to avoid aliases. Resolves :bbissue:`57`. + - Fix a problem with egrep argument escaping (:bbissue:`55`). + - Fix a problem with running mkvirtualenv without arguments (:bbissue:`56`). 2.2.1 diff --git a/setup.py b/setup.py index 2ddde33..9bc9c0e 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' -VERSION = '2.2.1' +VERSION = '2.2.2' # Bootstrap installation of Distribute import distribute_setup From 27afc9ccc62bd346f22ca25675908577fbcdf4cd Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 27 Jun 2010 18:04:06 -0400 Subject: [PATCH 313/947] Added tag 2.2.2 for changeset 266a166f80da --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 431588b..b9f0ece 100644 --- a/.hgtags +++ b/.hgtags @@ -55,3 +55,4 @@ d5c5faecc92daef3d15510f0314d4d5e6c95e234 2.2 66a89d019905aa7b697b7ce69303201f50e1d4e7 2.2.1 66a89d019905aa7b697b7ce69303201f50e1d4e7 2.2.1 87d60f20a715e5641e819d127cfdc31f8003c4f2 2.2.1 +266a166f80da390a22e684497f971b6b22776cb9 2.2.2 From aad3987019ac5074af0ca33a5284211419fadf4b Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 16 Aug 2010 11:15:04 -0400 Subject: [PATCH 314/947] add get_env_details hook --- ChangeLog | 10 ++++++++++ docs/en/history.rst | 4 ++++ docs/en/plugins.rst | 11 +++++++++++ docs/en/scripts.rst | 14 ++++++++++++++ setup.py | 6 +++++- virtualenvwrapper.sh | 8 +++++++- virtualenvwrapper/user_scripts.py | 16 ++++++++++++++++ 7 files changed, 67 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 35bfde4..30a8c12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-08-16 Doug Hellmann + + * virtualenvwrapper/user_scripts.py (get_env_details): New hook to + optionally give more detail than the name of an environment when + the user requests a list. + + * virtualenvwrapper.sh: Update workon to use the get_env_details + hook to print more details, if the user provides scripts to give + them. + 2010-06-03 Doug Hellmann * virtualenvwrapper.sh: Escape the call to "which" so we don't use diff --git a/docs/en/history.rst b/docs/en/history.rst index 2d5c38e..daaa643 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,10 @@ Release History =============== +2.3 + + - Added ``get_env_details`` hook. + 2.2.2 - Integrate Fred Palmer's patch to escape more shell commands to diff --git a/docs/en/plugins.rst b/docs/en/plugins.rst index 50e4a0a..300c8f4 100644 --- a/docs/en/plugins.rst +++ b/docs/en/plugins.rst @@ -298,6 +298,17 @@ before or after the event. The suffix ``_source`` is added for extensions that return shell code instead of taking action directly (see :ref:`plugins-user-env`). +.. _plugins-get_env_details: + +get_env_details +=============== + +The ``virtualenvwrapper.get_env_details`` hooks are run when +``workon`` is run with no arguments and a list of the virtual +environments is printed. The hook is run once for each environment, +after the name is printed, and can be used to show additional +information about that environment. + .. _plugins-initialize: initialize diff --git a/docs/en/scripts.rst b/docs/en/scripts.rst index 02fa798..96bb51a 100644 --- a/docs/en/scripts.rst +++ b/docs/en/scripts.rst @@ -8,6 +8,20 @@ The end-user customization scripts are either *sourced* (allowing them to modify your shell environment) or *run* as an external program at the appropriate trigger time. +.. _scripts-get_env_details: + +get_env_details +=============== + + :Global/Local: both + :Argument(s): env name + :Sourced/Run: run + +``$WORKON_HOME/get_env_details`` is run when ``workon`` is run with no +arguments and a list of the virtual environments is printed. The hook +is run once for each environment, after the name is printed, and can +print additional information about that environment. + .. _scripts-initialize: initialize diff --git a/setup.py b/setup.py index 9bc9c0e..860166f 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' -VERSION = '2.2.2' +VERSION = '2.3' # Bootstrap installation of Distribute import distribute_setup @@ -194,6 +194,10 @@ def find_package_data( 'virtualenvwrapper.post_deactivate_source': [ 'user_scripts = virtualenvwrapper.user_scripts:post_deactivate_source', ], + + 'virtualenvwrapper.get_env_details': [ + 'user_scripts = virtualenvwrapper.user_scripts:get_env_details', + ], }, zip_safe=False, diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index e0198c8..621f3c6 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -236,6 +236,7 @@ virtualenvwrapper_show_workon_options () { # into the output list. # echo seems a little faster than find, even with -depth 3. (cd "$WORKON_HOME"; for f in */bin/activate; do echo $f; done) 2>/dev/null | \sed 's|^\./||' | \sed 's|/bin/activate||' | \sort | (unset GREP_OPTIONS; \egrep -v '^\*$') + # (cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort } @@ -247,7 +248,12 @@ workon () { typeset env_name="$1" if [ "$env_name" = "" ] then - virtualenvwrapper_show_workon_options + for env_name in $(virtualenvwrapper_show_workon_options) + do + echo -n "$env_name" + virtualenvwrapper_run_hook "get_env_details" "$env_name" + echo + done return 1 fi diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 17c693e..7b414c9 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -73,6 +73,10 @@ def run_global(script_name, *args): "This hook is run before every virtualenv is activated."), ("postactivate", "This hook is run after every virtualenv is activated."), + + # get_env_details + ("get_env_details", + "This hook is run when the list of virtualenvs is printed so each name can include details."), ] @@ -88,6 +92,10 @@ def run_global(script_name, *args): "This hook is run before this virtualenv is activated."), ("postactivate", "This hook is run after this virtualenv is activated."), + + # get_env_details + ("get_env_details", + "This hook is run when the list of virtualenvs is printed so each name can include details."), ] @@ -218,3 +226,11 @@ def post_deactivate_source(args): [ -f "$WORKON_HOME/postdeactivate" ] && source "$WORKON_HOME/postdeactivate" unset VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV """ % { 'env_name':args[0] } + + +def get_env_details(args): + log.debug('get_env_details') + run_global('get_env_details', *args) + script_path = os.path.expandvars(os.path.join('$WORKON_HOME', args[0], 'bin', 'get_env_details')) + run_script(script_path, *args) + return From 3510c41119312b44e2c96ff1da04dc8625c5c301 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 16 Aug 2010 11:15:07 -0400 Subject: [PATCH 315/947] Added tag 2.3 for changeset b9d4591458bb --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index b9f0ece..267adb7 100644 --- a/.hgtags +++ b/.hgtags @@ -56,3 +56,4 @@ d5c5faecc92daef3d15510f0314d4d5e6c95e234 2.2 66a89d019905aa7b697b7ce69303201f50e1d4e7 2.2.1 87d60f20a715e5641e819d127cfdc31f8003c4f2 2.2.1 266a166f80da390a22e684497f971b6b22776cb9 2.2.2 +b9d4591458bbaf41d4e40104e8f19c19d76b4664 2.3 From 7e33c281fb258f25c59c691dd1aa8dbfb376fad8 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 26 Aug 2010 09:31:24 -0400 Subject: [PATCH 316/947] add lsvirtualenv command with -l option --- docs/en/command_ref.rst | 20 ++++++++++++++ docs/en/history.rst | 6 +++++ setup.py | 2 +- virtualenvwrapper.sh | 44 ++++++++++++++++++++++++++----- virtualenvwrapper/user_scripts.py | 2 +- 5 files changed, 66 insertions(+), 8 deletions(-) diff --git a/docs/en/command_ref.rst b/docs/en/command_ref.rst index 13958f7..46684d1 100644 --- a/docs/en/command_ref.rst +++ b/docs/en/command_ref.rst @@ -45,6 +45,26 @@ new environment is automatically activated after being initialized. * :ref:`scripts-premkvirtualenv` * :ref:`scripts-postmkvirtualenv` +.. _command-lsvirtualenv: + +lsvirtualenv +------------ + +List all of the environments. + +Syntax:: + + lsvirtualenv [-l] [-h] + +-l + Long mode, enables verbose output. +-h + Print the help for lsvirtualenv. + +.. seealso:: + + * :ref:`scripts-get_env_details` + rmvirtualenv ------------ diff --git a/docs/en/history.rst b/docs/en/history.rst index daaa643..85c022a 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,12 @@ Release History =============== +2.4 + + - Add ``lsvirtualenv`` command with ``-l`` option to run + ``get_env_details`` hook instead of always running it when + ``workon`` has no arguments. + 2.3 - Added ``get_env_details`` hook. diff --git a/setup.py b/setup.py index 860166f..4e62bef 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' -VERSION = '2.3' +VERSION = '2.4' # Bootstrap installation of Distribute import distribute_setup diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 621f3c6..7e320d0 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -240,13 +240,31 @@ virtualenvwrapper_show_workon_options () { # (cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort } -# List or change working virtual environments -# -# Usage: workon [environment_name] +_lsvirtualenv_usage () { + echo "lsvirtualenv [-lh]" +} + +# List virtual environments # -workon () { - typeset env_name="$1" - if [ "$env_name" = "" ] +# Usage: lsvirtualenv [-l] +lsvirtualenv () { + typeset args=$(getopt lh $*) + if [ $? != 0 ] + then + _lsvirtualenv_usage + return 1 + fi + typeset long_mode=false + for opt in $args + do + case "$opt" in + -l) long_mode=true;; + -h) _lsvirtualenv_usage; + return 1;; + esac + done + + if $long_mode then for env_name in $(virtualenvwrapper_show_workon_options) do @@ -254,6 +272,20 @@ workon () { virtualenvwrapper_run_hook "get_env_details" "$env_name" echo done + else + virtualenvwrapper_show_workon_options + fi +} + +# List or change working virtual environments +# +# Usage: workon [environment_name] +# +workon () { + typeset env_name="$1" + if [ "$env_name" = "" ] + then + lsvirtualenv return 1 fi diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 7b414c9..1ba3f74 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -95,7 +95,7 @@ def run_global(script_name, *args): # get_env_details ("get_env_details", - "This hook is run when the list of virtualenvs is printed so each name can include details."), + "This hook is run when the list of virtualenvs is printed in 'long' mode so each name can include details."), ] From 1ca01c61acfe6ccb7a6f447b94e1ddff5ab17d29 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 26 Aug 2010 09:31:32 -0400 Subject: [PATCH 317/947] Added tag 2.4 for changeset 64f858d461d4 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 267adb7..d4dedda 100644 --- a/.hgtags +++ b/.hgtags @@ -57,3 +57,4 @@ d5c5faecc92daef3d15510f0314d4d5e6c95e234 2.2 87d60f20a715e5641e819d127cfdc31f8003c4f2 2.2.1 266a166f80da390a22e684497f971b6b22776cb9 2.2.2 b9d4591458bbaf41d4e40104e8f19c19d76b4664 2.3 +64f858d461d449601d6bc3e2521b34dbd1c916a5 2.4 From f52ab19d0436d2330884a1bd977ad67212fddda6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 26 Aug 2010 09:32:25 -0400 Subject: [PATCH 318/947] tweak history file --- docs/en/history.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 85c022a..e1c71c1 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -4,9 +4,9 @@ Release History 2.4 - - Add ``lsvirtualenv`` command with ``-l`` option to run - ``get_env_details`` hook instead of always running it when - ``workon`` has no arguments. + - Add :ref:`command-lsvirtualenv` command with ``-l`` option to run + :ref:`scripts-get_env_details` hook instead of always running it + when :ref:`command-workon` has no arguments. 2.3 From 376947999010188e98dbd3728932fcbb73cbade3 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 26 Aug 2010 09:32:28 -0400 Subject: [PATCH 319/947] Added tag 2.4 for changeset a85d80e88996 --- .hgtags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.hgtags b/.hgtags index d4dedda..701fab7 100644 --- a/.hgtags +++ b/.hgtags @@ -58,3 +58,5 @@ d5c5faecc92daef3d15510f0314d4d5e6c95e234 2.2 266a166f80da390a22e684497f971b6b22776cb9 2.2.2 b9d4591458bbaf41d4e40104e8f19c19d76b4664 2.3 64f858d461d449601d6bc3e2521b34dbd1c916a5 2.4 +64f858d461d449601d6bc3e2521b34dbd1c916a5 2.4 +a85d80e88996c15e2e2b832e2956811eea73ee34 2.4 From 4ceb6961be970bfe6d8e43deb9b6becf25c18c9d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 9 Sep 2010 20:46:24 -0400 Subject: [PATCH 320/947] add showvirtualenv and re-implement lsvirtualenv with it --- virtualenvwrapper.sh | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 7e320d0..b3be66e 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -241,24 +241,28 @@ virtualenvwrapper_show_workon_options () { } _lsvirtualenv_usage () { - echo "lsvirtualenv [-lh]" + echo "lsvirtualenv [-blh]" + echo " -b -- brief mode" + echo " -l -- long mode" + echo " -h -- this help message" } # List virtual environments # # Usage: lsvirtualenv [-l] lsvirtualenv () { - typeset args=$(getopt lh $*) + typeset args=$(getopt blh $*) if [ $? != 0 ] then _lsvirtualenv_usage return 1 fi - typeset long_mode=false + typeset long_mode=true for opt in $args do case "$opt" in -l) long_mode=true;; + -b) long_mode=false;; -h) _lsvirtualenv_usage; return 1;; esac @@ -268,15 +272,33 @@ lsvirtualenv () { then for env_name in $(virtualenvwrapper_show_workon_options) do - echo -n "$env_name" - virtualenvwrapper_run_hook "get_env_details" "$env_name" - echo + showvirtualenv "$env_name" done else virtualenvwrapper_show_workon_options fi } +# Show details of a virtualenv +# +# Usage: showvirtualenv [env] +showvirtualenv () { + typeset env_name="$1" + if [ -z "$env_name" ] + then + if [ -z "$VIRTUAL_ENV" ] + then + echo "showvirtualenv [env]" + return 1 + fi + env_name=$(basename $VIRTUAL_ENV) + fi + + echo -n "$env_name" + virtualenvwrapper_run_hook "get_env_details" "$env_name" + echo +} + # List or change working virtual environments # # Usage: workon [environment_name] From c791a901b23e75fe543a1ad1af8573e202c7a1b5 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 9 Sep 2010 20:49:07 -0400 Subject: [PATCH 321/947] add docs for showvirtualenv --- docs/en/command_ref.rst | 21 +++++++++++++++++++-- docs/en/history.rst | 5 +++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/docs/en/command_ref.rst b/docs/en/command_ref.rst index 46684d1..369aa60 100644 --- a/docs/en/command_ref.rst +++ b/docs/en/command_ref.rst @@ -54,10 +54,12 @@ List all of the environments. Syntax:: - lsvirtualenv [-l] [-h] + lsvirtualenv [-b] [-l] [-h] +-b + Brief mode, disables verbose output. -l - Long mode, enables verbose output. + Long mode, enables verbose output. Default. -h Print the help for lsvirtualenv. @@ -65,6 +67,21 @@ Syntax:: * :ref:`scripts-get_env_details` +.. _command-showvirtualenv: + +showvirtualenv +-------------- + +Show the details for a single virtualenv. + +Syntax:: + + showvirtualenv [env] + +.. seealso:: + + * :ref:`scripts-get_env_details` + rmvirtualenv ------------ diff --git a/docs/en/history.rst b/docs/en/history.rst index e1c71c1..3a679f7 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,11 @@ Release History =============== +2.5 + + - Add :ref:`command-showvirtualenv` command. Modify + :ref:`command-lsvirtualenv` to make verbose output the default. + 2.4 - Add :ref:`command-lsvirtualenv` command with ``-l`` option to run From d0b2895f77e252e1563e2a519e4191d2c282dd15 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 9 Sep 2010 20:49:23 -0400 Subject: [PATCH 322/947] bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 4e62bef..31ad001 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' -VERSION = '2.4' +VERSION = '2.5' # Bootstrap installation of Distribute import distribute_setup From 3e9b176cbb137f70a71fdcc6652273826231e76e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 9 Sep 2010 20:49:25 -0400 Subject: [PATCH 323/947] Added tag 2.5 for changeset 80e2fcda77ac --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 701fab7..015ed5f 100644 --- a/.hgtags +++ b/.hgtags @@ -60,3 +60,4 @@ b9d4591458bbaf41d4e40104e8f19c19d76b4664 2.3 64f858d461d449601d6bc3e2521b34dbd1c916a5 2.4 64f858d461d449601d6bc3e2521b34dbd1c916a5 2.4 a85d80e88996c15e2e2b832e2956811eea73ee34 2.4 +80e2fcda77acd85500159e3e688e5acfa3d99bd3 2.5 From 5e60d1ca44c8ed98ce50af0ab70e48effdb4d938 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 14 Sep 2010 09:01:16 -0400 Subject: [PATCH 324/947] fix workon to list in brief mode --- ChangeLog | 5 +++++ setup.py | 2 +- virtualenvwrapper.sh | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 30a8c12..677960a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-09-14 Doug Hellmann + + * virtualenvwrapper.sh (workon): Use the brief list format by + default. + 2010-08-16 Doug Hellmann * virtualenvwrapper/user_scripts.py (get_env_details): New hook to diff --git a/setup.py b/setup.py index 31ad001..c7c38d8 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' -VERSION = '2.5' +VERSION = '2.5.1' # Bootstrap installation of Distribute import distribute_setup diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index b3be66e..d8a3df3 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -307,7 +307,7 @@ workon () { typeset env_name="$1" if [ "$env_name" = "" ] then - lsvirtualenv + lsvirtualenv -b return 1 fi From 6487a2e82b12196fc23dbd4d96e16a553e99331a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 14 Sep 2010 09:01:21 -0400 Subject: [PATCH 325/947] Added tag 2.5.1 for changeset 2ab678413a29 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 015ed5f..2649f4c 100644 --- a/.hgtags +++ b/.hgtags @@ -61,3 +61,4 @@ b9d4591458bbaf41d4e40104e8f19c19d76b4664 2.3 64f858d461d449601d6bc3e2521b34dbd1c916a5 2.4 a85d80e88996c15e2e2b832e2956811eea73ee34 2.4 80e2fcda77acd85500159e3e688e5acfa3d99bd3 2.5 +2ab678413a290410ed4c8a1b72a567d79caa5ae5 2.5.1 From 8fd0bad7299c4bdfb63a88691ee46e8c4d38b433 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 18 Sep 2010 08:56:50 -0400 Subject: [PATCH 326/947] Make lsvirtualenv work under zsh using patch from Zach Voase. Fixes #64 --- ChangeLog | 5 +++++ docs/en/history.rst | 10 ++++++++++ setup.py | 2 +- virtualenvwrapper.sh | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 677960a..9a1122a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-09-18 Doug Hellmann + + * virtualenvwrapper.sh: Apply patch from Zach Voase to fix + lsvirtualenv under zsh. + 2010-09-14 Doug Hellmann * virtualenvwrapper.sh (workon): Use the brief list format by diff --git a/docs/en/history.rst b/docs/en/history.rst index 3a679f7..1ca20f4 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,16 @@ Release History =============== +2.5.2 + + - Apply patch from Zach Voase to fix :ref:`command-lsvirtualenv` + under zsh. Resolves :bbissue:`64`. + +2.5.1 + + - Make :ref:`command-workon` list brief environment details when run + without argument, instead of full details. + 2.5 - Add :ref:`command-showvirtualenv` command. Modify diff --git a/setup.py b/setup.py index c7c38d8..256706c 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' -VERSION = '2.5.1' +VERSION = '2.5.2' # Bootstrap installation of Distribute import distribute_setup diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index d8a3df3..f97f8ed 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -251,7 +251,7 @@ _lsvirtualenv_usage () { # # Usage: lsvirtualenv [-l] lsvirtualenv () { - typeset args=$(getopt blh $*) + typeset args="$(getopt blh "$@")" if [ $? != 0 ] then _lsvirtualenv_usage From b0d2ebe120d7b9e4efd1818388170397c3c16c74 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 18 Sep 2010 08:56:54 -0400 Subject: [PATCH 327/947] Added tag 2.5.2 for changeset f71ffbb996c4 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 2649f4c..eb5874a 100644 --- a/.hgtags +++ b/.hgtags @@ -62,3 +62,4 @@ b9d4591458bbaf41d4e40104e8f19c19d76b4664 2.3 a85d80e88996c15e2e2b832e2956811eea73ee34 2.4 80e2fcda77acd85500159e3e688e5acfa3d99bd3 2.5 2ab678413a290410ed4c8a1b72a567d79caa5ae5 2.5.1 +f71ffbb996c41606aea15b2114120d9fca3adfc6 2.5.2 From ec01f96f6b37bfc86472c5d10628c4b4168382ab Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 1 Oct 2010 11:23:40 -0400 Subject: [PATCH 328/947] point release before uploading sdist --- docs/en/history.rst | 4 ++++ setup.py | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 1ca20f4..8275b28 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,10 @@ Release History =============== +2.5.3 + + - Point release uploaded to PyPI during outage on doughellmann.com. + 2.5.2 - Apply patch from Zach Voase to fix :ref:`command-lsvirtualenv` diff --git a/setup.py b/setup.py index 256706c..0845779 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' -VERSION = '2.5.2' +VERSION = '2.5.3' # Bootstrap installation of Distribute import distribute_setup @@ -120,8 +120,8 @@ def find_package_data( author_email = 'doug.hellmann@gmail.com', url = 'http://www.doughellmann.com/projects/%s/' % PROJECT, - download_url = 'http://www.doughellmann.com/downloads/%s-%s.tar.gz' % \ - (PROJECT, VERSION), +# download_url = 'http://www.doughellmann.com/downloads/%s-%s.tar.gz' % \ +# (PROJECT, VERSION), classifiers = [ 'Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: BSD License', From c96f72d9ed40c6e41863806901aa36e3e7cddbe6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 1 Oct 2010 11:23:59 -0400 Subject: [PATCH 329/947] Added tag 2.5.3 for changeset dc74f106d8d2 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index eb5874a..553454a 100644 --- a/.hgtags +++ b/.hgtags @@ -63,3 +63,4 @@ a85d80e88996c15e2e2b832e2956811eea73ee34 2.4 80e2fcda77acd85500159e3e688e5acfa3d99bd3 2.5 2ab678413a290410ed4c8a1b72a567d79caa5ae5 2.5.1 f71ffbb996c41606aea15b2114120d9fca3adfc6 2.5.2 +dc74f106d8d2dd58031b2dbac31b1e068f780de4 2.5.3 From cdb750b408e8eb3e27e40a21c0484ff793ed73ff Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 1 Oct 2010 11:38:42 -0400 Subject: [PATCH 330/947] fix platforms definition so upload to pypi will work --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0845779..43f4ccc 100644 --- a/setup.py +++ b/setup.py @@ -130,7 +130,7 @@ def find_package_data( 'Environment :: Console', ], - platforms = ('Any',), + platforms = ['Any'], scripts = ['virtualenvwrapper.sh', ], From f1392cff5610080dc00f797bf6bf2c8499ac4acd Mon Sep 17 00:00:00 2001 From: Carl Karsten Date: Sat, 30 Oct 2010 12:58:19 -0500 Subject: [PATCH 331/947] create the WORKON_HOME dir if it doesn't exist. --- virtualenvwrapper.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index d27df64..db7a0ca 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -90,12 +90,15 @@ virtualenvwrapper_derive_workon_home() { return 0 } -# Verify that the WORKON_HOME directory exists +# Check if the WORKON_HOME directory exists, +# create it if it does not +# seperate from creating the files in it because this used to just error +# and maybe other things rely on the dir existing before that happens. virtualenvwrapper_verify_workon_home () { if [ ! -d "$WORKON_HOME" ] then - [ "$1" != "-q" ] && echo "ERROR: Virtual environments directory '$WORKON_HOME' does not exist. Create it or set WORKON_HOME to an existing directory." 1>&2 - return 1 + [ "$1" != "-q" ] && echo "NOTE: Virtual environments directory '$WORKON_HOME' does not exist. Creating..." 1>&2 + mkdir $WORKON_HOME fi return 0 } From 25ab840f4674956b352182b0e853d8425a6a554b Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 24 Dec 2010 18:09:39 -0500 Subject: [PATCH 332/947] convert test scripts to use tox instead of home-grown multi-version system in the Makefile --- .hgignore | 1 + ChangeLog | 23 ++++++++++ Makefile | 71 ++----------------------------- docs/en/developers.rst | 8 ++-- tests/run_tests | 56 ++++++++++++++++++++++++ tests/test.sh | 5 +-- tests/test_add2virtualenv.sh | 0 tests/test_cd.sh | 0 tests/test_cp.sh | 9 ++++ tests/test_deactivate.sh | 0 tests/test_derive_workon_home.sh | 0 tests/test_ls.sh | 0 tests/test_mkvirtualenv.sh | 3 ++ tests/test_rmvirtualenv.sh | 0 tests/test_run_hook.sh | 6 +-- tests/test_tempfile.sh | 0 tests/test_workon.sh | 5 ++- tox.ini | 14 ++++++ virtualenvwrapper.sh | 7 ++- virtualenvwrapper/user_scripts.py | 6 +-- 20 files changed, 129 insertions(+), 85 deletions(-) create mode 100755 tests/run_tests mode change 100644 => 100755 tests/test_add2virtualenv.sh mode change 100644 => 100755 tests/test_cd.sh mode change 100644 => 100755 tests/test_cp.sh mode change 100644 => 100755 tests/test_deactivate.sh mode change 100644 => 100755 tests/test_derive_workon_home.sh mode change 100644 => 100755 tests/test_ls.sh mode change 100644 => 100755 tests/test_mkvirtualenv.sh mode change 100644 => 100755 tests/test_rmvirtualenv.sh mode change 100644 => 100755 tests/test_run_hook.sh mode change 100644 => 100755 tests/test_tempfile.sh mode change 100644 => 100755 tests/test_workon.sh create mode 100644 tox.ini diff --git a/.hgignore b/.hgignore index d203a1e..2f9aff6 100644 --- a/.hgignore +++ b/.hgignore @@ -15,6 +15,7 @@ tests/testpackage/testpackage.egg-info trace.txt virtualenvwrapper.egg-info virtualenvwrapper/docs +.tox syntax: re .DS_Store diff --git a/ChangeLog b/ChangeLog index 9a1122a..823c736 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2010-12-24 Doug Hellmann + + * virtualenvwrapper.sh (cpvirtualenv): Ensure that both pre hooks + are run, even if one produces an error. + + * virtualenvwrapper/user_scripts.py: Change log message format. + + * tox.ini: Configuration file for running tests under tox. + + * tests/test_run_hook.sh (test_virtualenvwrapper_run_hook_permissions): + Fix the expected output message. + + * tests/*: Make sure all of the test scripts have execute permission. + + * tests/test.sh (test_virtualenvwrapper_verify_workon_home_missing_dir_quiet_init): + Use source instead of starting another shell, since zsh doesn't + play nicely with inheriting environment settings otherwise. + (test_python_interpreter_set_incorrectly): Force + VIRTUALENVWRAPPER_PYTHON before running the script in a sub-shell. + + * tests/run_tests: Script to run through all of the other test + scripts one at a time. + 2010-09-18 Doug Hellmann * virtualenvwrapper.sh: Apply patch from Zach Voase to fix diff --git a/Makefile b/Makefile index db02a0e..24729ce 100644 --- a/Makefile +++ b/Makefile @@ -1,24 +1,6 @@ # Get the version of the app. This is used in the doc build. export VERSION=$(shell python setup.py --version) -# Locations of Python interpreter binaries -PYTHON27=/Users/dhellmann/Devel/virtualenvwrapper/Python/2.7b1/bin/python2.7 -ifeq ($VIRTUAL_ENV,) -PYTHON26=$(shell which python2.6) -else -PYTHON26=/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 -endif -PYTHON25=/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5 -PYTHON24=/Users/dhellmann/Devel/virtualenvwrapper/Python/2.4.6/bin/python2.4 - -# The test-quick pattern changes the definition of -# this variable to only run against a single version of python. -ifeq ($(PYTHON_BINARIES),) -PYTHON_BINARIES=$(PYTHON26) $(PYTHON27) $(PYTHON25) $(PYTHON24) -endif - -SUPPORTED_SHELLS=bash sh ksh zsh - # Default target is to show help help: @echo "sdist - Source distribution" @@ -67,56 +49,11 @@ register: python setup.py register # Testing -TEST_SCRIPTS=$(wildcard tests/test*.sh) - test: - for name in $(SUPPORTED_SHELLS) ; do \ - $(MAKE) test-$$name || exit 1 ; \ - done - $(MAKE) test-install + tox + +test-quick: + tox -e py27 develop: python setup.py develop - -test-bash test-ksh test-sh: - TEST_SHELL=$(subst test-,,$@) $(MAKE) test-loop - -test-zsh: - TEST_SHELL="zsh -o shwordsplit" $(MAKE) test-loop - -# For each supported version of Python, -# - Create a new virtualenv in a temporary directory. -# - Install virtualenvwrapper into the new virtualenv -# - Run each test script in tests -test-loop: - for py_bin in $(PYTHON_BINARIES) ; do \ - (cd $$TMPDIR/ && rm -rf virtualenvwrapper-test-env \ - && virtualenv -p $$py_bin --no-site-packages virtualenvwrapper-test-env) \ - || exit 1 ; \ - $$TMPDIR/virtualenvwrapper-test-env/bin/python setup.py install || exit 1 ; \ - for test_script in tests/test*.sh ; do \ - echo ; \ - echo '********************************************************************************' ; \ - echo "Running $$test_script with $(TEST_SHELL) under Python $(basename $$py_bin)" ; \ - echo ; \ - HOOK_VERBOSE_OPTION=-v VIRTUALENVWRAPPER_PYTHON=$$TMPDIR/virtualenvwrapper-test-env/bin/python SHUNIT_PARENT=$$test_script $(TEST_SHELL) $$test_script || exit 1 ; \ - echo ; \ - done \ - done - -test-quick:: test-26 - -test-24: - PYTHON_BINARIES=$(PYTHON24) $(MAKE) test-bash - -test-25: - PYTHON_BINARIES=$(PYTHON25) $(MAKE) test-bash - -test-26: - PYTHON_BINARIES=$(PYTHON26) $(MAKE) test-bash - -test-27: - PYTHON_BINARIES=$(PYTHON27) $(MAKE) test-bash - -test-install: - bash ./tests/manual_test_install.sh `pwd`/dist "$(VERSION)" diff --git a/docs/en/developers.rst b/docs/en/developers.rst index 0420975..2d01ae3 100644 --- a/docs/en/developers.rst +++ b/docs/en/developers.rst @@ -65,6 +65,8 @@ Running Tests ============= The test suite for virtualenvwrapper uses `shunit2 -`_. To run the tests under bash, sh, -and zsh, use ``make test``. In order to add new tests, you will need -to modify or create an appropriate script in the ``tests`` directory. +`_ and `tox +`_. To run the tests under bash, sh, and +zsh, use ``make test`` or just ``tox``. In order to add new tests, +you will need to modify or create an appropriate script in the +``tests`` directory. diff --git a/tests/run_tests b/tests/run_tests new file mode 100755 index 0000000..4e0d1e4 --- /dev/null +++ b/tests/run_tests @@ -0,0 +1,56 @@ +#!/bin/sh + +## +## ONLY RUN THIS VIA TOX +## + +#set -x + +envdir="$1" +shift +scripts="$*" +if [ -z "$scripts" ] +then + scripts=$(ls tests/test*.sh) +fi + +# Force the tox virtualenv to be active. +# +# Since this script runs from within a separate shell created by tox, +# the name of the virtualenv (in $VIRTUAL_ENV) is inherited, but the +# shell functions and other settings created by the activate script +# are *not* inherited. +# +source "$envdir/bin/activate" + +# Set up virtualenvwrapper.hook_loader to print more details than usual for debugging. +export HOOK_VERBOSE_OPTION=-vvv + +# Force virtualenvwrapper to use the python interpreter in the +# tox-created virtualenv. +export VIRTUALENVWRAPPER_PYTHON="$envdir/bin/python" + +if [ -n "${ZSH_VERSION:-}" ] +then + export SHELL=$(which zsh) +fi + +# Run the test scripts with a little formatting around them to make it +# easier to find where each script output starts. +for test_script in $scripts +do + echo + echo '********************************************************************************' + echo "Running $test_script" + echo " VIRTUAL_ENV=$VIRTUAL_ENV" + echo " VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON" + echo " $($VIRTUALENVWRAPPER_PYTHON -V 2>&1)" + echo " PYTHONPATH=$PYTHONPATH" + echo " SHELL=$SHELL" + echo + export SHUNIT_PARENT="$test_script" + $test_script || exit 1 + echo +done + +exit 0 diff --git a/tests/test.sh b/tests/test.sh index 32d96f4..915fe79 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -10,7 +10,6 @@ oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" source "$test_dir/../virtualenvwrapper.sh" - echo $PYTHONPATH } oneTimeTearDown() { @@ -63,7 +62,7 @@ test_virtualenvwrapper_verify_workon_home_missing_dir_grep_options() { test_virtualenvwrapper_verify_workon_home_missing_dir_quiet_init() { old_home="$WORKON_HOME" export WORKON_HOME="$WORKON_HOME/not_there" - output=`$SHELL $test_dir/../virtualenvwrapper.sh 2>&1` + output=$(source $test_dir/../virtualenvwrapper.sh 2>&1) assertSame "" "$output" WORKON_HOME="$old_home" } @@ -79,7 +78,7 @@ test_python_interpreter_set_incorrectly() { cd "$WORKON_HOME" mkvirtualenv --no-site-packages no_wrappers expected="ImportError: No module named virtualenvwrapper.hook_loader" - output=$(VIRTUALENVWRAPPER_PYTHON=$VIRTUAL_ENV/bin/python $SHELL $return_to/virtualenvwrapper.sh 2>&1) + output=$(VIRTUALENVWRAPPER_PYTHON=$(which python) $SHELL $return_to/virtualenvwrapper.sh 2>&1) echo "$output" | grep "$expected" 2>&1 found=$? assertTrue "Expected \"$expected\", got: \"$output\"" "[ $found -eq 0 ]" diff --git a/tests/test_add2virtualenv.sh b/tests/test_add2virtualenv.sh old mode 100644 new mode 100755 diff --git a/tests/test_cd.sh b/tests/test_cd.sh old mode 100644 new mode 100755 diff --git a/tests/test_cp.sh b/tests/test_cp.sh old mode 100644 new mode 100755 index a0a9f79..1812967 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -63,12 +63,20 @@ test_hooks () { mkvirtualenv "source" export pre_test_dir=$(cd "$test_dir"; pwd) + + # Set the interpreter of the hook script to the simple shell + echo "#!/bin/sh" > "$WORKON_HOME/premkvirtualenv" echo "echo GLOBAL premkvirtualenv \`pwd\` \"\$@\" >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" chmod +x "$WORKON_HOME/premkvirtualenv" + echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" + + # Set the interpreter of the hook script to the simple shell echo "#!/bin/sh" > "$WORKON_HOME/precpvirtualenv" echo "echo GLOBAL precpvirtualenv \`pwd\` \"\$@\" >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/precpvirtualenv" chmod +x "$WORKON_HOME/precpvirtualenv" + + # Set the interpreter of the hook script to the simple shell echo "#!/bin/sh" > "$WORKON_HOME/postcpvirtualenv" echo "echo GLOBAL postcpvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postcpvirtualenv" @@ -83,6 +91,7 @@ GLOBAL postmkvirtualenv GLOBAL postcpvirtualenv" assertSame "$expected" "$output" + rm -f "$WORKON_HOME/premkvirtualenv" rm -f "$WORKON_HOME/postmkvirtualenv" } diff --git a/tests/test_deactivate.sh b/tests/test_deactivate.sh old mode 100644 new mode 100755 diff --git a/tests/test_derive_workon_home.sh b/tests/test_derive_workon_home.sh old mode 100644 new mode 100755 diff --git a/tests/test_ls.sh b/tests/test_ls.sh old mode 100644 new mode 100755 diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh old mode 100644 new mode 100755 index fc8f36d..1e7a783 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -39,8 +39,11 @@ test_activates () { test_hooks () { export pre_test_dir=$(cd "$test_dir"; pwd) + + echo "#!/bin/sh" > "$WORKON_HOME/premkvirtualenv" echo "echo GLOBAL premkvirtualenv \`pwd\` \"\$@\" >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" chmod +x "$WORKON_HOME/premkvirtualenv" + echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" mkvirtualenv "env3" output=$(cat "$test_dir/catch_output") diff --git a/tests/test_rmvirtualenv.sh b/tests/test_rmvirtualenv.sh old mode 100644 new mode 100755 diff --git a/tests/test_run_hook.sh b/tests/test_run_hook.sh old mode 100644 new mode 100755 index b68f293..9cd45d0 --- a/tests/test_run_hook.sh +++ b/tests/test_run_hook.sh @@ -44,13 +44,13 @@ test_virtualenvwrapper_source_hook_permissions() { test_virtualenvwrapper_run_hook_permissions() { echo "#!/bin/sh" > "$WORKON_HOME/prermvirtualenv" echo "echo run $@ >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/prermvirtualenv" - chmod -x "$WORKON_HOME/prermvirtualenv" + chmod 0444 "$WORKON_HOME/prermvirtualenv" touch "$test_dir/catch_output" - error=$(virtualenvwrapper_run_hook "pre_rmvirtualenv" "foo" 2>&1 | grep "ERROR") + error=$(virtualenvwrapper_run_hook "pre_rmvirtualenv" "foo" 2>&1 | grep "could not run" | cut -f2- -d'[') output=$(cat "$test_dir/catch_output") expected="" assertSame "$expected" "$output" - assertSame "virtualenvwrapper.user_scripts ERROR: Could not run $WORKON_HOME/prermvirtualenv. [Errno 13] Permission denied" "$error" + assertSame "Errno 13] Permission denied" "$error" } . "$test_dir/shunit2" diff --git a/tests/test_tempfile.sh b/tests/test_tempfile.sh old mode 100644 new mode 100755 diff --git a/tests/test_workon.sh b/tests/test_workon.sh old mode 100644 new mode 100755 index 707e132..6f8dc39 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -37,10 +37,11 @@ test_workon () { test_workon_activate_hooks () { for t in pre post do - echo "#!/bin/bash" > "$WORKON_HOME/${t}activate" + echo "#!/bin/sh" > "$WORKON_HOME/${t}activate" echo "echo GLOBAL ${t}activate >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/${t}activate" chmod +x "$WORKON_HOME/${t}activate" - echo "#!/bin/bash" > "$WORKON_HOME/env2/bin/${t}activate" + + echo "#!/bin/sh" > "$WORKON_HOME/env2/bin/${t}activate" echo "echo ENV ${t}activate >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/env1/bin/${t}activate" chmod +x "$WORKON_HOME/env1/bin/${t}activate" done diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..6a95ce1 --- /dev/null +++ b/tox.ini @@ -0,0 +1,14 @@ +[tox] +envlist = py27,py26,py25,py24 + +[testenv] +commands = + zsh -o shwordsplit ./tests/run_tests {envdir} [] + ksh ./tests/run_tests {envdir} [] + bash ./tests/run_tests {envdir} [] + +# Not sure why this is needed, but on my system if it isn't included then +# the python version picked up for 2.6 is actually 2.7. +# IF THIS CAUSES YOU A PROBLEM COMMENT IT OUT BEFORE RUNNING THE TESTS. +[testenv:py26] +basepython=/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 \ No newline at end of file diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index f97f8ed..df19b9e 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -501,7 +501,6 @@ lssitepackages () { # Duplicate the named virtualenv to make a new one. cpvirtualenv() { - typeset env_name="$1" if [ "$env_name" = "" ] then @@ -541,10 +540,10 @@ cpvirtualenv() { virtualenv "$target_env" --relocatable \sed "s/VIRTUAL_ENV\(.*\)$env_name/VIRTUAL_ENV\1$new_env/g" < "$source_env/bin/activate" > "$target_env/bin/activate" - (cd "$WORKON_HOME" && - virtualenvwrapper_run_hook "pre_cpvirtualenv" "$env_name" "$new_env" && + (cd "$WORKON_HOME" && ( + virtualenvwrapper_run_hook "pre_cpvirtualenv" "$env_name" "$new_env"; virtualenvwrapper_run_hook "pre_mkvirtualenv" "$new_env" - ) + )) workon "$new_env" virtualenvwrapper_run_hook "post_mkvirtualenv" virtualenvwrapper_run_hook "post_cpvirtualenv" diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 1ba3f74..6535bf0 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -25,11 +25,11 @@ def run_script(script_path, *args): # print f.read() # print '+' * 80 cmd = [script_path] + list(args) - log.debug('Running %s', str(cmd)) + log.debug('running %s', str(cmd)) try: return_code = subprocess.call(cmd) except OSError, msg: - log.error('ERROR: Could not run %s. %s', script_path, str(msg)) + log.error('could not run "%s": %s', script_path, str(msg)) #log.debug('Returned %s', return_code) return @@ -107,7 +107,7 @@ def make_hook(filename, comment): """ filename = os.path.expanduser(os.path.expandvars(filename)) if not os.path.exists(filename): - log.info('Creating %s', filename) + log.warning('creating %s', filename) f = open(filename, 'wt') try: f.write("""#!%(shell)s From 085120a4f849459d06d7657142e832e7a5063622 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 26 Dec 2010 10:15:38 -0500 Subject: [PATCH 333/947] change the way we determine the python version --- ChangeLog | 6 ++++++ tests/test_ls.sh | 5 +++++ tests/test_support.sh | 34 ++++++++++++++++++++++++++++++++++ virtualenvwrapper.sh | 2 +- 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100755 tests/test_support.sh diff --git a/ChangeLog b/ChangeLog index 823c736..edc548a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-12-26 Doug Hellmann + + * virtualenvwrapper.sh (virtualenvwrapper_get_python_version): Use + python's -V option and cut to get the version instead of a python + one-liner. + 2010-12-24 Doug Hellmann * virtualenvwrapper.sh (cpvirtualenv): Ensure that both pre hooks diff --git a/tests/test_ls.sh b/tests/test_ls.sh index 03731fa..8909207 100755 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -44,5 +44,10 @@ test_no_workon_home () { WORKON_HOME="$old_home" } +test_get_site_packages_dir () { + d=$(virtualenvwrapper_get_site_packages_dir) + assertTrue "[ -d $d ]" +} + . "$test_dir/shunit2" diff --git a/tests/test_support.sh b/tests/test_support.sh new file mode 100755 index 0000000..466afac --- /dev/null +++ b/tests/test_support.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +#set -x + +test_dir=$(cd $(dirname $0) && pwd) + +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" + mkvirtualenv testing +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +test_get_python_version () { + expected="$($VIRTUAL_ENV/bin/python -V 2>&1 | cut -f2 -d' ')" + echo "Expecting: $expected" + vers=$(virtualenvwrapper_get_python_version) + echo "Got : $vers" + assertSame "$expected" "$vers" +} + + +. "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index df19b9e..f53234b 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -407,7 +407,7 @@ virtualenvwrapper_get_python_version () { # Uses the Python from the virtualenv because we're trying to # determine the version installed there so we can build # up the path to the site-packages directory. - python -c 'import sys; print ".".join(str(p) for p in sys.version_info[:2])' + python -V 2>&1 | cut -f2 -d' ' } # Prints the path to the site-packages directory for the current environment. From 343a9f9a7d8c5fd14ee976b00e7b95d18c29c788 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 26 Dec 2010 10:52:36 -0500 Subject: [PATCH 334/947] fix #60 by setting install_requires instead of requires --- ChangeLog | 3 +++ setup.py | 2 +- tests/manual_test_install.sh | 8 ++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index edc548a..e685975 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2010-12-26 Doug Hellmann + * setup.py: Change "requires" to "install_requires" so pip will + try to install virtualenv if it is not already there. + * virtualenvwrapper.sh (virtualenvwrapper_get_python_version): Use python's -V option and cut to get the version instead of a python one-liner. diff --git a/setup.py b/setup.py index 43f4ccc..c0156d3 100644 --- a/setup.py +++ b/setup.py @@ -138,7 +138,7 @@ def find_package_data( provides=['virtualenvwrapper', 'virtualenvwrapper.user_scripts', ], - requires=['virtualenv'], + install_requires=['virtualenv'], namespace_packages = [ 'virtualenvwrapper' ], packages = find_packages(), diff --git a/tests/manual_test_install.sh b/tests/manual_test_install.sh index 5907bd2..317d958 100755 --- a/tests/manual_test_install.sh +++ b/tests/manual_test_install.sh @@ -13,8 +13,6 @@ VERSION=$(python setup.py --version) oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" - mkvirtualenv "installtest" - (cd "$test_dir/.." && make sdist) } oneTimeTearDown() { @@ -25,6 +23,12 @@ setUp () { echo } +test_build_ok () { + (cd "$test_dir/.." && make sdist) + outcome=$? + assertSame "0" "$outcome" +} + test_install () { dist_dir=$(dirname $test_dir)/dist pip install "$dist_dir/virtualenvwrapper-$VERSION.tar.gz" From 6d8d90cb86c237363ad7c69d053df2da4f416c82 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 26 Dec 2010 11:06:00 -0500 Subject: [PATCH 335/947] closes #70 by adding a list of supported shells and python versions to documentation and trove classifiers --- ChangeLog | 3 ++- docs/en/install.rst | 24 ++++++++++++++++++++++++ setup.py | 5 +++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e685975..01183ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,8 @@ 2010-12-26 Doug Hellmann * setup.py: Change "requires" to "install_requires" so pip will - try to install virtualenv if it is not already there. + try to install virtualenv if it is not already there. Add trove + classifiers for the supported Python versions. * virtualenvwrapper.sh (virtualenvwrapper_get_python_version): Use python's -V option and cut to get the version instead of a python diff --git a/docs/en/install.rst b/docs/en/install.rst index b0450fa..bcfa89a 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -2,6 +2,23 @@ Installation ============ +Supported Shells +================ + +virtualenvwrapper is a set of shell *functions* defined in Bourne +shell compatible syntax. It is tested under `bash`, `ksh`, and `zsh`. +It may work with other shells, so if you find that it does work with a +shell not listed here please let me know. If you can modify it to +work with another shell, without completely rewriting it, send a pull +request through the bitbucket project page. If you write a clone to +work with an incompatible shell, let me know and I will link to it +from this page. + +Python Versions +=============== + +virtualenvwrapper is tested under Python 2.4 - 2.7. + Basic Installation ================== @@ -13,6 +30,13 @@ You will want to install it into the global Python site-packages area, along with virtualenv. You may need administrative privileges to do that. +An alternative to installing it into the global site-packages is to +add it to your user local directory (usually `~/.local`). + +:: + + $ pip install --install-option="--user" virtualenvwrapper + WORKON_HOME =========== diff --git a/setup.py b/setup.py index c0156d3..a0f1889 100644 --- a/setup.py +++ b/setup.py @@ -126,6 +126,11 @@ def find_package_data( classifiers = [ 'Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: BSD License', 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.4', + 'Programming Language :: Python :: 2.5', + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', 'Intended Audience :: Developers', 'Environment :: Console', ], From e40bc72d75c887bffb0d833f3e000c062264032e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 26 Dec 2010 11:24:39 -0500 Subject: [PATCH 336/947] avoid specifying text mode when creating hook scripts (fixes #68) --- ChangeLog | 4 ++++ virtualenvwrapper/user_scripts.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 01183ab..3b813e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2010-12-26 Doug Hellmann + * virtualenvwrapper/user_scripts.py (make_hook): Do not specify + text mode when creating the files so cygwin will not replace \n + with \r\n. + * setup.py: Change "requires" to "install_requires" so pip will try to install virtualenv if it is not already there. Add trove classifiers for the supported Python versions. diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 6535bf0..7cbe6c6 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -108,7 +108,7 @@ def make_hook(filename, comment): filename = os.path.expanduser(os.path.expandvars(filename)) if not os.path.exists(filename): log.warning('creating %s', filename) - f = open(filename, 'wt') + f = open(filename, 'w') try: f.write("""#!%(shell)s # %(comment)s From 3c9a57e1bf99605f8928ea63102981561eabc484 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 26 Dec 2010 11:39:04 -0500 Subject: [PATCH 337/947] bump version to 2.6 and document updates --- docs/en/history.rst | 14 ++++++++++++++ docs/en/install.rst | 4 ++++ setup.py | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 8275b28..3986e86 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,20 @@ Release History =============== +2.6 + + - Fixed a problem with hook script line endings under Cygwin + (:bbissue:`68`). + - Updated documentation to include a list of the compatible shells + (:ref:`supported-shells`) and Python versions + (:ref:`supported-versions`) (:bbissue:`70`). + - Fixed installation dependency on virtualenv (:bbissue:`60`). + - Fixed the method for determining the Python version so it works + under Python 2.4 (:bbissue:`61`). + - Converted the test infrastructure to use `tox + `_ instead of home-grown + scripts in the Makefile. + 2.5.3 - Point release uploaded to PyPI during outage on doughellmann.com. diff --git a/docs/en/install.rst b/docs/en/install.rst index bcfa89a..e07ac0c 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -2,6 +2,8 @@ Installation ============ +.. _supported-shells: + Supported Shells ================ @@ -14,6 +16,8 @@ request through the bitbucket project page. If you write a clone to work with an incompatible shell, let me know and I will link to it from this page. +.. _supported-versions: + Python Versions =============== diff --git a/setup.py b/setup.py index a0f1889..692d8c5 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' -VERSION = '2.5.3' +VERSION = '2.6' # Bootstrap installation of Distribute import distribute_setup From 35c97abf5bd545ccaf551f6146549c7a0c50300f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 26 Dec 2010 11:39:17 -0500 Subject: [PATCH 338/947] Added tag 2.6 for changeset b0f27c65fa64 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 553454a..cd6eb65 100644 --- a/.hgtags +++ b/.hgtags @@ -64,3 +64,4 @@ a85d80e88996c15e2e2b832e2956811eea73ee34 2.4 2ab678413a290410ed4c8a1b72a567d79caa5ae5 2.5.1 f71ffbb996c41606aea15b2114120d9fca3adfc6 2.5.2 dc74f106d8d2dd58031b2dbac31b1e068f780de4 2.5.3 +b0f27c65fa64627599c2a022a076ae5ee7157ae4 2.6 From 9fe5296b25d404d40f17237b14d5aeb1b09a0f05 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 26 Dec 2010 11:45:24 -0500 Subject: [PATCH 339/947] add supported version info to readme so it appears on pypi page. --- README.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.txt b/README.txt index d7f073d..4d7f422 100644 --- a/README.txt +++ b/README.txt @@ -41,6 +41,23 @@ See the `project documentation `__ for installation and setup instructions. +Supported Shells +================ + +virtualenvwrapper is a set of shell *functions* defined in Bourne +shell compatible syntax. It is tested under `bash`, `ksh`, and `zsh`. +It may work with other shells, so if you find that it does work with a +shell not listed here please let me know. If you can modify it to +work with another shell, without completely rewriting it, send a pull +request through the bitbucket project page. If you write a clone to +work with an incompatible shell, let me know and I will link to it +from this page. + +Python Versions +=============== + +virtualenvwrapper is tested under Python 2.4 - 2.7. + Upgrading from 1.x ================== From 4a90bdec2582e073aaffdea0f498b1a7a79eac30 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 27 Dec 2010 11:39:49 -0500 Subject: [PATCH 340/947] fixes issue #73 by changing virtualenvwrapper_get_python_version to only include the major and minor numbers --- ChangeLog | 5 +++++ docs/en/history.rst | 4 ++++ tests/test_ls.sh | 23 ++++++++++++++++------- tests/test_support.sh | 3 +-- virtualenvwrapper.sh | 2 +- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3b813e7..610c6ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-12-27 Doug Hellmann + + * virtualenvwrapper.sh (virtualenvwrapper_get_python_version): + Only include the major and minor numbers, not the patch level. + 2010-12-26 Doug Hellmann * virtualenvwrapper/user_scripts.py (make_hook): Do not specify diff --git a/docs/en/history.rst b/docs/en/history.rst index 3986e86..e0f6e15 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,10 @@ Release History =============== +2.6.1 + + - Fixed virtualenvwrapper_get_python_version (:bbissue:`73`). + 2.6 - Fixed a problem with hook script line endings under Cygwin diff --git a/tests/test_ls.sh b/tests/test_ls.sh index 8909207..793ffde 100755 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -21,10 +21,21 @@ setUp () { rm -f "$test_dir/catch_output" } +test_get_site_packages_dir () { + mkvirtualenv "lssitepackagestest" + d=$(virtualenvwrapper_get_site_packages_dir) + echo "site-packages in $d" + assertTrue "site-packages dir $d does not exist" "[ -d $d ]" + deactivate +} + test_lssitepackages () { mkvirtualenv "lssitepackagestest" contents="$(lssitepackages)" - assertTrue "No easy-install.pth in $contents" "echo $contents | grep easy-install.pth" + actual=$(echo $contents | grep easy-install.pth) + expected=$(echo $contents) + assertSame "$expected" "$actual" + deactivate } test_lssitepackages_add2virtualenv () { @@ -33,7 +44,10 @@ test_lssitepackages_add2virtualenv () { base_dir=$(basename $(pwd)) add2virtualenv "../$base_dir" contents="$(lssitepackages)" - assertTrue "No $base_dir in $contents" "echo $contents | grep $base_dir" + actual=$(echo $contents | grep $base_dir) + expected=$(echo $contents) + assertSame "$expected" "$actual" + deactivate } test_no_workon_home () { @@ -44,10 +58,5 @@ test_no_workon_home () { WORKON_HOME="$old_home" } -test_get_site_packages_dir () { - d=$(virtualenvwrapper_get_site_packages_dir) - assertTrue "[ -d $d ]" -} - . "$test_dir/shunit2" diff --git a/tests/test_support.sh b/tests/test_support.sh index 466afac..a8e223d 100755 --- a/tests/test_support.sh +++ b/tests/test_support.sh @@ -10,7 +10,6 @@ oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" source "$test_dir/../virtualenvwrapper.sh" - mkvirtualenv testing } oneTimeTearDown() { @@ -23,7 +22,7 @@ setUp () { } test_get_python_version () { - expected="$($VIRTUAL_ENV/bin/python -V 2>&1 | cut -f2 -d' ')" + expected="$(python -c 'import sys; print ".".join([str(p) for p in sys.version_info[:2]])')" echo "Expecting: $expected" vers=$(virtualenvwrapper_get_python_version) echo "Got : $vers" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index f53234b..78a9d36 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -407,7 +407,7 @@ virtualenvwrapper_get_python_version () { # Uses the Python from the virtualenv because we're trying to # determine the version installed there so we can build # up the path to the site-packages directory. - python -V 2>&1 | cut -f2 -d' ' + python -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d. } # Prints the path to the site-packages directory for the current environment. From 0af57cdf6d5ed128f58358cdc8327477d3041993 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 27 Dec 2010 12:21:37 -0500 Subject: [PATCH 341/947] version 2.6.1 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 692d8c5..ca51079 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' -VERSION = '2.6' +VERSION = '2.6.1' # Bootstrap installation of Distribute import distribute_setup From 55c4d0c63df7c887dfa77d3e35d2ffb2692b5267 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 27 Dec 2010 12:21:46 -0500 Subject: [PATCH 342/947] Added tag 2.6.1 for changeset 445a58d5a05a --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index cd6eb65..9553b91 100644 --- a/.hgtags +++ b/.hgtags @@ -65,3 +65,4 @@ a85d80e88996c15e2e2b832e2956811eea73ee34 2.4 f71ffbb996c41606aea15b2114120d9fca3adfc6 2.5.2 dc74f106d8d2dd58031b2dbac31b1e068f780de4 2.5.3 b0f27c65fa64627599c2a022a076ae5ee7157ae4 2.6 +445a58d5a05a1426cefb47e54b692b6a58fdcc4f 2.6.1 From 8a173ec3b189f080cab34ee426c61d41a14e2ff4 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 29 Dec 2010 13:46:59 -0500 Subject: [PATCH 343/947] restore download url --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index ca51079..92d6dc8 100644 --- a/setup.py +++ b/setup.py @@ -120,8 +120,8 @@ def find_package_data( author_email = 'doug.hellmann@gmail.com', url = 'http://www.doughellmann.com/projects/%s/' % PROJECT, -# download_url = 'http://www.doughellmann.com/downloads/%s-%s.tar.gz' % \ -# (PROJECT, VERSION), + download_url = 'http://www.doughellmann.com/downloads/%s-%s.tar.gz' % \ + (PROJECT, VERSION), classifiers = [ 'Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: BSD License', From ae71461faf1bcc25867a22ad373a5ccd64e7799c Mon Sep 17 00:00:00 2001 From: t2y Date: Thu, 30 Dec 2010 16:58:29 +0900 Subject: [PATCH 344/947] Added Japanese translation for the documentation Added to make html/website for the Japanese documentation Added the Japanese documentation link in original English index.rst --- Makefile | 3 + README.ja.txt | 123 ++++++++ docs/en/index.rst | 3 + docs/ja/command_ref.rst | 499 ++++++++++++++++++++++++++++++++ docs/ja/developers.rst | 104 +++++++ docs/ja/extensions.rst | 65 +++++ docs/ja/history.rst | 354 +++++++++++++++++++++++ docs/ja/hooks.rst | 22 ++ docs/ja/index.rst | 352 +++++++++++++++++++++++ docs/ja/install.rst | 204 +++++++++++++ docs/ja/plugins.rst | 613 ++++++++++++++++++++++++++++++++++++++++ docs/ja/scripts.rst | 307 ++++++++++++++++++++ docs/ja/tips.rst | 261 +++++++++++++++++ 13 files changed, 2910 insertions(+) create mode 100644 README.ja.txt create mode 100644 docs/ja/command_ref.rst create mode 100644 docs/ja/developers.rst create mode 100644 docs/ja/extensions.rst create mode 100644 docs/ja/history.rst create mode 100644 docs/ja/hooks.rst create mode 100644 docs/ja/index.rst create mode 100644 docs/ja/install.rst create mode 100644 docs/ja/plugins.rst create mode 100644 docs/ja/scripts.rst create mode 100644 docs/ja/tips.rst diff --git a/Makefile b/Makefile index 24729ce..3542a99 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,7 @@ sdist: html html: (cd docs && $(MAKE) html LANGUAGE="en") (cd docs && $(MAKE) html LANGUAGE="es") + (cd docs && $(MAKE) html LANGUAGE="ja") .PHONY: docclean docclean: @@ -38,10 +39,12 @@ website: rm -rf docs/website (cd docs && $(MAKE) html BUILDING_WEB=1 BUILDDIR="website/en" LANGUAGE="en") (cd docs && $(MAKE) html BUILDING_WEB=1 BUILDDIR="website/es" LANGUAGE="es") + (cd docs && $(MAKE) html BUILDING_WEB=1 BUILDDIR="website/ja" LANGUAGE="ja") installwebsite: website (cd docs/website/en && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper/) (cd docs/website/es && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper/es/) + (cd docs/website/ja && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper/ja/) # Register the new version on pypi .PHONY: register diff --git a/README.ja.txt b/README.ja.txt new file mode 100644 index 0000000..607814e --- /dev/null +++ b/README.ja.txt @@ -0,0 +1,123 @@ +.. -*- mode: rst -*- + +################# +virtualenvwrapper +################# + +virtualenvwrapper は Ian Bicking の +`virtualenv `_ ツールの +拡張機能です。この拡張機能は仮想環境の作成・削除を行ったり、 +開発ワークフローを管理するラッパーを提供します。このラッパーを +使用することで、開発環境の依存による競合を発生させず、1つ以上の +プロジェクトで同時に作業し易くなります。 + +==== +機能 +==== + +1. 1つの開発環境で全ての仮想環境を構成する + +2. 仮想環境を管理(作成、削除、コピー)するラッパー + +3. たった1つのコマンドで仮想環境を切り替える + +4. コマンドの引数として仮想環境がタブ補完できる + +5. 全ての操作に対してユーザ設定でフックできる(:ref:`scripts` を参照) + +6. さらに共有可能な拡張機能を作成できるプラグインシステム(:ref:`plugins` を参照) + +Rich Leland は virtualenvwrapper の機能を誇示するために短い +`スクリーンキャスト `__ +を作成しました。 + +============ +インストール +============ + +インストールとインフラを設定するには +`プロジェクトのドキュメント `__ +を参照してください。 + +サポートシェル +============== + +virtualenvwrapper は Bourne シェル互換の構文で定義された +シェル *関数* のセットです。それは `bash`, `ksh` と `zsh` で +テストされています。その他のシェルでも動作するかもしれませんが、 +ここに記載されていないシェルで動作することを発見したら私に +教えてください。もしあなたがその他のシェルで動作させるために +virtualenvwrapper を完全に書き直すことなく修正できるなら、 +bitbucket のプロジェクトページを通じて pull リクエストを +送ってください。あなたが非互換なシェル上で動作させるクローンを +作成するなら、このページでリンクを張るので私に連絡してください。 + +Python バージョン +================= + +virtualenvwrapper は Python 2.4 - 2.7 でテストされています。 + +1.x からのアップグレード +======================== + +ラッパー関数を含むシェルスクリプトは 2.x バージョンで bash +以外のシェルをサポートするためにその名前が変更されました。 +あなたの起動ファイルの ``source /usr/local/bin/virtualenvwrapper_bashrc`` を +``source /usr/local/bin/virtualenvwrapper.sh`` へ変更してください。 + +==== +貢献 +==== + +virtualenvwrapper のコアへ新しい機能を追加する前に、 +その代わりに機能拡張として実装すべきかどうかをよく考えてください。 + +パッチを提供するための tips は +`開発者ドキュメント `__ +を参照してください。 + +======== +サポート +======== + +問題や機能を議論するには +`virtualenvwrapper Google Group `__ +に参加してください。 + +`BitBucket のバグトラッカー `__ +でバグを報告してください。 + +シェルエイリアス +================ + +virtualenvwrapper は大きなシェルスクリプトなので、 +多くのアクションはシェルコマンドを使用します。 +あなたの環境が多くのシェルエイリアスやその他の +カスタマイズを行っているなら、何かしら問題に +遭遇する可能性があります。バグトラッカーにバグを +報告する前に、そういったエイリアスを無効な *状態* で +テストしてください。あなたがその問題を引き起こす +エイリアスを判別できるなら virtualenvwrapper を +もっと堅牢なものにすることに役立つでしょう。 + +========== +ライセンス +========== + +Copyright Doug Hellmann, All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Doug Hellmann not be used +in advertising or publicity pertaining to distribution of the software +without specific, written prior permission. + +DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/docs/en/index.rst b/docs/en/index.rst index d43599a..c7ba8f8 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -201,6 +201,9 @@ showing off the features of virtualenvwrapper. Manuel Kaufmann has `translated this documentation into Spanish `__. +Tetsuya Morimoto has `translated this documentation into Japanese +`__. + ======= Support ======= diff --git a/docs/ja/command_ref.rst b/docs/ja/command_ref.rst new file mode 100644 index 0000000..c360a99 --- /dev/null +++ b/docs/ja/command_ref.rst @@ -0,0 +1,499 @@ +.. Quick reference documentation for virtualenvwrapper command line functions + Originally contributed Thursday, May 28, 2009 by Steve Steiner (ssteinerX@gmail.com) + +.. + ################# + Command Reference + ################# + +.. _command: + +#################### +コマンドリファレンス +#################### + +.. + All of the commands below are to be used on the Terminal command line. + +全てのコマンドは次のようにターミナル上で使用されます。 + +.. + ===================== + Managing Environments + ===================== + +================== +仮想環境を管理する +================== + +.. _command-mkvirtualenv: + +mkvirtualenv +------------ + +.. + Create a new environment, in the WORKON_HOME. + +WORKON_HOME に新たな仮想環境を作成します。 + +.. + Syntax:: + +構文:: + + mkvirtualenv [options] ENVNAME + +.. + All command line options are passed directly to ``virtualenv``. The + new environment is automatically activated after being initialized. + +全てのコマンドラインオプションは ``virtualenv`` へ直接渡されます。新しい仮想環境は初期化された後に自動的にアクティブ化されます。 + +:: + + $ workon + $ mkvirtualenv mynewenv + New python executable in mynewenv/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (mynewenv)$ workon + mynewenv + (mynewenv)$ + +.. seealso:: + + * :ref:`scripts-premkvirtualenv` + * :ref:`scripts-postmkvirtualenv` + +.. _command-lsvirtualenv: + +lsvirtualenv +------------ + +.. + List all of the environments. + +全ての仮想環境を表示します。 + +.. + Syntax:: + +構文:: + + lsvirtualenv [-b] [-l] [-h] + +-b + .. Brief mode, disables verbose output. + ブリーフモード、冗長な出力を無効にする +-l + .. Long mode, enables verbose output. Default. + ロングモード、冗長な出力を有効にする(デフォルト) +-h + .. Print the help for lsvirtualenv. + lsvirtualenv のヘルプを表示する + +.. seealso:: + + * :ref:`scripts-get_env_details` + +.. _command-showvirtualenv: + +showvirtualenv +-------------- + +.. + Show the details for a single virtualenv. + +1つの仮想環境の詳細を表示します。 + +.. + Syntax:: + +構文:: + + showvirtualenv [env] + +.. seealso:: + + * :ref:`scripts-get_env_details` + +rmvirtualenv +------------ + +.. + Remove an environment, in the WORKON_HOME. + +WORKON_HOME の仮想環境を削除します。 + +.. + Syntax:: + +構文:: + + rmvirtualenv ENVNAME + +.. + You must use :ref:`command-deactivate` before removing the current + environment. + +カレントの仮想環境を削除する前に :ref:`command-deactivate` を実行しなければなりません。 + +:: + + (mynewenv)$ deactivate + $ rmvirtualenv mynewenv + $ workon + $ + +.. seealso:: + + * :ref:`scripts-prermvirtualenv` + * :ref:`scripts-postrmvirtualenv` + +.. _command-cpvirtualenv: + +cpvirtualenv +------------ + +.. + Duplicate an environment, in the WORKON_HOME. + +WORKON_HOME の仮想環境を複製します。 + +.. + Syntax:: +構文:: + + cpvirtualenv ENVNAME TARGETENVNAME + +.. note:: + + .. The environment created by the copy operation is made `relocatable + `__. + + コピー操作で作成された仮想環境は `再配置可能 `__ です。 + +:: + + $ workon + $ mkvirtualenv source + New python executable in source/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (source)$ cpvirtualenv source dest + Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/easy_install relative + Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/easy_install-2.6 relative + Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/pip relative + Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/postactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) + Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/postdeactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) + Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/preactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) + Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/predeactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) + (dest)$ workon + dest + source + (dest)$ + +.. seealso:: + + * :ref:`scripts-precpvirtualenv` + * :ref:`scripts-postcpvirtualenv` + * :ref:`scripts-premkvirtualenv` + * :ref:`scripts-postmkvirtualenv` + +.. + ================================== + Controlling the Active Environment + ================================== + +============================== +アクティブな仮想環境を制御する +============================== + +workon +------ + +.. + List or change working virtual environments + +作業する仮想環境を変更、または表示します。 + +.. + Syntax:: + +構文:: + + workon [environment_name] + +.. + If no ``environment_name`` is given the list of available environments + is printed to stdout. + +``environment_name`` が与えられない場合は標準出力に利用可能な仮想環境を表示します。 + +:: + + $ workon + $ mkvirtualenv env1 + New python executable in env1/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (env1)$ mkvirtualenv env2 + New python executable in env2/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (env2)$ workon + env1 + env2 + (env2)$ workon env1 + (env1)$ echo $VIRTUAL_ENV + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 + (env1)$ workon env2 + (env2)$ echo $VIRTUAL_ENV + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env2 + (env2)$ + + +.. seealso:: + + * :ref:`scripts-predeactivate` + * :ref:`scripts-postdeactivate` + * :ref:`scripts-preactivate` + * :ref:`scripts-postactivate` + +.. _command-deactivate: + +deactivate +---------- + +.. + Switch from a virtual environment to the system-installed version of + Python. + +仮想環境からシステムにインストールされた Python のバージョンに切り替えます。 + +.. + Syntax:: + +構文:: + + deactivate + +.. note:: + + .. This command is actually part of virtualenv, but is wrapped to + provide before and after hooks, just as workon does for activate. + + このコマンドは、実際は virtualenv の一部ですが、まさに workon が行うようにアクティブ化のために、処理の前後にフック機能を提供するためにラップされます。 + +:: + + $ workon + $ echo $VIRTUAL_ENV + + $ mkvirtualenv env1 + New python executable in env1/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (env1)$ echo $VIRTUAL_ENV + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 + (env1)$ deactivate + $ echo $VIRTUAL_ENV + + $ + +.. seealso:: + + * :ref:`scripts-predeactivate` + * :ref:`scripts-postdeactivate` + +.. + ================================== + Quickly Navigating to a virtualenv + ================================== + +======================== +仮想環境へ簡単に移動する +======================== + +.. + There are two functions to provide shortcuts to navigate into the + currently-active virtualenv. + +カレントのアクティブ化された仮想環境内へ移動するためのショートカットを提供する2つの機能があります。 + +cdvirtualenv +------------ + +.. + Change the current working directory to ``$VIRTUAL_ENV``. + +``$VIRTUAL_ENV`` へカレントワークディレクトリを移動します。 + +.. + Syntax:: + +構文:: + + cdvirtualenv [subdir] + +.. + Calling ``cdvirtualenv`` changes the current working directory to the + top of the virtualenv (``$VIRTUAL_ENV``). An optional argument is + appended to the path, allowing navigation directly into a + subdirectory. + +``cdvirtualenv`` を呼び出すと、カレントワークディレクトリを仮想環境(``$VIRTUAL_ENV``)のトップへ移動します。オプションの引数はそのパスに追加されて、サブディレクトリへ直接的に移動することもできます。 + +:: + + $ mkvirtualenv env1 + New python executable in env1/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (env1)$ echo $VIRTUAL_ENV + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 + (env1)$ cdvirtualenv + (env1)$ pwd + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 + (env1)$ cdvirtualenv bin + (env1)$ pwd + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1/bin + +cdsitepackages +-------------- + +.. + Change the current working directory to the ``site-packages`` for + ``$VIRTUAL_ENV``. + +``$VIRTUAL_ENV`` の ``site-packages`` へカレントワークディレクトリを移動します。 + +.. + Syntax:: + +構文:: + + cdsitepackages [subdir] + +.. + Because the exact path to the site-packages directory in the + virtualenv depends on the version of Python, ``cdsitepackages`` is + provided as a shortcut for ``cdvirtualenv + lib/python${pyvers}/site-packages``. An optional argument is also + allowed, to specify a directory hierarchy within the ``site-packages`` + directory to change into. + +仮想環境の site-packages ディレクトリへの正確なパスは Python のバージョンに依存するので、 ``cdsitepackages`` は ``cdvirtualenv lib/python${pyvers}/site-packages`` のショートカットです。さらにオプションの引数は直接移動する ``site-packages`` 内の階層構造のディレクトリを指定することもできます。 + +:: + + $ mkvirtualenv env1 + New python executable in env1/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (env1)$ echo $VIRTUAL_ENV + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 + (env1)$ cdsitepackages PyMOTW/bisect/ + (env1)$ pwd + /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1/lib/python2.6/site-packages/PyMOTW/bisect + +lssitepackages +-------------- + +.. + Calling ``lssitepackages`` shows the content of the ``site-packages`` + directory of the currently-active virtualenv. + +``lssitepackages`` を呼び出すと、カレントのアクティブ化された仮想環境の ``site-packages`` ディレクトリのコンテンツを表示します。 + +.. + Syntax:: + +構文:: + + lssitepackages + +:: + + $ mkvirtualenv env1 + New python executable in env1/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (env1)$ $ workon env1 + (env1)$ lssitepackages + distribute-0.6.10-py2.6.egg pip-0.6.3-py2.6.egg + easy-install.pth setuptools.pth + +.. + =============== + Path Management + =============== + +======== +パス管理 +======== + +add2virtualenv +-------------- + +.. + Adds the specified directories to the Python path for the + currently-active virtualenv. + +カレントのアクティブ化された仮想環境の Python パスへ指定したディレクトリを追加します。 + +.. + Syntax:: + +構文:: + + add2virtualenv directory1 directory2 ... + +.. + Sometimes it is desirable to share installed packages that are not in + the system ``site-pacakges`` directory and which should not be + installed in each virtualenv. One possible solution is to symlink the + source into the environment ``site-packages`` directory, but it is + also easy to add extra directories to the PYTHONPATH by including them + in a ``.pth`` file inside ``site-packages`` using ``add2virtualenv``. + +システムの ``site-pacakges`` ディレクトリに存在しないインストール済みのパッケージやそれぞれの仮想環境にインストールしたくないパッケージを共有したいときがあります。1つの解決方法はその仮想環境の ``site-packages`` ディレクトリへシンボリックリンクを張ることです。しかし、 ``add2virtualenv`` を使用して ``site-packages`` 内の ``.pth`` ファイルへそういったパッケージを含めることで、PYTHONPATH へ拡張ディレクトリを追加することも簡単です。 + +.. + 1. Check out the source for a big project, such as Django. + 2. Run: ``add2virtualenv path_to_source``. + 3. Run: ``add2virtualenv``. + 4. A usage message and list of current "extra" paths is printed. + +1. Django のような、大きなプロジェクトのソースをチェックアウトする +2. ``add2virtualenv path_to_source`` を実行する +3. ``add2virtualenv`` を実行する +4. 使用方法とカレントの "拡張された" パスリストが表示される + +.. + The directory names are added to a path file named + ``virtualenv_path_extensions.pth`` inside the site-packages directory + for the environment. + +site-packages ディレクトリ内の ``virtualenv_path_extensions.pth`` と名付けられたパスファイルへそのディレクトリ名が追加されます。 + +.. + *Based on a contribution from James Bennett and Jannis Leidel.* + +*James Bennett と Jannis Leidel から提供されたものに基づいています。* diff --git a/docs/ja/developers.rst b/docs/ja/developers.rst new file mode 100644 index 0000000..9b927b1 --- /dev/null +++ b/docs/ja/developers.rst @@ -0,0 +1,104 @@ +.. + ############## + For Developers + ############## + +########## +開発者向け +########## + +.. + If you would like to contribute to virtualenvwrapper directly, these + instructions should help you get started. Patches, bug reports, and + feature requests are all welcome through the `BitBucket site + `_. Contributions + in the form of patches or pull requests are easier to integrate and + will receive priority attention. + +あなたが直接 virtualenvwrapper に貢献したいなら、次の説明が役に立つでしょう。パッチ、バグレポートや機能要求は `BitBucket サイト `_ で歓んで受け付けます。パッチや pull リクエストによる貢献はその修正を取り込んだり、優先度の配慮も行い易いでしょう。 + +.. note:: + + .. Before contributing new features to virtualenvwrapper core, please + consider whether they should be implemented as an extension instead. + + virtualenvwrapper のコアへ新しい機能を追加する前に、その代わりに機能拡張として実装すべきかどうかをよく考えてください。 + +.. + Building Documentation + ====================== + +ドキュメントを作成する +====================== + +.. + The documentation for virtualenvwrapper is written in reStructuredText + and converted to HTML using Sphinx. The build itself is driven by + make. You will need the following packages in order to build the + docs: + +virtualenvwrapper のドキュメントは reStructuredText で書かれていて Sphinx で HTML に変換されます。それは make コマンドでビルドされます。ドキュメントをビルドするために次のパッケージが必要になります。 + +- Sphinx +- docutils + +.. + Once all of the tools are installed into a virtualenv using + pip, run ``make html`` to generate the HTML version of the + documentation:: + +全てのツールが pip を使用して仮想環境内にインストールされたら、ドキュメントの HTML バージョンを生成するために ``make html`` を実行してください。 + +:: + + $ make html + rm -rf virtualenvwrapper/docs + (cd docs && make html SPHINXOPTS="-c sphinx/pkg") + sphinx-build -b html -d build/doctrees -c sphinx/pkg source build/html + Running Sphinx v0.6.4 + loading pickled environment... done + building [html]: targets for 2 source files that are out of date + updating environment: 0 added, 2 changed, 0 removed + reading sources... [ 50%] command_ref + reading sources... [100%] developers + + looking for now-outdated files... none found + pickling environment... done + checking consistency... done + preparing documents... done + writing output... [ 33%] command_ref + writing output... [ 66%] developers + writing output... [100%] index + + writing additional files... search + copying static files... WARNING: static directory '/Users/dhellmann/Devel/virtualenvwrapper/plugins/docs/sphinx/pkg/static' does not exist + done + dumping search index... done + dumping object inventory... done + build succeeded, 1 warning. + + Build finished. The HTML pages are in build/html. + cp -r docs/build/html virtualenvwrapper/docs + +.. + The output version of the documentation ends up in + ``./virtualenvwrapper/docs`` inside your sandbox. + +最終的なドキュメントの生成内容はサンドボックスの ``./virtualenvwrapper/docs`` にあります。 + +.. + Running Tests + ============= + +テストを実行する +================ + +.. + The test suite for virtualenvwrapper uses `shunit2 + `_ and `tox + `_. To run the tests under bash, sh, and + zsh, use ``make test`` or just ``tox``. In order to add new tests, + you will need to modify or create an appropriate script in the + ``tests`` directory. + +virtualenvwrapper のテストセットは `shunit2 `_ と `tox `_ を使用します。bash, sh や zsh でテストを実行するには ``make test`` か、ただ ``tox`` を実行してください。新しくテストを追加するには、 ``tests`` ディレクトリの適切なスクリプトを作成したり、修正する必要があります。 diff --git a/docs/ja/extensions.rst b/docs/ja/extensions.rst new file mode 100644 index 0000000..fde65f4 --- /dev/null +++ b/docs/ja/extensions.rst @@ -0,0 +1,65 @@ +.. + ===================== + Existing Extensions + ===================== + +================ + 既存の拡張機能 +================ + +.. + Below is a list of some of the extensions available for use with + virtualenvwrapper. + +次に virtualenvwrapper で利用できる拡張機能を紹介します。 + +.. _extensions-user_scripts: + +project +======= + +.. + The project_ extension adds development directory management with + templates to virtualenvwrapper. + +project_ 拡張は virtualenvwrapper にテンプレートで開発ディレクトリ管理機能を追加します。 + +bitbucket +--------- + +.. + The bitbucket_ project template creates a working directory and + automatically clones the repository from BitBucket. Requires + project_. + +bitbucket_ プロジェクトテンプレートはワークディレクトリを作成して Bitbucket から自動的にクローンします。使用するには project_ が必要です。 + +.. _project: http://www.doughellmann.com/projects/virtualenvwrapper.project/ + +.. _bitbucket: http://www.doughellmann.com/projects/virtualenvwrapper.bitbucket/ + +emacs-desktop +============= + +.. + Emacs desktop-mode_ lets you save the state of emacs (open buffers, + kill rings, buffer positions, etc.) between sessions. It can also be + used as a project file similar to other IDEs. The emacs-desktop_ + plugin adds a trigger to save the current desktop file and load a new + one when activating a new virtualenv using ``workon``. + +emacs desktop-mode_ はセッション間で emacs の状態(バッファのオープン、リングの削除、バッファの位置等)を保存させます。それは他の IDE に対する1つのプロジェクトファイルとして使用することもできます。 emacs-desktop_ プラグインは、カレントのデスクトップファイルを保存するトリガーを追加して、 ``workon`` で新しい仮想環境をアクティブ化するときに新たなファイルを読み込みます。 + +.. _desktop-mode: http://www.emacswiki.org/emacs/DeskTop + +.. _emacs-desktop: http://www.doughellmann.com/projects/virtualenvwrapper-emacs-desktop/ + +user_scripts +============ + +.. + The ``user_scripts`` extension is delivered with virtualenvwrapper and + enabled by default. It implements the user customization script + features described in :ref:`scripts`. + +``user_scripts`` 拡張は virtualenvwrapper で提供され、デフォルトで有効です。それは :ref:`scripts` で説明したユーザのカスタマイズスクリプト機能を実装します。 diff --git a/docs/ja/history.rst b/docs/ja/history.rst new file mode 100644 index 0000000..0999577 --- /dev/null +++ b/docs/ja/history.rst @@ -0,0 +1,354 @@ +.. + =============== + Release History + =============== + +============ +リリース履歴 +============ + +2.6.1 + + .. - Fixed virtualenvwrapper_get_python_version (:bbissue:`73`). + + - virtualenvwrapper_get_python_version を修正しました(:bbissue:`73`)。 + +2.6 + + .. - Fixed a problem with hook script line endings under Cygwin + (:bbissue:`68`). + - Updated documentation to include a list of the compatible shells + (:ref:`supported-shells`) and Python versions + (:ref:`supported-versions`) (:bbissue:`70`). + - Fixed installation dependency on virtualenv (:bbissue:`60`). + - Fixed the method for determining the Python version so it works + under Python 2.4 (:bbissue:`61`). + - Converted the test infrastructure to use `tox + `_ instead of home-grown + scripts in the Makefile. + + - Cygwin 環境でフックスクリプトの改行の問題を修正しました(:bbissue:`68`)。 + - 互換シェルのリスト(:ref:`supported-shells`) と Python バージョン(:ref:`supported-versions`)を含むようにドキュメントを更新しました(:bbissue:`70`)。 + - virtualenv のインストールの依存関係を修正しました(:bbissue:`60`)。 + - Python 2.4 で動作するように Python バージョンを決定するメソッドを修正しました(:bbissue:`61`)。 + - Makefile の自作スクリプトの代わりに `tox `_ を使用するためにテストインフラを変換しました。 + +2.5.3 + + .. - Point release uploaded to PyPI during outage on doughellmann.com. + + - doughellmann.com の休止期間中に PyPI へアップロードしたポイントリリースです。 + +2.5.2 + + .. - Apply patch from Zach Voase to fix :ref:`command-lsvirtualenv` + under zsh. Resolves :bbissue:`64`. + + - zsh 環境の :ref:`command-lsvirtualenv` を修正する Zach Voase からのパッチを適用しました。 :bbissue:`64` を解決しました。 + +2.5.1 + + .. - Make :ref:`command-workon` list brief environment details when run + without argument, instead of full details. + + - 数無しで実行したときに :ref:`command-workon` に完全な環境詳細ではなく簡潔な詳細を表示するようにしました。 + +2.5 + + .. - Add :ref:`command-showvirtualenv` command. Modify + :ref:`command-lsvirtualenv` to make verbose output the default. + + - :ref:`command-showvirtualenv` コマンドを追加しました。デフォルトで冗長な出力を行うように :ref:`command-lsvirtualenv` を変更しました。 + +2.4 + + .. - Add :ref:`command-lsvirtualenv` command with ``-l`` option to run + :ref:`scripts-get_env_details` hook instead of always running it + when :ref:`command-workon` has no arguments. + + - :ref:`command-workon` が引数無しで実行されるときに :ref:`scripts-get_env_details` フックを実行するために ``-l`` オプションを持つ :ref:`command-lsvirtualenv` コマンドを追加しました。 + +2.3 + + .. - Added ``get_env_details`` hook. + + - ``get_env_details`` フックを追加しました。 + +2.2.2 + + .. - Integrate Fred Palmer's patch to escape more shell commands to + avoid aliases. Resolves :bbissue:`57`. + - Fix a problem with egrep argument escaping (:bbissue:`55`). + - Fix a problem with running mkvirtualenv without arguments (:bbissue:`56`). + + - エイリアスを避けてシェルコマンドをさらにエスケープ処理する Fred Palmer のパッチを取り込みました。 :bbissue:`57` を解決しました。 + - egrep 引数のエスケープ処理の問題を修正しました(:bbissue:`55`)。 + - 引数無しで mkvirtualenv を実行するときの問題を修正しました(:bbissue:`56`)。 + +2.2.1 + + .. - Escape ``which`` calls to avoid aliases. Resolves :bbissue:`46`. + - Integrate Manuel Kaufmann's patch to unset GREP_OPTIONS before + calling grep. Resolves :bbissue:`51`. + - Escape ``$`` in regex to resolve :bbissue:`53`. + - Escape ``rm`` to avoid issues with aliases and resolve + :bbissue:`50`. + + - ``which`` 呼び出しがエイリアスを避けるようにエスケープしました。 :bbissue:`46` を解決しました。 + - grep を呼び出す前に GREP_OPTIONS をアンセットする Manuel Kaufmann のパッチを取り込みました。 :bbissue:`51` を解決しました。 + - :bbissue:`53` を解決する正規表現の ``$`` をエスケープしました。 + - ``rm`` のエイリアスに関する問題をエスケープして :bbissue:`50` を解決しました。 + +2.2 + + .. - Switched hook loader execution to a form that works with Python + 2.4 to resolve :bbissue:`43`. + - Tested under Python 2.7b1. See :bbissue:`44`. + - Incorporated performance improvements from David Wolever. See + :bbissue:`38`. + - Added some debug instrumentation for :bbissue:`35`. + + - :bbissue:`43` を解決するために Python 2.4 で動作する形でフックローダの実行を切り替えました。 + - Python 2.7b1 でテストしました。 :bbissue:`44` を参照してください。 + - David Wolever からのパフォーマンス改善を取り込みました。 :bbissue:`38` を参照してください。 + - :bbissue:`35` のためにデバッグ命令を追加しました。 + +2.1.1 + + .. - Added `Spanish translation for the documentation + `__ via + Manuel Kaufmann's fork at + http://bitbucket.org/humitos/virtualenvwrapper-es-translation/ + - Fixed improper use of python from ``$PATH`` instead of the + location where the wrappers are installed. See :bbissue:`41`. + - Quiet spurrious error/warning messages when deactivating a + virtualenv under zsh. See :bbissue:`42`. + + - Manuel Kaufmann の http://bitbucket.org/humitos/virtualenvwrapper-es-translation/ から `スペイン語の翻訳ドキュメント `__ を追加しました。 + - ラッパーがインストールされる場所ではなく ``$PATH`` から Python の不適切な利用を修正しました。 :bbissue:`41` を参照してください。 + - zsh で仮想環境を非アクティブ化したときの誤ったエラー/ワーニングメッセージをなだめました。 :bbissue:`42` を参照してください。 + +2.1 + + .. - Add support for ksh. Thanks to Doug Latornell for doing the + research on what needed to be changed. + - Test import of virtualenvwrapper.hook_loader on startup and report + the error in a way that should help the user figure out how to fix + it (:bbissue:`33`). + - Update :ref:`command-mkvirtualenv` documentation to include the + fact that a new environment is activated immediately after it is + created (:bbissue:`30`). + - Added hooks around :ref:`command-cpvirtualenv`. + - Made deactivation more robust, especially under ksh. + - Use Python's ``tempfile`` module for creating temporary filenames + safely and portably. + - Fix a problem with ``virtualenvwrapper_show_workon_options`` that + caused it to show ``*`` as the name of a virtualenv when no + environments had yet been created. + - Change the hook loader so it can be told to run only a set of + named hooks. + - Add support for listing the available hooks, to be used in help + output of commands like virtualenvwrapper.project's mkproject. + - Fix mkvirtualenv -h option behavior. + - Change logging so the $WORKON_HOME/hook.log file rotates after + 10KiB. + + - ksh サポートを追加しました。変更する箇所を調査してくれた Doug Latornell に感謝します。 + - 起動時に virtualenvwrapper.hook_loader のインポートテストをして、ユーザへ修正方法を理解するのに役立つようにエラーを報告します(:bbissue:`33`)。 + - 新しい仮想環境が作成された後ですぐにアクティブ化することについて :ref:`command-mkvirtualenv` ドキュメントを更新しました(:bbissue:`30`)。 + - :ref:`command-cpvirtualenv` に関連するフックを追加しました。 + - 特に ksh 環境で、非アクティブ化をより堅牢にしました。 + - 安全で移植性の高い一時ファイル名を作成するために Python の ``tempfile`` モジュールを使用しました。 + - 仮想環境がまだ1つも作成されていないときに仮想環境の名前として ``*`` を表示することで発生する ``virtualenvwrapper_show_workon_options`` の問題を修正しました。 + - 名前付きフックのみを実行できるようにフックローダを変更しました。 + - virtualenvwrapper.project の mkproject のようにコマンドのヘルプ出力を使用して利用可能なフックの取得サポートを追加しました。 + - mkvirtualenv の -h オプションの振る舞いを修正しました。 + - $WORKON_HOME/hook.log ファイルを 10KiB でローテートするように logging を変更しました。 + +2.0.2 + + .. - Fixed :bbissue:`32`, making virtualenvwrapper.user_scripts compatible + with Python 2.5 again. + + - virtualenvwrapper.user_scripts が Python 2.5 互換になるように :bbissue:`32` を修正しました。 + +2.0.1 + + .. - Fixed :bbissue:`29`, to use a default value for ``TMPDIR`` if it + is not set in the user's shell environment. + + - ``TMPDIR`` がユーザのシェル環境でセットされていないときにデフォルト値を使用するように :bbissue:`29` を修正しました。 + +2.0 + + .. - Rewrote hook management using Distribute_ entry points to make it + easier to share extensions. + + - 拡張機能を共有し易くするために Distribute_ エントリポイントを使用してフック管理を書き直しました。 + +.. _Distribute: http://packages.python.org/distribute/ + +1.27 + + - Added cpvirtualenv command [Thomas Desvenain] + +1.26 + + - Fix a problem with error messages showing up during init for users + with the wrappers installed site-wide but who are not actually + using them. See :bbissue:`26`. + - Split up the tests into multiple files. + - Run all tests with all supported shells. + +1.25 + + - Merged in changes to cdsitepackages from William McVey. It now + takes an argument and supports tab-completion for directories + within site-packages. + +1.24.2 + + - Add user provided :ref:`tips-and-tricks` section. + - Add link to Rich Leland's screencast to :ref:`references` section. + +1.24.1 + + - Add license text to the header of the script. + +1.24 + + - Resolve a bug with the preactivate hook not being run properly. + Refer to :bbissue:`21` for complete details. + +1.23 + + - Resolve a bug with the postmkvirtualenv hook not being run + properly. Refer to :bbissue:`19` and :bbissue:`20` for complete + details. + +1.22 + + - Automatically create any missing hook scripts as stubs with + comments to expose the feature in case users are not aware of it. + +1.21 + + - Better protection of ``$WORKON_HOME`` does not exist when the + wrapper script is sourced. + +1.20 + + - Incorporate lssitepackages feature from Sander Smits. + - Refactor some of the functions that were using copy-and-paste code + to build path names. + - Add a few tests. + +1.19 + + - Fix problem with add2virtualenv and relative paths. Thanks to Doug + Latornell for the bug report James Bennett for the suggested fix. + +1.18.1 + + - Incorporate patch from Sascha Brossmann to fix a + :bbissue:`15`. Directory normalization was causing ``WORKON_HOME`` + to appear to be a missing directory if there were control + characters in the output of ``pwd``. + +1.18 + + - Remove warning during installation if sphinxcontrib.paverutils is + not installed. (:bbissue:`10`) + - Added some basic developer information to the documentation. + - Added documentation for deactivate command. + +1.17 + + - Added documentation updates provided by Steve Steiner. + +1.16 + + - Merged in changes to ``cdvirtualenv`` from wam and added tests and + docs. + - Merged in changes to make error messages go to stderr, also + provided by wam. + +1.15 + - Better error handling in mkvirtualenv. + - Remove bogus VIRTUALENV_WRAPPER_BIN variable. + +1.14 + - Wrap the virtualenv version of deactivate() with one that lets us + invoke the predeactivate hooks. + - Fix virtualenvwrapper_show_workon_options for colorized versions + of ls and write myself a note so I don't break it again later. + - Convert test.sh to use true tests with `shunit2 + `_ + +1.13 + + - Fix :bbissue:`5` by correctly handling symlinks and limiting the + list of envs to things that look like they can be activated. + +1.12 + + - Check return value of virtualenvwrapper_verify_workon_home + everywhere, thanks to Jeff Forcier for pointing out the errors. + - Fix instructions at top of README, pointed out by Matthew Scott. + - Add cdvirtualenv and cdsitepackages, contributed by James Bennett. + - Enhance test.sh. + +1.11 + + - Optimize virtualenvwrapper_show_workon_options. + - Add global postactivate hook. + +1.10 + + - Pull in fix for colorized ls from Jeff Forcier + (:bbchangeset:`b42a25f7b74a`). + +1.9 + + - Add more hooks for operations to run before and after creating or + deleting environments based on changes from Chris Hasenpflug. + +1.8.1 + + - Corrected a problem with change to mkvirtualenv that lead to + release 1.8 by using an alternate fix proposed by James in + comments on release 1.4. + +1.8 + + - Fix for processing the argument list in mkvirtualenv from + jorgevargas (:bbissue:`1`) + +1.7 + + - Move to bitbucket.org for hosting + - clean up TODO list and svn keywords + - add license section below + +1.6.1 + + - More zsh support (fixes to rmvirtualenv) from Byron Clark. + +1.6 + + - Add completion support for zsh, courtesy of Ted Leung. + +1.5 + + - Fix some issues with spaces in directory or env names. They still + don't really work with virtualenv, though. + - Added documentation for the postactivate and predeactivate scripts. + +1.4 + + - Includes a new .pth management function based on work contributed + by James Bennett and Jannis Leidel. + +1.3.x + + - Includes a fix for a nasty bug in rmvirtualenv identified by John Shimek. diff --git a/docs/ja/hooks.rst b/docs/ja/hooks.rst new file mode 100644 index 0000000..5c4923a --- /dev/null +++ b/docs/ja/hooks.rst @@ -0,0 +1,22 @@ +.. + =============================== + Customizing Virtualenvwrapper + =============================== + +====================================== + virtualenvwrapper をカスタマイズする +====================================== + +.. + virtualenvwrapper adds several hook points you can use to change your + settings, shell environment, or other configuration values when + creating, deleting, or moving between environments. These hooks are + exposed in two ways: + +virtualenvwrapper は仮想環境を作成・削除したり、環境間を移動したりするときに、設定内容、シェル環境またはその他の設定値を変更できる複数のフックポイントを追加します。そういったフック機能は2つの方法で提供されています。 + +.. toctree:: + :maxdepth: 1 + + scripts + plugins diff --git a/docs/ja/index.rst b/docs/ja/index.rst new file mode 100644 index 0000000..74f37aa --- /dev/null +++ b/docs/ja/index.rst @@ -0,0 +1,352 @@ +.. virtualenvwrapper documentation master file, created by + sphinx-quickstart on Thu May 28 22:35:13 2009. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +########################### +virtualenvwrapper |release| +########################### + +.. + virtualenvwrapper is a set of extensions to Ian Bicking's `virtualenv + `_ tool. The extensions + include wrappers for creating and deleting virtual environments and + otherwise managing your development workflow, making it easier to work + on more than one project at a time without introducing conflicts in + their dependencies. + +virtualenvwrapper は Ian Bicking の `virtualenv `_ ツールの拡張機能です。この拡張機能は仮想環境の作成・削除を行ったり、開発ワークフローを管理するラッパーを提供します。このラッパーを使用することで、開発環境の依存による競合を発生させず、1つ以上のプロジェクトで同時に作業し易くなります。 + +.. + ======== + Features + ======== + +==== +機能 +==== + +.. + 1. Organizes all of your virtual environments in one place. + 2. Wrappers for managing your virtual environments (create, delete, + copy). + 3. Use a single command to switch between environments. + 4. Tab completion for commands that take a virtual environment as + argument. + 5. User-configurable hooks for all operations (see :ref:`scripts`). + 6. Plugin system for more creating sharable extensions (see + :ref:`plugins`). + +1. 1つの開発環境で全ての仮想環境を構成する +2. 仮想環境を管理(作成、削除、コピー)するラッパー +3. たった1つのコマンドで仮想環境を切り替える +4. コマンドの引数として仮想環境がタブ補完できる +5. 全ての操作に対してユーザ設定でフックできる(:ref:`scripts` を参照) +6. さらに共有可能な拡張機能を作成できるプラグインシステム(:ref:`plugins` を参照) + +.. + ============ + Introduction + ============ + +==== +入門 +==== + +.. + The best way to explain the features virtualenvwrapper gives you is to + show it in use. + +virtualenvwrapper が提供する機能を説明する最善の方法は実際に使ってみることです。 + +.. + First, some initialization steps. Most of this only needs to be done + one time. You will want to add the command to ``source + /usr/local/bin/virtualenvwrapper.sh`` to your shell startup file, + changing the path to virtualenvwrapper.sh depending on where it was + installed by pip. + +まず初期化の作業があります。この作業の大半は同時に行う必要があります。pip によりインストールされた場所に依存する virtualenvwrapper.sh のパスを変更して、きっと ``source /usr/local/bin/virtualenvwrapper.sh`` に対するコマンドをシェル起動時に読み込まれるファイルへ追加したくなるでしょう。 + +:: + + $ pip install virtualenvwrapper + ... + $ export WORKON_HOME=~/Envs + $ mkdir -p $WORKON_HOME + $ source /usr/local/bin/virtualenvwrapper.sh + $ mkvirtualenv env1 + Installing + distribute.......................................... + .................................................... + .................................................... + ...............................done. + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/predeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/postdeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/preactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/postactivate New python executable in env1/bin/python + (env1)$ ls $WORKON_HOME + env1 hook.log + +.. + Now we can install some software into the environment. + +いま、作成した仮想環境内にソフトウェアをインストールできます。 + +:: + + (env1)$ pip install django + Downloading/unpacking django + Downloading Django-1.1.1.tar.gz (5.6Mb): 5.6Mb downloaded + Running setup.py egg_info for package django + Installing collected packages: django + Running setup.py install for django + changing mode of build/scripts-2.6/django-admin.py from 644 to 755 + changing mode of /Users/dhellmann/Envs/env1/bin/django-admin.py to 755 + Successfully installed django + +.. + We can see the new package with ``lssitepackages`` + +``lssitepackages`` で新たにインストールしたパッケージを調べることができます。 + +:: + + (env1)$ lssitepackages + Django-1.1.1-py2.6.egg-info easy-install.pth + distribute-0.6.10-py2.6.egg pip-0.6.3-py2.6.egg + django setuptools.pth + +.. + Of course we are not limited to a single virtualenv + +もちろん、たった1つの仮想環境に制限されるものではありません。 + +:: + + (env1)$ ls $WORKON_HOME + env1 hook.log + (env1)$ mkvirtualenv env2 + Installing distribute............................... + .................................................... + .................................................... + ........... ...............................done. + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/predeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/postdeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/preactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/postactivate New python executable in env2/bin/python + (env2)$ ls $WORKON_HOME + env1 env2 hook.log + +.. + Switch between environments with ``workon`` + +``workon`` で仮想環境を切り替えます。 + +:: + + (env2)$ workon env1 + (env1)$ echo $VIRTUAL_ENV + /Users/dhellmann/Envs/env1 + (env1)$ + +.. + The ``workon`` command also includes tab completion for the + environment names, and invokes customization scripts as an environment + is activated or deactivated (see :ref:`scripts`). + +さらに ``workon`` コマンドは仮想環境名をタブ補完することもできます。そして、ある仮想環境がアクティブ化または非アクティブ化されるようにカスタムスクリプトを実行します(:ref:`scripts` を参照)。 + +:: + + (env1)$ echo 'cd $VIRTUAL_ENV' >> $WORKON_HOME/postactivate + (env1)$ workon env2 + (env2)$ pwd + /Users/dhellmann/Envs/env2 + +.. + :ref:`scripts-postmkvirtualenv` is run when a new environment is + created, letting you automatically install commonly-used tools. + +新たな環境が作成されるときに :ref:`scripts-postmkvirtualenv` が実行されて、一般的に使用するツールを自動的にインストールします。 + +:: + + (env2)$ echo 'pip install sphinx' >> $WORKON_HOME/postmkvirtualenv + (env3)$ mkvirtualenv env3 + New python executable in env3/bin/python + Installing distribute............................... + .................................................... + .................................................... + ........... ...............................done. + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/predeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/postdeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/preactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/postactivate + Downloading/unpacking sphinx + Downloading Sphinx-0.6.5.tar.gz (972Kb): 972Kb downloaded + Running setup.py egg_info for package sphinx + no previously-included directories found matching 'doc/_build' + Downloading/unpacking Pygments>=0.8 (from sphinx) + Downloading Pygments-1.3.1.tar.gz (1.1Mb): 1.1Mb downloaded + Running setup.py egg_info for package Pygments + Downloading/unpacking Jinja2>=2.1 (from sphinx) + Downloading Jinja2-2.4.tar.gz (688Kb): 688Kb downloaded + Running setup.py egg_info for package Jinja2 + warning: no previously-included files matching '*' found under directory 'docs/_build/doctrees' + Downloading/unpacking docutils>=0.4 (from sphinx) + Downloading docutils-0.6.tar.gz (1.4Mb): 1.4Mb downloaded + Running setup.py egg_info for package docutils + Installing collected packages: docutils, Jinja2, Pygments, sphinx + Running setup.py install for docutils + Running setup.py install for Jinja2 + Running setup.py install for Pygments + Running setup.py install for sphinx + no previously-included directories found matching 'doc/_build' + Installing sphinx-build script to /Users/dhellmann/Envs/env3/bin + Installing sphinx-quickstart script to /Users/dhellmann/Envs/env3/bin + Installing sphinx-autogen script to /Users/dhellmann/Envs/env3/bin + Successfully installed docutils Jinja2 Pygments sphinx (env3)$ + (venv3)$ which sphinx-build + /Users/dhellmann/Envs/env3/bin/sphinx-build + +.. + Through a combination of the existing functions defined by the core + package (see :ref:`command`), third-party plugins (see + :ref:`plugins`), and user-defined scripts (see :ref:`scripts`) + virtualenvwrapper gives you a wide variety of opportunities to + automate repetitive operations. + +コアパッケージで定義された既存機能(:ref:`command` を参照)、サードパーティのプラグイン(:ref:`plugins` を参照)やユーザ定義スクリプト(:ref:`scripts` を参照)を組み合わせて、virtualenvwrapper は多種多様な繰り返し行うような操作を自動化する機会を提供します。 + +.. + ======= + Details + ======= + +======== +詳細内容 +======== + +.. toctree:: + :maxdepth: 2 + + install + command_ref + hooks + tips + developers + extensions + history + +.. _references: + +.. + ========== + References + ========== + +======== +参考文献 +======== + +.. + `virtualenv `_, from Ian + Bicking, is a pre-requisite to using these extensions. + +Ian Bicking の `virtualenv `_ が virtualenvwrapper の拡張機能を使用するために必須です。 + +.. + For more details, refer to the column I wrote for the May 2008 issue + of Python Magazine: `virtualenvwrapper | And Now For Something + Completely Different + `_. + +さらに詳細は私が書いた2008年5月の Python マガジンのコラムを参照してください。 +`virtualenvwrapper | ところで話は変わりますが +`_ + +.. + Rich Leland has created a short `screencast + `__ + showing off the features of virtualenvwrapper. + +Rich Leland は virtualenvwrapper の機能を誇示するために短い `スクリーンキャスト `__ を作成しました。 + +.. + Manuel Kaufmann has `translated this documentation into Spanish + `__. + +Manuel Kaufmann は `このドキュメントをスペイン語に翻訳しました `__ 。 + +.. + Tetsuya Morimoto has `translated this documentation into Japanese + `__. + +Tetsuya Morimoto は `このドキュメントを日本語に翻訳しました `__ 。 + +.. + ======= + Support + ======= + +======== +サポート +======== + +.. + Join the `virtualenvwrapper Google Group + `__ to discuss + issues and features. + +問題や機能を議論するには `virtualenvwrapper Google Group `__ に参加してください。 + +.. + Report bugs via the `bug tracker on BitBucket + `__. + +`BitBucket のバグトラッカー `__ でバグを報告してください。 + +.. + Shell Aliases + ============= + +シェルエイリアス +================ + +.. + Since virtualenvwrapper is largely a shell script, it uses shell + commands for a lot of its actions. If your environment makes heavy + use of shell aliases or other customizations, you may encounter + issues. Before reporting bugs in the bug tracker, please test + *without* your aliases enabled. If you can identify the alias causing + the problem, that will help make virtualenvwrapper more robust. + +virtualenvwrapper は大きなシェルスクリプトなので、多くのアクションはシェルコマンドを使用します。あなたの環境が多くのシェルエイリアスやその他のカスタマイズを行っているなら、何かしら問題に遭遇する可能性があります。バグトラッカーにバグを報告する前に、そういったエイリアスを無効な *状態* でテストしてください。あなたがその問題を引き起こすエイリアスを判別できるなら virtualenvwrapper をもっと堅牢なものにすることに役立つでしょう。 + +.. + ======= + License + ======= + +========== +ライセンス +========== + +Copyright Doug Hellmann, All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Doug Hellmann not be +used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. + +DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/docs/ja/install.rst b/docs/ja/install.rst new file mode 100644 index 0000000..d008fe0 --- /dev/null +++ b/docs/ja/install.rst @@ -0,0 +1,204 @@ +.. + ============ + Installation + ============ + +============ +インストール +============ + +.. + Supported Shells + ================ + +.. _supported-shells: + +サポートシェル +============== + +.. + virtualenvwrapper is a set of shell *functions* defined in Bourne + shell compatible syntax. It is tested under `bash`, `ksh`, and `zsh`. + It may work with other shells, so if you find that it does work with a + shell not listed here please let me know. If you can modify it to + work with another shell, without completely rewriting it, send a pull + request through the bitbucket project page. If you write a clone to + work with an incompatible shell, let me know and I will link to it + from this page. + +virtualenvwrapper は Bourne シェル互換の構文で定義されたシェル *関数* のセットです。それは `bash`, `ksh` と `zsh` でテストされています。その他のシェルでも動作するかもしれませんが、ここに記載されていないシェルで動作することを発見したら私に教えてください。もしあなたがその他のシェルで動作させるために virtualenvwrapper を完全に書き直すことなく修正できるなら、bitbucket のプロジェクトページを通じて pull リクエストを送ってください。あなたが非互換なシェル上で動作させるクローンを作成するなら、このページでリンクを張るので私に連絡してください。 + +.. + Python Versions + =============== + +.. _supported-versions: + +Python バージョン +================= + +.. + virtualenvwrapper is tested under Python 2.4 - 2.7. + +virtualenvwrapper は Python 2.4 - 2.7 でテストされています。 + +.. + Basic Installation + ================== + +基本的なインストール +==================== + +.. + virtualenvwrapper should be installed using pip_:: + +virtualenvwrapper は pip_ でインストールすべきです。 + +:: + + $ pip install virtualenvwrapper + +.. + You will want to install it into the global Python site-packages area, + along with virtualenv. You may need administrative privileges to do + that. + +virtualenv と同様にグローバルな Python site-packages にインストールしたくなるでしょう。そうするには管理者権限が必要になるかもしれません。 + +.. + An alternative to installing it into the global site-packages is to + add it to your user local directory (usually `~/.local`). + +グローバルな site-packages にインストールに対する代替案は、ユーザのローカルディレクトリ (普通は `~/.local`) に追加することです。 + +:: + + $ pip install --install-option="--user" virtualenvwrapper + +WORKON_HOME +=========== + +.. + The variable ``WORKON_HOME`` tells virtualenvwrapper where to place + your virtual environments. The default is ``$HOME/.virtualenvs``. + This directory must be created before using any virtualenvwrapper + commands. + +変数 ``WORKON_HOME`` は 仮想環境の作成場所を virtualenvwrapper に伝えます。デフォルトは ``$HOME/.virtualenvs`` です。このディレクトリは virtualenvwrapper のコマンドを使用する前に作成しなければなりません。 + +.. _install-shell-config: + +.. + Shell Startup File + ================== + +シェルの起動ファイル +==================== + +.. + Add two lines to your shell startup file (``.bashrc``, ``.profile``, + etc.) to set the location where the virtual environments should live + and the location of the script installed with this package:: + +シェルの起動ファイル(``.bashrc``, ``.profile`` 等)に、仮想環境が構築される場所と virtualenvwrapper がインストールしたシェルスクリプトの場所の2行追加してください。 + +:: + + export WORKON_HOME=$HOME/.virtualenvs + source /usr/local/bin/virtualenvwrapper.sh + +.. + After editing it, reload the startup file (e.g., run: ``source + ~/.bashrc``). + +編集後に起動ファイルを再読み込みしてください(例えば ``source ~/.bashrc`` を実行する)。 + +.. + Python Interpreter and $PATH + ============================ + +Python インタープリタと $PATH +============================= + +.. + During startup, ``virtualenvwrapper.sh`` finds the first ``python`` on + the ``$PATH`` and remembers it to use later. This eliminates any + conflict as the ``$PATH`` changes, enabling interpreters inside + virtual environments where virtualenvwrapper is not installed. + Because of this behavior, it is important for the ``$PATH`` to be set + **before** sourcing ``virtualenvwrapper.sh``. For example:: + +起動ファイルの読み込み時に ``virtualenvwrapper.sh`` は最初に ``$PATH`` 上の ``python`` を見つけて、後で使うために覚えておきます。これは virtualenvwrapper がインストールされていない仮想環境内部でインタープリタを有効にして ``$PATH`` 変更による競合が起こらないようにします。この動作の理由は ``virtualenvwrapper.sh`` を source する **前に** セットされた ``$PATH`` が重要だからです。 + +:: + + export PATH=/usr/local/bin:$PATH + source /usr/local/bin/virtualenvwrapper.sh + +.. + To override the ``$PATH`` search, set the variable + ``VIRTUALENVWRAPPER_PYTHON`` to the full path of the interpreter to + use (also **before** sourcing ``virtualenvwrapper.sh``). For + example:: + +``$PATH`` 探索を上書きするには、使用するインタープリタのフルパスを(``virtualenvwrapper.sh`` を source する **前に** )変数 ``VIRTUALENVWRAPPER_PYTHON`` にセットしてください。 + +:: + + export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python + source /usr/local/bin/virtualenvwrapper.sh + +.. + Quick-Start + =========== + +クイックスタート +================ + +.. + 1. Run: ``workon`` + 2. A list of environments, empty, is printed. + 3. Run: ``mkvirtualenv temp`` + 4. A new environment, ``temp`` is created and activated. + 5. Run: ``workon`` + 6. This time, the ``temp`` environment is included. + +1. ``workon`` を実行する +2. 仮想環境のリストが表示されるか、何も表示されない +3. ``mkvirtualenv temp`` を実行する +4. 新たな仮想環境 ``temp`` が作成されてアクティブ化される +5. ``workon`` を実行する +6. このときに ``temp`` の仮想環境が提供される + +.. + Temporary Files + =============== + +一時ファイル +============ + +.. + virtualenvwrapper creates temporary files in ``$TMPDIR``. If the + variable is not set, it uses ``/tmp``. To change the location of + temporary files just for virtualenvwrapper, set + ``VIRTUALENVWRAPPER_TMPDIR``. + +virtualenvwrapper は ``$TMPDIR`` に一時ファイルを作成します。その環境変数がセットされていない場合は ``/tmp`` を使用します。virtualenvwrapper 向けだけの一時ファイルの作成場所を変更するには ``VIRTUALENVWRAPPER_TMPDIR`` をセットしてください。 + +.. + Upgrading from 1.x + ================== + +1.x からのアップグレード +======================== + +.. + The shell script containing the wrapper functions has been renamed in + the 2.x series to reflect the fact that shells other than bash are + supported. In your startup file, change ``source + /usr/local/bin/virtualenvwrapper_bashrc`` to ``source + /usr/local/bin/virtualenvwrapper.sh``. + +ラッパー関数を含むシェルスクリプトは 2.x バージョンで bash 以外のシェルをサポートするためにその名前が変更されました。あなたの起動ファイルの ``source /usr/local/bin/virtualenvwrapper_bashrc`` を ``source /usr/local/bin/virtualenvwrapper.sh`` へ変更してください。 + +.. _pip: http://pypi.python.org/pypi/pip diff --git a/docs/ja/plugins.rst b/docs/ja/plugins.rst new file mode 100644 index 0000000..f1a4169 --- /dev/null +++ b/docs/ja/plugins.rst @@ -0,0 +1,613 @@ +.. + =========================== + Extending Virtualenvwrapper + =========================== + +.. _plugins: + +============================ +virtualenvwrapper を拡張する +============================ + +.. + Long experience with home-grown solutions for customizing a + development environment has proven how valuable it can be to have the + ability to automate common tasks and eliminate persistent annoyances. + Carpenters build jigs, software developers write shell scripts. + virtualenvwrapper continues the tradition of encouraging a craftsman + to modify their tools to work the way they want, rather than the other + way around. + +開発環境をカスタマイズするために自作で解決してきた長い経験から、共通タスクを自動化して何度も繰り返す苛々する作業を取り除く機能はどれだけ価値があるかが分かりました。大工は治具を組み立て、ソフトウェア開発者はシェルスクリプトを書きます。virtualenvwrapper は逆になりますが、求める方法で動作するようにツールを修正する職人を励ます伝統を受け継いでいます。 + +.. + Use the hooks provided to eliminate repetitive manual operations and + streamline your development workflow. For example, set up the + :ref:`plugins-pre_activate` and :ref:`plugins-post_activate` hooks to + trigger an IDE to load a project file to reload files from the last + editing session, manage time-tracking records, or start and stop + development versions of an application server. Use the + :ref:`plugins-initialize` hook to add entirely new commands and hooks + to virtualenvwrapper. And the :ref:`plugins-pre_mkvirtualenv` and + :ref:`plugins-post_mkvirtualenv` hooks give you an opportunity to + install basic requirements into each new development environment, + initialize a source code control repository, or otherwise set up a new + project. + +繰り返し行う手動の操作を取り除いたり開発ワークフローを効率化するために提供されるフックを使用してください。例えば、最後に編集されたセッションからファイルを再読み込みするために IDE にプロジェクトファイルを読む込ませる、時間追跡記録を管理する、もしくはアプリケーションサーバの開発バージョンを起動・停止するために :ref:`plugins-pre_activate` や :ref:`plugins-post_activate` フックを設定してください。 :ref:`plugins-initialize` は virtualenvwrapper に対するフックや完全に新しいコマンドを追加するためのフックです。そして :ref:`plugins-pre_mkvirtualenv` や :ref:`plugins-post_mkvirtualenv` といったフックはそれぞれの新しい開発環境へ基本的な必需品をインストールする、ソースコードリポジトリの初期化、その他の新たなプロジェクトの設定を行うといった機会を与えます。 + +.. + There are two ways to attach your code so that virtualenvwrapper will + run it: End-users can use shell scripts or other programs for personal + customization (see :ref:`scripts`). Extensions can also be + implemented in Python by using Distribute_ *entry points*, making it + possible to share common behaviors between systems and developers. + +virtualenvwrapper がそういったことを実行できるようにあなたのコードをアタッチする方法が2つあります。エンドユーザはシェルスクリプトか、個人的なカスタマイズを施したプログラムを使用することができます(:ref:`scripts` を参照)。さらに拡張機能は、システムと開発者間で共通の振る舞いを共有できるようにする Distribute_ *エントリポイント* を使用して Python で実装することもできます。 + +.. + Defining an Extension + ===================== + +拡張機能を定義する +================== + +.. note:: + + .. Virtualenvwrapper is delivered with a plugin for creating and + running the user customization scripts + (:ref:`extensions-user_scripts`). The examples below are taken from + the implementation of that plugin. + + virtualenvwrapper はユーザのカスタムスクリプトを作成して実行することをプラグインで実現します(:ref:`extensions-user_scripts`)。次のサンプルはそういったプラグインの実装を紹介します。 + +.. + Code Organization + ----------------- + +コードの構成 +------------ + +.. + The Python package for ``virtualenvwrapper`` is a *namespace package*. + That means multiple libraries can install code into the package, even + if they are not distributed together or installed into the same + directory. Extensions can (optionally) use the ``virtualenvwrapper`` + namespace by setting up their source tree like: + +``virtualenvwrapper`` の Python パッケージは *名前空間パッケージ* です。複数のライブラリが一緒に配布されていなかったり同じディレクトリ内にインストールされていなかったとしても、そのパッケージ内へインストールすることができます。拡張機能は次のようにソースツリーを設定することで ``virtualenvwrapper`` の名前空間を(オプションで)使用することが出来ます。 + +* virtualenvwrapper/ + + * __init__.py + * user_scripts.py + +.. + And placing the following code in ``__init__.py``:: + +そして ``__init__.py`` に次のコードを含めます。 + +:: + + """virtualenvwrapper module + """ + + __import__('pkg_resources').declare_namespace(__name__) + +.. note:: + + .. Extensions can be loaded from any package, so using the + ``virtualenvwrapper`` namespace is not required. + + 拡張機能はどんなパッケージからも読み込まれるので ``virtualenvwrapper`` の名前空間を使用する必要はありません。 + +.. + Extension API + ------------- + +拡張 API +-------- + +.. + After the package is established, the next step is to create a module + to hold the extension code. For example, + ``virtualenvwrapper/user_scripts.py``. The module should contain the + actual extension entry points. Supporting code can be included, or + imported from elsewhere using standard Python code organization + techniques. + +パッケージを作成した次のステップは拡張コードを保持するモジュールを作成することです。例えば ``virtualenvwrapper/user_scripts.py`` です。そのモジュールは実際の拡張機能のエントリポイントを含むべきです。サポートするコードが含められるか、標準の Python コードの構成テクニックを使用してどこかからインポートされます。 + +.. + The API is the same for every extension point. Each uses a Python + function that takes a single argument, a list of strings passed to the + hook loader on the command line. + +API は全ての拡張ポイントで同じです。それぞれは1つの引数、つまりコマンドライン上でフックローダへ渡される文字列のリストを受け取る Python 関数を使用します。 + +:: + + def function_name(args): + # args is a list of strings passed to the hook loader + +.. + The contents of the argument list are defined for each extension point + below (see :ref:`plugins-extension-points`). + +引数リストのコンテンツは次の拡張ポイント毎に定義されます(:ref:`plugins-extension-points` を参照)。 + +.. + Extension Invocation + -------------------- + +拡張機能の起動 +-------------- + +.. + Direct Action + ~~~~~~~~~~~~~ + +ダイレクトアクション +~~~~~~~~~~~~~~~~~~~~ + +.. + Plugins can attach to each hook in two different ways. The default is + to have a function run and do some work directly. For example, the + ``initialize()`` function for the user scripts plugin creates default + user scripts when ``virtualenvwrapper.sh`` is loaded. + +プラグインは2つの方法でそれぞれのフックをアタッチできます。デフォルトは直接的に何らかの処理を実行する関数を持ちます。例えば、ユーザスクリプトプラグインの ``initialize()`` 関数は ``virtualenvwrapper.sh`` が読み込まれるときにデフォルトユーザスクリプトを作成します。 + +:: + + def initialize(args): + for filename, comment in GLOBAL_HOOKS: + make_hook(os.path.join('$WORKON_HOME', filename), comment) + return + +.. + Modifying the User Environment + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. _plugins-user-env: + +ユーザ環境を変更する +~~~~~~~~~~~~~~~~~~~~ + +.. + There are cases where the extension needs to update the user's + environment (e.g., changing the current working directory or setting + environment variables). Modifications to the user environment must be + made within the user's current shell, and cannot be run in a separate + process. To have code run in the user's shell process, extensions can + define hook functions to return the text of the shell statements to be + executed. These *source* hooks are run after the regular hooks with + the same name, and should not do any work of their own. + +拡張機能がユーザ環境のアップデートを必要とするケースがあります(例えば、カレントワークディレクトリを変更したり、環境変数を設定する等)。ユーザ環境に対する変更はユーザのカレントシェル内で行われなければならず、独立したプロセスで実行できません。ユーザのシェルプロセスで実行するコードを持つために、拡張機能は実行されるシェル構文のテキストを返すフック関数を定義できます。これらの *source* フックは同じ名前を持つ通常のフックの後で実行されます。そして、そのフック内部で処理を行ってはいけません。 + +.. + The ``initialize_source()`` hook for the user scripts plugin looks for + a global initialize script and causes it to be run in the current + shell process. + +ユーザスクリプトプラグインの ``initialize_source()`` フックは、グローバルな初期化スクリプトを調べてカレントのシェルプロセスでそのスクリプトを実行させます。 + +:: + + def initialize_source(args): + return """ + # + # Run user-provided scripts + # + [ -f "$WORKON_HOME/initialize" ] && source "$WORKON_HOME/initialize" + """ + +.. warning:: + + .. Because the extension is modifying the user's working shell, care + must be taken not to corrupt the environment by overwriting + existing variable values unexpectedly. Avoid creating temporary + variables where possible, and use unique names where variables + cannot be avoided. Prefixing variables with the extension name is + a good way to manage the namespace. For example, instead of + ``temp_file`` use ``user_scripts_temp_file``. Use ``unset`` to + release temporary variable names when they are no longer needed. + + 拡張機能はユーザのワークシェルを変更しているので、予期しない既存変数の上書きにより環境が汚染されないように注意しなければなりません。できるだけ一時的な変数を作成せずに、必要なところで一意な名前を使用してください。接頭辞として拡張名が付く変数は名前空間を管理するのに良い方法です。例えば、 ``temp_file`` ではなく ``user_scripts_temp_file`` を使用してください。一時的な変数は必要なくなったときに ``unset`` で解放してください。 + +.. warning:: + + .. virtualenvwrapper works under several shells with slightly + different syntax (bash, sh, zsh, ksh). Take this portability into + account when defining source hooks. Sticking to the simplest + possible syntax usually avoids problems, but there may be cases + where examining the ``SHELL`` environment variable to generate + different syntax for each case is the only way to achieve the + desired result. + + virtualenvwrapper は構文が少し違う複数のシェル(bash, sh, zsh, ksh)で動作します。ソースフックを定義するときにアカウント内にこの移植性を考慮してください。最も簡単な構文のみを使用することで普通は問題ありませんが、求める結果を得るためには唯一の方法しかないケースにおいて、違う構文を生成する ``SHELL`` 環境変数を調べる可能性があります。 + +.. + Registering Entry Points + ------------------------ + +エントリポイントを登録する +-------------------------- + +.. + The functions defined in the plugin need to be registered as *entry + points* in order for virtualenvwrapper's hook loader to find them. + Distribute_ entry points are configured in the ``setup.py`` for your + package by mapping the entry point name to the function in the package + that implements it. + +プラグインで定義された関数は virtualenvwrapper のフックローダが見つけられるために *エントリポイント* として登録される必要があります。 Distribute_ エントリポイントは関数を実装するパッケージでその関数に対するエントリポイントの名前をマッピングすることにより、そのパッケージの ``setup.py`` で設定されます。 + +.. + This partial copy of virtualenvwrapper's ``setup.py`` illustrates how + the ``initialize()`` and ``initialize_source()`` entry points are + configured. + +この virtualenvwrapper の ``setup.py`` の一部は ``initialize()`` や ``initialize_source()`` エントリポイントの設定方法を説明します。 + +:: + + # Bootstrap installation of Distribute + import distribute_setup + distribute_setup.use_setuptools() + + from setuptools import setup + + setup( + name = 'virtualenvwrapper', + version = '2.0', + + description = 'Enhancements to virtualenv', + + # ... details omitted ... + + namespace_packages = [ 'virtualenvwrapper' ], + + entry_points = { + 'virtualenvwrapper.initialize': [ + 'user_scripts = virtualenvwrapper.user_scripts:initialize', + ], + 'virtualenvwrapper.initialize_source': [ + 'user_scripts = virtualenvwrapper.user_scripts:initialize_source', + ], + + # ... details omitted ... + }, + ) + +.. + The ``entry_points`` argument to ``setup()`` is a dictionary mapping + the entry point *group names* to lists of entry point specifiers. A + different group name is defined by virtualenvwrapper for each + extension point (see :ref:`plugins-extension-points`). + +``setup()`` への ``entry_points`` 引数はエントリポイントの指定子を表示するエントリポイント *グループ名* をマッピングするディクショナリです。違うグループ名はそれぞれの拡張ポイントのために virtualenvwrapper により定義されます(:ref:`plugins-extension-points` を参照)。 + +.. + The entry point specifiers are strings with the syntax ``name = + package.module:function``. By convention, the *name* of each entry + point is the plugin name, but that is not required (the names are not + used). + +エントリポイント指定子は ``name = package.module:function`` という構文の文字列です。 +慣例により、それぞれのエントリポイントの *名前* はプラグインの名前ですが、それが必要ではありません(その名前は使用されない)。 + +.. seealso:: + + .. * `namespace packages `__ + * `Extensible Applications and Frameworks `__ + + * `名前空間パッケージ `__ + * `拡張可能なアプリケーションとフレームワーク `__ + +.. + The Hook Loader + --------------- + +フックローダ +------------ + +.. + Extensions are run through a command line application implemented in + ``virtualenvwrapper.hook_loader``. Because ``virtualenvwrapper.sh`` + is the primary caller and users do not typically need to run the app + directly, no separate script is installed. Instead, to run the + application, use the ``-m`` option to the interpreter:: + +拡張機能は ``virtualenvwrapper.hook_loader`` で実装されたコマンドラインアプリケーションを通して実行されます。 ``virtualenvwrapper.sh`` がプライマリの呼び出しであり、ユーザはそのアプリケーションを直接的に実行する必要はないので、分割されたスクリプトはインストールされません。その代わり、そのアプリケーションを実行するにはインタープリタに ``-m`` オプションを指定してください。 + +:: + + $ python -m virtualenvwrapper.hook_loader -h + Usage: virtualenvwrapper.hook_loader [options] [] + + Manage hooks for virtualenvwrapper + + Options: + -h, --help show this help message and exit + -s, --source Print the shell commands to be run in the current + shell + -l, --list Print a list of the plugins available for the given + hook + -v, --verbose Show more information on the console + -q, --quiet Show less information on the console + -n NAMES, --name=NAMES + Only run the hook from the named plugin + +.. + To run the extensions for the initialize hook + +initialize フックのためにその拡張機能を実行するには次のようにします。 + +:: + + $ python -m virtualenvwrapper.hook_loader -v initialize + +.. + To get the shell commands for the initialize hook + +initialize フックのためにシェルコマンドを読み込むには次のようにします。 + +:: + + $ python -m virtualenvwrapper.hook_loader --source initialize + +.. + In practice, rather than invoking the hook loader directly it is more + convenient to use the shell function, ``virtualenvwrapper_run_hook`` + to run the hooks in both modes. + +実際は、フックローダが直接フックを実行するよりも両方のモードでフックを実行するシェル関数 ``virtualenvwrapper_run_hook`` を使用する方がもっと便利です。 + +:: + + $ virtualenvwrapper_run_hook initialize + +.. + All of the arguments given to shell function are passed directly to + the hook loader. + +シェル関数に与えられた全ての引数はフックローダへ直接渡されます。 + +.. + Logging + ------- + +ロギング +-------- + +.. + The hook loader configures logging so that messages are written to + ``$WORKON_HOME/hook.log``. Messages also may be written to stderr, + depending on the verbosity flag. The default is for messages at *info* + or higher levels to be written to stderr, and *debug* or higher to go to + the log file. Using logging in this way provides a convenient + mechanism for users to control the verbosity of extensions. + +フックローダはログメッセージを ``$WORKON_HOME/hook.log`` に書き込むように設定します。またログメッセージは冗長フラグにより標準エラーにも出力されます。デフォルトでは、ログメッセージは *info* かそれ以上のレベルが標準エラーへ出力され、 *debug* かそれ以上がログファイルへ書き込まれます。この方法でロギングを使用することでユーザに拡張機能の冗長性を制御する便利な仕組みを提供します。 + +.. + To use logging from within your extension, simply instantiate a logger + and call its ``info()``, ``debug()`` and other methods with the + messages. + +拡張機能からロギングを使用するには、単純にロガーをインスタンス化して、ログメッセージと共にその ``info()``, ``debug()`` やその他のメソッドを呼び出してください。 + +:: + + import logging + log = logging.getLogger(__name__) + + def pre_mkvirtualenv(args): + log.debug('pre_mkvirtualenv %s', str(args)) + # ... + +.. seealso:: + + .. * `Standard library documentation for logging `__ + * `PyMOTW for logging `__ + + * `logging の標準ライブラリドキュメント `__ + * `logging の PyMOTW `__ + +.. + Extension Points + ================ + +.. _plugins-extension-points: + +拡張ポイント +============ + +.. + The extension point names for native plugins follow a naming + convention with several parts: + ``virtualenvwrapper.(pre|post)_[_source]``. The ** is + the action taken by the user or virtualenvwrapper that triggers the + extension. ``(pre|post)`` indicates whether to call the extension + before or after the event. The suffix ``_source`` is added for + extensions that return shell code instead of taking action directly + (see :ref:`plugins-user-env`). + +ネイティブプラグインの拡張ポイントの名前は複数のパートを持つ命名規則 ``virtualenvwrapper.(pre|post)_[_source]`` に従います。 ** は拡張機能が引き起こす virtualenvwrapper またはユーザによるアクションです。 ``(pre|post)`` はその拡張機能の呼び出しがイベントの前か後かのどちらかを指します。接尾辞 ``_source`` は直接アクションを受け取らずにシェルスクリプトのコードを返す拡張機能に追加されます(:ref:`plugins-user-env` を参照)。 + +.. _plugins-get_env_details: + +get_env_details +=============== + +.. + The ``virtualenvwrapper.get_env_details`` hooks are run when + ``workon`` is run with no arguments and a list of the virtual + environments is printed. The hook is run once for each environment, + after the name is printed, and can be used to show additional + information about that environment. + +``virtualenvwrapper.get_env_details`` フックは ``workon`` が引数無しで実行されるときに実行されます。そして、仮想環境のリストを表示します。仮想環境の名前が表示された後で、そのフックは環境毎に一度実行されて、その環境に関する追加情報を表示します。 + +.. _plugins-initialize: + +initialize +---------- + +.. + The ``virtualenvwrapper.initialize`` hooks are run each time + ``virtualenvwrapper.sh`` is loaded into the user's environment. The + initialize hook can be used to install templates for configuration + files or otherwise prepare the system for proper plugin operation. + +``virtualenvwrapper.initialize`` フックは ``virtualenvwrapper.sh`` が環境に読み込まれる毎に実行されます。initialize フックは設定ファイルのテンプレートをインストールしたり、適切なプラグイン操作のためにシステムを整備するために使用されます。 + +.. _plugins-pre_mkvirtualenv: + +pre_mkvirtualenv +---------------- + +.. + The ``virtualenvwrapper.pre_mkvirtualenv`` hooks are run after the + virtual environment is created, but before the new environment is + activated. The current working directory for when the hook is run is + ``$WORKON_HOME`` and the name of the new environment is passed as an + argument. + +``virtualenvwrapper.pre_mkvirtualenv`` フックは仮想環境が作成された後で実行されますが、新しい環境がアクティブ化される前に実行されます。そのフックが実行されるときのためにカレントワークディレクトリは ``$WORKON_HOME`` で、1つの引数として新しい環境の名前が渡されます。 + +.. _plugins-post_mkvirtualenv: + +post_mkvirtualenv +----------------- + +.. + The ``virtualenvwrapper.post_mkvirtualenv`` hooks are run after a new + virtual environment is created and activated. ``$VIRTUAL_ENV`` is set + to point to the new environment. + +``virtualenvwrapper.post_mkvirtualenv`` フックは新しい仮想仮想が作成されて、アクティブ化された後で実行されます。 ``$VIRTUAL_ENV`` は新しい環境を指すようにセットされます。 + +.. _plugins-pre_activate: + +pre_activate +------------ + +.. + The ``virtualenvwrapper.pre_activate`` hooks are run just before an + environment is enabled. The environment name is passed as the first + argument. + +``virtualenvwrapper.pre_activate`` フックは仮想環境が有効になる前に実行されます。環境の名前は1番目の引数として渡されます。 + +.. _plugins-post_activate: + +post_activate +------------- + +.. + The ``virtualenvwrapper.post_activate`` hooks are run just after an + environment is enabled. ``$VIRTUAL_ENV`` is set to point to the + current environment. + +``virtualenvwrapper.post_activate`` フックは仮想環境が有効になった後で実行されます。 ``$VIRTUAL_ENV`` はカレント環境を指すようにセットされます。 + +.. _plugins-pre_deactivate: + +pre_deactivate +-------------- + +.. + The ``virtualenvwrapper.pre_deactivate`` hooks are run just before an + environment is disabled. ``$VIRTUAL_ENV`` is set to point to the + current environment. + +``virtualenvwrapper.pre_deactivate`` フックは仮想環境が無効になる前に実行されます。 ``$VIRTUAL_ENV`` はカレント環境を指すようにセットされます。 + +.. _plugins-post_deactivate: + +post_deactivate +--------------- + +.. + The ``virtualenvwrapper.post_deactivate`` hooks are run just after an + environment is disabled. The name of the environment just deactivated + is passed as the first argument. + +``virtualenvwrapper.post_deactivate`` フックは仮想環境が無効になった後で実行されます。非アクティブ化される環境の名前は1番目の引数として渡されます。 + +.. _plugins-pre_rmvirtualenv: + +pre_rmvirtualenv +---------------- + +.. + The ``virtualenvwrapper.pre_rmvirtualenv`` hooks are run just before + an environment is deleted. The name of the environment being deleted + is passed as the first argument. + +``virtualenvwrapper.pre_rmvirtualenv`` フックは仮想環境が削除される前に実行されます。削除される環境の名前は1番目の引数として渡されます。 + +.. _plugins-post_rmvirtualenv: + +post_rmvirtualenv +----------------- + +.. + The ``virtualenvwrapper.post_rmvirtualenv`` hooks are run just after + an environment is deleted. The name of the environment being deleted + is passed as the first argument. + +``virtualenvwrapper.post_rmvirtualenv`` フックは仮想環境が削除された後で実行されます。削除される環境の名前は1番目の引数として渡されます。 + +.. + Adding New Extension Points + =========================== + +新しい拡張ポイントを追加する +============================ + +.. + Plugins that define new operations can also define new extension + points. No setup needs to be done to allow the hook loader to find + the extensions; documenting the names and adding calls to + ``virtualenvwrapper_run_hook`` is sufficient to cause them to be + invoked. + +さらに新しい操作を定義するプラグインは新しい拡張ポイントを定義することもできます。フックローダが拡張機能を見つけるために行う設定は必要ありません。名前を記述して ``virtualenvwrapper_run_hook`` の呼び出しを追加することで、追加した拡張機能が実行されるようになります。 + +.. + The hook loader assumes all extension point names start with + ``virtualenvwrapper.`` and new plugins will want to use their own + namespace qualifier to append to that. For example, the project_ + extension defines new events around creating project directories (pre + and post). These are called + ``virtualenvwrapper.project.pre_mkproject`` and + ``virtualenvwrapper.project.post_mkproject``. These are invoked + with:: + +フックローダは全ての拡張ポイントの名前が ``virtualenvwrapper.`` で始まることを前提としています。そして、新しいプラグインは独自の名前空間の修飾語句をその接頭辞に追加したくなるでしょう。例えば project_ 拡張はプロジェクトのディレクトリ作成(前後)に関連して新たなイベントを定義します。そこで ``virtualenvwrapper.project.pre_mkproject`` と ``virtualenvwrapper.project.post_mkproject`` が呼び出されます。それは次のように1つずつ実行されます。 + +:: + + virtualenvwrapper_run_hook project.pre_mkproject $project_name + +.. + and + +と + +:: + + virtualenvwrapper_run_hook project.post_mkproject + +.. + respectively. + +です。 + +.. _Distribute: http://packages.python.org/distribute/ + +.. _project: http://www.doughellmann.com/projects/virtualenvwrapper.project/ diff --git a/docs/ja/scripts.rst b/docs/ja/scripts.rst new file mode 100644 index 0000000..1213c51 --- /dev/null +++ b/docs/ja/scripts.rst @@ -0,0 +1,307 @@ +.. + ======================== + Per-User Customization + ======================== + +.. _scripts: + +==================== + ユーザカスタマイズ +==================== + +.. + The end-user customization scripts are either *sourced* (allowing them + to modify your shell environment) or *run* as an external program at + the appropriate trigger time. + +エンドユーザのカスタマイズスクリプトは *読み込み* (シェル環境を変更できる) されるか、適切な条件で外部プログラムのように *実行* されるかのどちらかです。 + +.. _scripts-get_env_details: + +get_env_details +=============== + + .. :Global/Local: both + :Argument(s): env name + :Sourced/Run: run + + :グローバル/ローカル: 両方 + :引数: 環境名 + :読み込み/実行: 実行 + +.. + ``$WORKON_HOME/get_env_details`` is run when ``workon`` is run with no + arguments and a list of the virtual environments is printed. The hook + is run once for each environment, after the name is printed, and can + print additional information about that environment. + +``$WORKON_HOME/get_env_details`` は ``workon`` が引数無しで実行されるときに実行されます。そして、仮想環境のリストを表示します。仮想環境の名前が表示された後で、そのフックは環境毎に一度実行されて、その環境に関する追加情報を表示します。 + +.. _scripts-initialize: + +initialize +========== + + .. :Global/Local: global + :Argument(s): None + :Sourced/Run: sourced + + :グローバル/ローカル: グローバル + :引数: 無し + :読み込み/実行: 読み込み + +.. + ``$WORKON_HOME/initialize`` is sourced when ``virtualenvwrapper.sh`` + is loaded into your environment. Use it to adjust global settings + when virtualenvwrapper is enabled. + +あなたの環境に ``virtualenvwrapper.sh`` を読み込むときに ``$WORKON_HOME/initialize`` が読み込まれます。virtualenvwrapper が有効になるときにグローバルな設定を調整するために使用してください。 + +.. _scripts-premkvirtualenv: + +premkvirtualenv +=============== + + .. :Global/Local: global + :Argument(s): name of new environment + :Sourced/Run: run + + :グローバル/ローカル: グローバル + :引数: 新しい環境名 + :読み込み/実行: 実行 + +.. + ``$WORKON_HOME/premkvirtualenv`` is run as an external program after + the virtual environment is created but before the current environment + is switched to point to the new env. The current working directory for + the script is ``$WORKON_HOME`` and the name of the new environment is + passed as an argument to the script. + +``$WORKON_HOME/premkvirtualenv`` は仮想環境が作成された後で外部プログラムのように実行されますが、カレントの環境が新しい環境へ切り替わる前に実行されます。そのスクリプトのカレントワークディレクトリは ``$WORKON_HOME`` で、そのスクリプトへの引数として新しい環境の名前が渡されます。 + +.. _scripts-postmkvirtualenv: + +postmkvirtualenv +================ + + .. :Global/Local: global + :Argument(s): none + :Sourced/Run: sourced + + :グローバル/ローカル: グローバル + :引数: 無し + :読み込み/実行: 読み込み + +.. + ``$WORKON_HOME/postmkvirtualenv`` is sourced after the new environment + is created and activated. + +``$WORKON_HOME/postmkvirtualenv`` は新しい環境が作成されてアクティブ化された後で読み込まれます。 + +.. _scripts-precpvirtualenv: + +precpvirtualenv +=============== + + .. :Global/Local: global + :Argument(s): name of original environment, name of new environment + :Sourced/Run: run + + :グローバル/ローカル: グローバル + :引数: オリジナルの環境名、新しい環境名 + :読み込み/実行: 実行 + +.. + ``$WORKON_HOME/precpvirtualenv`` is run as an external program after + the source environment is duplicated and made relocatable, but before + the ``premkvirtualenv`` hook is run or the current environment is + switched to point to the new env. The current working directory for + the script is ``$WORKON_HOME`` and the names of the source and new + environments are passed as arguments to the script. + +``$WORKON_HOME/precpvirtualenv`` は元の環境が複製されて再配置可能になるときに外部プログラムのように実行されますが、 ``premkvirtualenv`` フックが実行される前、もしくはカレントの環境が新しい環境へ切り替わる前に実行されます。そのスクリプトのカレントワークディレクトリは ``$WORKON_HOME`` で、そのスクリプトへの引数として元の環境名と新しい環境名が渡されます。 + +.. _scripts-postcpvirtualenv: + +postcpvirtualenv +================ + + .. :Global/Local: global + :Argument(s): none + :Sourced/Run: sourced + + :グローバル/ローカル: グローバル + :引数: 無し + :読み込み/実行: 読み込み + +.. + ``$WORKON_HOME/postmkvirtualenv`` is sourced after the new environment + is created and activated. + +``$WORKON_HOME/postmkvirtualenv`` は新しい環境が作成されてアクティブ化された後で読み込まれます。 + +.. _scripts-preactivate: + +preactivate +=========== + + .. :Global/Local: global, local + :Argument(s): environment name + :Sourced/Run: run + + :グローバル/ローカル: グローバル、ローカル + :引数: 環境名 + :読み込み/実行: 実行 + +.. + The global ``$WORKON_HOME/preactivate`` script is run before the new + environment is enabled. The environment name is passed as the first + argument. + +グローバルの ``$WORKON_HOME/preactivate`` スクリプトは新しい仮想環境が有効になる前に実行されます。その環境名は1番目の引数として渡されます。 + +.. + The local ``$VIRTUAL_ENV/bin/preactivate`` hook is run before the new + environment is enabled. The environment name is passed as the first + argument. + +ローカルの ``$VIRTUAL_ENV/bin/preactivate`` フックは新しい仮想環境が有効になる前に実行されます。その環境名は1番目の引数として渡されます。 + +.. _scripts-postactivate: + +postactivate +============ + + .. :Global/Local: global, local + :Argument(s): none + :Sourced/Run: sourced + + :グローバル/ローカル: グローバル、ローカル + :引数: 無し + :読み込み/実行: 読み込み + +.. + The global ``$WORKON_HOME/postactivate`` script is sourced after the + new environment is enabled. ``$VIRTUAL_ENV`` refers to the new + environment at the time the script runs. + +グローバルの ``$WORKON_HOME/postactivate`` スクリプトは新しい仮想環境が有効になった後で読み込まれます。 ``$VIRTUAL_ENV`` はそのスクリプトが実行されるときに新しい環境を参照します。 + +.. + This example script adds a space between the virtual environment name + and your old PS1 by making use of ``_OLD_VIRTUAL_PS1``. + +このサンプルスクリプトは ``_OLD_VIRTUAL_PS1`` を使用して仮想環境の名前と古い PS1 名前の間にスペースを追加します。 + +:: + + PS1="(`basename \"$VIRTUAL_ENV\"`) $_OLD_VIRTUAL_PS1" + +.. + The local ``$VIRTUAL_ENV/bin/postactivate`` script is sourced after + the new environment is enabled. ``$VIRTUAL_ENV`` refers to the new + environment at the time the script runs. + +ローカルの ``$VIRTUAL_ENV/bin/postactivate`` スクリプトは新しい仮想環境が有効になった後で読み込まれます。 ``$VIRTUAL_ENV`` はそのスクリプトが実行されるときに新しい環境を参照します。 + +.. + This example script for the PyMOTW environment changes the current + working directory and the PATH variable to refer to the source tree + containing the PyMOTW source. + +この PyMOTW 環境のサンプルは PyMOTW に含まれるソースツリーを参照して PATH 変数とカレントワークディレクトリを変更します。 + +:: + + pymotw_root=/Users/dhellmann/Documents/PyMOTW + cd $pymotw_root + PATH=$pymotw_root/bin:$PATH + +.. _scripts-predeactivate: + +predeactivate +============= + + .. :Global/Local: local, global + :Argument(s): none + :Sourced/Run: sourced + + :グローバル/ローカル: グローバル、ローカル + :引数: 無し + :読み込み/実行: 読み込み + +.. + The local ``$VIRTUAL_ENV/bin/predeactivate`` script is sourced before the + current environment is deactivated, and can be used to disable or + clear settings in your environment. ``$VIRTUAL_ENV`` refers to the old + environment at the time the script runs. + +ローカルの ``$VIRTUAL_ENV/bin/predeactivate`` スクリプトはカレントの仮想環境が非アクティブ化される前に読み込まれます。そして、あなたの環境の設定をクリアしたり、無効にするために使用されます。 ``$VIRTUAL_ENV`` はそのスクリプトが実行されるときに古い環境を参照します。 + +.. + The global ``$WORKON_HOME/predeactivate`` script is sourced before the + current environment is deactivated. ``$VIRTUAL_ENV`` refers to the + old environment at the time the script runs. + +グローバルの ``$WORKON_HOME/predeactivate`` スクリプトはカレントの仮想環境が非アクティブ化される前に読み込まれます。 ``$VIRTUAL_ENV`` はそのスクリプトが実行されるときに古い環境を参照します。 + +.. _scripts-postdeactivate: + +postdeactivate +============== + + .. :Global/Local: local, global + :Argument(s): none + :Sourced/Run: sourced + + :グローバル/ローカル: グローバル、ローカル + :引数: 無し + :読み込み/実行: 読み込み + +.. + The ``$VIRTUAL_ENV/bin/postdeactivate`` script is sourced after the + current environment is deactivated, and can be used to disable or + clear settings in your environment. The path to the environment just + deactivated is available in ``$VIRTUALENVWRAPPER_LAST_VIRTUALENV``. + +``$VIRTUAL_ENV/bin/postdeactivate`` スクリプトはカレントの仮想環境が非アクティブ化される前に読み込まれます。そして、あなたの環境の設定をクリアしたり、無効にするために使用されます。非アクティブ化される環境へのパスは ``$VIRTUALENVWRAPPER_LAST_VIRTUALENV`` でのみ有効です。 + +.. _scripts-prermvirtualenv: + +prermvirtualenv +=============== + + .. :Global/Local: global + :Argument(s): environment name + :Sourced/Run: run + + :グローバル/ローカル: グローバル + :引数: 環境名 + :読み込み/実行: 実行 + +.. + The ``$WORKON_HOME/prermvirtualenv`` script is run as an external + program before the environment is removed. The full path to the + environment directory is passed as an argument to the script. + +``$WORKON_HOME/prermvirtualenv`` スクリプトは仮想環境が削除される前に外部コマンドのように実行されます。そのスクリプトへの引数としてその環境のディレクトリに対するフルパスが渡されます。 + +.. _scripts-postrmvirtualenv: + +postrmvirtualenv +================ + + .. :Global/Local: global + :Argument(s): environment name + :Sourced/Run: run + + :グローバル/ローカル: グローバル + :引数: 環境名 + :読み込み/実行: 実行 + +.. + The ``$WORKON_HOME/postrmvirtualenv`` script is run as an external + program after the environment is removed. The full path to the + environment directory is passed as an argument to the script. + +``$WORKON_HOME/postrmvirtualenv`` スクリプトは仮想環境が削除された後で外部コマンドのように実行されます。そのスクリプトへの引数としてその環境のディレクトリに対するフルパスが渡されます。 diff --git a/docs/ja/tips.rst b/docs/ja/tips.rst new file mode 100644 index 0000000..5a66da6 --- /dev/null +++ b/docs/ja/tips.rst @@ -0,0 +1,261 @@ +.. + ================= + Tips and Tricks + ================= + +.. _tips-and-tricks: + +================= + Tips とトリック +================= + +.. + This is a list of user-contributed tips for making virtualenv and + virtualenvwrapper even more useful. If you have tip to share, drop me + an email or post a comment on `this blog post + `__ + and I'll add it here. + +これは virtualenv と virtualenvwrapper をさらに使い易くするためにユーザが教えてくれた tips です。あなたが共有したい tip を持っているなら、私にメールを送ってもらうか、 `このブログ `__ にコメントをください。私はこのページにその tip を追加します。 + +.. + zsh Prompt + ========== + +zsh プロンプト +============== + +.. + From `Nat `_: + +`Nat `_ からです。 + +.. + Using zsh, I added some bits to ``$WORKON_HOME/post(de)activate`` to show + the active virtualenv on the right side of my screen instead. + +zsh を使用して、アクティブな仮想環境をスクリーンの右側に表示するために ``$WORKON_HOME/post(de)activate`` に少し追加しました。 + +``postactivate`` は次になります。 + +:: + + PS1="$_OLD_VIRTUAL_PS1" + _OLD_RPROMPT="$RPROMPT" + RPROMPT="%{${fg_bold[white]}%}(env: %{${fg[green]}%}`basename \"$VIRTUAL_ENV\"`%{${fg_bold[white]}%})%{${reset_color}%} $RPROMPT" + +そして ``postdeactivate`` は次になります。 + +:: + + RPROMPT="$_OLD_RPROMPT" + +.. + Adjust colors according to your own personal tastes or environment. + +個人的な趣向や環境に応じて色を調整してください。 + +.. + Updating cached ``$PATH`` entries + ================================= + +キャッシュされた ``$PATH`` エントリを更新する +============================================= + +.. + From `Nat `_: + +`Nat `_ からです。 + +.. + I also added the command 'rehash' to ``$WORKON_HOME/postactivate`` and + ``$WORKON_HOME/postdeactivate`` as I was having some problems with zsh + not picking up the new paths immediately. + +さらに zsh は新たなパスをすぐに取得しない問題があったので ``$WORKON_HOME/postactivate`` と ``$WORKON_HOME/postdeactivate`` へコマンド 'rehash' も追加しました。 + +.. + Tying to pip's virtualenv support + ================================= + +pip の virtualenv サポート +========================== + +.. + Via http://becomingguru.com/: + +http://becomingguru.com/ からです。 + +.. + Add this to your shell login script to make pip use the same directory + for virtualenvs as virtualenvwrapper + +virtualenvwrapper として virtualenvs のために pip が同じディレクトリを使用するようにログインシェルに次の内容を追加してください。 + +:: + + export PIP_VIRTUALENV_BASE=$WORKON_HOME + +.. + and Via Nat: + +さらに Nat からです。 + +.. + in addition to what becomingguru said, this line is key + +becomingguru が指摘したことに加えて次の行がキーになります。 + +:: + + export PIP_RESPECT_VIRTUALENV=true + +.. + That makes pip detect an active virtualenv and install to it, without + having to pass it the -E parameter. + +それは -E パラメータを pip へ渡さずに pip がアクティブな仮想環境を検出してインストールします。 + +.. + Creating Project Work Directories + ================================= + +プロジェクトのワークディレクトリを作成する +========================================== + +`James `_ からです。 + +.. + In the ``postmkvirtualenv`` script I have the following to create a + directory based on the project name, add that directory to the python + path and then cd into it:: + +私は ``postmkvirtualenv`` スクリプトでプロジェクト名に基づいてディレクトリを作成して、 +Python パスへそのディレクトリを追加してからそこへ移動します。 + +:: + + proj_name=$(echo $VIRTUAL_ENV|awk -F'/' '{print $NF}') + mkdir $HOME/projects/$proj_name + add2virtualenv $HOME/projects/$proj_name + cd $HOME/projects/$proj_name + +.. + In the ``postactivate`` script I have it set to automatically change + to the project directory when I use the workon command:: + +私は ``postactivate`` スクリプトで workon コマンドを使用するときに自動的にプロジェクトディレクトリへ移動するようにセットします。 + +:: + + proj_name=$(echo $VIRTUAL_ENV|awk -F'/' '{print $NF}') + cd ~/projects/$proj_name + +.. + Automatically Run workon When Entering a Directory + ================================================== + +ディレクトリへ移動したときに自動的に workon を実行する +====================================================== + +.. + `Justin Lily posted + `__ + about some code he added to his shell environment to look at the + directory each time he runs ``cd``. If it finds a ``.venv`` file, it + activates the environment named within. On leaving that directory, + the current virtualenv is automatically deactivated. + +``cd`` を実行する毎にそのディレクトリでシェル環境を調べるように追加したコードを `Justin Lily が投稿しました `__ 。 ``.venv`` ファイルを見つけたら、そのファイルに含まれる環境の名前でアクティブ化します。そのディレクトリから移動すると、カレントの仮想環境は自動的に非アクティブ化します。 + +.. + `Harry Marr `__ + wrote a similar function that works with `git repositories + `__. + +`Harry Marr `__ は `git リポジトリ `__ で動作するよく似た機能を書きました。 + +.. + Installing Common Tools Automatically in New Environments + ========================================================= + +新しい環境に共通ツールを自動的にインストールする +================================================ + +.. + Via `rizumu `__: + +`rizumu `__ からです。 + +.. + I have this ``postmkvirtualenv`` to install the get a basic setup. + +私はこの ``postmkvirtualenv`` を基本的なセットアップを行うインストールに使用します。 + +:: + + $ cat postmkvirtualenv + #!/usr/bin/env bash + curl -O http://python-distribute.org/distribute_setup.p... />python distribute_setup.py + rm distribute_setup.py + easy_install pip==dev + pip install Mercurial + +.. + Then I have a pip requirement file with my dev tools. + +それから、私の開発ツールと共に pip の要求ファイルを持ちます。 + +:: + + $ cat developer_requirements.txt + ipdb + ipython + pastescript + nose + http://douglatornell.ca/software/python/Nosy-1.0.tar.gz + coverage + sphinx + grin + pyflakes + pep8 + +.. + Then each project has it's own pip requirement file for things like + PIL, psycopg2, django-apps, numpy, etc. + +それぞれのプロジェクトは PIL, psycopg2, django-apps, numpy といったその独自の pip 要求ファイルを持ちます。 + +.. + Changing the Default Behavior of ``cd`` + ======================================= + +``cd`` のデフォルトの振る舞いを変更する +======================================= + +.. + Via `mae `__: + +`mae `__ からです。 + +.. + This is supposed to be executed after workon, that is as a + ``postactivate`` hook. It basically overrides ``cd`` to know about the + VENV so instead of doing ``cd`` to go to ``~`` you will go to the venv + root, IMO very handy and I can't live without it anymore. if you pass + it a proper path then it will do the right thing. + +これは workon の後で実行することになる ``postactivate`` フックです。venv ルートへ移動する ``~`` へ ``cd`` で移動する代わりに VENV を知っているように ``cd`` を基本的に上書きします。IMO はとても扱い易くて、もうそれなしでは生きていけません。適切なパスが渡されると正常に移動します。 + +:: + + cd () { + if (( $# == 0 )) + then + builtin cd $VIRTUAL_ENV + else + builtin cd "$@" + fi + } + + cd From ad8176ebd3794cfd9103e3ef2fd6bc8d1fa96600 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 30 Dec 2010 10:32:30 -0500 Subject: [PATCH 345/947] add spelling extension --- docs/sphinx/conf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/sphinx/conf.py b/docs/sphinx/conf.py index 1bed798..20f0beb 100644 --- a/docs/sphinx/conf.py +++ b/docs/sphinx/conf.py @@ -24,7 +24,9 @@ # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = [ 'sphinxcontrib.bitbucket' ] +extensions = [ 'sphinxcontrib.bitbucket', + 'sphinxcontrib.spelling', + ] bitbucket_project_url = 'http://bitbucket.org/dhellmann/virtualenvwrapper/' From fe1639e94339e9453ba991c6c54a9eb7ba44e493 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 30 Dec 2010 10:43:02 -0500 Subject: [PATCH 346/947] update history --- docs/en/history.rst | 6 ++++++ docs/spelling_wordlist.txt | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 docs/spelling_wordlist.txt diff --git a/docs/en/history.rst b/docs/en/history.rst index e0f6e15..ad53e12 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,12 @@ Release History =============== +Dev + + - Merged in `Japanese translation of the documentation + `__ from + Tetsuya Morimoto. + 2.6.1 - Fixed virtualenvwrapper_get_python_version (:bbissue:`73`). diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt new file mode 100644 index 0000000..89ea196 --- /dev/null +++ b/docs/spelling_wordlist.txt @@ -0,0 +1,7 @@ +Hellmann +Bicking +virtualenvwrapper +mkvirtualenv +rmvirtualenv +virtualenv +stderr From 7f55596c490bf23656c156412d15daf5765dea3d Mon Sep 17 00:00:00 2001 From: t2y Date: Sat, 1 Jan 2011 14:00:18 +0900 Subject: [PATCH 347/947] merged a few fixes and updated history --- docs/ja/history.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/ja/history.rst b/docs/ja/history.rst index 0999577..ae50da7 100644 --- a/docs/ja/history.rst +++ b/docs/ja/history.rst @@ -7,6 +7,14 @@ リリース履歴 ============ +Dev + + .. - Merged in `Japanese translation of the documentation + `__ from + Tetsuya Morimoto. + + - Tetsuya Morimoto からの `日本語の翻訳ドキュメント `__ を取り込みました。 + 2.6.1 .. - Fixed virtualenvwrapper_get_python_version (:bbissue:`73`). From eeb7efe5578a4c8e7ec57156e4e024fe9eb82a0f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 24 Jan 2011 09:47:02 -0500 Subject: [PATCH 348/947] add a test to verify that when virtualenv fails to create an environment the hook scripts are not run. see #76 --- ChangeLog | 9 +++++++++ docs/en/history.rst | 3 +++ tests/test_mkvirtualenv.sh | 28 ++++++++++++++++++++++++++++ virtualenvwrapper.sh | 18 +++++++++++++----- 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 610c6ee..1180539 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-01-24 Doug Hellmann + + * virtualenvwrapper.sh: Replace hard-coded name "virtualenv" with + the variable VIRTUALENVWRAPPER_VIRTUALENV to allow tests (and + users) to override it. + + * tests/test_mkvirtualenv.sh (test_virtualenv_fails): Add a test + to reproduce the conditions reported in issue #76. + 2010-12-27 Doug Hellmann * virtualenvwrapper.sh (virtualenvwrapper_get_python_version): diff --git a/docs/en/history.rst b/docs/en/history.rst index ad53e12..151bd14 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -7,6 +7,9 @@ Dev - Merged in `Japanese translation of the documentation `__ from Tetsuya Morimoto. + - Incorporate a suggestion from Ales Zoulek to let the user specify + the virtualenv binary through an environment variable + (``VIRTUALENVWRAPPER_VIRTUALENV``). 2.6.1 diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index 1e7a783..01471d5 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -84,6 +84,34 @@ test_no_workon_home () { WORKON_HOME="$old_home" } +test_virtualenv_fails () { + # Test to reproduce the conditions in issue #76 + # https://bitbucket.org/dhellmann/virtualenvwrapper/issue/76/ + # + # Should not run the premkvirtualenv or postmkvirtualenv hooks + # because the environment is not created and even the + # premkvirtualenv hooks are run *after* the environment exists + # (but before it is activated). + export pre_test_dir=$(cd "$test_dir"; pwd) + + VIRTUALENVWRAPPER_VIRTUALENV=false + + echo "#!/bin/sh" > "$WORKON_HOME/premkvirtualenv" + echo "echo GLOBAL premkvirtualenv \`pwd\` \"\$@\" >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" + chmod +x "$WORKON_HOME/premkvirtualenv" + + echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" + mkvirtualenv "env3" + output=$(cat "$test_dir/catch_output" 2>/dev/null) + workon_home_as_pwd=$(cd $WORKON_HOME; pwd) + expected="" + assertSame "$expected" "$output" + rm -f "$WORKON_HOME/premkvirtualenv" + rm -f "$WORKON_HOME/postmkvirtualenv" + + VIRTUALENVWRAPPER_VIRTUALENV=virtualenv +} + # test_mkvirtualenv_sitepackages () { # # Without the option verify that site-packages are copied. # mkvirtualenv "env3" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 78a9d36..37376ee 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -50,6 +50,12 @@ then VIRTUALENVWRAPPER_PYTHON="$(\which python)" fi +# Set the name of the virtualenv app to use. +if [ "$VIRTUALENVWRAPPER_VIRTUALENV" = "" ] +then + VIRTUALENVWRAPPER_VIRTUALENV="virtualenv" +fi + virtualenvwrapper_derive_workon_home() { typeset workon_home_dir="$WORKON_HOME" @@ -149,15 +155,15 @@ virtualenvwrapper_initialize () { # Verify that virtualenv is installed and visible virtualenvwrapper_verify_virtualenv () { - typeset venv=$(\which virtualenv | (unset GREP_OPTIONS; \grep -v "not found")) + typeset venv=$(\which "$VIRTUALENVWRAPPER_VIRTUALENV" | (unset GREP_OPTIONS; \grep -v "not found")) if [ "$venv" = "" ] then - echo "ERROR: virtualenvwrapper could not find virtualenv in your path" >&2 + echo "ERROR: virtualenvwrapper could not find $VIRTUALENVWRAPPER_VIRTUALENV in your path" >&2 return 1 fi if [ ! -e "$venv" ] then - echo "ERROR: Found virtualenv in path as \"$venv\" but that does not exist" >&2 + echo "ERROR: Found $VIRTUALENVWRAPPER_VIRTUALENV in path as \"$venv\" but that does not exist" >&2 return 1 fi return 0 @@ -194,11 +200,13 @@ mkvirtualenv () { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_virtualenv || return 1 (cd "$WORKON_HOME" && - virtualenv "$@" && - [ -d "$WORKON_HOME/$envname" ] && virtualenvwrapper_run_hook "pre_mkvirtualenv" "$envname" + "$VIRTUALENVWRAPPER_VIRTUALENV" "$@" && + [ -d "$WORKON_HOME/$envname" ] && \ + virtualenvwrapper_run_hook "pre_mkvirtualenv" "$envname" ) typeset RC=$? [ $RC -ne 0 ] && return $RC + # If they passed a help option or got an error from virtualenv, # the environment won't exist. Use that to tell whether # we should switch to the environment and run the hook. From f160690516da780db526fc335b4f2427fcca7b82 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 6 Feb 2011 08:36:00 -0500 Subject: [PATCH 349/947] add test for space in WORKON_HOME to address #79 --- tests/test.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/test.sh b/tests/test.sh index 915fe79..be32e24 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -37,6 +37,18 @@ test_virtualenvwrapper_initialize() { assertSame "$expected" "$output" } +test_virtualenvwrapper_space_in_workon_home() { + before="$WORKON_HOME" + export WORKON_HOME="$WORKON_HOME/this has spaces" + expected="$WORKON_HOME" + mkdir -p "$expected" + virtualenvwrapper_initialize + RC=$? + assertSame "$expected" "$WORKON_HOME" + assertSame "0" "$RC" + export WORKON_HOME="$before" +} + test_virtualenvwrapper_verify_workon_home() { assertTrue "WORKON_HOME not verified" virtualenvwrapper_verify_workon_home } @@ -79,7 +91,7 @@ test_python_interpreter_set_incorrectly() { mkvirtualenv --no-site-packages no_wrappers expected="ImportError: No module named virtualenvwrapper.hook_loader" output=$(VIRTUALENVWRAPPER_PYTHON=$(which python) $SHELL $return_to/virtualenvwrapper.sh 2>&1) - echo "$output" | grep "$expected" 2>&1 + echo "$output" | grep -q "$expected" 2>&1 found=$? assertTrue "Expected \"$expected\", got: \"$output\"" "[ $found -eq 0 ]" assertFalse "Failed to detect invalid Python location" "VIRTUALENVWRAPPER_PYTHON=$VIRTUAL_ENV/bin/python $SHELL $return_to/virtualenvwrapper.sh >/dev/null 2>&1" From c110861d0cc15903c07efd47afc1b9cfb36383d4 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 26 Feb 2011 19:26:49 -0500 Subject: [PATCH 350/947] fix doc build for readthedocs.org --- ChangeLog | 14 ++++++++++++++ Makefile | 3 --- docs/sphinx/conf.py | 3 ++- setup.py | 4 +++- virtualenvwrapper/version.py | 9 +++++++++ 5 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 virtualenvwrapper/version.py diff --git a/ChangeLog b/ChangeLog index 1180539..3f2e207 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2011-02-26 Doug Hellmann + + * virtualenvwrapper/version.py: Put the version info inside the + package so it is available to the doc build and packaging + script. This also makes the readthedocs.org build work properly. + + * setup.py: Import the version information from the package. + + * docs/sphinx/conf.py: Import the version information from the + package. + + * Makefile: Remove rule to get the version from the installer for + the doc build. + 2011-01-24 Doug Hellmann * virtualenvwrapper.sh: Replace hard-coded name "virtualenv" with diff --git a/Makefile b/Makefile index 3542a99..30e9a90 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,3 @@ -# Get the version of the app. This is used in the doc build. -export VERSION=$(shell python setup.py --version) - # Default target is to show help help: @echo "sdist - Source distribution" diff --git a/docs/sphinx/conf.py b/docs/sphinx/conf.py index 1bed798..f273451 100644 --- a/docs/sphinx/conf.py +++ b/docs/sphinx/conf.py @@ -52,7 +52,8 @@ # built documents. # # The short X.Y version. -version = os.environ['VERSION'] +import virtualenvwrapper.version +version = virtualenvwrapper.version.VERSION # The full version, including alpha/beta/rc tags. release = version diff --git a/setup.py b/setup.py index 92d6dc8..b8e93cc 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,9 @@ #!/usr/bin/env python +import virtualenvwrapper.version + PROJECT = 'virtualenvwrapper' -VERSION = '2.6.1' +VERSION = virtualenvwrapper.version.VERSION # Bootstrap installation of Distribute import distribute_setup diff --git a/virtualenvwrapper/version.py b/virtualenvwrapper/version.py new file mode 100644 index 0000000..49a0417 --- /dev/null +++ b/virtualenvwrapper/version.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python +# encoding: utf-8 +# +# Copyright (c) 2011 Doug Hellmann. All rights reserved. +# +"""Version info for virtualenvwrapper base system. +""" + +VERSION = '2.6.2' From cef16dfaadbd9400239489bb8a78cf8db4a7265c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 26 Feb 2011 19:27:01 -0500 Subject: [PATCH 351/947] Added tag 2.6.2 for changeset 625d85d3136f --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 9553b91..c2b22ab 100644 --- a/.hgtags +++ b/.hgtags @@ -66,3 +66,4 @@ f71ffbb996c41606aea15b2114120d9fca3adfc6 2.5.2 dc74f106d8d2dd58031b2dbac31b1e068f780de4 2.5.3 b0f27c65fa64627599c2a022a076ae5ee7157ae4 2.6 445a58d5a05a1426cefb47e54b692b6a58fdcc4f 2.6.1 +625d85d3136ff746accc490c5f9210b1b0074533 2.6.2 From b1ca52e79eb9dff61bfb8be8fc83285a1e6d1765 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 26 Feb 2011 19:33:15 -0500 Subject: [PATCH 352/947] add upload target --- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 30e9a90..7da20e0 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ help: @echo "sdist - Source distribution" @echo "html - HTML documentation" @echo "docclean - Remove documentation build files" - @echo "register - register a new release on PyPI" + @echo "upload - upload a new release to PyPI" @echo "website - build web version of docs" @echo "installwebsite - deploy web version of docs" @echo "develop - install development version" @@ -46,8 +46,14 @@ installwebsite: website # Register the new version on pypi .PHONY: register register: + echo "USE upload target" + exit 1 python setup.py register +.PHONY: upload +upload: + python setup.py sdist upload + # Testing test: tox From 71331818de07a75bf549251ec7808fae089ba436 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 26 Feb 2011 19:52:15 -0500 Subject: [PATCH 353/947] more doc build changes --- ChangeLog | 4 + Makefile | 11 +- docs/en/history.rst | 8 +- docs/sphinx/conf.py | 15 +-- docs/sphinx/web/templates/base.html | 155 -------------------------- docs/sphinx/web/templates/layout.html | 118 -------------------- setup.py | 6 +- virtualenvwrapper/version.py | 9 -- 8 files changed, 23 insertions(+), 303 deletions(-) delete mode 100644 docs/sphinx/web/templates/base.html delete mode 100755 docs/sphinx/web/templates/layout.html delete mode 100644 virtualenvwrapper/version.py diff --git a/ChangeLog b/ChangeLog index 3f2e207..c9c23df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2011-02-26 Doug Hellmann + * docs/sphinx/conf.py: Just hard-code the version. + + * setup.py: Just hard-code the version. + * virtualenvwrapper/version.py: Put the version info inside the package so it is available to the doc build and packaging script. This also makes the readthedocs.org build work properly. diff --git a/Makefile b/Makefile index 7da20e0..1ba267c 100644 --- a/Makefile +++ b/Makefile @@ -4,12 +4,11 @@ help: @echo "html - HTML documentation" @echo "docclean - Remove documentation build files" @echo "upload - upload a new release to PyPI" - @echo "website - build web version of docs" - @echo "installwebsite - deploy web version of docs" @echo "develop - install development version" @echo "test - run the test suite" @echo "test-quick - run the test suite for bash and one version of Python ($(PYTHON26))" - + @echo "website - generate web version of the docs" + @echo "installwebsite - copy web version of HTML docs up to server" .PHONY: sdist sdist: html @@ -34,9 +33,9 @@ docclean: website: [ ~/Devel/doughellmann/doughellmann/templates/base.html -nt docs/sphinx/web/templates/base.html ] && (echo "Updating base.html" ; cp ~/Devel/doughellmann/doughellmann/templates/base.html docs/sphinx/web/templates/base.html) || exit 0 rm -rf docs/website - (cd docs && $(MAKE) html BUILDING_WEB=1 BUILDDIR="website/en" LANGUAGE="en") - (cd docs && $(MAKE) html BUILDING_WEB=1 BUILDDIR="website/es" LANGUAGE="es") - (cd docs && $(MAKE) html BUILDING_WEB=1 BUILDDIR="website/ja" LANGUAGE="ja") + (cd docs && $(MAKE) html BUILDDIR="website/en" LANGUAGE="en") + (cd docs && $(MAKE) html BUILDDIR="website/es" LANGUAGE="es") + (cd docs && $(MAKE) html BUILDDIR="website/ja" LANGUAGE="ja") installwebsite: website (cd docs/website/en && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper/) diff --git a/docs/en/history.rst b/docs/en/history.rst index 151bd14..27fad3d 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,8 +2,14 @@ Release History =============== -Dev +2.6.3 + - Hard-code the version information in the setup.py and conf.py + scripts so it works for http://readthedocs.org. + +2.6.2 + + - Attempted to make the doc build work with http://readthedocs.org. - Merged in `Japanese translation of the documentation `__ from Tetsuya Morimoto. diff --git a/docs/sphinx/conf.py b/docs/sphinx/conf.py index f273451..4d6de5d 100644 --- a/docs/sphinx/conf.py +++ b/docs/sphinx/conf.py @@ -29,10 +29,7 @@ bitbucket_project_url = 'http://bitbucket.org/dhellmann/virtualenvwrapper/' # Add any paths that contain templates here, relative to this directory. -if building_web: - templates_path = ['web/templates'] -else: - templates_path = ['pkg/templates'] +#templates_path = ['pkg/templates'] # The suffix of source filenames. source_suffix = '.rst' @@ -45,15 +42,14 @@ # General information about the project. project = u'virtualenvwrapper' -copyright = u'2009, Doug Hellmann' +copyright = u'2009-2011, Doug Hellmann' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -import virtualenvwrapper.version -version = virtualenvwrapper.version.VERSION +version = '2.6.3' # The full version, including alpha/beta/rc tags. release = version @@ -99,10 +95,7 @@ # The theme to use for HTML and HTML Help pages. Major themes that come with # Sphinx are currently 'default' and 'sphinxdoc'. -if building_web: - html_theme = 'default' -else: - html_theme = 'sphinxdoc' +html_theme = 'nature' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the diff --git a/docs/sphinx/web/templates/base.html b/docs/sphinx/web/templates/base.html deleted file mode 100644 index 3f590e9..0000000 --- a/docs/sphinx/web/templates/base.html +++ /dev/null @@ -1,155 +0,0 @@ - - - - - {% block title %}Doug Hellmann{% endblock %} -{% block head_before_css %} -{% endblock %} - -{% block head_after_css %} -{% endblock %} -{% block head %} -{% endblock %} - - - - -
- - - - - - - -
-{% block content %} -{% block relbar1 %}{% endblock %} - -

Welcome to Leaves.

-

Welcome to Leaves, a static, 3 column layout made with your usual CSS and XHTML. It is able to correctly accommodate any font size increases or shrinkages (Is that a word?). It seems to work fine in Firefox, Opera, Internet Explorer and Safari. It's more minimal than other designs, because I think images (drop shadows, giant header images) are being obsessively over used these days. I think it detracts from the content and shoves way too much information to a viewer all at the same time, so here you go: Leaves, a minimalist design. Feel free to massacre or change the design to your liking. Well, I guess it's time for some more Latin. If you want me to create a custom design for you, feel free to drop me a line anytime at web@smallpark.org

- -{% block relbar2 %}{% endblock %} -{% endblock %} - -{% block addthis %} -
Bookmark and Share
-{% endblock %} - -{% block comments %} - - -{% endblock %} -
- - - - - -
- - - - - - - diff --git a/docs/sphinx/web/templates/layout.html b/docs/sphinx/web/templates/layout.html deleted file mode 100755 index 7118594..0000000 --- a/docs/sphinx/web/templates/layout.html +++ /dev/null @@ -1,118 +0,0 @@ -{% extends "base.html" %} - -{% block title %}{{ title }} - {{ project }}{% endblock %} - -{% block head_before_css %} - - -{% endblock %} - -{% block head %} - - - - - -{%- block rellinks %} - {%- if hasdoc('about') %} - - {%- endif %} - - - {%- if hasdoc('copyright') %} - - {%- endif %} - - {%- if parents %} - - {%- endif %} - {%- if next %} - - {%- endif %} - {%- if prev %} - - {%- endif %} -{%- endblock %} -{% endblock %} - -{% block sidebar %} -{%- block sidebartoc %} -{%- if display_toc %} -

Page Contents

- {{ toc }} -{%- endif %} -{%- endblock %} - -

Navigation

- Top
-{% if next or prev %} - {%- if prev %} - Previous: {{ prev.title }}
- {%- endif %} - - {%- if next %} - Next: {{ next.title }}
- {%- endif %} -{% endif %} - {{project}} Home
- - {%- if show_source and has_source and sourcename %} -

{{ _('This Page') }}

- {{ _('Show Source') }} - - {%- endif %} - -

- Creative Commons License -

-{% endblock %} - -{% block sidebar_l %} -{% endblock %} - -{% block content %} -{% block body %}{% endblock %} -{% endblock %} - -{% block footer %} -

- {%- if hasdoc('copyright') %} - © Copyright {{ copyright }}. - {%- else %} - © Copyright {{ copyright }}. - {%- endif %} - {%- if last_updated %} - | Last updated on {{ last_updated }}. - {%- endif %} - {%- if show_sphinx %} - | Created using Sphinx. - {%- endif %} - | Design based on "Leaves" by SmallPark -

- - -{% endblock %} diff --git a/setup.py b/setup.py index b8e93cc..ec570e7 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,9 @@ #!/usr/bin/env python -import virtualenvwrapper.version - PROJECT = 'virtualenvwrapper' -VERSION = virtualenvwrapper.version.VERSION + +# Change docs/sphinx/conf.py too! +VERSION = '2.6.3' # Bootstrap installation of Distribute import distribute_setup diff --git a/virtualenvwrapper/version.py b/virtualenvwrapper/version.py deleted file mode 100644 index 49a0417..0000000 --- a/virtualenvwrapper/version.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python -# encoding: utf-8 -# -# Copyright (c) 2011 Doug Hellmann. All rights reserved. -# -"""Version info for virtualenvwrapper base system. -""" - -VERSION = '2.6.2' From ef8690591b683d012ed57ba6d7b72990977905e0 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 26 Feb 2011 19:52:18 -0500 Subject: [PATCH 354/947] Added tag 2.6.3 for changeset e7582879df06 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index c2b22ab..97ad1fc 100644 --- a/.hgtags +++ b/.hgtags @@ -67,3 +67,4 @@ dc74f106d8d2dd58031b2dbac31b1e068f780de4 2.5.3 b0f27c65fa64627599c2a022a076ae5ee7157ae4 2.6 445a58d5a05a1426cefb47e54b692b6a58fdcc4f 2.6.1 625d85d3136ff746accc490c5f9210b1b0074533 2.6.2 +e7582879df06689ec54cd820c377e89114b75ee2 2.6.3 From 029c3278ab24b2a05f2fb4cc75086b139c68a113 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 26 Feb 2011 19:55:18 -0500 Subject: [PATCH 355/947] tweak history --- docs/en/history.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 27fad3d..aaa1871 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -5,7 +5,9 @@ Release History 2.6.3 - Hard-code the version information in the setup.py and conf.py - scripts so it works for http://readthedocs.org. + scripts. This still doesn't work for http://readthedocs.org, since + the doc build needs the sphinxcontrib.bitbucket extension, but + will make it easier to transition the docs to another site later. 2.6.2 From bf6946b38b9d3f4ceae2a723db80a0ddf166620c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 26 Feb 2011 19:55:27 -0500 Subject: [PATCH 356/947] Added tag 2.6.3 for changeset 246ce68795ea --- .hgtags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.hgtags b/.hgtags index 97ad1fc..9590faf 100644 --- a/.hgtags +++ b/.hgtags @@ -68,3 +68,5 @@ b0f27c65fa64627599c2a022a076ae5ee7157ae4 2.6 445a58d5a05a1426cefb47e54b692b6a58fdcc4f 2.6.1 625d85d3136ff746accc490c5f9210b1b0074533 2.6.2 e7582879df06689ec54cd820c377e89114b75ee2 2.6.3 +e7582879df06689ec54cd820c377e89114b75ee2 2.6.3 +246ce68795ea9caeb88ec2fa17e4f3151c58cf3f 2.6.3 From cd0bb77492eebbed68eb19570085b601649cd420 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 27 Feb 2011 09:24:38 -0500 Subject: [PATCH 357/947] fixes issue 79 by enclosing WORKON_HOME in quotes --- docs/en/history.rst | 4 ++++ virtualenvwrapper.sh | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index aaa1871..dfd3de5 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,10 @@ Release History =============== +dev + + - Fix problem with space in WORKON_HOME path (:bbissue:`79`). + 2.6.3 - Hard-code the version information in the setup.py and conf.py diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 37376ee..fc9351f 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -143,7 +143,7 @@ virtualenvwrapper_run_hook () { # Set up virtualenvwrapper properly virtualenvwrapper_initialize () { - export WORKON_HOME=$(virtualenvwrapper_derive_workon_home) + export WORKON_HOME="$(virtualenvwrapper_derive_workon_home)" virtualenvwrapper_verify_workon_home -q || return 1 virtualenvwrapper_run_hook "initialize" if [ $? -ne 0 ] From 3edf55b0dab4bdd7db8c579bdb0119f53786bf5a Mon Sep 17 00:00:00 2001 From: t2y Date: Mon, 28 Feb 2011 00:07:28 +0900 Subject: [PATCH 358/947] translated 2.6.2/2.6.3 history into Japanese --- docs/ja/history.rst | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/docs/ja/history.rst b/docs/ja/history.rst index ae50da7..606917d 100644 --- a/docs/ja/history.rst +++ b/docs/ja/history.rst @@ -7,13 +7,26 @@ リリース履歴 ============ -Dev +2.6.3 - .. - Merged in `Japanese translation of the documentation - `__ from - Tetsuya Morimoto. + .. - Hard-code the version information in the setup.py and conf.py + scripts so it works for http://readthedocs.org. + - http://readthedocs.org でドキュメントを生成するために setup.py や conf.py スクリプトのバージョン情報をハードコードしました。 + +2.6.2 + + .. - Attempted to make the doc build work with http://readthedocs.org. + - Merged in `Japanese translation of the documentation + `__ from + Tetsuya Morimoto. + - Incorporate a suggestion from Ales Zoulek to let the user specify + the virtualenv binary through an environment variable + (``VIRTUALENVWRAPPER_VIRTUALENV``). + + - http://readthedocs.org でドキュメントを生成してみました。 - Tetsuya Morimoto からの `日本語の翻訳ドキュメント `__ を取り込みました。 + - 環境変数(``VIRTUALENVWRAPPER_VIRTUALENV``)で virtualenv バイナリをユーザが指定できるように Ales Zoulek からの提案を取り入れました。 2.6.1 From cc5dbccb54c63d0a3259868f1d60d07a269fca26 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 28 Feb 2011 17:00:19 -0500 Subject: [PATCH 359/947] remove the download url since I upload packages to pypi now --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index ec570e7..c38cb54 100644 --- a/setup.py +++ b/setup.py @@ -122,8 +122,8 @@ def find_package_data( author_email = 'doug.hellmann@gmail.com', url = 'http://www.doughellmann.com/projects/%s/' % PROJECT, - download_url = 'http://www.doughellmann.com/downloads/%s-%s.tar.gz' % \ - (PROJECT, VERSION), + #download_url = 'http://www.doughellmann.com/downloads/%s-%s.tar.gz' % \ + # (PROJECT, VERSION), classifiers = [ 'Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: BSD License', From 6206c035902b50c8d4c8041bf0e46112dda34b50 Mon Sep 17 00:00:00 2001 From: Nat Williams Date: Mon, 28 Feb 2011 16:51:41 -0600 Subject: [PATCH 360/947] fix lsvirtualenv to read args in zsh --- virtualenvwrapper.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index fc9351f..d27df64 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -259,7 +259,8 @@ _lsvirtualenv_usage () { # # Usage: lsvirtualenv [-l] lsvirtualenv () { - typeset args="$(getopt blh "$@")" + typeset -a args + args=($(getopt blh "$@")) if [ $? != 0 ] then _lsvirtualenv_usage From eafcb10263489130fd480ba3a461046f6b6de990 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 5 Mar 2011 17:06:10 -0500 Subject: [PATCH 361/947] ignore .orig files created by hg --- .hgignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgignore b/.hgignore index 2f9aff6..61dc40e 100644 --- a/.hgignore +++ b/.hgignore @@ -16,6 +16,7 @@ trace.txt virtualenvwrapper.egg-info virtualenvwrapper/docs .tox +*.orig syntax: re .DS_Store From 5bd7338db8c994baf04300b87c20b9292dbd86c1 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 5 Mar 2011 17:14:42 -0500 Subject: [PATCH 362/947] trying readthedocs again --- docs/en/history.rst | 3 ++ docs/sphinx/conf.py | 89 +++++++++++++++++++++++++++++++++++- docs/sphinx/requirements.txt | 1 + 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 docs/sphinx/requirements.txt diff --git a/docs/en/history.rst b/docs/en/history.rst index dfd3de5..3f1bd66 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -5,6 +5,9 @@ Release History dev - Fix problem with space in WORKON_HOME path (:bbissue:`79`). + - Add bitbucket directives to the local sphinx config file to avoid + the extra build dependency and to try the doc build on readthedocs, + again. 2.6.3 diff --git a/docs/sphinx/conf.py b/docs/sphinx/conf.py index 4d6de5d..befd9ac 100644 --- a/docs/sphinx/conf.py +++ b/docs/sphinx/conf.py @@ -24,7 +24,7 @@ # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = [ 'sphinxcontrib.bitbucket' ] +extensions = [ ] bitbucket_project_url = 'http://bitbucket.org/dhellmann/virtualenvwrapper/' @@ -196,3 +196,90 @@ # If false, no module index is generated. #latex_use_modindex = True + +from docutils import nodes, utils +from docutils.parsers.rst.roles import set_classes + +def make_link_node(rawtext, app, type, slug, options): + """Create a link to a BitBucket resource. + + :param rawtext: Text being replaced with link node. + :param app: Sphinx application context + :param type: Link type (issue, changeset, etc.) + :param slug: ID of the thing to link to + :param options: Options dictionary passed to role func. + """ + # + try: + base = app.config.bitbucket_project_url + if not base: + raise AttributeError + except AttributeError, err: + raise ValueError('bitbucket_project_url configuration value is not set (%s)' % str(err)) + # + slash = '/' if base[-1] != '/' else '' + ref = base + slash + type + '/' + slug + '/' + set_classes(options) + node = nodes.reference(rawtext, type + ' ' + utils.unescape(slug), refuri=ref, + **options) + return node + + +def bbissue_role(name, rawtext, text, lineno, inliner, options={}, content=[]): + """Link to a BitBucket issue. + + Returns 2 part tuple containing list of nodes to insert into the + document and a list of system messages. Both are allowed to be + empty. + + :param name: The role name used in the document. + :param rawtext: The entire markup snippet, with role. + :param text: The text marked with the role. + :param lineno: The line number where rawtext appears in the input. + :param inliner: The inliner instance that called us. + :param options: Directive options for customization. + :param content: The directive content for customization. + """ + try: + issue_num = int(text) + if issue_num <= 0: + raise ValueError + except ValueError: + msg = inliner.reporter.error( + 'BitBucket issue number must be a number greater than or equal to 1; ' + '"%s" is invalid.' % text, line=lineno) + prb = inliner.problematic(rawtext, rawtext, msg) + return [prb], [msg] + app = inliner.document.settings.env.app + node = make_link_node(rawtext, app, 'issue', str(issue_num), options) + return [node], [] + +def bbchangeset_role(name, rawtext, text, lineno, inliner, options={}, content=[]): + """Link to a BitBucket changeset. + + Returns 2 part tuple containing list of nodes to insert into the + document and a list of system messages. Both are allowed to be + empty. + + :param name: The role name used in the document. + :param rawtext: The entire markup snippet, with role. + :param text: The text marked with the role. + :param lineno: The line number where rawtext appears in the input. + :param inliner: The inliner instance that called us. + :param options: Directive options for customization. + :param content: The directive content for customization. + """ + app = inliner.document.settings.env.app + node = make_link_node(rawtext, app, 'changeset', text, options) + return [node], [] + + +def setup(app): + """Install the plugin. + + :param app: Sphinx application context. + """ + app.add_role('bbissue', bbissue_role) + app.add_role('bbchangeset', bbchangeset_role) + app.add_config_value('bitbucket_project_url', None, 'env') + return diff --git a/docs/sphinx/requirements.txt b/docs/sphinx/requirements.txt new file mode 100644 index 0000000..a35bfac --- /dev/null +++ b/docs/sphinx/requirements.txt @@ -0,0 +1 @@ +sphinxcontrib-bitbucket From 41f36628d9ab5c22504fbc733c342a7b05916c7a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 5 Mar 2011 17:26:45 -0500 Subject: [PATCH 363/947] remove the custom functions from the sphinx config, since rtd does not support them --- docs/en/history.rst | 3 -- docs/sphinx/conf.py | 91 +-------------------------------------------- 2 files changed, 1 insertion(+), 93 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 3f1bd66..dfd3de5 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -5,9 +5,6 @@ Release History dev - Fix problem with space in WORKON_HOME path (:bbissue:`79`). - - Add bitbucket directives to the local sphinx config file to avoid - the extra build dependency and to try the doc build on readthedocs, - again. 2.6.3 diff --git a/docs/sphinx/conf.py b/docs/sphinx/conf.py index befd9ac..40c4859 100644 --- a/docs/sphinx/conf.py +++ b/docs/sphinx/conf.py @@ -13,8 +13,6 @@ import sys, os -building_web = int(os.environ.get('BUILDING_WEB', '0')) - # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. @@ -24,7 +22,7 @@ # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = [ ] +extensions = [ 'sphinxcontrib.bitbucket' ] bitbucket_project_url = 'http://bitbucket.org/dhellmann/virtualenvwrapper/' @@ -196,90 +194,3 @@ # If false, no module index is generated. #latex_use_modindex = True - -from docutils import nodes, utils -from docutils.parsers.rst.roles import set_classes - -def make_link_node(rawtext, app, type, slug, options): - """Create a link to a BitBucket resource. - - :param rawtext: Text being replaced with link node. - :param app: Sphinx application context - :param type: Link type (issue, changeset, etc.) - :param slug: ID of the thing to link to - :param options: Options dictionary passed to role func. - """ - # - try: - base = app.config.bitbucket_project_url - if not base: - raise AttributeError - except AttributeError, err: - raise ValueError('bitbucket_project_url configuration value is not set (%s)' % str(err)) - # - slash = '/' if base[-1] != '/' else '' - ref = base + slash + type + '/' + slug + '/' - set_classes(options) - node = nodes.reference(rawtext, type + ' ' + utils.unescape(slug), refuri=ref, - **options) - return node - - -def bbissue_role(name, rawtext, text, lineno, inliner, options={}, content=[]): - """Link to a BitBucket issue. - - Returns 2 part tuple containing list of nodes to insert into the - document and a list of system messages. Both are allowed to be - empty. - - :param name: The role name used in the document. - :param rawtext: The entire markup snippet, with role. - :param text: The text marked with the role. - :param lineno: The line number where rawtext appears in the input. - :param inliner: The inliner instance that called us. - :param options: Directive options for customization. - :param content: The directive content for customization. - """ - try: - issue_num = int(text) - if issue_num <= 0: - raise ValueError - except ValueError: - msg = inliner.reporter.error( - 'BitBucket issue number must be a number greater than or equal to 1; ' - '"%s" is invalid.' % text, line=lineno) - prb = inliner.problematic(rawtext, rawtext, msg) - return [prb], [msg] - app = inliner.document.settings.env.app - node = make_link_node(rawtext, app, 'issue', str(issue_num), options) - return [node], [] - -def bbchangeset_role(name, rawtext, text, lineno, inliner, options={}, content=[]): - """Link to a BitBucket changeset. - - Returns 2 part tuple containing list of nodes to insert into the - document and a list of system messages. Both are allowed to be - empty. - - :param name: The role name used in the document. - :param rawtext: The entire markup snippet, with role. - :param text: The text marked with the role. - :param lineno: The line number where rawtext appears in the input. - :param inliner: The inliner instance that called us. - :param options: Directive options for customization. - :param content: The directive content for customization. - """ - app = inliner.document.settings.env.app - node = make_link_node(rawtext, app, 'changeset', text, options) - return [node], [] - - -def setup(app): - """Install the plugin. - - :param app: Sphinx application context. - """ - app.add_role('bbissue', bbissue_role) - app.add_role('bbchangeset', bbchangeset_role) - app.add_config_value('bitbucket_project_url', None, 'env') - return From 7a4a540e9bc5fc33588c44dfad22eb61393665f4 Mon Sep 17 00:00:00 2001 From: Paul McLanahan Date: Wed, 6 Apr 2011 11:17:05 -0400 Subject: [PATCH 364/947] Modified the test runner to reliably use the intended shells. --- tests/run_tests | 40 ++++++++++++++++++++++------------------ tox.ini | 7 ++----- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/tests/run_tests b/tests/run_tests index 4e0d1e4..6b6126b 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -30,27 +30,31 @@ export HOOK_VERBOSE_OPTION=-vvv # tox-created virtualenv. export VIRTUALENVWRAPPER_PYTHON="$envdir/bin/python" -if [ -n "${ZSH_VERSION:-}" ] -then - export SHELL=$(which zsh) -fi - # Run the test scripts with a little formatting around them to make it # easier to find where each script output starts. -for test_script in $scripts +for test_shell in bash ksh zsh do - echo - echo '********************************************************************************' - echo "Running $test_script" - echo " VIRTUAL_ENV=$VIRTUAL_ENV" - echo " VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON" - echo " $($VIRTUALENVWRAPPER_PYTHON -V 2>&1)" - echo " PYTHONPATH=$PYTHONPATH" - echo " SHELL=$SHELL" - echo - export SHUNIT_PARENT="$test_script" - $test_script || exit 1 - echo + test_shell_opts= + if [ $test_shell = "zsh" ]; then + test_shell_opts="-o shwordsplit" + fi + test_shell=$(which $test_shell) + + for test_script in $scripts + do + echo + echo '********************************************************************************' + echo "Running $test_script" + echo " VIRTUAL_ENV=$VIRTUAL_ENV" + echo " VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON" + echo " $($VIRTUALENVWRAPPER_PYTHON -V 2>&1)" + echo " PYTHONPATH=$PYTHONPATH" + echo " SHELL=$test_shell" + echo + export SHUNIT_PARENT="$test_script" + $test_shell $test_shell_opts $test_script || exit 1 + echo + done done exit 0 diff --git a/tox.ini b/tox.ini index 6a95ce1..3326c3c 100644 --- a/tox.ini +++ b/tox.ini @@ -2,13 +2,10 @@ envlist = py27,py26,py25,py24 [testenv] -commands = - zsh -o shwordsplit ./tests/run_tests {envdir} [] - ksh ./tests/run_tests {envdir} [] - bash ./tests/run_tests {envdir} [] +commands = bash ./tests/run_tests {envdir} [] # Not sure why this is needed, but on my system if it isn't included then # the python version picked up for 2.6 is actually 2.7. # IF THIS CAUSES YOU A PROBLEM COMMENT IT OUT BEFORE RUNNING THE TESTS. [testenv:py26] -basepython=/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 \ No newline at end of file +basepython=/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 From 0359a7c680aba5bed89a95431c6f5ede3735e9bd Mon Sep 17 00:00:00 2001 From: Paul McLanahan Date: Wed, 6 Apr 2011 13:56:17 -0400 Subject: [PATCH 365/947] Added "toggleglobalsitepackages" command. Added tests for the new command. --- tests/test_toggleglobalsitepackages.sh | 47 ++++++++++++++++++++++++++ virtualenvwrapper.sh | 15 ++++++++ 2 files changed, 62 insertions(+) create mode 100755 tests/test_toggleglobalsitepackages.sh mode change 100644 => 100755 virtualenvwrapper.sh diff --git a/tests/test_toggleglobalsitepackages.sh b/tests/test_toggleglobalsitepackages.sh new file mode 100755 index 0000000..3eb5e79 --- /dev/null +++ b/tests/test_toggleglobalsitepackages.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +#set -x + +test_dir=$(cd $(dirname $0) && pwd) + +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" + mkvirtualenv --no-site-packages "globaltest" +} + +tearDown () { + deactivate + rmvirtualenv "globaltest" +} + +test_toggleglobalsitepackages () { + ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" + assertTrue "$ngsp_file does not exist" "[ -f "$ngsp_file" ]" + toggleglobalsitepackages -q + assertFalse "$ngsp_file exists" "[ -f "$ngsp_file" ]" + toggleglobalsitepackages -q + assertTrue "$ngsp_file does not exist" "[ -f "$ngsp_file" ]" +} + +test_toggleglobalsitepackages_quiet () { + assertEquals "Command output is not correct" "Enabled global site-packages" "`toggleglobalsitepackages`" + assertEquals "Command output is not correct" "Disabled global site-packages" "`toggleglobalsitepackages`" + + assertEquals "Command output is not correct" "" "`toggleglobalsitepackages -q`" + assertEquals "Command output is not correct" "" "`toggleglobalsitepackages -q`" +} + +. "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh old mode 100644 new mode 100755 index d27df64..4db4c62 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -508,6 +508,21 @@ lssitepackages () { fi } +# Toggles the currently-active virtualenv between having and not having +# access to the global site-packages. +toggleglobalsitepackages () { + virtualenvwrapper_verify_workon_home || return 1 + virtualenvwrapper_verify_active_environment || return 1 + typeset no_global_site_packages_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" + if [ -f $no_global_site_packages_file ]; then + rm $no_global_site_packages_file + [ "$1" = "-q" ] || echo "Enabled global site-packages" + else + touch $no_global_site_packages_file + [ "$1" = "-q" ] || echo "Disabled global site-packages" + fi +} + # Duplicate the named virtualenv to make a new one. cpvirtualenv() { typeset env_name="$1" From 5507739dc4bce94aed6c0a592d9711216879c52e Mon Sep 17 00:00:00 2001 From: Paul McLanahan Date: Wed, 6 Apr 2011 14:19:07 -0400 Subject: [PATCH 366/947] Added docs for the toggleglobalsitepackages command --- docs/en/command_ref.rst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/en/command_ref.rst b/docs/en/command_ref.rst index 369aa60..b1e6196 100644 --- a/docs/en/command_ref.rst +++ b/docs/en/command_ref.rst @@ -364,3 +364,31 @@ The directory names are added to a path file named for the environment. *Based on a contribution from James Bennett and Jannis Leidel.* + +toggleglobalsitepackages +------------------------ + +Toggles the state of the currently active virtualenv's access to the packages +in the global python ``site-packages`` directory. + +Syntax:: + + toggleglobalsitepackages [-q] + +Outputs the new state of the virtualenv. Use the ``-q`` switch to turn off all +output. + +:: + + $ mkvirtualenv env1 + New python executable in env1/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (env1)$ toggleglobalsitepackages + Disabled global site-packages + (env1)$ toggleglobalsitepackages + Enabled global site-packages + (env1)$ toggleglobalsitepackages -q + (env1)$ From b2314d27ef43c9e8dc660d161286a2aebd4bb30a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 10 Apr 2011 09:29:53 -0400 Subject: [PATCH 367/947] change verbosity level when creating hook scripts so the messages can be suppressed in tests --- ChangeLog | 6 ++++++ virtualenvwrapper/user_scripts.py | 6 +----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index c9c23df..38fa9e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-04-10 Doug Hellmann + + * virtualenvwrapper/user_scripts.py (make_hook): Change verbosity + of message telling the user we have created a new hook script for + them. + 2011-02-26 Doug Hellmann * docs/sphinx/conf.py: Just hard-code the version. diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 7cbe6c6..c83c251 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -20,10 +20,6 @@ def run_script(script_path, *args): """Execute a script in a subshell. """ if os.path.exists(script_path): -# with open(script_path, 'rt') as f: -# print '+' * 80 -# print f.read() -# print '+' * 80 cmd = [script_path] + list(args) log.debug('running %s', str(cmd)) try: @@ -107,7 +103,7 @@ def make_hook(filename, comment): """ filename = os.path.expanduser(os.path.expandvars(filename)) if not os.path.exists(filename): - log.warning('creating %s', filename) + log.info('creating %s', filename) f = open(filename, 'w') try: f.write("""#!%(shell)s From 8cc975982bb85f46c343b1b539d7c9d9d1fcef00 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 10 Apr 2011 09:30:27 -0400 Subject: [PATCH 368/947] suppress hook loader messages in tests --- tests/run_tests | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/run_tests b/tests/run_tests index 4e0d1e4..736f385 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -24,7 +24,8 @@ fi source "$envdir/bin/activate" # Set up virtualenvwrapper.hook_loader to print more details than usual for debugging. -export HOOK_VERBOSE_OPTION=-vvv +#export HOOK_VERBOSE_OPTION=-vvv +export HOOK_VERBOSE_OPTION="-q" # Force virtualenvwrapper to use the python interpreter in the # tox-created virtualenv. From 141de5e0caf5dcac17cb1c99029d17b4fc967fa3 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 10 Apr 2011 09:31:03 -0400 Subject: [PATCH 369/947] fix tests for changes to virtualenvwrapper_verify_workon_home --- tests/test.sh | 14 ++++---------- tests/test_cd.sh | 10 ++++++---- tests/test_cp.sh | 2 +- virtualenvwrapper.sh | 4 ++-- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index be32e24..9684776 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -56,7 +56,9 @@ test_virtualenvwrapper_verify_workon_home() { test_virtualenvwrapper_verify_workon_home_missing_dir() { old_home="$WORKON_HOME" WORKON_HOME="$WORKON_HOME/not_there" - assertFalse "WORKON_HOME verified unexpectedly" virtualenvwrapper_verify_workon_home + output=$(virtualenvwrapper_verify_workon_home 2>&1) + assertSame "NOTE: Virtual environments directory $WORKON_HOME does not exist. Creating..." "$output" + assertTrue "WORKON_HOME verified unexpectedly" virtualenvwrapper_verify_workon_home WORKON_HOME="$old_home" } @@ -66,19 +68,11 @@ test_virtualenvwrapper_verify_workon_home_missing_dir_grep_options() { # This should prevent the message from being found if it isn't # unset correctly. export GREP_OPTIONS="--count" - assertFalse "WORKON_HOME verified unexpectedly" virtualenvwrapper_verify_workon_home + assertTrue "WORKON_HOME not verified" virtualenvwrapper_verify_workon_home WORKON_HOME="$old_home" unset GREP_OPTIONS } -test_virtualenvwrapper_verify_workon_home_missing_dir_quiet_init() { - old_home="$WORKON_HOME" - export WORKON_HOME="$WORKON_HOME/not_there" - output=$(source $test_dir/../virtualenvwrapper.sh 2>&1) - assertSame "" "$output" - WORKON_HOME="$old_home" -} - test_get_python_version() { expected=$(python -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d.) actual=$(virtualenvwrapper_get_python_version) diff --git a/tests/test_cd.sh b/tests/test_cd.sh index cee9b67..5c871bf 100755 --- a/tests/test_cd.sh +++ b/tests/test_cd.sh @@ -26,7 +26,7 @@ setUp () { } tearDown () { - deactivate + deactivate >/dev/null 2>&1 } test_cdvirtual() { @@ -60,16 +60,18 @@ test_cdsitepackages_with_arg () { test_cdvirtualenv_no_workon_home () { old_home="$WORKON_HOME" export WORKON_HOME="$WORKON_HOME/not_there" - output=`cdvirtualenv 2>&1` + output=$(cdvirtualenv 2>&1) assertTrue "Did not see expected message" "echo $output | grep 'does not exist'" WORKON_HOME="$old_home" } test_cdsitepackages_no_workon_home () { + deactivate 2>&1 old_home="$WORKON_HOME" + cd "$WORKON_HOME" export WORKON_HOME="$WORKON_HOME/not_there" - output=`cdsitepackages 2>&1` - assertTrue "Did not see expected message" "echo $output | grep 'does not exist'" + assertFalse "Was able to change to site-packages" cdsitepackages + assertSame "$old_home" "$(pwd)" WORKON_HOME="$old_home" } diff --git a/tests/test_cp.sh b/tests/test_cp.sh index 1812967..db298c1 100755 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -6,7 +6,7 @@ test_dir=$(cd $(dirname $0) && pwd) export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" -unset HOOK_VERBOSE_OPTION +#unset HOOK_VERBOSE_OPTION setUp () { rm -rf "$WORKON_HOME" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index db7a0ca..3f1c963 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -97,13 +97,13 @@ virtualenvwrapper_derive_workon_home() { virtualenvwrapper_verify_workon_home () { if [ ! -d "$WORKON_HOME" ] then - [ "$1" != "-q" ] && echo "NOTE: Virtual environments directory '$WORKON_HOME' does not exist. Creating..." 1>&2 + [ "$1" != "-q" ] && echo "NOTE: Virtual environments directory $WORKON_HOME does not exist. Creating..." 1>&2 mkdir $WORKON_HOME fi return 0 } -#HOOK_VERBOSE_OPTION="-v" +#HOOK_VERBOSE_OPTION="-q" # Expects 1 argument, the suffix for the new file. virtualenvwrapper_tempfile () { From b72f4ac448948105a4e98cedb5d30b17b1648a5d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 10 Apr 2011 09:52:57 -0400 Subject: [PATCH 370/947] Add attribution for recent patches to the history file. --- docs/en/history.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index 35bfb34..683a679 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -8,6 +8,9 @@ dev - Fix problem with argument processing in lsvirtualenv under zsh (:bbissue:`86`). Thanks to Nat Williams (:bbuser:`natw`) for the bug report and patch. + - If WORKON_HOME does not exist, create it. Patch from Carl Karsten + (:bbuser:`CarlFK`). Test updates based on patches from Matt Austin + (:bbuser:`maafy6`) and Hugo Lopes Tavares (:bbuser:`hltbra`). 2.6.3 From 949014181886782d6e96552159a10b1fa1fc801d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 10 Apr 2011 14:55:58 +0000 Subject: [PATCH 371/947] fix tempdir tests to work on ubuntu 10.10 --- tests/test_tempfile.sh | 11 ++++++----- tox.ini | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/test_tempfile.sh b/tests/test_tempfile.sh index 46619ff..017193a 100755 --- a/tests/test_tempfile.sh +++ b/tests/test_tempfile.sh @@ -4,7 +4,8 @@ test_dir=$(cd $(dirname $0) && pwd) -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +tmplocation=${TMPDIR:-/tmp} +export WORKON_HOME="$(echo ${tmplocation}/WORKON_HOME | sed 's|//|/|g')" export HOOK_VERBOSE_OPTION=-v @@ -28,15 +29,15 @@ test_tempfile () { filename=$(virtualenvwrapper_tempfile hook) assertTrue "Filename is empty" "[ ! -z \"$filename\" ]" rm -f $filename - comparable_tmpdir=$(echo $TMPDIR | sed 's|/$||') + comparable_tmpdir=$(echo $tmplocation | sed 's|/$||') comparable_dirname=$(dirname $filename | sed 's|/$||') - assertSame "TMPDIR and path not the same for $filename" "$comparable_tmpdir" "$comparable_dirname" + assertSame "Temporary directory \"$tmplocation\" and path not the same for $filename" "$comparable_tmpdir" "$comparable_dirname" assertTrue "virtualenvwrapper-hook not in filename." "echo $filename | grep virtualenvwrapper-hook" } test_no_such_tmpdir () { old_tmpdir="$TMPDIR" - TMPDIR="$TMPDIR/does-not-exist" + export TMPDIR="$tmplocation/does-not-exist" virtualenvwrapper_run_hook "initialize" >/dev/null 2>&1 RC=$? assertSame "Unexpected exit code $RC" "1" "$RC" @@ -45,7 +46,7 @@ test_no_such_tmpdir () { test_tmpdir_not_writable () { old_tmpdir="$TMPDIR" - TMPDIR="$TMPDIR/cannot-write" + export TMPDIR="$tmplocation/cannot-write" mkdir "$TMPDIR" chmod ugo-w "$TMPDIR" virtualenvwrapper_run_hook "initialize" >/dev/null 2>&1 diff --git a/tox.ini b/tox.ini index 3326c3c..56e9ebc 100644 --- a/tox.ini +++ b/tox.ini @@ -7,5 +7,5 @@ commands = bash ./tests/run_tests {envdir} [] # Not sure why this is needed, but on my system if it isn't included then # the python version picked up for 2.6 is actually 2.7. # IF THIS CAUSES YOU A PROBLEM COMMENT IT OUT BEFORE RUNNING THE TESTS. -[testenv:py26] -basepython=/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 +#[testenv:py26] +#basepython=/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 From bf03d91a94c1f6b0f24af574a826a03c9a6c230e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 10 Apr 2011 15:53:02 +0000 Subject: [PATCH 372/947] fix tests to work under ksh on ubuntu 10.10 by using alternate syntax for capturing messages sent to stderr --- tests/test.sh | 14 ++++++++++++-- tests/test_cd.sh | 3 ++- tests/test_ls.sh | 3 ++- tests/test_mkvirtualenv.sh | 4 +++- tests/test_rmvirtualenv.sh | 5 ++--- tests/test_workon.sh | 3 ++- virtualenvwrapper.sh | 11 ++++++++--- 7 files changed, 31 insertions(+), 12 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index 9684776..c751f1c 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -56,9 +56,19 @@ test_virtualenvwrapper_verify_workon_home() { test_virtualenvwrapper_verify_workon_home_missing_dir() { old_home="$WORKON_HOME" WORKON_HOME="$WORKON_HOME/not_there" - output=$(virtualenvwrapper_verify_workon_home 2>&1) + assertTrue "Directory already exists" "[ ! -d \"$WORKON_HOME\" ]" + virtualenvwrapper_verify_workon_home >"$old_home/output" 2>&1 + output=$(cat "$old_home/output") assertSame "NOTE: Virtual environments directory $WORKON_HOME does not exist. Creating..." "$output" - assertTrue "WORKON_HOME verified unexpectedly" virtualenvwrapper_verify_workon_home + WORKON_HOME="$old_home" +} + +test_virtualenvwrapper_verify_workon_home_missing_dir_quiet() { + old_home="$WORKON_HOME" + WORKON_HOME="$WORKON_HOME/not_there_quiet" + assertTrue "Directory already exists" "[ ! -d \"$WORKON_HOME\" ]" + output=$(virtualenvwrapper_verify_workon_home -q 2>&1) + assertSame "" "$output" WORKON_HOME="$old_home" } diff --git a/tests/test_cd.sh b/tests/test_cd.sh index 5c871bf..cd12fa6 100755 --- a/tests/test_cd.sh +++ b/tests/test_cd.sh @@ -60,7 +60,8 @@ test_cdsitepackages_with_arg () { test_cdvirtualenv_no_workon_home () { old_home="$WORKON_HOME" export WORKON_HOME="$WORKON_HOME/not_there" - output=$(cdvirtualenv 2>&1) + cdvirtualenv >"$old_home/output" 2>&1 + output=$(cat "$old_home/output") assertTrue "Did not see expected message" "echo $output | grep 'does not exist'" WORKON_HOME="$old_home" } diff --git a/tests/test_ls.sh b/tests/test_ls.sh index 793ffde..6dea47d 100755 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -53,7 +53,8 @@ test_lssitepackages_add2virtualenv () { test_no_workon_home () { old_home="$WORKON_HOME" export WORKON_HOME="$WORKON_HOME/not_there" - output=`lssitepackages should_not_be_created 2>&1` + lssitepackages >"$old_home/output" 2>&1 + output=$(cat "$old_home/output") assertTrue "Did not see expected message" "echo $output | grep 'does not exist'" WORKON_HOME="$old_home" } diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index 01471d5..9a6aec7 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -79,8 +79,10 @@ test_no_args () { test_no_workon_home () { old_home="$WORKON_HOME" export WORKON_HOME="$WORKON_HOME/not_there" - output=`mkvirtualenv should_not_be_created 2>&1` + mkvirtualenv should_be_created >"$old_home/output" 2>&1 + output=$(cat "$old_home/output") assertTrue "Did not see expected message" "echo $output | grep 'does not exist'" + assertTrue "Did not create environment" "[ -d \"$WORKON_HOME/should_be_created\" ]" WORKON_HOME="$old_home" } diff --git a/tests/test_rmvirtualenv.sh b/tests/test_rmvirtualenv.sh index 169af89..1f14bfd 100755 --- a/tests/test_rmvirtualenv.sh +++ b/tests/test_rmvirtualenv.sh @@ -33,9 +33,7 @@ test_rm_aliased () { mkvirtualenv "deleteme" deactivate alias rm='rm -i' - set -x rmvirtualenv "deleteme" - set +x unalias rm } @@ -47,7 +45,8 @@ test_no_such_env () { test_no_workon_home () { old_home="$WORKON_HOME" export WORKON_HOME="$WORKON_HOME/not_there" - output=`rmvirtualenv should_not_be_created 2>&1` + rmvirtualenv should_not_be_created >"$old_home/output" 2>&1 + output=$(cat "$old_home/output") assertTrue "Did not see expected message" "echo $output | grep 'does not exist'" WORKON_HOME="$old_home" } diff --git a/tests/test_workon.sh b/tests/test_workon.sh index 6f8dc39..1a8a911 100755 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -97,7 +97,8 @@ test_virtualenvwrapper_show_workon_options_no_envs () { test_no_workon_home () { old_home="$WORKON_HOME" export WORKON_HOME="$WORKON_HOME/not_there" - output=`workon should_not_be_created 2>&1` + workon should_not_be_created >"$old_home/output" 2>&1 + output=$(cat "$old_home/output") assertTrue "Did not see expected message" "echo $output | grep 'does not exist'" WORKON_HOME="$old_home" } diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index fcbed66..fb635e2 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -95,12 +95,17 @@ virtualenvwrapper_derive_workon_home() { # seperate from creating the files in it because this used to just error # and maybe other things rely on the dir existing before that happens. virtualenvwrapper_verify_workon_home () { + RC=0 if [ ! -d "$WORKON_HOME" ] then - [ "$1" != "-q" ] && echo "NOTE: Virtual environments directory $WORKON_HOME does not exist. Creating..." 1>&2 - mkdir $WORKON_HOME + if [ "$1" != "-q" ] + then + echo "NOTE: Virtual environments directory $WORKON_HOME does not exist. Creating..." 1>&2 + fi + mkdir -p $WORKON_HOME + RC=$? fi - return 0 + return $RC } #HOOK_VERBOSE_OPTION="-q" From 170108f6ff604800cb26276dc564233b9d0f2b2d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 10 Apr 2011 13:01:49 -0400 Subject: [PATCH 373/947] doc updates for VIRTUALENVWRAPPER_VIRTUALENV --- docs/en/history.rst | 5 ++++- docs/en/install.rst | 29 +++++++++++++++++++---------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 93ea81d..4b8e54e 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -18,6 +18,9 @@ dev from Paul McLanahan (:bbuser:`pmclanahan`). The new command changes the configuration of the active virtualenv to enable or disable the global ``site-packages`` directory. + - Fixed some tests that were failing under ksh on Ubuntu 10.10. + - Document the :ref:`VIRTUALENVWRAPPER_VIRTUALENV + ` variable. 2.6.3 @@ -34,7 +37,7 @@ dev Tetsuya Morimoto. - Incorporate a suggestion from Ales Zoulek to let the user specify the virtualenv binary through an environment variable - (``VIRTUALENVWRAPPER_VIRTUALENV``). + (:ref:`VIRTUALENVWRAPPER_VIRTUALENV `). 2.6.1 diff --git a/docs/en/install.rst b/docs/en/install.rst index e07ac0c..0a97aeb 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -64,27 +64,36 @@ and the location of the script installed with this package:: After editing it, reload the startup file (e.g., run: ``source ~/.bashrc``). -Python Interpreter and $PATH -============================ +.. _variable-VIRTUALENVWRAPPER_VIRTUALENV: -During startup, ``virtualenvwrapper.sh`` finds the first ``python`` on -the ``$PATH`` and remembers it to use later. This eliminates any -conflict as the ``$PATH`` changes, enabling interpreters inside -virtual environments where virtualenvwrapper is not installed. -Because of this behavior, it is important for the ``$PATH`` to be set -**before** sourcing ``virtualenvwrapper.sh``. For example:: +.. _variable-VIRTUALENVWRAPPER_PYTHON: + +Python Interpreter, virtualenv, and $PATH +========================================= + +During startup, ``virtualenvwrapper.sh`` finds the first ``python`` +and ``virtualenv`` programs on the ``$PATH`` and remembers them to use +later. This eliminates any conflict as the ``$PATH`` changes, +enabling interpreters inside virtual environments where +virtualenvwrapper is not installed or where different versions of +virtualenv are installed. Because of this behavior, it is important +for the ``$PATH`` to be set **before** sourcing +``virtualenvwrapper.sh``. For example:: export PATH=/usr/local/bin:$PATH source /usr/local/bin/virtualenvwrapper.sh To override the ``$PATH`` search, set the variable ``VIRTUALENVWRAPPER_PYTHON`` to the full path of the interpreter to -use (also **before** sourcing ``virtualenvwrapper.sh``). For -example:: +use and ``VIRTUALENVWRAPPER_VIRTUALENV`` to the full path of the +``virtualenv`` binary to use. Both variables *must* be set before +sourcing ``virtualenvwrapper.sh``. For example:: export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python + export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv source /usr/local/bin/virtualenvwrapper.sh + Quick-Start =========== From b2008114764562a6e418d138ca91962853acf67d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 10 Apr 2011 14:11:54 -0400 Subject: [PATCH 374/947] Use VIRTUALENVWRAPPER_HOOK_DIR to control where the hooks are defined. --- tests/test_hook_dir.sh | 35 +++++++++++++++++++++++++++++++ tests/test_run_hook.sh | 14 +++++++++++++ virtualenvwrapper.sh | 6 ++++++ virtualenvwrapper/user_scripts.py | 18 ++++++++-------- 4 files changed, 64 insertions(+), 9 deletions(-) create mode 100644 tests/test_hook_dir.sh diff --git a/tests/test_hook_dir.sh b/tests/test_hook_dir.sh new file mode 100644 index 0000000..9849bef --- /dev/null +++ b/tests/test_hook_dir.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +#set -x + +test_dir=$(cd $(dirname $0) && pwd) + +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + mkdir -p "$WORKON_HOME/hooks" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" + rm -f "$WORKON_HOME/hooks/*" +} + +test_virtualenvwrapper_initialize() { + export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME/hooks" + source "$test_dir/../virtualenvwrapper.sh" + for hook in premkvirtualenv postmkvirtualenv prermvirtualenv postrmvirtualenv preactivate postactivate predeactivate postdeactivate + do + assertTrue "Global $hook was not created" "[ -f $WORKON_HOME/hooks/$hook ]" + assertTrue "Global $hook is not executable" "[ -x $WORKON_HOME/hooks/$hook ]" + done +} + +. "$test_dir/shunit2" diff --git a/tests/test_run_hook.sh b/tests/test_run_hook.sh index 9cd45d0..27b444a 100755 --- a/tests/test_run_hook.sh +++ b/tests/test_run_hook.sh @@ -32,6 +32,20 @@ test_virtualenvwrapper_run_hook() { assertSame "$expected" "$output" } +test_virtualenvwrapper_run_hook_alternate_dir() { + mkdir "$WORKON_HOME/hooks" + echo "echo WORKON_HOME >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/initialize" + echo "echo WORKON_HOME/hooks >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/hooks/initialize" + chmod +x "$WORKON_HOME/initialize" + chmod +x "$WORKON_HOME/hooks/initialize" + VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME/hooks" + virtualenvwrapper_run_hook "initialize" + output=$(cat "$test_dir/catch_output") + expected="WORKON_HOME/hooks" + assertSame "$expected" "$output" + VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME" +} + test_virtualenvwrapper_source_hook_permissions() { echo "echo run >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/initialize" chmod -x "$WORKON_HOME/initialize" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index fb635e2..1bd5bef 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -56,6 +56,12 @@ then VIRTUALENVWRAPPER_VIRTUALENV="virtualenv" fi +# Set the location of the hook scripts +if [ "$VIRTUALENVWRAPPER_HOOK_DIR" = "" ] +then + export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME" +fi + virtualenvwrapper_derive_workon_home() { typeset workon_home_dir="$WORKON_HOME" diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index c83c251..521212a 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -31,9 +31,9 @@ def run_script(script_path, *args): def run_global(script_name, *args): - """Run a script from $WORKON_HOME. + """Run a script from $VIRTUALENVWRAPPER_HOOK_DIR. """ - script_path = os.path.expandvars(os.path.join('$WORKON_HOME', script_name)) + script_path = os.path.expandvars(os.path.join('$VIRTUALENVWRAPPER_HOOK_DIR', script_name)) run_script(script_path, *args) return @@ -122,7 +122,7 @@ def make_hook(filename, comment): def initialize(args): for filename, comment in GLOBAL_HOOKS: - make_hook(os.path.join('$WORKON_HOME', filename), comment) + make_hook(os.path.join('$VIRTUALENVWRAPPER_HOOK_DIR', filename), comment) return @@ -131,7 +131,7 @@ def initialize_source(args): # # Run user-provided scripts # -[ -f "$WORKON_HOME/initialize" ] && source "$WORKON_HOME/initialize" +[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/initialize" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/initialize" """ def pre_mkvirtualenv(args): @@ -148,7 +148,7 @@ def post_mkvirtualenv_source(args): # # Run user-provided scripts # -[ -f "$WORKON_HOME/postmkvirtualenv" ] && source "$WORKON_HOME/postmkvirtualenv" +[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postmkvirtualenv" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/postmkvirtualenv" """ def pre_cpvirtualenv(args): @@ -165,7 +165,7 @@ def post_cpvirtualenv_source(args): # # Run user-provided scripts # -[ -f "$WORKON_HOME/postcpvirtualenv" ] && source "$WORKON_HOME/postcpvirtualenv" +[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postcpvirtualenv" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/postcpvirtualenv" """ @@ -195,7 +195,7 @@ def post_activate_source(args): # # Run user-provided scripts # -[ -f "$WORKON_HOME/postactivate" ] && source "$WORKON_HOME/postactivate" +[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postactivate" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/postactivate" [ -f "$VIRTUAL_ENV/bin/postactivate" ] && source "$VIRTUAL_ENV/bin/postactivate" """ @@ -207,7 +207,7 @@ def pre_deactivate_source(args): # Run user-provided scripts # [ -f "$VIRTUAL_ENV/bin/predeactivate" ] && source "$VIRTUAL_ENV/bin/predeactivate" -[ -f "$WORKON_HOME/predeactivate" ] && source "$WORKON_HOME/predeactivate" +[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/predeactivate" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/predeactivate" """ @@ -219,7 +219,7 @@ def post_deactivate_source(args): # VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV="$WORKON_HOME/%(env_name)s" [ -f "$WORKON_HOME/%(env_name)s/bin/postdeactivate" ] && source "$WORKON_HOME/%(env_name)s/bin/postdeactivate" -[ -f "$WORKON_HOME/postdeactivate" ] && source "$WORKON_HOME/postdeactivate" +[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postdeactivate" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/postdeactivate" unset VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV """ % { 'env_name':args[0] } From 1e52750226fe3302a8c84d56162aacb07a3b9c60 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 11 Apr 2011 07:44:59 -0400 Subject: [PATCH 375/947] Add VIRTUALENVWRAPPER_LOG_DIR variable. --- ChangeLog | 7 +++++++ docs/en/history.rst | 6 ++++++ docs/en/install.rst | 24 +++++++++++++++++++++--- docs/en/scripts.rst | 27 ++++++++++++++++----------- tests/test_log_dir.sh | 32 ++++++++++++++++++++++++++++++++ virtualenvwrapper.sh | 6 ++++++ virtualenvwrapper/hook_loader.py | 2 +- 7 files changed, 89 insertions(+), 15 deletions(-) create mode 100644 tests/test_log_dir.sh diff --git a/ChangeLog b/ChangeLog index 38fa9e9..e1f3e3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2011-04-10 Doug Hellmann + * virtualenvwrapper.sh: Initialize VIRTUALENVWRAPPER_LOG_DIR and + VIRTUALENVWRAPPER_HOOK_DIR. + + * virtualenvwrapper/hook_loader.py (main): Use + VIRTUALENVWRAPPER_LOG_DIR for logs instead of assuming + WORKON_HOME. + * virtualenvwrapper/user_scripts.py (make_hook): Change verbosity of message telling the user we have created a new hook script for them. diff --git a/docs/en/history.rst b/docs/en/history.rst index 4b8e54e..141ecf0 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -21,6 +21,12 @@ dev - Fixed some tests that were failing under ksh on Ubuntu 10.10. - Document the :ref:`VIRTUALENVWRAPPER_VIRTUALENV ` variable. + - Implement suggestion by Van Lindberg to have + :ref:`VIRTUALENVWRAPPER_HOOK_DIR + ` and + :ref:`VIRTUALENVWRAPPER_LOG_DIR + ` variables to control the + locations of hooks and logs. 2.6.3 diff --git a/docs/en/install.rst b/docs/en/install.rst index 0a97aeb..8d18187 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -45,9 +45,27 @@ WORKON_HOME =========== The variable ``WORKON_HOME`` tells virtualenvwrapper where to place -your virtual environments. The default is ``$HOME/.virtualenvs``. -This directory must be created before using any virtualenvwrapper -commands. +your virtual environments. The default is ``$HOME/.virtualenvs``. If +the directory does not exist when virtualenvwrapper is loaded, it will +be created automatically. + +.. _variable-VIRTUALENVWRAPPER_HOOK_DIR: + +VIRTUALENVWRAPPER_HOOK_DIR +========================== + +The variable ``VIRTUALENVWRAPPER_HOOK_DIR`` tells virtualenvwrapper +where the user-defined hooks should be placed. The default is +``$WORKON_HOME``. + +.. _variable-VIRTUALENVWRAPPER_LOG_DIR: + +VIRTUALENVWRAPPER_LOG_DIR +========================== + +The variable ``VIRTUALENVWRAPPER_LOG_DIR`` tells virtualenvwrapper +where the user-defined logs should be written. The default is +``$WORKON_HOME``. .. _install-shell-config: diff --git a/docs/en/scripts.rst b/docs/en/scripts.rst index 96bb51a..5bd0184 100644 --- a/docs/en/scripts.rst +++ b/docs/en/scripts.rst @@ -8,6 +8,11 @@ The end-user customization scripts are either *sourced* (allowing them to modify your shell environment) or *run* as an external program at the appropriate trigger time. +The global scripts applied to all environments should be placed in the +directory named by :ref:`VIRTUALENVWRAPPER_HOOK_DIR +`. The local scripts should be +placed in the ``bin`` directory of the virtualenv. + .. _scripts-get_env_details: get_env_details @@ -17,7 +22,7 @@ get_env_details :Argument(s): env name :Sourced/Run: run -``$WORKON_HOME/get_env_details`` is run when ``workon`` is run with no +``$VIRTUALENVWRAPPER_HOOK_DIR/get_env_details`` is run when ``workon`` is run with no arguments and a list of the virtual environments is printed. The hook is run once for each environment, after the name is printed, and can print additional information about that environment. @@ -31,7 +36,7 @@ initialize :Argument(s): None :Sourced/Run: sourced -``$WORKON_HOME/initialize`` is sourced when ``virtualenvwrapper.sh`` +``$VIRTUALENVWRAPPER_HOOK_DIR/initialize`` is sourced when ``virtualenvwrapper.sh`` is loaded into your environment. Use it to adjust global settings when virtualenvwrapper is enabled. @@ -44,7 +49,7 @@ premkvirtualenv :Argument(s): name of new environment :Sourced/Run: run -``$WORKON_HOME/premkvirtualenv`` is run as an external program after +``$VIRTUALENVWRAPPER_HOOK_DIR/premkvirtualenv`` is run as an external program after the virtual environment is created but before the current environment is switched to point to the new env. The current working directory for the script is ``$WORKON_HOME`` and the name of the new environment is @@ -59,7 +64,7 @@ postmkvirtualenv :Argument(s): none :Sourced/Run: sourced -``$WORKON_HOME/postmkvirtualenv`` is sourced after the new environment +``$VIRTUALENVWRAPPER_HOOK_DIR/postmkvirtualenv`` is sourced after the new environment is created and activated. .. _scripts-precpvirtualenv: @@ -71,7 +76,7 @@ precpvirtualenv :Argument(s): name of original environment, name of new environment :Sourced/Run: run -``$WORKON_HOME/precpvirtualenv`` is run as an external program after +``$VIRTUALENVWRAPPER_HOOK_DIR/precpvirtualenv`` is run as an external program after the source environment is duplicated and made relocatable, but before the ``premkvirtualenv`` hook is run or the current environment is switched to point to the new env. The current working directory for @@ -87,7 +92,7 @@ postcpvirtualenv :Argument(s): none :Sourced/Run: sourced -``$WORKON_HOME/postcpvirtualenv`` is sourced after the new environment +``$VIRTUALENVWRAPPER_HOOK_DIR/postcpvirtualenv`` is sourced after the new environment is created and activated. .. _scripts-preactivate: @@ -99,7 +104,7 @@ preactivate :Argument(s): environment name :Sourced/Run: run -The global ``$WORKON_HOME/preactivate`` script is run before the new +The global ``$VIRTUALENVWRAPPER_HOOK_DIR/preactivate`` script is run before the new environment is enabled. The environment name is passed as the first argument. @@ -116,7 +121,7 @@ postactivate :Argument(s): none :Sourced/Run: sourced -The global ``$WORKON_HOME/postactivate`` script is sourced after the +The global ``$VIRTUALENVWRAPPER_HOOK_DIR/postactivate`` script is sourced after the new environment is enabled. ``$VIRTUAL_ENV`` refers to the new environment at the time the script runs. @@ -155,7 +160,7 @@ current environment is deactivated, and can be used to disable or clear settings in your environment. ``$VIRTUAL_ENV`` refers to the old environment at the time the script runs. -The global ``$WORKON_HOME/predeactivate`` script is sourced before the +The global ``$VIRTUALENVWRAPPER_HOOK_DIR/predeactivate`` script is sourced before the current environment is deactivated. ``$VIRTUAL_ENV`` refers to the old environment at the time the script runs. @@ -182,7 +187,7 @@ prermvirtualenv :Argument(s): environment name :Sourced/Run: run -The ``$WORKON_HOME/prermvirtualenv`` script is run as an external +The ``$VIRTUALENVWRAPPER_HOOK_DIR/prermvirtualenv`` script is run as an external program before the environment is removed. The full path to the environment directory is passed as an argument to the script. @@ -195,6 +200,6 @@ postrmvirtualenv :Argument(s): environment name :Sourced/Run: run -The ``$WORKON_HOME/postrmvirtualenv`` script is run as an external +The ``$VIRTUALENVWRAPPER_HOOK_DIR/postrmvirtualenv`` script is run as an external program after the environment is removed. The full path to the environment directory is passed as an argument to the script. diff --git a/tests/test_log_dir.sh b/tests/test_log_dir.sh new file mode 100644 index 0000000..e2eb325 --- /dev/null +++ b/tests/test_log_dir.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +#set -x + +test_dir=$(cd $(dirname $0) && pwd) + +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + mkdir -p "$WORKON_HOME/hooks" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" + rm -f "$WORKON_HOME/hooks/*" +} + +test_virtualenvwrapper_initialize() { + export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME/logs" + mkdir -p "$VIRTUALENVWRAPPER_LOG_DIR" + source "$test_dir/../virtualenvwrapper.sh" + assertTrue "Log file was not created" "[ -f $WORKON_HOME/logs/hook.log ]" +} + +. "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 1bd5bef..99bc579 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -62,6 +62,12 @@ then export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME" fi +# Set the location of the hook script logs +if [ "$VIRTUALENVWRAPPER_LOG_DIR" = "" ] +then + export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME" +fi + virtualenvwrapper_derive_workon_home() { typeset workon_home_dir="$WORKON_HOME" diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 0dc9725..9d7c785 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -67,7 +67,7 @@ def main(): # Set up logging to a file root_logger.setLevel(logging.DEBUG) file_handler = logging.handlers.RotatingFileHandler( - os.path.expandvars(os.path.join('$WORKON_HOME', 'hook.log')), + os.path.expandvars(os.path.join('$VIRTUALENVWRAPPER_LOG_DIR', 'hook.log')), maxBytes=10240, backupCount=1, ) From 8f3917a0fd37cb12dc969abf90378e0b6d9aa1f6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 11 Apr 2011 09:04:31 -0400 Subject: [PATCH 376/947] fix typo in cpvirtualenv; fixes #71 --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 99bc579..68b0791 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -559,7 +559,7 @@ cpvirtualenv() { fi if echo "$WORKON_HOME" | (unset GREP_OPTIONS; \grep -e "/$" > /dev/null) then - typset env_home="$WORKON_HOME" + typeset env_home="$WORKON_HOME" else typeset env_home="$WORKON_HOME/" fi From a80bef1ea40d8ffcd62737555cad436bae9fc9d7 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 11 Apr 2011 09:10:14 -0400 Subject: [PATCH 377/947] clear configuration variables before running tests --- tests/run_tests | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/run_tests b/tests/run_tests index 81b1955..4065b71 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -31,6 +31,10 @@ export HOOK_VERBOSE_OPTION="-q" # tox-created virtualenv. export VIRTUALENVWRAPPER_PYTHON="$envdir/bin/python" +# Clear any user settings for the hook directory or log directory +unset VIRTUALENVWRAPPER_HOOK_DIR +unset VIRTUALENVWRAPPER_LOG_DIR + # Run the test scripts with a little formatting around them to make it # easier to find where each script output starts. for test_shell in bash ksh zsh From 5938c374c5f4a73200aad328325e1fc9a467d141 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 11 Apr 2011 09:12:46 -0400 Subject: [PATCH 378/947] clean up test instructions for developers; fixes #75 --- docs/en/developers.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/en/developers.rst b/docs/en/developers.rst index 2d01ae3..9b67e8e 100644 --- a/docs/en/developers.rst +++ b/docs/en/developers.rst @@ -67,6 +67,8 @@ Running Tests The test suite for virtualenvwrapper uses `shunit2 `_ and `tox `_. To run the tests under bash, sh, and -zsh, use ``make test`` or just ``tox``. In order to add new tests, -you will need to modify or create an appropriate script in the +zsh for Python 2.4-2.7, use ``tox`` from the top level directory of +the hg repository. + +Add new tests by modifying or creating an appropriate script in the ``tests`` directory. From 9fb54f309b331a713ccebdd649967627301aa807 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 11 Apr 2011 09:16:37 -0400 Subject: [PATCH 379/947] enable tab completion for showvirtualenv; fixes #78 --- docs/en/history.rst | 2 ++ virtualenvwrapper.sh | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 141ecf0..9d4e02b 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -27,6 +27,8 @@ dev :ref:`VIRTUALENVWRAPPER_LOG_DIR ` variables to control the locations of hooks and logs. + - Enabled tab completion for :ref:`command-showvirtualenv` + (:bbissue:`78`). 2.6.3 diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 68b0791..38177c3 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -411,6 +411,7 @@ if [ -n "$BASH" ] ; then COMPREPLY=( $(compgen -W "`virtualenvwrapper_show_workon_options`" -- ${cur}) ) } + _cdvirtualenv_complete () { local cur="$2" @@ -427,8 +428,9 @@ if [ -n "$BASH" ] ; then complete -o default -o nospace -F _virtualenvs workon complete -o default -o nospace -F _virtualenvs rmvirtualenv complete -o default -o nospace -F _virtualenvs cpvirtualenv + complete -o default -o nospace -F _virtualenvs showvirtualenv elif [ -n "$ZSH_VERSION" ] ; then - compctl -g "`virtualenvwrapper_show_workon_options`" workon rmvirtualenv cpvirtualenv + compctl -g "`virtualenvwrapper_show_workon_options`" workon rmvirtualenv cpvirtualenv showvirtualenv fi # Prints the Python version string for the current interpreter. From ae242aa23d0d59e6abaa25948d4fea637c3ae4da Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 12 Apr 2011 07:24:43 -0400 Subject: [PATCH 380/947] add link to vim-virtualenv --- docs/en/extensions.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/en/extensions.rst b/docs/en/extensions.rst index cf0f461..b06f7fb 100644 --- a/docs/en/extensions.rst +++ b/docs/en/extensions.rst @@ -43,3 +43,13 @@ user_scripts The ``user_scripts`` extension is delivered with virtualenvwrapper and enabled by default. It implements the user customization script features described in :ref:`scripts`. + +vim-virtualenv +============== + +`vim-virtualenv`_ is Jeremey Cantrell's plugin for controlling +virtualenvs from within vim. When used together with +virtualenvwrapper, vim-virtualenv identifies the virtualenv to +activate based on the name of the file being edited. + +.. _vim-virtualenv: https://github.com/jmcantrell/vim-virtualenv From 388546065738178f45566226495cf5e6b892bf05 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 12 Apr 2011 09:06:45 -0400 Subject: [PATCH 381/947] pass VIRTUALENVWRAPPER_VIRTUALENV_ARGS when calling VIRTUALENVWRAPPER_VIRTUALENV; fixes #89; fixes #87 --- docs/en/install.rst | 15 +++++++ tests/run_tests | 2 + tests/test_mkvirtualenv.sh | 56 ++++++++++++++------------ tests/test_toggleglobalsitepackages.sh | 6 +-- virtualenvwrapper.sh | 2 +- 5 files changed, 52 insertions(+), 29 deletions(-) diff --git a/docs/en/install.rst b/docs/en/install.rst index 8d18187..bcdb547 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -84,6 +84,8 @@ After editing it, reload the startup file (e.g., run: ``source .. _variable-VIRTUALENVWRAPPER_VIRTUALENV: +.. _variable-VIRTUALENVWRAPPER_VIRTUALENV_ARGS: + .. _variable-VIRTUALENVWRAPPER_PYTHON: Python Interpreter, virtualenv, and $PATH @@ -111,6 +113,19 @@ sourcing ``virtualenvwrapper.sh``. For example:: export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv source /usr/local/bin/virtualenvwrapper.sh +Default Arguments for virtualenv +================================ + +If the application identified by ``VIRTUALENVWRAPPER_VIRTUALENV`` +needs arguments, they can be set in +``VIRTUALENVWRAPPER_VIRTUALENV_ARGS``. The same variable can be used +to set default arguments to be passed to ``virtualenv``. For example, +set the value to ``--no-site-packages`` to ensure that all new +environments are isolated from the system ``site-packages`` directory. + +:: + + export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages' Quick-Start =========== diff --git a/tests/run_tests b/tests/run_tests index 4065b71..369ce6f 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -34,6 +34,8 @@ export VIRTUALENVWRAPPER_PYTHON="$envdir/bin/python" # Clear any user settings for the hook directory or log directory unset VIRTUALENVWRAPPER_HOOK_DIR unset VIRTUALENVWRAPPER_LOG_DIR +unset VIRTUALENVWRAPPER_VIRTUALENV +unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS # Run the test scripts with a little formatting around them to make it # easier to find where each script output starts. diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index 9a6aec7..12c7c22 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -22,7 +22,7 @@ setUp () { } test_create() { - mkvirtualenv "env1" + mkvirtualenv "env1" >/dev/null 2>&1 assertTrue "Environment directory was not created" "[ -d $WORKON_HOME/env1 ]" for hook in postactivate predeactivate postdeactivate do @@ -32,7 +32,7 @@ test_create() { } test_activates () { - mkvirtualenv "env2" + mkvirtualenv "env2" >/dev/null 2>&1 assertTrue virtualenvwrapper_verify_active_environment assertSame "env2" $(basename "$VIRTUAL_ENV") } @@ -45,7 +45,7 @@ test_hooks () { chmod +x "$WORKON_HOME/premkvirtualenv" echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" - mkvirtualenv "env3" + mkvirtualenv "env3" >/dev/null 2>&1 output=$(cat "$test_dir/catch_output") workon_home_as_pwd=$(cd $WORKON_HOME; pwd) expected="GLOBAL premkvirtualenv $workon_home_as_pwd env3 @@ -86,6 +86,33 @@ test_no_workon_home () { WORKON_HOME="$old_home" } +test_mkvirtualenv_sitepackages () { + # This part of the test is not reliable because + # creating a new virtualenv from inside the + # tox virtualenv inherits the setting from there. +# # Without the option, verify that site-packages are copied. +# mkvirtualenv "with_sp" >/dev/null 2>&1 +# ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" +# assertFalse "$ngsp_file exists" "[ -f \"$ngsp_file\" ]" +# rmvirtualenv "env3" + + # With the argument, verify that they are not copied. + mkvirtualenv --no-site-packages "without_sp" >/dev/null 2>&1 + ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" + assertTrue "$ngsp_file does not exist" "[ -f \"$ngsp_file\" ]" + rmvirtualenv "env4" +} + +test_mkvirtualenv_args () { + VIRTUALENVWRAPPER_VIRTUALENV_ARGS="--no-site-packages" + # With the argument, verify that they are not copied. + mkvirtualenv "without_sp2" >/dev/null 2>&1 + ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" + assertTrue "$ngsp_file does not exist" "[ -f \"$ngsp_file\" ]" + rmvirtualenv "env4" + unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS +} + test_virtualenv_fails () { # Test to reproduce the conditions in issue #76 # https://bitbucket.org/dhellmann/virtualenvwrapper/issue/76/ @@ -103,7 +130,7 @@ test_virtualenv_fails () { chmod +x "$WORKON_HOME/premkvirtualenv" echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" - mkvirtualenv "env3" + mkvirtualenv "env3" >/dev/null 2>&1 output=$(cat "$test_dir/catch_output" 2>/dev/null) workon_home_as_pwd=$(cd $WORKON_HOME; pwd) expected="" @@ -114,26 +141,5 @@ test_virtualenv_fails () { VIRTUALENVWRAPPER_VIRTUALENV=virtualenv } -# test_mkvirtualenv_sitepackages () { -# # Without the option verify that site-packages are copied. -# mkvirtualenv "env3" -# assertSame "env3" "$(basename $VIRTUAL_ENV)" -# pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) -# sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" -# #cat "$sitepackages/easy-install.pth" -# assertTrue "Do not have expected virtualenv.py" "[ -f $sitepackages/virtualenv.py ]" -# rmvirtualenv "env3" -# -# # With the argument, verify that they are not copied. -# mkvirtualenv --no-site-packages "env4" -# assertSame "env4" $(basename "$VIRTUAL_ENV") -# pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) -# sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" -# assertTrue "[ -f $sitepackages/setuptools.pth ]" -# assertTrue "[ -f $sitepackages/easy-install.pth ]" -# assertFalse "Have virtualenv.py but should not" "[ -f $sitepackages/virtualenv.py ]" -# rmvirtualenv "env4" -# } - . "$test_dir/shunit2" diff --git a/tests/test_toggleglobalsitepackages.sh b/tests/test_toggleglobalsitepackages.sh index 3eb5e79..4c78467 100755 --- a/tests/test_toggleglobalsitepackages.sh +++ b/tests/test_toggleglobalsitepackages.sh @@ -29,11 +29,11 @@ tearDown () { test_toggleglobalsitepackages () { ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" - assertTrue "$ngsp_file does not exist" "[ -f "$ngsp_file" ]" + assertTrue "$ngsp_file does not exist" "[ -f \"$ngsp_file\" ]" toggleglobalsitepackages -q - assertFalse "$ngsp_file exists" "[ -f "$ngsp_file" ]" + assertFalse "$ngsp_file exists" "[ -f \"$ngsp_file\" ]" toggleglobalsitepackages -q - assertTrue "$ngsp_file does not exist" "[ -f "$ngsp_file" ]" + assertTrue "$ngsp_file does not exist" "[ -f \"$ngsp_file\" ]" } test_toggleglobalsitepackages_quiet () { diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 38177c3..4e017b4 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -220,7 +220,7 @@ mkvirtualenv () { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_virtualenv || return 1 (cd "$WORKON_HOME" && - "$VIRTUALENVWRAPPER_VIRTUALENV" "$@" && + "$VIRTUALENVWRAPPER_VIRTUALENV" $VIRTUALENVWRAPPER_VIRTUALENV_ARGS "$@" && [ -d "$WORKON_HOME/$envname" ] && \ virtualenvwrapper_run_hook "pre_mkvirtualenv" "$envname" ) From bae98628e74fc736b035ffb10153d5cf148025ce Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 13 Apr 2011 06:32:13 -0400 Subject: [PATCH 382/947] make it possible to remove a virtualenv while inside it; fixes #83 --- ChangeLog | 6 ++++++ docs/en/history.rst | 2 ++ tests/test_rmvirtualenv.sh | 15 +++++++++++++-- virtualenvwrapper.sh | 12 ++++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e1f3e3b..caaecc6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-04-13 Doug Hellmann + + * virtualenvwrapper.sh (rmvirtualenv): Move to a safe directory + before removing the virtual environment, and only move back if the + previously occupied directory still exists. + 2011-04-10 Doug Hellmann * virtualenvwrapper.sh: Initialize VIRTUALENVWRAPPER_LOG_DIR and diff --git a/docs/en/history.rst b/docs/en/history.rst index 9d4e02b..3da8b6b 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -29,6 +29,8 @@ dev locations of hooks and logs. - Enabled tab completion for :ref:`command-showvirtualenv` (:bbissue:`78`). + - Fixed a problem with running :ref:`command-rmvirtualenv` from + within the environment being removed (:bbissue:`83`). 2.6.3 diff --git a/tests/test_rmvirtualenv.sh b/tests/test_rmvirtualenv.sh index 1f14bfd..5327953 100755 --- a/tests/test_rmvirtualenv.sh +++ b/tests/test_rmvirtualenv.sh @@ -22,15 +22,26 @@ setUp () { } test_remove () { - mkvirtualenv "deleteme" + mkvirtualenv "deleteme" >/dev/null 2>&1 assertTrue "[ -d $WORKON_HOME/deleteme ]" deactivate rmvirtualenv "deleteme" assertFalse "[ -d $WORKON_HOME/deleteme ]" } +test_within_virtualenv () { + mkvirtualenv "deleteme" >/dev/null 2>&1 + assertTrue "[ -d $WORKON_HOME/deleteme ]" + cdvirtualenv + assertSame "$VIRTUAL_ENV" "$(pwd)" + deactivate + rmvirtualenv "deleteme" + assertSame "$WORKON_HOME" "$(pwd)" + assertFalse "[ -d $WORKON_HOME/deleteme ]" +} + test_rm_aliased () { - mkvirtualenv "deleteme" + mkvirtualenv "deleteme" >/dev/null 2>&1 deactivate alias rm='rm -i' rmvirtualenv "deleteme" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 4e017b4..620297a 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -252,9 +252,21 @@ rmvirtualenv () { echo "Either switch to another environment, or run 'deactivate'." >&2 return 1 fi + + # Move out of the current directory to one known to be + # safe, in case we are inside the environment somewhere. + typeset prior_dir="$(pwd)" + cd "$WORKON_HOME" + virtualenvwrapper_run_hook "pre_rmvirtualenv" "$env_name" \rm -rf "$env_dir" virtualenvwrapper_run_hook "post_rmvirtualenv" "$env_name" + + # If the directory we used to be in still exists, move back to it. + if [ -d "$prior_dir" ] + then + cd "$prior_dir" + fi } # List the available environments. From b7d4fe38f1948f851efdf959a784e93042b6f06a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 13 Apr 2011 06:47:01 -0400 Subject: [PATCH 383/947] reorg install docs to separate the customization stuff; add some comments about site-wide installation; fixes #87 --- docs/en/install.rst | 84 ++++++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 31 deletions(-) diff --git a/docs/en/install.rst b/docs/en/install.rst index bcdb547..56dce43 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -41,9 +41,37 @@ add it to your user local directory (usually `~/.local`). $ pip install --install-option="--user" virtualenvwrapper -WORKON_HOME +.. _install-shell-config: + +Shell Startup File +================== + +Add two lines to your shell startup file (``.bashrc``, ``.profile``, +etc.) to set the location where the virtual environments should live +and the location of the script installed with this package:: + + export WORKON_HOME=$HOME/.virtualenvs + source /usr/local/bin/virtualenvwrapper.sh + +After editing it, reload the startup file (e.g., run ``source +~/.bashrc``). + +Quick-Start =========== +1. Run: ``workon`` +2. A list of environments, empty, is printed. +3. Run: ``mkvirtualenv temp`` +4. A new environment, ``temp`` is created and activated. +5. Run: ``workon`` +6. This time, the ``temp`` environment is included. + +Customization +============= + +WORKON_HOME +----------- + The variable ``WORKON_HOME`` tells virtualenvwrapper where to place your virtual environments. The default is ``$HOME/.virtualenvs``. If the directory does not exist when virtualenvwrapper is loaded, it will @@ -52,7 +80,7 @@ be created automatically. .. _variable-VIRTUALENVWRAPPER_HOOK_DIR: VIRTUALENVWRAPPER_HOOK_DIR -========================== +-------------------------- The variable ``VIRTUALENVWRAPPER_HOOK_DIR`` tells virtualenvwrapper where the user-defined hooks should be placed. The default is @@ -61,27 +89,12 @@ where the user-defined hooks should be placed. The default is .. _variable-VIRTUALENVWRAPPER_LOG_DIR: VIRTUALENVWRAPPER_LOG_DIR -========================== +------------------------- The variable ``VIRTUALENVWRAPPER_LOG_DIR`` tells virtualenvwrapper where the user-defined logs should be written. The default is ``$WORKON_HOME``. -.. _install-shell-config: - -Shell Startup File -================== - -Add two lines to your shell startup file (``.bashrc``, ``.profile``, -etc.) to set the location where the virtual environments should live -and the location of the script installed with this package:: - - export WORKON_HOME=$HOME/.virtualenvs - source /usr/local/bin/virtualenvwrapper.sh - -After editing it, reload the startup file (e.g., run: ``source -~/.bashrc``). - .. _variable-VIRTUALENVWRAPPER_VIRTUALENV: .. _variable-VIRTUALENVWRAPPER_VIRTUALENV_ARGS: @@ -89,7 +102,7 @@ After editing it, reload the startup file (e.g., run: ``source .. _variable-VIRTUALENVWRAPPER_PYTHON: Python Interpreter, virtualenv, and $PATH -========================================= +----------------------------------------- During startup, ``virtualenvwrapper.sh`` finds the first ``python`` and ``virtualenv`` programs on the ``$PATH`` and remembers them to use @@ -114,7 +127,7 @@ sourcing ``virtualenvwrapper.sh``. For example:: source /usr/local/bin/virtualenvwrapper.sh Default Arguments for virtualenv -================================ +-------------------------------- If the application identified by ``VIRTUALENVWRAPPER_VIRTUALENV`` needs arguments, they can be set in @@ -127,24 +140,33 @@ environments are isolated from the system ``site-packages`` directory. export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages' -Quick-Start -=========== - -1. Run: ``workon`` -2. A list of environments, empty, is printed. -3. Run: ``mkvirtualenv temp`` -4. A new environment, ``temp`` is created and activated. -5. Run: ``workon`` -6. This time, the ``temp`` environment is included. - Temporary Files -=============== +--------------- virtualenvwrapper creates temporary files in ``$TMPDIR``. If the variable is not set, it uses ``/tmp``. To change the location of temporary files just for virtualenvwrapper, set ``VIRTUALENVWRAPPER_TMPDIR``. +Site-wide Configuration +----------------------- + +Most UNIX systems include the ability to change the configuration for +all users. This typically takes one of two forms: editing the +*skeleton* files for new accounts or editing the global startup file +for a shell. + +Editing the skeleton files for new accounts means that each new user +will have their private startup files preconfigured to load +virtualenvwrapper. They can disable it by commenting out or removing +those lines. Refer to the documentation for the shell and operating +system to identify the appropriate file to edit. + +Modifying the global startup file for a given shell means that all +users of that shell will have virtualenvwrapper enabled, and they +cannot disable it. Refer to the documentation for the shell to +identify the appropriate file to edit. + Upgrading from 1.x ================== From d48379848bb6b7898be083a18b4f3ce889e6de82 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 13 Apr 2011 06:50:53 -0400 Subject: [PATCH 384/947] nicer titles for configuration section --- docs/en/install.rst | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/docs/en/install.rst b/docs/en/install.rst index 56dce43..3f833aa 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -66,11 +66,15 @@ Quick-Start 5. Run: ``workon`` 6. This time, the ``temp`` environment is included. -Customization +Configuration ============= -WORKON_HOME ------------ +virtualenvwrapper can be customized by changing environment +variables. Set the variables in your shell startup file *before* +loading ``virtualenvwrapper.sh``. + +Location of Environments +------------------------ The variable ``WORKON_HOME`` tells virtualenvwrapper where to place your virtual environments. The default is ``$HOME/.virtualenvs``. If @@ -79,20 +83,20 @@ be created automatically. .. _variable-VIRTUALENVWRAPPER_HOOK_DIR: -VIRTUALENVWRAPPER_HOOK_DIR --------------------------- +Location of Hook Scripts +------------------------ The variable ``VIRTUALENVWRAPPER_HOOK_DIR`` tells virtualenvwrapper -where the user-defined hooks should be placed. The default is -``$WORKON_HOME``. +where the :ref:`user-defined hooks ` should be placed. The +default is ``$WORKON_HOME``. .. _variable-VIRTUALENVWRAPPER_LOG_DIR: -VIRTUALENVWRAPPER_LOG_DIR -------------------------- +Location of Hook Logs +--------------------- The variable ``VIRTUALENVWRAPPER_LOG_DIR`` tells virtualenvwrapper -where the user-defined logs should be written. The default is +where the logs for the hook loader should be written. The default is ``$WORKON_HOME``. .. _variable-VIRTUALENVWRAPPER_VIRTUALENV: From 5a08a1666a8c866b038c6db2b1d14386ec53ae13 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 13 Apr 2011 07:08:34 -0400 Subject: [PATCH 385/947] remove -e option from all calls to grep for better portability; fixes #85 --- virtualenvwrapper.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 620297a..5255217 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -80,7 +80,7 @@ virtualenvwrapper_derive_workon_home() { # If the path is relative, prefix it with $HOME # (note: for compatibility) - if echo "$workon_home_dir" | (unset GREP_OPTIONS; \grep -e '^[^/~]' > /dev/null) + if echo "$workon_home_dir" | (unset GREP_OPTIONS; \grep '^[^/~]' > /dev/null) then workon_home_dir="$HOME/$WORKON_HOME" fi @@ -89,7 +89,7 @@ virtualenvwrapper_derive_workon_home() { # path might contain stuff to expand. # (it might be possible to do this in shell, but I don't know a # cross-shell-safe way of doing it -wolever) - if echo "$workon_home_dir" | (unset GREP_OPTIONS; \egrep -e '([\$~]|//)' >/dev/null) + if echo "$workon_home_dir" | (unset GREP_OPTIONS; \egrep '([\$~]|//)' >/dev/null) then # This will normalize the path by: # - Removing extra slashes (e.g., when TMPDIR ends in a slash) @@ -571,7 +571,7 @@ cpvirtualenv() { echo "Please specify target virtualenv" return 1 fi - if echo "$WORKON_HOME" | (unset GREP_OPTIONS; \grep -e "/$" > /dev/null) + if echo "$WORKON_HOME" | (unset GREP_OPTIONS; \grep "/$" > /dev/null) then typeset env_home="$WORKON_HOME" else From 3b6fc0191be2e84b100cd5aa57192d27fbf31781 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 13 Apr 2011 07:58:40 -0400 Subject: [PATCH 386/947] add grep fix to history --- docs/en/history.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index 3da8b6b..6aefc23 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -31,6 +31,8 @@ dev (:bbissue:`78`). - Fixed a problem with running :ref:`command-rmvirtualenv` from within the environment being removed (:bbissue:`83`). + - Removed use of -e option in calls to grep for better portability + (:bbissue:`85`). 2.6.3 From e1d1e10a6211531217f00c90fd686c35f247acf6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 13 Apr 2011 08:14:53 -0400 Subject: [PATCH 387/947] update version and draft announcement --- announce.rst | 36 ++++++++++++++++++++++++++++++------ docs/en/history.rst | 2 +- docs/sphinx/conf.py | 2 +- setup.py | 2 +- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/announce.rst b/announce.rst index e0940d6..c6318f5 100644 --- a/announce.rst +++ b/announce.rst @@ -1,3 +1,7 @@ +======================= + virtualenvwrapper 2.7 +======================= + What is virtualenvwrapper ========================= @@ -7,15 +11,35 @@ virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. -What's New in 2.2.1 +What's New in 2.7 ================= -Version 2.2.1 is a bug-fix release: +This release clears most of the bugs from the backlog and adds a few +new features. -- Escape ``which`` calls to avoid aliases. (#46) -- Integrate Manuel Kaufmann's patch to unset GREP_OPTIONS before - calling grep. (#51) -- Escape ``$`` in regex to resolve #53. +- Fix problem with space in WORKON_HOME path (#79). +- Fix problem with argument processing in ``lsvirtualenv`` under zsh + (#86). Thanks to Nat Williams for the bug report and patch. +- If WORKON_HOME does not exist, create it. Patch from Carl + Karsten. Test updates based on patches from Matt Austin + and Hugo Lopes Tavares. +- Merge in contributions from Paul McLanahan to fix the test harness + to ensure that the test scripts are actually running under the + expected shell. +- Merge in new shell command ``toggleglobalsitepackages`` from Paul + McLanahan. The new command changes the configuration of the active + virtualenv to enable or disable the global ``site-packages`` + directory. +- Fixed some tests that were failing under ksh on Ubuntu 10.10. +- Document the ``VIRTUALENVWRAPPER_VIRTUALENV`` variable. +- Implement suggestion by Van Lindberg to have + ``VIRTUALENVWRAPPER_HOOK_DIR`` and ``VIRTUALENVWRAPPER_LOG_DIR`` + variables to control the locations of hooks and logs. +- Enabled tab completion for ``showvirtualenv`` (#78). +- Fixed a problem with running ``rmvirtualenv`` from within the + environment being removed (#83). +- Removed use of -e option in calls to grep for better portability + (#85`). .. _virtualenv: http://pypi.python.org/pypi/virtualenv diff --git a/docs/en/history.rst b/docs/en/history.rst index 6aefc23..b785cdf 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,7 +2,7 @@ Release History =============== -dev +2.7 - Fix problem with space in WORKON_HOME path (:bbissue:`79`). - Fix problem with argument processing in lsvirtualenv under zsh diff --git a/docs/sphinx/conf.py b/docs/sphinx/conf.py index 40c4859..4357a0c 100644 --- a/docs/sphinx/conf.py +++ b/docs/sphinx/conf.py @@ -47,7 +47,7 @@ # built documents. # # The short X.Y version. -version = '2.6.3' +version = '2.7' # The full version, including alpha/beta/rc tags. release = version diff --git a/setup.py b/setup.py index c38cb54..8212602 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ PROJECT = 'virtualenvwrapper' # Change docs/sphinx/conf.py too! -VERSION = '2.6.3' +VERSION = '2.7' # Bootstrap installation of Distribute import distribute_setup From b28ba904d221cdf1f55f6271f9c2d770f5be1443 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 13 Apr 2011 08:16:24 -0400 Subject: [PATCH 388/947] Added tag 2.7 for changeset ea378ef00313 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 9590faf..0f41f16 100644 --- a/.hgtags +++ b/.hgtags @@ -70,3 +70,4 @@ b0f27c65fa64627599c2a022a076ae5ee7157ae4 2.6 e7582879df06689ec54cd820c377e89114b75ee2 2.6.3 e7582879df06689ec54cd820c377e89114b75ee2 2.6.3 246ce68795ea9caeb88ec2fa17e4f3151c58cf3f 2.6.3 +ea378ef00313cd77d251e61b4c0422503972b79f 2.7 From caa2c979a3c07e0ddcde7da64319bbdb3a7ee23c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 13 Apr 2011 08:34:46 -0400 Subject: [PATCH 389/947] report an error if there are no test scripts --- tests/run_tests | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/run_tests b/tests/run_tests index 369ce6f..a773fb1 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -12,6 +12,11 @@ scripts="$*" if [ -z "$scripts" ] then scripts=$(ls tests/test*.sh) + if [ -z "$scripts" ] + then + echo "Could not find any test scripts to run" 1>&2 + exit 1 + fi fi # Force the tox virtualenv to be active. From b1f4fcda2815eed2c3166a049d30fb6903380332 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 16 Apr 2011 15:35:27 -0400 Subject: [PATCH 390/947] clarify instructions for running tests; fixes #92 --- docs/en/developers.rst | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/docs/en/developers.rst b/docs/en/developers.rst index 9b67e8e..09b5c80 100644 --- a/docs/en/developers.rst +++ b/docs/en/developers.rst @@ -64,11 +64,30 @@ The output version of the documentation ends up in Running Tests ============= -The test suite for virtualenvwrapper uses `shunit2 -`_ and `tox -`_. To run the tests under bash, sh, and -zsh for Python 2.4-2.7, use ``tox`` from the top level directory of -the hg repository. - -Add new tests by modifying or creating an appropriate script in the -``tests`` directory. +The test suite for virtualenvwrapper uses shunit2_ and tox_. The +shunit2 source is included in the ``tests`` directory, but tox must be +installed separately (``pip install tox``). + +To run the tests under bash, zsh, and ksh for Python 2.4 through 2.7, +run ``tox`` from the top level directory of the hg repository. + +To run individual test scripts, use a command like:: + + $ tox tests/test_cd.sh + +To run tests under a single version of Python, specify the appropriate +environment when running tox:: + + $ tox -e py27 + +Combine the two modes to run specific tests with a single version of +Python:: + + $ tox -e py27 tests/test_cd.sh + +Add new tests by modifying an existing file or creating new script in +the ``tests`` directory. + +.. _shunit2: http://shunit2.googlecode.com/ + +.. _tox: http://codespeak.net/tox From c5d40b839ee79a705454c9b139dd9cd0ffa4dd5a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 17 Apr 2011 09:54:12 -0400 Subject: [PATCH 391/947] add a warning about installing into a virtualenv --- docs/en/install.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/en/install.rst b/docs/en/install.rst index 3f833aa..082627f 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -34,6 +34,11 @@ You will want to install it into the global Python site-packages area, along with virtualenv. You may need administrative privileges to do that. +.. warning:: + + You almost certainly do not want to install virtualenvwrapper into + a virtualenv. + An alternative to installing it into the global site-packages is to add it to your user local directory (usually `~/.local`). From d06ead64c51fa55911ae7fee4d8713cc695a5da8 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 17 Apr 2011 10:42:04 -0400 Subject: [PATCH 392/947] further installation doc clarification --- docs/en/install.rst | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/en/install.rst b/docs/en/install.rst index 082627f..7d1467e 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -26,18 +26,24 @@ virtualenvwrapper is tested under Python 2.4 - 2.7. Basic Installation ================== -virtualenvwrapper should be installed using pip_:: +virtualenvwrapper should be installed into the same global +site-packages area where virtualenv is installed. You may need +administrative privileges to do that. The easiest way to install it +is using pip_:: $ pip install virtualenvwrapper -You will want to install it into the global Python site-packages area, -along with virtualenv. You may need administrative privileges to do -that. +or:: + + $ sudo pip install virtualenvwrapper .. warning:: - You almost certainly do not want to install virtualenvwrapper into - a virtualenv. + virtualenv lets you create many different Python environments. You + should only ever install virtualenv and virtualenvwrapper on your + base Python installation (i.e. NOT while a virtualenv is active) + so that the same release is shared by all Python environments that + depend on it. An alternative to installing it into the global site-packages is to add it to your user local directory (usually `~/.local`). From 5967013f816aba9773d182385a69992534dab7e0 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 17 Apr 2011 10:45:00 -0400 Subject: [PATCH 393/947] link to documentation about installing into user directory --- docs/en/install.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/en/install.rst b/docs/en/install.rst index 7d1467e..22b4ee7 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -46,7 +46,9 @@ or:: depend on it. An alternative to installing it into the global site-packages is to -add it to your user local directory (usually `~/.local`). +add it to `your user local directory +`__ +(usually `~/.local`). :: From 55ee2f779033fb6e5dedff29be0186657ec8b998 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 17 Apr 2011 13:41:50 -0400 Subject: [PATCH 394/947] set log dir and hook dir variables after WORKON_HOME is set; fixes #94 --- docs/en/history.rst | 11 +++++++++++ docs/en/install.rst | 2 ++ tests/test_log_dir.sh | 22 +++++++++------------- virtualenvwrapper.sh | 28 +++++++++++++++------------- 4 files changed, 37 insertions(+), 26 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index b785cdf..9ba70ff 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,17 @@ Release History =============== +2.7.1 + + - When testing for WORKON_HOME during startup, dereference any + symlink to make sure it is a directory. + - Set VIRTUALENVWRAPPER_HOOK_DIR and VIRTUALENV_WRAPPER_LOG DIR in + virtualenvwrapper_initialize after WORKON_HOME is set + (:bbissue:`94`). + - Update the :ref:`install-basic` instructions to be more explicit + about needing to install virtualenvwrapper globally (or at least + outside of a virtualenv). + 2.7 - Fix problem with space in WORKON_HOME path (:bbissue:`79`). diff --git a/docs/en/install.rst b/docs/en/install.rst index 22b4ee7..154ac62 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -23,6 +23,8 @@ Python Versions virtualenvwrapper is tested under Python 2.4 - 2.7. +.. _install-basic: + Basic Installation ================== diff --git a/tests/test_log_dir.sh b/tests/test_log_dir.sh index e2eb325..2a1fc45 100644 --- a/tests/test_log_dir.sh +++ b/tests/test_log_dir.sh @@ -6,27 +6,23 @@ test_dir=$(cd $(dirname $0) && pwd) export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" -oneTimeSetUp() { - rm -rf "$WORKON_HOME" - mkdir -p "$WORKON_HOME" - mkdir -p "$WORKON_HOME/hooks" -} - -oneTimeTearDown() { - rm -rf "$WORKON_HOME" -} - setUp () { echo - rm -f "$test_dir/catch_output" - rm -f "$WORKON_HOME/hooks/*" } -test_virtualenvwrapper_initialize() { +test_set_by_user() { export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME/logs" mkdir -p "$VIRTUALENVWRAPPER_LOG_DIR" source "$test_dir/../virtualenvwrapper.sh" assertTrue "Log file was not created" "[ -f $WORKON_HOME/logs/hook.log ]" } +test_not_set_by_user() { + unset WORKON_HOME + unset VIRTUALENVWRAPPER_LOG_DIR + unset VIRTUALENVWRAPPER_HOOK_DIR + source "$test_dir/../virtualenvwrapper.sh" + assertSame "$WORKON_HOME" "$VIRTUALENVWRAPPER_LOG_DIR" +} + . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 5255217..abd5bc0 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -56,18 +56,6 @@ then VIRTUALENVWRAPPER_VIRTUALENV="virtualenv" fi -# Set the location of the hook scripts -if [ "$VIRTUALENVWRAPPER_HOOK_DIR" = "" ] -then - export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME" -fi - -# Set the location of the hook script logs -if [ "$VIRTUALENVWRAPPER_LOG_DIR" = "" ] -then - export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME" -fi - virtualenvwrapper_derive_workon_home() { typeset workon_home_dir="$WORKON_HOME" @@ -108,7 +96,7 @@ virtualenvwrapper_derive_workon_home() { # and maybe other things rely on the dir existing before that happens. virtualenvwrapper_verify_workon_home () { RC=0 - if [ ! -d "$WORKON_HOME" ] + if [ ! -d "$WORKON_HOME/" ] then if [ "$1" != "-q" ] then @@ -164,7 +152,21 @@ virtualenvwrapper_run_hook () { # Set up virtualenvwrapper properly virtualenvwrapper_initialize () { export WORKON_HOME="$(virtualenvwrapper_derive_workon_home)" + virtualenvwrapper_verify_workon_home -q || return 1 + + # Set the location of the hook scripts + if [ "$VIRTUALENVWRAPPER_HOOK_DIR" = "" ] + then + export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME" + fi + + # Set the location of the hook script logs + if [ "$VIRTUALENVWRAPPER_LOG_DIR" = "" ] + then + export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME" + fi + virtualenvwrapper_run_hook "initialize" if [ $? -ne 0 ] then From 0dd1f0120d9e91f9ee6b44c284162cc3e347aefe Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 17 Apr 2011 13:42:07 -0400 Subject: [PATCH 395/947] bump version number for bug release --- docs/sphinx/conf.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/conf.py b/docs/sphinx/conf.py index 4357a0c..c7b4474 100644 --- a/docs/sphinx/conf.py +++ b/docs/sphinx/conf.py @@ -47,7 +47,7 @@ # built documents. # # The short X.Y version. -version = '2.7' +version = '2.7.1' # The full version, including alpha/beta/rc tags. release = version diff --git a/setup.py b/setup.py index 8212602..81cad92 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ PROJECT = 'virtualenvwrapper' # Change docs/sphinx/conf.py too! -VERSION = '2.7' +VERSION = '2.7.1' # Bootstrap installation of Distribute import distribute_setup From b55baeed237888d8141a87a76fd7b47e9c5f03ea Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 17 Apr 2011 13:42:28 -0400 Subject: [PATCH 396/947] Added tag 2.7.1 for changeset b20cf787d8e1 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 0f41f16..526621d 100644 --- a/.hgtags +++ b/.hgtags @@ -71,3 +71,4 @@ e7582879df06689ec54cd820c377e89114b75ee2 2.6.3 e7582879df06689ec54cd820c377e89114b75ee2 2.6.3 246ce68795ea9caeb88ec2fa17e4f3151c58cf3f 2.6.3 ea378ef00313cd77d251e61b4c0422503972b79f 2.7 +b20cf787d8e1c167853709ca01731a3efb4b5fe8 2.7.1 From f91d71788843393220845aa8744596e6cd50d806 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 17 Apr 2011 14:20:56 -0400 Subject: [PATCH 397/947] update announce file --- announce.rst | 38 +++++++------------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/announce.rst b/announce.rst index c6318f5..5ab6ea8 100644 --- a/announce.rst +++ b/announce.rst @@ -1,6 +1,6 @@ -======================= - virtualenvwrapper 2.7 -======================= +========================= + virtualenvwrapper 2.7.1 +========================= What is virtualenvwrapper ========================= @@ -11,35 +11,11 @@ virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. -What's New in 2.7 -================= - -This release clears most of the bugs from the backlog and adds a few -new features. +What's New in 2.7.1 +=================== -- Fix problem with space in WORKON_HOME path (#79). -- Fix problem with argument processing in ``lsvirtualenv`` under zsh - (#86). Thanks to Nat Williams for the bug report and patch. -- If WORKON_HOME does not exist, create it. Patch from Carl - Karsten. Test updates based on patches from Matt Austin - and Hugo Lopes Tavares. -- Merge in contributions from Paul McLanahan to fix the test harness - to ensure that the test scripts are actually running under the - expected shell. -- Merge in new shell command ``toggleglobalsitepackages`` from Paul - McLanahan. The new command changes the configuration of the active - virtualenv to enable or disable the global ``site-packages`` - directory. -- Fixed some tests that were failing under ksh on Ubuntu 10.10. -- Document the ``VIRTUALENVWRAPPER_VIRTUALENV`` variable. -- Implement suggestion by Van Lindberg to have - ``VIRTUALENVWRAPPER_HOOK_DIR`` and ``VIRTUALENVWRAPPER_LOG_DIR`` - variables to control the locations of hooks and logs. -- Enabled tab completion for ``showvirtualenv`` (#78). -- Fixed a problem with running ``rmvirtualenv`` from within the - environment being removed (#83). -- Removed use of -e option in calls to grep for better portability - (#85`). +This release includes a fix for a minor intialization problem in 2.7 +and updated installization instructions for first-time users. .. _virtualenv: http://pypi.python.org/pypi/virtualenv From 8a74267dc49fe96a19db31a84498e91f1142dff4 Mon Sep 17 00:00:00 2001 From: "Axel H." Date: Tue, 17 May 2011 10:46:06 +0200 Subject: [PATCH 398/947] Added msys paths support --- virtualenvwrapper.sh | 19 ++++++++++---- virtualenvwrapper/user_scripts.py | 42 +++++++++++++++++++++++++------ 2 files changed, 49 insertions(+), 12 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index abd5bc0..94f5b46 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -56,6 +56,15 @@ then VIRTUALENVWRAPPER_VIRTUALENV="virtualenv" fi +# Define script folder depending on the platorm (Win32/Unix) +script_folder="bin" +if [ "$OS" = "Windows_NT" ] && [ "$MSYSTEM" = "MINGW32" ] +then + # Only assign this for msys, cygwin use standard Unix paths + # and its own python installation + script_folder="Scripts" +fi + virtualenvwrapper_derive_workon_home() { typeset workon_home_dir="$WORKON_HOME" @@ -277,7 +286,7 @@ virtualenvwrapper_show_workon_options () { # NOTE: DO NOT use ls here because colorized versions spew control characters # into the output list. # echo seems a little faster than find, even with -depth 3. - (cd "$WORKON_HOME"; for f in */bin/activate; do echo $f; done) 2>/dev/null | \sed 's|^\./||' | \sed 's|/bin/activate||' | \sort | (unset GREP_OPTIONS; \egrep -v '^\*$') + (cd "$WORKON_HOME"; for f in */$script_folder/activate; do echo $f; done) 2>/dev/null | \sed 's|^\./||' | \sed 's|/bin/activate||' | \sort | (unset GREP_OPTIONS; \egrep -v '^\*$') # (cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort } @@ -357,7 +366,7 @@ workon () { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_workon_environment $env_name || return 1 - activate="$WORKON_HOME/$env_name/bin/activate" + activate="$WORKON_HOME/$env_name/$script_folder/activate" if [ ! -f "$activate" ] then echo "ERROR: Environment '$WORKON_HOME/$env_name' does not contain an activate script." >&2 @@ -390,7 +399,7 @@ workon () { # any settings made by the local postactivate first. virtualenvwrapper_run_hook "pre_deactivate" - env_postdeactivate_hook="$VIRTUAL_ENV/bin/postdeactivate" + env_postdeactivate_hook="$VIRTUAL_ENV/$script_folder/postdeactivate" old_env=$(basename "$VIRTUAL_ENV") # Call the original function. @@ -589,7 +598,7 @@ cpvirtualenv() { fi \cp -r "$source_env" "$target_env" - for script in $( \ls $target_env/bin/* ) + for script in $( \ls $target_env/$script_folder/* ) do newscript="$script-new" \sed "s|$source_env|$target_env|g" < "$script" > "$newscript" @@ -598,7 +607,7 @@ cpvirtualenv() { done virtualenv "$target_env" --relocatable - \sed "s/VIRTUAL_ENV\(.*\)$env_name/VIRTUAL_ENV\1$new_env/g" < "$source_env/bin/activate" > "$target_env/bin/activate" + \sed "s/VIRTUAL_ENV\(.*\)$env_name/VIRTUAL_ENV\1$new_env/g" < "$source_env/bin/activate" > "$target_env/$script_folder/activate" (cd "$WORKON_HOME" && ( virtualenvwrapper_run_hook "pre_cpvirtualenv" "$env_name" "$new_env"; diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 521212a..2b4c178 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -8,19 +8,31 @@ import logging import os +import re import stat import subprocess +import sys import pkg_resources log = logging.getLogger(__name__) + +# Are we running under msys +if sys.platform == 'win32' and os.environ.get('OS') == 'Windows_NT' and os.environ.get('MSYSTEM') == 'MINGW32': + msys = True + script_folder = 'Scripts' +else: + script_folder = 'bin' + def run_script(script_path, *args): """Execute a script in a subshell. """ if os.path.exists(script_path): cmd = [script_path] + list(args) + if msys: + cmd = [os.path.join(os.environ['MSYS_HOME'],'bin','sh.exe')] + cmd log.debug('running %s', str(cmd)) try: return_code = subprocess.call(cmd) @@ -33,7 +45,7 @@ def run_script(script_path, *args): def run_global(script_name, *args): """Run a script from $VIRTUALENVWRAPPER_HOOK_DIR. """ - script_path = os.path.expandvars(os.path.join('$VIRTUALENVWRAPPER_HOOK_DIR', script_name)) + script_path = get_path('$VIRTUALENVWRAPPER_HOOK_DIR', script_name) run_script(script_path, *args) return @@ -101,7 +113,7 @@ def make_hook(filename, comment): :param filename: The name of the file to write. :param comment: The comment to insert into the file. """ - filename = os.path.expanduser(os.path.expandvars(filename)) + filename = get_path(filename) if not os.path.exists(filename): log.info('creating %s', filename) f = open(filename, 'w') @@ -122,7 +134,7 @@ def make_hook(filename, comment): def initialize(args): for filename, comment in GLOBAL_HOOKS: - make_hook(os.path.join('$VIRTUALENVWRAPPER_HOOK_DIR', filename), comment) + make_hook(get_path('$VIRTUALENVWRAPPER_HOOK_DIR', filename), comment) return @@ -138,7 +150,7 @@ def pre_mkvirtualenv(args): log.debug('pre_mkvirtualenv %s', str(args)) envname=args[0] for filename, comment in LOCAL_HOOKS: - make_hook(os.path.join('$WORKON_HOME', envname, 'bin', filename), comment) + make_hook(get_path('$WORKON_HOME', envname, script_folder, filename), comment) run_global('premkvirtualenv', *args) return @@ -155,7 +167,7 @@ def pre_cpvirtualenv(args): log.debug('pre_cpvirtualenv %s', str(args)) envname=args[0] for filename, comment in LOCAL_HOOKS: - make_hook(os.path.join('$WORKON_HOME', envname, 'bin', filename), comment) + make_hook(get_path('$WORKON_HOME', envname, script_folder, filename), comment) run_global('precpvirtualenv', *args) return @@ -184,7 +196,7 @@ def post_rmvirtualenv(args): def pre_activate(args): log.debug('pre_activate') run_global('preactivate', *args) - script_path = os.path.expandvars(os.path.join('$WORKON_HOME', args[0], 'bin', 'preactivate')) + script_path = get_path('$WORKON_HOME', args[0], script_folder, 'preactivate') run_script(script_path, *args) return @@ -227,6 +239,22 @@ def post_deactivate_source(args): def get_env_details(args): log.debug('get_env_details') run_global('get_env_details', *args) - script_path = os.path.expandvars(os.path.join('$WORKON_HOME', args[0], 'bin', 'get_env_details')) + script_path = get_path('$WORKON_HOME', args[0], script_folder, 'get_env_details') run_script(script_path, *args) return + +def get_path(*args): + ''' + Get a full path from args. + Path separator is determined according to the os and the shell and allow to use msys. + Variables and user are expanded during the process. + ''' + path = os.path.expanduser(os.path.expandvars(os.path.join(*args))) + if msys: + # MSYS accept unix or Win32 and sometimes it conduce to mixed style paths + if re.match(r'^/[a-zA-Z](/|^)', path): + # msys path could starts with '/c/'-form drive letter + path = ''.join((path[1],':',path[2:])) + path = path.replace('/', os.sep) + + return os.path.abspath(path) From 99483393e1da7ca449e9f965e5027bfed9378416 Mon Sep 17 00:00:00 2001 From: "Axel H." Date: Tue, 17 May 2011 11:18:30 +0200 Subject: [PATCH 399/947] Allow Win32 and Unix paths for MSYS_HOME variable --- virtualenvwrapper/user_scripts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 2b4c178..4cea06f 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -32,7 +32,7 @@ def run_script(script_path, *args): if os.path.exists(script_path): cmd = [script_path] + list(args) if msys: - cmd = [os.path.join(os.environ['MSYS_HOME'],'bin','sh.exe')] + cmd + cmd = [get_path(os.environ['MSYS_HOME'],'bin','sh.exe')] + cmd log.debug('running %s', str(cmd)) try: return_code = subprocess.call(cmd) From e6c11fda68ed03b286e3fedeb4709cfbb5ddfd1e Mon Sep 17 00:00:00 2001 From: "Axel H." Date: Tue, 17 May 2011 11:18:49 +0200 Subject: [PATCH 400/947] Document MSys installation --- docs/en/install.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/en/install.rst b/docs/en/install.rst index 154ac62..d2c84ed 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -196,3 +196,23 @@ supported. In your startup file, change ``source /usr/local/bin/virtualenvwrapper.sh``. .. _pip: http://pypi.python.org/pypi/pip + +Using virtualenvwrapper into MSys +================================= + +It is possible to use virtualenv wrapper into msys or msysgit with a +native Windows Python installation. +In order to make it work, you need to define an extra environment +variable named ``MSYS_HOME`` containing the root path to msys installation. + + export WORKON_HOME=$HOME/.virtualenvs + export MSYS_HOME=/c/msys/1.0 + source /usr/local/bin/virtualenvwrapper.sh + +or + + export WORKON_HOME=$HOME/.virtualenvs + export MSYS_HOME=C:\msys\1.0 + source /usr/local/bin/virtualenvwrapper.sh + +Right now, ``lsvirtualenv`` is not working because of the lack of ``getopt`` under msys. From a20f320b3578274b371d5fece2289497eb4726c2 Mon Sep 17 00:00:00 2001 From: "Axel H." Date: Thu, 19 May 2011 14:51:22 +0200 Subject: [PATCH 401/947] Improved variable name: VIRTUALENVWRAPPER_ENV_BIN_DIR instead of script_folder and is_msys instead of msys. --- virtualenvwrapper.sh | 14 +++++++------- virtualenvwrapper/user_scripts.py | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 94f5b46..17140ae 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -57,12 +57,12 @@ then fi # Define script folder depending on the platorm (Win32/Unix) -script_folder="bin" +VIRTUALENVWRAPPER_ENV_BIN_DIR="bin" if [ "$OS" = "Windows_NT" ] && [ "$MSYSTEM" = "MINGW32" ] then # Only assign this for msys, cygwin use standard Unix paths # and its own python installation - script_folder="Scripts" + VIRTUALENVWRAPPER_ENV_BIN_DIR="Scripts" fi virtualenvwrapper_derive_workon_home() { @@ -286,7 +286,7 @@ virtualenvwrapper_show_workon_options () { # NOTE: DO NOT use ls here because colorized versions spew control characters # into the output list. # echo seems a little faster than find, even with -depth 3. - (cd "$WORKON_HOME"; for f in */$script_folder/activate; do echo $f; done) 2>/dev/null | \sed 's|^\./||' | \sed 's|/bin/activate||' | \sort | (unset GREP_OPTIONS; \egrep -v '^\*$') + (cd "$WORKON_HOME"; for f in */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate; do echo $f; done) 2>/dev/null | \sed 's|^\./||' | \sed 's|/bin/activate||' | \sort | (unset GREP_OPTIONS; \egrep -v '^\*$') # (cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort } @@ -366,7 +366,7 @@ workon () { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_workon_environment $env_name || return 1 - activate="$WORKON_HOME/$env_name/$script_folder/activate" + activate="$WORKON_HOME/$env_name/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate" if [ ! -f "$activate" ] then echo "ERROR: Environment '$WORKON_HOME/$env_name' does not contain an activate script." >&2 @@ -399,7 +399,7 @@ workon () { # any settings made by the local postactivate first. virtualenvwrapper_run_hook "pre_deactivate" - env_postdeactivate_hook="$VIRTUAL_ENV/$script_folder/postdeactivate" + env_postdeactivate_hook="$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/postdeactivate" old_env=$(basename "$VIRTUAL_ENV") # Call the original function. @@ -598,7 +598,7 @@ cpvirtualenv() { fi \cp -r "$source_env" "$target_env" - for script in $( \ls $target_env/$script_folder/* ) + for script in $( \ls $target_env/$VIRTUALENVWRAPPER_ENV_BIN_DIR/* ) do newscript="$script-new" \sed "s|$source_env|$target_env|g" < "$script" > "$newscript" @@ -607,7 +607,7 @@ cpvirtualenv() { done virtualenv "$target_env" --relocatable - \sed "s/VIRTUAL_ENV\(.*\)$env_name/VIRTUAL_ENV\1$new_env/g" < "$source_env/bin/activate" > "$target_env/$script_folder/activate" + \sed "s/VIRTUAL_ENV\(.*\)$env_name/VIRTUAL_ENV\1$new_env/g" < "$source_env/bin/activate" > "$target_env/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate" (cd "$WORKON_HOME" && ( virtualenvwrapper_run_hook "pre_cpvirtualenv" "$env_name" "$new_env"; diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 4cea06f..fc1054b 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -20,7 +20,7 @@ # Are we running under msys if sys.platform == 'win32' and os.environ.get('OS') == 'Windows_NT' and os.environ.get('MSYSTEM') == 'MINGW32': - msys = True + is_msys = True script_folder = 'Scripts' else: script_folder = 'bin' @@ -31,7 +31,7 @@ def run_script(script_path, *args): """ if os.path.exists(script_path): cmd = [script_path] + list(args) - if msys: + if is_msys: cmd = [get_path(os.environ['MSYS_HOME'],'bin','sh.exe')] + cmd log.debug('running %s', str(cmd)) try: @@ -246,12 +246,12 @@ def get_env_details(args): def get_path(*args): ''' Get a full path from args. - Path separator is determined according to the os and the shell and allow to use msys. + Path separator is determined according to the os and the shell and allow to use is_msys. Variables and user are expanded during the process. ''' path = os.path.expanduser(os.path.expandvars(os.path.join(*args))) - if msys: - # MSYS accept unix or Win32 and sometimes it conduce to mixed style paths + if is_msys: + # MSYS accept unix or Win32 and sometimes it drives to mixed style paths if re.match(r'^/[a-zA-Z](/|^)', path): # msys path could starts with '/c/'-form drive letter path = ''.join((path[1],':',path[2:])) From f40ffce8d2d50a73c8b6689de00589e9dd3f38d4 Mon Sep 17 00:00:00 2001 From: "Axel H." Date: Thu, 19 May 2011 16:56:36 +0200 Subject: [PATCH 402/947] Added support for getopts with fallback on getopt. --- virtualenvwrapper.sh | 56 ++++++++++++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 17140ae..778b524 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -291,6 +291,12 @@ virtualenvwrapper_show_workon_options () { # (cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort } + +# test if a given command exists +command_exists () { + command -v "$1" &> /dev/null ; +} + _lsvirtualenv_usage () { echo "lsvirtualenv [-blh]" echo " -b -- brief mode" @@ -302,23 +308,43 @@ _lsvirtualenv_usage () { # # Usage: lsvirtualenv [-l] lsvirtualenv () { - typeset -a args - args=($(getopt blh "$@")) - if [ $? != 0 ] + + typeset long_mode=true + if command_exists getopts then - _lsvirtualenv_usage - return 1 + # Use getopts when possible + OPTIND=1 + while getopts ":blh" opt "$@" + do + case "$opt" in + l) long_mode=true;; + b) long_mode=false;; + h) _lsvirtualenv_usage; + return 1;; + ?) echo "Invalid option: -$OPTARG" >&2; + _lsvirtualenv_usage; + return 1;; + esac + done + else + # fallback on getopt for other shell + typeset -a args + args=($(getopt blh "$@")) + if [ $? != 0 ] + then + _lsvirtualenv_usage + return 1 + fi + for opt in $args + do + case "$opt" in + -l) long_mode=true;; + -b) long_mode=false;; + -h) _lsvirtualenv_usage; + return 1;; + esac + done fi - typeset long_mode=true - for opt in $args - do - case "$opt" in - -l) long_mode=true;; - -b) long_mode=false;; - -h) _lsvirtualenv_usage; - return 1;; - esac - done if $long_mode then From c23f915d25688a9ad35eb2621510dcd3e015b95b Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 30 May 2011 14:45:19 -0400 Subject: [PATCH 403/947] move tab completion initialization; expand support for tab completion in zsh (fixes #97) --- docs/en/history.rst | 6 ++++ virtualenvwrapper.sh | 76 ++++++++++++++++++++++++-------------------- 2 files changed, 48 insertions(+), 34 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 9ba70ff..efed50d 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,12 @@ Release History =============== +2.7.2 + + - Move setup code for tab completion later in the startup code so + all of the needed variables are configured. (:bbissue:`97`) + - Expand tab completion for zsh to work for all commands. + 2.7.1 - When testing for WORKON_HOME during startup, dereference any diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index abd5bc0..6ebebf2 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -149,6 +149,44 @@ virtualenvwrapper_run_hook () { return $result } +# Set up tab completion. (Adapted from Arthur Koziel's version at +# http://arthurkoziel.com/2008/10/11/virtualenvwrapper-bash-completion/) +virtualenvwrapper_setup_tab_completion () { + if [ -n "$BASH" ] ; then + _virtualenvs () { + local cur="${COMP_WORDS[COMP_CWORD]}" + COMPREPLY=( $(compgen -W "`virtualenvwrapper_show_workon_options`" -- ${cur}) ) + } + _cdvirtualenv_complete () { + local cur="$2" + COMPREPLY=( $(cdvirtualenv && compgen -d -- "${cur}" ) ) + } + _cdsitepackages_complete () { + local cur="$2" + COMPREPLY=( $(cdsitepackages && compgen -d -- "${cur}" ) ) + } + complete -o nospace -F _cdvirtualenv_complete -S/ cdvirtualenv + complete -o nospace -F _cdsitepackages_complete -S/ cdsitepackages + complete -o default -o nospace -F _virtualenvs workon + complete -o default -o nospace -F _virtualenvs rmvirtualenv + complete -o default -o nospace -F _virtualenvs cpvirtualenv + complete -o default -o nospace -F _virtualenvs showvirtualenv + elif [ -n "$ZSH_VERSION" ] ; then + _virtualenvs () { + reply=( $(virtualenvwrapper_show_workon_options) ) + } + _cdvirtualenv_complete () { + reply=( $(cdvirtualenv && ls -d ${1}*) ) + } + _cdsitepackages_complete () { + reply=( $(cdsitepackages && ls -d ${1}*) ) + } + compctl -K _virtualenvs workon rmvirtualenv cpvirtualenv showvirtualenv + compctl -K _cdvirtualenv_complete cdvirtualenv + compctl -K _cdsitepackages_complete cdsitepackages + fi +} + # Set up virtualenvwrapper properly virtualenvwrapper_initialize () { export WORKON_HOME="$(virtualenvwrapper_derive_workon_home)" @@ -173,8 +211,12 @@ virtualenvwrapper_initialize () { echo "virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON and that PATH is set properly." 1>&2 return 1 fi + + virtualenvwrapper_setup_tab_completion + } + # Verify that virtualenv is installed and visible virtualenvwrapper_verify_virtualenv () { typeset venv=$(\which "$VIRTUALENVWRAPPER_VIRTUALENV" | (unset GREP_OPTIONS; \grep -v "not found")) @@ -413,40 +455,6 @@ workon () { } -# -# Set up tab completion. (Adapted from Arthur Koziel's version at -# http://arthurkoziel.com/2008/10/11/virtualenvwrapper-bash-completion/) -# - -if [ -n "$BASH" ] ; then - _virtualenvs () - { - local cur="${COMP_WORDS[COMP_CWORD]}" - COMPREPLY=( $(compgen -W "`virtualenvwrapper_show_workon_options`" -- ${cur}) ) - } - - - _cdvirtualenv_complete () - { - local cur="$2" - # COMPREPLY=( $(compgen -d -- "${VIRTUAL_ENV}/${cur}" | sed -e "s@${VIRTUAL_ENV}/@@" ) ) - COMPREPLY=( $(cdvirtualenv && compgen -d -- "${cur}" ) ) - } - _cdsitepackages_complete () - { - local cur="$2" - COMPREPLY=( $(cdsitepackages && compgen -d -- "${cur}" ) ) - } - complete -o nospace -F _cdvirtualenv_complete -S/ cdvirtualenv - complete -o nospace -F _cdsitepackages_complete -S/ cdsitepackages - complete -o default -o nospace -F _virtualenvs workon - complete -o default -o nospace -F _virtualenvs rmvirtualenv - complete -o default -o nospace -F _virtualenvs cpvirtualenv - complete -o default -o nospace -F _virtualenvs showvirtualenv -elif [ -n "$ZSH_VERSION" ] ; then - compctl -g "`virtualenvwrapper_show_workon_options`" workon rmvirtualenv cpvirtualenv showvirtualenv -fi - # Prints the Python version string for the current interpreter. virtualenvwrapper_get_python_version () { # Uses the Python from the virtualenv because we're trying to From 639fe5dea2502316284a6bf724eeafcf0bd0fcf3 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 30 May 2011 15:09:13 -0400 Subject: [PATCH 404/947] add some debugging and a test to try to reproduce problem with log directory variable; addresses #95 --- tests/test_run_hook.sh | 7 +++++++ virtualenvwrapper.sh | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/tests/test_run_hook.sh b/tests/test_run_hook.sh index 27b444a..29b1430 100755 --- a/tests/test_run_hook.sh +++ b/tests/test_run_hook.sh @@ -67,4 +67,11 @@ test_virtualenvwrapper_run_hook_permissions() { assertSame "Errno 13] Permission denied" "$error" } +test_virtualenvwrapper_run_hook_without_log_dir() { + old_log_dir="$VIRTUALENVWRAPPER_LOG_DIR" + unset VIRTUALENVWRAPPER_LOG_DIR + assertFalse "virtualenvwrapper_run_hook initialize" + export VIRTUALENVWRAPPER_LOG_DIR="$old_log_dir" +} + . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 6ebebf2..1cfe700 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -133,6 +133,11 @@ virtualenvwrapper_run_hook () { echo "ERROR: Could not create temporary file name. Make sure TMPDIR is set." 1>&2 return 1 fi + if [ -z "$VIRTUALENVWRAPPER_LOG_DIR" ] + then + echo "ERROR: VIRTUALENVWRAPPER_LOG_DIR is not set." 1>&2 + return 1 + fi "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' $HOOK_VERBOSE_OPTION --script "$hook_script" "$@" result=$? From 6d07a512097734c0577eea4ce1370e13b0da9fcd Mon Sep 17 00:00:00 2001 From: Greg Haskins Date: Wed, 15 Jun 2011 16:17:24 -0400 Subject: [PATCH 405/947] User scripts should be called based on new $VIRTUALENVWRAPPER_ENV_BIN_DIR variable --- virtualenvwrapper/user_scripts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index fc1054b..fab2039 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -208,7 +208,7 @@ def post_activate_source(args): # Run user-provided scripts # [ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postactivate" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/postactivate" -[ -f "$VIRTUAL_ENV/bin/postactivate" ] && source "$VIRTUAL_ENV/bin/postactivate" +[ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/postactivate" ] && source "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/postactivate" """ @@ -218,7 +218,7 @@ def pre_deactivate_source(args): # # Run user-provided scripts # -[ -f "$VIRTUAL_ENV/bin/predeactivate" ] && source "$VIRTUAL_ENV/bin/predeactivate" +[ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/predeactivate" ] && source "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/predeactivate" [ -f "$VIRTUALENVWRAPPER_HOOK_DIR/predeactivate" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/predeactivate" """ From b13f4b749ae995619fabb6c96d910e3628f93abf Mon Sep 17 00:00:00 2001 From: Shrikant-Sharat Date: Sat, 16 Jul 2011 12:00:15 +0530 Subject: [PATCH 406/947] VIRTUALENVWRAPPER_VIRTUALENV_ARGS not working with >1 args on zsh --HG-- branch : args-in-zsh --- virtualenvwrapper.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 1cfe700..ab95546 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -268,11 +268,13 @@ mkvirtualenv () { eval "envname=\$$#" virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_virtualenv || return 1 - (cd "$WORKON_HOME" && + ( + [ -n "$ZSH_VERSION" ] && setopt SH_WORD_SPLIT + cd "$WORKON_HOME" && "$VIRTUALENVWRAPPER_VIRTUALENV" $VIRTUALENVWRAPPER_VIRTUALENV_ARGS "$@" && [ -d "$WORKON_HOME/$envname" ] && \ virtualenvwrapper_run_hook "pre_mkvirtualenv" "$envname" - ) + ) typeset RC=$? [ $RC -ne 0 ] && return $RC From 3da10cbde4e825194ca2a4881dfab92fe3ec31a3 Mon Sep 17 00:00:00 2001 From: "Axel H." Date: Thu, 11 Aug 2011 12:27:37 +0200 Subject: [PATCH 407/947] Update documentation about mktemp --- docs/en/install.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/en/install.rst b/docs/en/install.rst index d2c84ed..a089d8b 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -215,4 +215,6 @@ or export MSYS_HOME=C:\msys\1.0 source /usr/local/bin/virtualenvwrapper.sh -Right now, ``lsvirtualenv`` is not working because of the lack of ``getopt`` under msys. +Depending on your MSYS setup, you may need to install mktemp in +your MSYS_HOME/bin folder. The MSYS mktemp binary is available +here: http://sourceforge.net/projects/mingw/files/MSYS/mktemp/ From e6b02012bd472e965f7ea448de1e353bb8ace0e8 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 13 Aug 2011 09:31:05 -0400 Subject: [PATCH 408/947] Use VIRTUALENVWRAPPER_VIRTUALENV in cpvirtualenv. fixes #104 --- docs/en/history.rst | 4 ++++ tests/test_cp.sh | 14 ++++++++++++++ virtualenvwrapper.sh | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index efed50d..96f57c5 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,10 @@ Release History =============== +dev + + - Use VIRTUALENVWRAPPER_VIRTUALENV in `cpvirtualenv` (:bbissue:`104`). + 2.7.2 - Move setup code for tab completion later in the startup code so diff --git a/tests/test_cp.sh b/tests/test_cp.sh index db298c1..7b8a3ca 100755 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -43,6 +43,20 @@ test_virtual_env_variable () { assertTrue "$WORKON_HOME not in $VIRTUAL_ENV" "echo $VIRTUAL_ENV | grep -q $WORKON_HOME" } +fake_virtualenv () { + typeset envname="$1" + touch "$envname/fake_virtualenv_was_here" + virtualenv $@ +} + +test_virtualenvwrapper_virtualenv_variable () { + mkvirtualenv "source" + export VIRTUALENVWRAPPER_VIRTUALENV=fake_virtualenv + cpvirtualenv "source" "destination" + unset VIRTUALENVWRAPPER_VIRTUALENV + assertTrue "wrapper was not run" "[ -f $VIRTUAL_ENV/fake_virtualenv_was_here ]" +} + test_source_relocatable () { mkvirtualenv "source" (cd tests/testpackage && python setup.py install) >/dev/null 2>&1 diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index ab95546..38d6b36 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -612,7 +612,7 @@ cpvirtualenv() { \chmod a+x "$script" done - virtualenv "$target_env" --relocatable + "$VIRTUALENVWRAPPER_VIRTUALENV" "$target_env" --relocatable \sed "s/VIRTUAL_ENV\(.*\)$env_name/VIRTUAL_ENV\1$new_env/g" < "$source_env/bin/activate" > "$target_env/bin/activate" (cd "$WORKON_HOME" && ( From 0f32d315f3c0884f4b9caf89199a617355516b49 Mon Sep 17 00:00:00 2001 From: noirbizarre Date: Sat, 13 Aug 2011 16:40:15 +0200 Subject: [PATCH 409/947] Replaced all remaining 'bin' occurences by $VIRTUALENVWRAPPER_ENV_BIN_DIR --- virtualenvwrapper.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 778b524..e8e69df 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -286,7 +286,7 @@ virtualenvwrapper_show_workon_options () { # NOTE: DO NOT use ls here because colorized versions spew control characters # into the output list. # echo seems a little faster than find, even with -depth 3. - (cd "$WORKON_HOME"; for f in */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate; do echo $f; done) 2>/dev/null | \sed 's|^\./||' | \sed 's|/bin/activate||' | \sort | (unset GREP_OPTIONS; \egrep -v '^\*$') + (cd "$WORKON_HOME"; for f in */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate; do echo $f; done) 2>/dev/null | \sed 's|^\./||' | \sed 's|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate||' | \sort | (unset GREP_OPTIONS; \egrep -v '^\*$') # (cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort } @@ -633,7 +633,7 @@ cpvirtualenv() { done virtualenv "$target_env" --relocatable - \sed "s/VIRTUAL_ENV\(.*\)$env_name/VIRTUAL_ENV\1$new_env/g" < "$source_env/bin/activate" > "$target_env/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate" + \sed "s/VIRTUAL_ENV\(.*\)$env_name/VIRTUAL_ENV\1$new_env/g" < "$source_env/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate" > "$target_env/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate" (cd "$WORKON_HOME" && ( virtualenvwrapper_run_hook "pre_cpvirtualenv" "$env_name" "$new_env"; From 0f04dcf6f978cf6c1bbe8be382f996ad03cccb97 Mon Sep 17 00:00:00 2001 From: noirbizarre Date: Sat, 13 Aug 2011 16:49:41 +0200 Subject: [PATCH 410/947] Avoid declaring the 'command_exists' function for a one shot use. --- virtualenvwrapper.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index e8e69df..033d6b1 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -291,12 +291,6 @@ virtualenvwrapper_show_workon_options () { # (cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort } - -# test if a given command exists -command_exists () { - command -v "$1" &> /dev/null ; -} - _lsvirtualenv_usage () { echo "lsvirtualenv [-blh]" echo " -b -- brief mode" @@ -310,7 +304,7 @@ _lsvirtualenv_usage () { lsvirtualenv () { typeset long_mode=true - if command_exists getopts + if command -v "getopts" &> /dev/null then # Use getopts when possible OPTIND=1 From c25649bf62e10efc18d7c373022e78da43ee3fce Mon Sep 17 00:00:00 2001 From: noirbizarre Date: Sat, 13 Aug 2011 16:50:42 +0200 Subject: [PATCH 411/947] Set is_msys to False when not in MSYS shell --- virtualenvwrapper/user_scripts.py | 1 + 1 file changed, 1 insertion(+) diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index fab2039..44d9016 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -23,6 +23,7 @@ is_msys = True script_folder = 'Scripts' else: + is_msys = False script_folder = 'bin' From f09399ed241d7bd0143d5d2c937eccf09444e921 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 13 Aug 2011 11:22:24 -0400 Subject: [PATCH 412/947] add a test to verify pushd/popd behavior; addresses #101 --- tests/test_dir_stack.sh | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/test_dir_stack.sh diff --git a/tests/test_dir_stack.sh b/tests/test_dir_stack.sh new file mode 100644 index 0000000..514349d --- /dev/null +++ b/tests/test_dir_stack.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +#set -x + +test_dir=$(cd $(dirname $0) && pwd) + +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" + +#unset HOOK_VERBOSE_OPTION + +setUp () { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" + mkdir "$WORKON_HOME/start_here" + mkdir "$WORKON_HOME/on_the_stack" + echo +} + +tearDown() { + if type deactivate >/dev/null 2>&1 + then + deactivate + fi + rm -rf "$WORKON_HOME" +} + +test_ticket_101 () { + mkvirtualenv some_env + deactivate + cd "$WORKON_HOME/start_here" + pushd "$WORKON_HOME/on_the_stack" + rmvirtualenv some_env + mkvirtualenv --no-site-packages some_env + #echo "After mkvirtualenv: `pwd`" + deactivate + #echo "After deactivate: `pwd`" + popd + #echo "After popd: `pwd`" + current_dir=$(pwd) + assertSame "$WORKON_HOME/start_here" "$current_dir" +} + +. "$test_dir/shunit2" From 719b25137b8066a72aaf5d61fa6d5998b9d516e1 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 13 Aug 2011 11:34:47 -0400 Subject: [PATCH 413/947] Escape uses of cd in case it is aliased. addresses #101 --- virtualenvwrapper.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 38d6b36..8e35e2e 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -270,7 +270,7 @@ mkvirtualenv () { virtualenvwrapper_verify_virtualenv || return 1 ( [ -n "$ZSH_VERSION" ] && setopt SH_WORD_SPLIT - cd "$WORKON_HOME" && + \cd "$WORKON_HOME" && "$VIRTUALENVWRAPPER_VIRTUALENV" $VIRTUALENVWRAPPER_VIRTUALENV_ARGS "$@" && [ -d "$WORKON_HOME/$envname" ] && \ virtualenvwrapper_run_hook "pre_mkvirtualenv" "$envname" @@ -307,7 +307,7 @@ rmvirtualenv () { # Move out of the current directory to one known to be # safe, in case we are inside the environment somewhere. typeset prior_dir="$(pwd)" - cd "$WORKON_HOME" + \cd "$WORKON_HOME" virtualenvwrapper_run_hook "pre_rmvirtualenv" "$env_name" \rm -rf "$env_dir" @@ -316,7 +316,7 @@ rmvirtualenv () { # If the directory we used to be in still exists, move back to it. if [ -d "$prior_dir" ] then - cd "$prior_dir" + \cd "$prior_dir" fi } @@ -326,9 +326,9 @@ virtualenvwrapper_show_workon_options () { # NOTE: DO NOT use ls here because colorized versions spew control characters # into the output list. # echo seems a little faster than find, even with -depth 3. - (cd "$WORKON_HOME"; for f in */bin/activate; do echo $f; done) 2>/dev/null | \sed 's|^\./||' | \sed 's|/bin/activate||' | \sort | (unset GREP_OPTIONS; \egrep -v '^\*$') + (\cd "$WORKON_HOME"; for f in */bin/activate; do echo $f; done) 2>/dev/null | \sed 's|^\./||' | \sed 's|/bin/activate||' | \sort | (unset GREP_OPTIONS; \egrep -v '^\*$') -# (cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort +# (\cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort } _lsvirtualenv_usage () { @@ -532,14 +532,14 @@ cdsitepackages () { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 typeset site_packages="`virtualenvwrapper_get_site_packages_dir`" - cd "$site_packages"/$1 + \cd "$site_packages"/$1 } # Does a ``cd`` to the root of the currently-active virtualenv. cdvirtualenv () { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 - cd $VIRTUAL_ENV/$1 + \cd $VIRTUAL_ENV/$1 } # Shows the content of the site-packages directory of the currently-active @@ -615,7 +615,7 @@ cpvirtualenv() { "$VIRTUALENVWRAPPER_VIRTUALENV" "$target_env" --relocatable \sed "s/VIRTUAL_ENV\(.*\)$env_name/VIRTUAL_ENV\1$new_env/g" < "$source_env/bin/activate" > "$target_env/bin/activate" - (cd "$WORKON_HOME" && ( + (\cd "$WORKON_HOME" && ( virtualenvwrapper_run_hook "pre_cpvirtualenv" "$env_name" "$new_env"; virtualenvwrapper_run_hook "pre_mkvirtualenv" "$new_env" )) From 284325cf284beba17e96f1007eba433678b18d94 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 13 Aug 2011 11:50:27 -0400 Subject: [PATCH 414/947] add test for --no-site-packages flag after cpvirtualenv; addresses #102 --- tests/test_cp.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_cp.sh b/tests/test_cp.sh index 7b8a3ca..8661055 100755 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -110,5 +110,13 @@ GLOBAL postcpvirtualenv" rm -f "$WORKON_HOME/postmkvirtualenv" } +test_no_site_packages () { + # See issue #102 + mkvirtualenv "source" --no-site-packages + cpvirtualenv "source" "destination" + ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" + assertTrue "$ngsp_file does not exist in copied env" "[ -f \"$ngsp_file\" ]" +} + . "$test_dir/shunit2" From daf7a3c866e11e4fe39716f39d0253ea962e7530 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 13 Aug 2011 11:58:42 -0400 Subject: [PATCH 415/947] Identify another --no-site-packages test and add one for cpvirtualenv using the default args variable; addresses #102 --- tests/test_cp.sh | 13 ++++++++++++- tests/test_mkvirtualenv.sh | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/test_cp.sh b/tests/test_cp.sh index 8661055..88953e4 100755 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -112,11 +112,22 @@ GLOBAL postcpvirtualenv" test_no_site_packages () { # See issue #102 - mkvirtualenv "source" --no-site-packages + mkvirtualenv "source" --no-site-packages >/dev/null 2>&1 cpvirtualenv "source" "destination" ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" assertTrue "$ngsp_file does not exist in copied env" "[ -f \"$ngsp_file\" ]" } +test_no_site_packages_default_args () { + # See issue #102 + VIRTUALENVWRAPPER_VIRTUALENV_ARGS="--no-site-packages" + # With the argument, verify that they are not copied. + mkvirtualenv "source" >/dev/null 2>&1 + cpvirtualenv "source" "destination" + ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" + assertTrue "$ngsp_file does not exist" "[ -f \"$ngsp_file\" ]" + unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS +} + . "$test_dir/shunit2" diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index 12c7c22..a1f5f47 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -104,6 +104,7 @@ test_mkvirtualenv_sitepackages () { } test_mkvirtualenv_args () { + # See issue #102 VIRTUALENVWRAPPER_VIRTUALENV_ARGS="--no-site-packages" # With the argument, verify that they are not copied. mkvirtualenv "without_sp2" >/dev/null 2>&1 From ee65fb95ec3db31a9e419ef5f2f27813da56f885 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 13 Aug 2011 20:14:05 -0400 Subject: [PATCH 416/947] bump version number --- docs/sphinx/conf.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/conf.py b/docs/sphinx/conf.py index c7b4474..3630441 100644 --- a/docs/sphinx/conf.py +++ b/docs/sphinx/conf.py @@ -47,7 +47,7 @@ # built documents. # # The short X.Y version. -version = '2.7.1' +version = '2.8' # The full version, including alpha/beta/rc tags. release = version diff --git a/setup.py b/setup.py index 81cad92..b5fc1ff 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ PROJECT = 'virtualenvwrapper' # Change docs/sphinx/conf.py too! -VERSION = '2.7.1' +VERSION = '2.8' # Bootstrap installation of Distribute import distribute_setup From 834fa92b8009412d7c0ed4905c1cca34e3d9c972 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 13 Aug 2011 20:14:18 -0400 Subject: [PATCH 417/947] Added tag 2.8 for changeset 7e0abe005937 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 526621d..7a6f536 100644 --- a/.hgtags +++ b/.hgtags @@ -72,3 +72,4 @@ e7582879df06689ec54cd820c377e89114b75ee2 2.6.3 246ce68795ea9caeb88ec2fa17e4f3151c58cf3f 2.6.3 ea378ef00313cd77d251e61b4c0422503972b79f 2.7 b20cf787d8e1c167853709ca01731a3efb4b5fe8 2.7.1 +7e0abe005937033aaf5d00fe3db3c94addecef7b 2.8 From 749cc752ea791c372bd54d3353e0a343d8bee59d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 13 Aug 2011 20:16:23 -0400 Subject: [PATCH 418/947] set version in history and update announcement --- announce.rst | 17 ++++++++++------- docs/en/history.rst | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/announce.rst b/announce.rst index 5ab6ea8..dd1b01e 100644 --- a/announce.rst +++ b/announce.rst @@ -1,6 +1,6 @@ -========================= - virtualenvwrapper 2.7.1 -========================= +======================= + virtualenvwrapper 2.8 +======================= What is virtualenvwrapper ========================= @@ -11,11 +11,14 @@ virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. -What's New in 2.7.1 -=================== +What's New in 2.8 +================= -This release includes a fix for a minor intialization problem in 2.7 -and updated installization instructions for first-time users. +This release includes a fix to make ``cpvirtualenv`` use the copy of +``virtualenv`` specified by the ``VIRTUALENVWRAPPER_VIRTUALENV`` +variable. It also adds support for running the wrapper commands under +the MSYS environment on Microsoft Windows systems (contributed by +noirbizarre). .. _virtualenv: http://pypi.python.org/pypi/virtualenv diff --git a/docs/en/history.rst b/docs/en/history.rst index f7ec999..3aaa9fa 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,7 +2,7 @@ Release History =============== -dev +2.8 - Use VIRTUALENVWRAPPER_VIRTUALENV in `cpvirtualenv` (:bbissue:`104`). - Add support for `MSYS `_ From 26a864cdfcf5ac553910095bc04b19ecbcbdf99e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 13 Aug 2011 20:16:26 -0400 Subject: [PATCH 419/947] Added tag 2.8 for changeset 279244c0fa41 --- .hgtags | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.hgtags b/.hgtags index 7a6f536..5ba322c 100644 --- a/.hgtags +++ b/.hgtags @@ -73,3 +73,5 @@ e7582879df06689ec54cd820c377e89114b75ee2 2.6.3 ea378ef00313cd77d251e61b4c0422503972b79f 2.7 b20cf787d8e1c167853709ca01731a3efb4b5fe8 2.7.1 7e0abe005937033aaf5d00fe3db3c94addecef7b 2.8 +7e0abe005937033aaf5d00fe3db3c94addecef7b 2.8 +279244c0fa41a327cc534fc40e9e7fadea180c23 2.8 From 415ea2810b4e046bb91fa6df881c10f42448e46a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 14 Aug 2011 09:17:46 -0400 Subject: [PATCH 420/947] add link to powershell port --- docs/en/install.rst | 77 ++++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 29 deletions(-) diff --git a/docs/en/install.rst b/docs/en/install.rst index 1c8b154..b4026b4 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -8,14 +8,59 @@ Supported Shells ================ virtualenvwrapper is a set of shell *functions* defined in Bourne -shell compatible syntax. It is tested under `bash`, `ksh`, and `zsh`. +shell compatible syntax. Its automated tests run under these +shells on OS X and Linux: + +* ``bash`` +* ``ksh`` +* ``zsh`` + It may work with other shells, so if you find that it does work with a shell not listed here please let me know. If you can modify it to -work with another shell, without completely rewriting it, send a pull -request through the bitbucket project page. If you write a clone to +work with another shell without completely rewriting it, then send a pull +request through the `bitbucket project page`_. If you write a clone to work with an incompatible shell, let me know and I will link to it from this page. +.. _bitbucket project page: https://bitbucket.org/dhellmann/virtualenvwrapper/ + +MSYS +---- + +It is possible to use virtualenv wrapper under `MSYS +`_ with a native Windows Python +installation. In order to make it work, you need to define an extra +environment variable named ``MSYS_HOME`` containing the root path to +the MSYS installation. + +:: + + export WORKON_HOME=$HOME/.virtualenvs + export MSYS_HOME=/c/msys/1.0 + source /usr/local/bin/virtualenvwrapper.sh + +or:: + + export WORKON_HOME=$HOME/.virtualenvs + export MSYS_HOME=C:\msys\1.0 + source /usr/local/bin/virtualenvwrapper.sh + +Depending on your MSYS setup, you may need to install the `MSYS mktemp +binary`_ in the ``MSYS_HOME/bin`` folder. + +.. _MSYS mktemp binary: http://sourceforge.net/projects/mingw/files/MSYS/mktemp/ + +PowerShell +---------- + +Guillermo López-Anglada has ported virtualenvwrapper to run under +Microsoft's PowerShell. We have agreed that since it is not compatible +with the rest of the extensions, and is largely a re-implementation +(rather than an adaptation), it should be distributed separately. You +can download virtualenvwrapper-powershell_ from PyPI. + +.. _virtualenvwrapper-powershell: http://pypi.python.org/pypi/virtualenvwrapper-powershell/2.7.1 + .. _supported-versions: Python Versions @@ -196,29 +241,3 @@ supported. In your startup file, change ``source /usr/local/bin/virtualenvwrapper.sh``. .. _pip: http://pypi.python.org/pypi/pip - -Using virtualenvwrapper Under MSys -================================== - -It is possible to use virtualenv wrapper under `MSYS -`_ with a native Windows Python -installation. In order to make it work, you need to define an extra -environment variable named ``MSYS_HOME`` containing the root path to -the MSYS installation. - -:: - - export WORKON_HOME=$HOME/.virtualenvs - export MSYS_HOME=/c/msys/1.0 - source /usr/local/bin/virtualenvwrapper.sh - -or:: - - export WORKON_HOME=$HOME/.virtualenvs - export MSYS_HOME=C:\msys\1.0 - source /usr/local/bin/virtualenvwrapper.sh - -Depending on your MSYS setup, you may need to install the `MSYS mktemp -binary`_ in the ``MSYS_HOME/bin`` folder. - -.. _MSYS mktemp binary: http://sourceforge.net/projects/mingw/files/MSYS/mktemp/ From e0512007336aa81df540d7079aa9eafc5e99a1b7 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 4 Sep 2011 09:32:02 -0400 Subject: [PATCH 421/947] convert function definition format so typeset works under ksh --- docs/en/history.rst | 5 +++++ virtualenvwrapper.sh | 48 ++++++++++++++++++++++---------------------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 3aaa9fa..0cbe231 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,11 @@ Release History =============== +dev + + - Change the shell function shell definition syntax so that ksh will + treat typeset-declared variables as local. No kidding. + 2.8 - Use VIRTUALENVWRAPPER_VIRTUALENV in `cpvirtualenv` (:bbissue:`104`). diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index ccd65c2..2bfaf76 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -65,7 +65,7 @@ then VIRTUALENVWRAPPER_ENV_BIN_DIR="Scripts" fi -virtualenvwrapper_derive_workon_home() { +function virtualenvwrapper_derive_workon_home { typeset workon_home_dir="$WORKON_HOME" # Make sure there is a default value for WORKON_HOME. @@ -103,7 +103,7 @@ virtualenvwrapper_derive_workon_home() { # create it if it does not # seperate from creating the files in it because this used to just error # and maybe other things rely on the dir existing before that happens. -virtualenvwrapper_verify_workon_home () { +function virtualenvwrapper_verify_workon_home { RC=0 if [ ! -d "$WORKON_HOME/" ] then @@ -120,7 +120,7 @@ virtualenvwrapper_verify_workon_home () { #HOOK_VERBOSE_OPTION="-q" # Expects 1 argument, the suffix for the new file. -virtualenvwrapper_tempfile () { +function virtualenvwrapper_tempfile { # Note: the 'X's must come last typeset suffix=${1:-hook} typeset file="`\mktemp -t virtualenvwrapper-$suffix-XXXXXXXXXX`" @@ -135,7 +135,7 @@ virtualenvwrapper_tempfile () { } # Run the hooks -virtualenvwrapper_run_hook () { +function virtualenvwrapper_run_hook { typeset hook_script="$(virtualenvwrapper_tempfile ${1}-hook)" if [ -z "$hook_script" ] then @@ -165,7 +165,7 @@ virtualenvwrapper_run_hook () { # Set up tab completion. (Adapted from Arthur Koziel's version at # http://arthurkoziel.com/2008/10/11/virtualenvwrapper-bash-completion/) -virtualenvwrapper_setup_tab_completion () { +function virtualenvwrapper_setup_tab_completion { if [ -n "$BASH" ] ; then _virtualenvs () { local cur="${COMP_WORDS[COMP_CWORD]}" @@ -202,7 +202,7 @@ virtualenvwrapper_setup_tab_completion () { } # Set up virtualenvwrapper properly -virtualenvwrapper_initialize () { +function virtualenvwrapper_initialize { export WORKON_HOME="$(virtualenvwrapper_derive_workon_home)" virtualenvwrapper_verify_workon_home -q || return 1 @@ -232,7 +232,7 @@ virtualenvwrapper_initialize () { # Verify that virtualenv is installed and visible -virtualenvwrapper_verify_virtualenv () { +function virtualenvwrapper_verify_virtualenv { typeset venv=$(\which "$VIRTUALENVWRAPPER_VIRTUALENV" | (unset GREP_OPTIONS; \grep -v "not found")) if [ "$venv" = "" ] then @@ -248,7 +248,7 @@ virtualenvwrapper_verify_virtualenv () { } # Verify that the requested environment exists -virtualenvwrapper_verify_workon_environment () { +function virtualenvwrapper_verify_workon_environment { typeset env_name="$1" if [ ! -d "$WORKON_HOME/$env_name" ] then @@ -259,7 +259,7 @@ virtualenvwrapper_verify_workon_environment () { } # Verify that the active environment exists -virtualenvwrapper_verify_active_environment () { +function virtualenvwrapper_verify_active_environment { if [ ! -n "${VIRTUAL_ENV}" ] || [ ! -d "${VIRTUAL_ENV}" ] then echo "ERROR: no virtualenv active, or active virtualenv is missing" >&2 @@ -273,7 +273,7 @@ virtualenvwrapper_verify_active_environment () { # Usage: mkvirtualenv [options] ENVNAME # (where the options are passed directly to virtualenv) # -mkvirtualenv () { +function mkvirtualenv { eval "envname=\$$#" virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_virtualenv || return 1 @@ -297,7 +297,7 @@ mkvirtualenv () { } # Remove an environment, in the WORKON_HOME. -rmvirtualenv () { +function rmvirtualenv { typeset env_name="$1" virtualenvwrapper_verify_workon_home || return 1 if [ "$env_name" = "" ] @@ -330,7 +330,7 @@ rmvirtualenv () { } # List the available environments. -virtualenvwrapper_show_workon_options () { +function virtualenvwrapper_show_workon_options { virtualenvwrapper_verify_workon_home || return 1 # NOTE: DO NOT use ls here because colorized versions spew control characters # into the output list. @@ -340,7 +340,7 @@ virtualenvwrapper_show_workon_options () { # (\cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort } -_lsvirtualenv_usage () { +function _lsvirtualenv_usage { echo "lsvirtualenv [-blh]" echo " -b -- brief mode" echo " -l -- long mode" @@ -350,7 +350,7 @@ _lsvirtualenv_usage () { # List virtual environments # # Usage: lsvirtualenv [-l] -lsvirtualenv () { +function lsvirtualenv { typeset long_mode=true if command -v "getopts" &> /dev/null @@ -403,7 +403,7 @@ lsvirtualenv () { # Show details of a virtualenv # # Usage: showvirtualenv [env] -showvirtualenv () { +function showvirtualenv { typeset env_name="$1" if [ -z "$env_name" ] then @@ -424,7 +424,7 @@ showvirtualenv () { # # Usage: workon [environment_name] # -workon () { +function workon { typeset env_name="$1" if [ "$env_name" = "" ] then @@ -492,7 +492,7 @@ workon () { # Prints the Python version string for the current interpreter. -virtualenvwrapper_get_python_version () { +function virtualenvwrapper_get_python_version { # Uses the Python from the virtualenv because we're trying to # determine the version installed there so we can build # up the path to the site-packages directory. @@ -500,7 +500,7 @@ virtualenvwrapper_get_python_version () { } # Prints the path to the site-packages directory for the current environment. -virtualenvwrapper_get_site_packages_dir () { +function virtualenvwrapper_get_site_packages_dir { echo "$VIRTUAL_ENV/lib/python`virtualenvwrapper_get_python_version`/site-packages" } @@ -515,7 +515,7 @@ virtualenvwrapper_get_site_packages_dir () { # "virtualenv_path_extensions.pth" inside the virtualenv's # site-packages directory; if this file does not exist, it will be # created first. -add2virtualenv () { +function add2virtualenv { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 @@ -557,7 +557,7 @@ add2virtualenv () { # Does a ``cd`` to the site-packages directory of the currently-active # virtualenv. -cdsitepackages () { +function cdsitepackages { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 typeset site_packages="`virtualenvwrapper_get_site_packages_dir`" @@ -565,7 +565,7 @@ cdsitepackages () { } # Does a ``cd`` to the root of the currently-active virtualenv. -cdvirtualenv () { +function cdvirtualenv { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 \cd $VIRTUAL_ENV/$1 @@ -573,7 +573,7 @@ cdvirtualenv () { # Shows the content of the site-packages directory of the currently-active # virtualenv -lssitepackages () { +function lssitepackages { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 typeset site_packages="`virtualenvwrapper_get_site_packages_dir`" @@ -590,7 +590,7 @@ lssitepackages () { # Toggles the currently-active virtualenv between having and not having # access to the global site-packages. -toggleglobalsitepackages () { +function toggleglobalsitepackages { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 typeset no_global_site_packages_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" @@ -604,7 +604,7 @@ toggleglobalsitepackages () { } # Duplicate the named virtualenv to make a new one. -cpvirtualenv() { +function cpvirtualenv { typeset env_name="$1" if [ "$env_name" = "" ] then From 3c306e16f2b2da56cb155f566fc5f522da16957b Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 5 Sep 2011 11:21:02 -0400 Subject: [PATCH 422/947] merge virtualenvwrapper.project features into virtualenvwrapper --- docs/en/command_ref.rst | 96 +++++++++++++++++++ docs/en/developers.rst | 27 ++++++ docs/en/extensions.rst | 52 +++++++---- docs/en/history.rst | 4 + docs/en/index.rst | 1 + docs/en/install.rst | 27 +++++- docs/en/projects.rst | 36 ++++++++ docs/en/scripts.rst | 29 ++++++ docs/sphinx/conf.py | 2 +- setup.py | 12 ++- tests/test_project.sh | 59 ++++++++++++ tests/test_project_activate.sh | 54 +++++++++++ tests/test_project_cd.sh | 59 ++++++++++++ tests/test_project_mk.sh | 84 +++++++++++++++++ tests/test_project_templates.sh | 36 ++++++++ virtualenvwrapper.sh | 157 ++++++++++++++++++++++++++++++++ virtualenvwrapper/project.py | 60 ++++++++++++ 17 files changed, 771 insertions(+), 24 deletions(-) create mode 100644 docs/en/projects.rst create mode 100755 tests/test_project.sh create mode 100755 tests/test_project_activate.sh create mode 100755 tests/test_project_cd.sh create mode 100755 tests/test_project_mk.sh create mode 100755 tests/test_project_templates.sh create mode 100644 virtualenvwrapper/project.py diff --git a/docs/en/command_ref.rst b/docs/en/command_ref.rst index 070006e..ca697ad 100644 --- a/docs/en/command_ref.rst +++ b/docs/en/command_ref.rst @@ -394,3 +394,99 @@ output. Enabled global site-packages (env1)$ toggleglobalsitepackages -q (env1)$ + +============================ +Project Directory Management +============================ + +.. seealso:: + + :ref:`project-management` + +.. _command-mkproject: + +mkproject +--------- + +Create a new virtualenv in the WORKON_HOME and project directory in +PROJECT_HOME. + +Syntax:: + + mkproject [-t template] [virtualenv_options] ENVNAME + +The template option may be repeated to have several templates used to +create a new project. The templates are applied in the order named on +the command line. All other options are passed to ``mkvirtualenv`` to +create a virtual environment with the same name as the project. + +:: + + $ mkproject myproj + New python executable in myproj/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + Creating /Users/dhellmann/Devel/myproj + (myproj)$ pwd + /Users/dhellmann/Devel/myproj + (myproj)$ echo $VIRTUAL_ENV + /Users/dhellmann/Envs/myproj + (myproj)$ + +.. seealso:: + + * :ref:`scripts-premkproject` + * :ref:`scripts-postmkproject` + +setvirtualenvproject +-------------------- + +Bind an existing virtualenv to an existing project. + +Syntax:: + + setvirtualenvproject [virtualenv_path project_path] + +The arguments to ``setvirtualenvproject`` are the full paths to the +virtualenv and project directory. An association is made so that when +``workon`` activates the virtualenv the project is also activated. + +:: + + $ mkproject myproj + New python executable in myproj/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + Creating /Users/dhellmann/Devel/myproj + (myproj)$ mkvirtualenv myproj_new_libs + New python executable in myproj/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + Creating /Users/dhellmann/Devel/myproj + (myproj_new_libs)$ setvirtualenvproject $VIRTUAL_ENV $(pwd) + +When no arguments are given, the current virtualenv and current +directory are assumed. + +Any number of virtualenvs can refer to the same project directory, +making it easy to switch between versions of Python or other +dependencies for testing. + +.. _command-cdproject: + +cdproject +--------- + +Change the current working directory to the one specified as the +project directory for the active virtualenv. + +Syntax:: + + cdproject + diff --git a/docs/en/developers.rst b/docs/en/developers.rst index 09b5c80..8f3ba2b 100644 --- a/docs/en/developers.rst +++ b/docs/en/developers.rst @@ -91,3 +91,30 @@ the ``tests`` directory. .. _shunit2: http://shunit2.googlecode.com/ .. _tox: http://codespeak.net/tox + +.. _developer-templates: + +Creating a New Template +======================= + +virtualenvwrapper.project templates work like `virtualenvwrapper +plugins +`__. +The *entry point* group name is +``virtualenvwrapper.project.template``. Configure your entry point to +refer to a function that will **run** (source hooks are not supported +for templates). + +The argument to the template function is the name of the project being +created. The current working directory is the directory created to +hold the project files (``$PROJECT_HOME/$envname``). + +Help Text +--------- + +One difference between project templates and other virtualenvwrapper +extensions is that only the templates specified by the user are run. +The ``mkproject`` command has a help option to give the user a list of +the available templates. The names are taken from the registered +entry point names, and the descriptions are taken from the docstrings +for the template functions. diff --git a/docs/en/extensions.rst b/docs/en/extensions.rst index b06f7fb..6c59902 100644 --- a/docs/en/extensions.rst +++ b/docs/en/extensions.rst @@ -5,25 +5,6 @@ Below is a list of some of the extensions available for use with virtualenvwrapper. -.. _extensions-user_scripts: - -project -======= - -The project_ extension adds development directory management with -templates to virtualenvwrapper. - -bitbucket ---------- - -The bitbucket_ project template creates a working directory and -automatically clones the repository from BitBucket. Requires -project_. - -.. _project: http://www.doughellmann.com/projects/virtualenvwrapper.project/ - -.. _bitbucket: http://www.doughellmann.com/projects/virtualenvwrapper.bitbucket/ - emacs-desktop ============= @@ -37,6 +18,8 @@ one when activating a new virtualenv using ``workon``. .. _emacs-desktop: http://www.doughellmann.com/projects/virtualenvwrapper-emacs-desktop/ +.. _extensions-user_scripts: + user_scripts ============ @@ -53,3 +36,34 @@ virtualenvwrapper, vim-virtualenv identifies the virtualenv to activate based on the name of the file being edited. .. _vim-virtualenv: https://github.com/jmcantrell/vim-virtualenv + +.. _extensions-templates: + +Templates +========= + +Below is a list of some of the templates available for use with +:ref:`command-mkproject`. + +.. _templates-bitbucket: + +bitbucket +--------- + +The bitbucket_ extension automatically clones a mercurial repository +from the specified bitbucket project. + +.. _bitbucket: http://www.doughellmann.com/projects/virtualenvwrapper.bitbucket/ + +.. _templates-django: + +django +------ + +The django_ extension automatically creates a new Django project. + +.. _django: http://www.doughellmann.com/projects/virtualenvwrapper.django/ + +.. seealso:: + + * :ref:`developer-templates` diff --git a/docs/en/history.rst b/docs/en/history.rst index 0cbe231..8f9142a 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -6,6 +6,10 @@ dev - Change the shell function shell definition syntax so that ksh will treat typeset-declared variables as local. No kidding. + - Merge the "project directory" features of the + ``virtualenvwrapper.project`` plugin into the main project, adding + :ref:`command-mkproject`, :ref:`command-cdproject`, and + :ref:`command-setvirtualenvproject` commands. 2.8 diff --git a/docs/en/index.rst b/docs/en/index.rst index c7ba8f8..d1aa204 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -175,6 +175,7 @@ Details install command_ref hooks + projects tips developers extensions diff --git a/docs/en/install.rst b/docs/en/install.rst index b4026b4..c0dfcdb 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -106,11 +106,13 @@ add it to `your user local directory Shell Startup File ================== -Add two lines to your shell startup file (``.bashrc``, ``.profile``, -etc.) to set the location where the virtual environments should live -and the location of the script installed with this package:: +Add three lines to your shell startup file (``.bashrc``, ``.profile``, +etc.) to set the location where the virtual environments should live, +the location of your development project directorkes, and the location +of the script installed with this package:: export WORKON_HOME=$HOME/.virtualenvs + export PROJECT_HOME=$HOME/Devel source /usr/local/bin/virtualenvwrapper.sh After editing it, reload the startup file (e.g., run ``source @@ -133,6 +135,8 @@ virtualenvwrapper can be customized by changing environment variables. Set the variables in your shell startup file *before* loading ``virtualenvwrapper.sh``. +.. _variable-WORKON_HOME: + Location of Environments ------------------------ @@ -141,6 +145,19 @@ your virtual environments. The default is ``$HOME/.virtualenvs``. If the directory does not exist when virtualenvwrapper is loaded, it will be created automatically. +.. _variable-PROJECT_HOME: + +Location of Project Directories +------------------------------- + +The variable ``PROJECT_HOME`` tells virtualenvwrapper where to place +your project working directories. The variable must be set and the +directory created before :ref:`command-mkproject` is used. + +.. seealso:: + + * :ref:`project-management` + .. _variable-VIRTUALENVWRAPPER_HOOK_DIR: Location of Hook Scripts @@ -150,6 +167,10 @@ The variable ``VIRTUALENVWRAPPER_HOOK_DIR`` tells virtualenvwrapper where the :ref:`user-defined hooks ` should be placed. The default is ``$WORKON_HOME``. +.. seealso:: + + * :ref:`scripts` + .. _variable-VIRTUALENVWRAPPER_LOG_DIR: Location of Hook Logs diff --git a/docs/en/projects.rst b/docs/en/projects.rst new file mode 100644 index 0000000..5a5ae89 --- /dev/null +++ b/docs/en/projects.rst @@ -0,0 +1,36 @@ +.. _project-management: + +==================== + Project Management +==================== + +A :term:`project directory` is associated with a virtualenv, but +usually contains the source code under active development rather than +the installed components needed to support the development. For +example, the project directory may contain the source code checked out +from a version control system, temporary artifacts created by testing, +experimental files not committed to version control, etc. + +A project directory is created and bound to a virtualenv when +:ref:`command-mkproject` is run instead of +:ref:`command-mkvirtualenv`. To bind an existing project directory to +a virtualenv, use :ref:`command-setvirtualenvproject`. + +Using Templates +=============== + +A new project directory can be created empty, or populated using one +or more :term:`template` plugins. Templates should be specified as +arguments to :ref:`command-mkproject`. Multiple values can be provided +to apply more than one template. For example, to check out a Mercurial +repository from on a project on bitbucket and create a new Django +site, combine the :ref:`templates-bitbucket` and +:ref:`templates-django` templates. + +:: + + $ mkproject -t bitbucket -t django my_site + +.. seealso:: + + * :ref:`extensions-templates` diff --git a/docs/en/scripts.rst b/docs/en/scripts.rst index 5bd0184..2a046b7 100644 --- a/docs/en/scripts.rst +++ b/docs/en/scripts.rst @@ -203,3 +203,32 @@ postrmvirtualenv The ``$VIRTUALENVWRAPPER_HOOK_DIR/postrmvirtualenv`` script is run as an external program after the environment is removed. The full path to the environment directory is passed as an argument to the script. + +.. _scripts-premkproject: + +premkproject +=============== + + :Global/Local: global + :Argument(s): name of new project + :Sourced/Run: run + +``$WORKON_HOME/premkproject`` is run as an external program after the +virtual environment is created and after the current environment is +switched to point to the new env, but before the new project directory +is created. The current working directory for the script is +``$PROJECT_HOME`` and the name of the new project is passed as an +argument to the script. + +.. _scripts-postmkproject: + +postmkproject +================ + + :Global/Local: global + :Argument(s): none + :Sourced/Run: sourced + +``$WORKON_HOME/postmkproject`` is sourced after the new environment +and project directories are created and the virtualenv is activated. +The current working directory is the project directory. diff --git a/docs/sphinx/conf.py b/docs/sphinx/conf.py index 3630441..f941841 100644 --- a/docs/sphinx/conf.py +++ b/docs/sphinx/conf.py @@ -47,7 +47,7 @@ # built documents. # # The short X.Y version. -version = '2.8' +version = '2.9' # The full version, including alpha/beta/rc tags. release = version diff --git a/setup.py b/setup.py index b5fc1ff..f2702e2 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ PROJECT = 'virtualenvwrapper' # Change docs/sphinx/conf.py too! -VERSION = '2.8' +VERSION = '2.9' # Bootstrap installation of Distribute import distribute_setup @@ -144,6 +144,7 @@ def find_package_data( provides=['virtualenvwrapper', 'virtualenvwrapper.user_scripts', + 'virtualenvwrapper.project', ], install_requires=['virtualenv'], @@ -162,6 +163,7 @@ def find_package_data( #'console_scripts': [ 'venvw_hook = virtualenvwrapper.hook_loader:main' ], 'virtualenvwrapper.initialize': [ 'user_scripts = virtualenvwrapper.user_scripts:initialize', + 'project = virtualenvwrapper.project:initialize', ], 'virtualenvwrapper.initialize_source': [ 'user_scripts = virtualenvwrapper.user_scripts:initialize_source', @@ -188,11 +190,19 @@ def find_package_data( 'user_scripts = virtualenvwrapper.user_scripts:post_rmvirtualenv', ], + 'virtualenvwrapper.project.pre_mkproject': [ + 'project = virtualenvwrapper.project:pre_mkproject', + ], + 'virtualenvwrapper.project.post_mkproject_source': [ + 'project = virtualenvwrapper.project:post_mkproject_source', + ], + 'virtualenvwrapper.pre_activate': [ 'user_scripts = virtualenvwrapper.user_scripts:pre_activate', ], 'virtualenvwrapper.post_activate_source': [ 'user_scripts = virtualenvwrapper.user_scripts:post_activate_source', + 'project = virtualenvwrapper.project:post_activate_source', ], 'virtualenvwrapper.pre_deactivate_source': [ diff --git a/tests/test_project.sh b/tests/test_project.sh new file mode 100755 index 0000000..2a71331 --- /dev/null +++ b/tests/test_project.sh @@ -0,0 +1,59 @@ +#!/bin/sh + +#set -x + +test_dir=$(dirname $0) + +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +export PROJECT_HOME="$(echo ${TMPDIR:-/tmp}/PROJECT_HOME | sed 's|//|/|g')" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + rm -rf "$PROJECT_HOME" + mkdir -p "$PROJECT_HOME" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" + rm -rf "$PROJECT_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +test_initialize() { + source "$test_dir/../virtualenvwrapper.sh" + for hook in premkproject postmkproject prermproject postrmproject + do + assertTrue "Global $hook was not created" "[ -f $WORKON_HOME/$hook ]" + assertTrue "Global $hook is not executable" "[ -x $WORKON_HOME/$hook ]" + done +} + +test_initialize_hook_dir() { + export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME/hooks" + mkdir -p "$VIRTUALENVWRAPPER_HOOK_DIR" + source "$test_dir/../virtualenvwrapper.sh" + for hook in premkproject postmkproject prermproject postrmproject + do + assertTrue "Global $hook was not created" "[ -f $VIRTUALENVWRAPPER_HOOK_DIR/$hook ]" + assertTrue "Global $hook is not executable" "[ -x $VIRTUALENVWRAPPER_HOOK_DIR/$hook ]" + done + VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME" +} + +test_virtualenvwrapper_verify_project_home() { + assertTrue "PROJECT_HOME not verified" virtualenvwrapper_verify_project_home +} + +test_virtualenvwrapper_verify_project_home_missing_dir() { + old_home="$PROJECT_HOME" + PROJECT_HOME="$PROJECT_HOME/not_there" + assertFalse "PROJECT_HOME verified unexpectedly" virtualenvwrapper_verify_project_home + PROJECT_HOME="$old_home" +} + +. "$test_dir/shunit2" diff --git a/tests/test_project_activate.sh b/tests/test_project_activate.sh new file mode 100755 index 0000000..95fa1d0 --- /dev/null +++ b/tests/test_project_activate.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +#set -x + +test_dir=$(dirname $0) + +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +export PROJECT_HOME="$(echo ${TMPDIR:-/tmp}/PROJECT_HOME | sed 's|//|/|g')" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + rm -rf "$PROJECT_HOME" + mkdir -p "$PROJECT_HOME" + source "$test_dir/../virtualenvwrapper.sh" +} + +# oneTimeTearDown() { +# rm -rf "$WORKON_HOME" +# rm -rf "$PROJECT_HOME" +# } + +setUp () { + echo + rm -f "$TMPDIR/catch_output" +} + +test_activate () { + mkproject myproject + deactivate + cd $TMPDIR + assertSame "" "$VIRTUAL_ENV" + workon myproject + assertSame "myproject" "$(basename $VIRTUAL_ENV)" + assertSame "$PROJECT_HOME/myproject" "$(pwd)" + deactivate +} + +test_space_in_path () { + old_project_home="$PROJECT_HOME" + PROJECT_HOME="$PROJECT_HOME/with spaces" + mkdir -p "$PROJECT_HOME" + mkproject "myproject" >/dev/null 2>&1 + deactivate + cd $TMPDIR + workon "myproject" + assertSame "myproject" "$(basename $VIRTUAL_ENV)" + assertSame "$PROJECT_HOME/myproject" "$(pwd)" + deactivate + PROJECT_HOME="$old_project_home" +} + + +. "$test_dir/shunit2" diff --git a/tests/test_project_cd.sh b/tests/test_project_cd.sh new file mode 100755 index 0000000..05940a2 --- /dev/null +++ b/tests/test_project_cd.sh @@ -0,0 +1,59 @@ +#!/bin/sh + +#set -x + +test_dir=$(dirname $0) + +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +export PROJECT_HOME="$(echo ${TMPDIR:-/tmp}/PROJECT_HOME | sed 's|//|/|g')" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + rm -rf "$PROJECT_HOME" + mkdir -p "$PROJECT_HOME" + source "$test_dir/../virtualenvwrapper.sh" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" + rm -rf "$PROJECT_HOME" +} + +setUp () { + echo + rm -f "$TMPDIR/catch_output" +} + +test_with_project () { + mkproject myproject >/dev/null 2>&1 + cd $TMPDIR + cdproject + assertSame "$PROJECT_HOME/myproject" "$(pwd)" + deactivate +} + +test_without_project () { + mkvirtualenv myproject >/dev/null 2>&1 + cd $TMPDIR + output=$(cdproject 2>&1) + echo "$output" | grep -q "No project set" + RC=$? + assertSame "1" "$RC" + deactivate +} + +test_space_in_path () { + old_project_home="$PROJECT_HOME" + PROJECT_HOME="$PROJECT_HOME/with spaces" + mkdir -p "$PROJECT_HOME" + mkproject "myproject" >/dev/null 2>&1 + cd $TMPDIR + cdproject + assertSame "$PROJECT_HOME/myproject" "$(pwd)" + deactivate + PROJECT_HOME="$old_project_home" +} + + +. "$test_dir/shunit2" diff --git a/tests/test_project_mk.sh b/tests/test_project_mk.sh new file mode 100755 index 0000000..4f50ab4 --- /dev/null +++ b/tests/test_project_mk.sh @@ -0,0 +1,84 @@ +#!/bin/sh + +#set -x + +test_dir=$(dirname $0) + +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +export PROJECT_HOME="$(echo ${TMPDIR:-/tmp}/PROJECT_HOME | sed 's|//|/|g')" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + rm -rf "$PROJECT_HOME" + mkdir -p "$PROJECT_HOME" + source "$test_dir/../virtualenvwrapper.sh" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" + rm -rf "$PROJECT_HOME" +} + +setUp () { + echo + rm -f "$WORKON_HOME/catch_output" +} + +tearDown () { + type deactivate >/dev/null 2>&1 && deactivate +} + +test_create_directories () { + mkproject myproject1 >/dev/null 2>&1 + assertTrue "env directory not created" "[ -d $WORKON_HOME/myproject1 ]" + assertTrue "project directory not created" "[ -d $PROJECT_HOME/myproject1 ]" +} + +test_create_virtualenv () { + mkproject myproject2 >/dev/null 2>&1 + assertSame "myproject2" $(basename "$VIRTUAL_ENV") + assertSame "$PROJECT_HOME/myproject2" "$(cat $VIRTUAL_ENV/.project)" +} + +test_hooks () { + echo "echo GLOBAL premkproject \`pwd\` \"\$@\" >> \"$WORKON_HOME/catch_output\"" >> "$VIRTUALENVWRAPPER_HOOK_DIR/premkproject" + chmod +x "$VIRTUALENVWRAPPER_HOOK_DIR/premkproject" + echo "echo GLOBAL postmkproject \`pwd\` >> $WORKON_HOME/catch_output" > "$VIRTUALENVWRAPPER_HOOK_DIR/postmkproject" + + mkproject myproject3 >/dev/null 2>&1 + + output=$(cat "$WORKON_HOME/catch_output") + + expected="GLOBAL premkproject $PROJECT_HOME myproject3 +GLOBAL postmkproject $PROJECT_HOME/myproject3" + assertSame "$expected" "$output" + + rm -f "$VIRTUALENVWRAPPER_HOOK_DIR/premkproject" + rm -f "$VIRTUALENVWRAPPER_HOOK_DIR/postmkproject" +} + +test_no_project_home () { + old_home="$PROJECT_HOME" + export PROJECT_HOME="$PROJECT_HOME/not_there" + output=`mkproject should_not_be_created 2>&1` + assertTrue "Did not see expected message" "echo $output | grep 'does not exist'" + PROJECT_HOME="$old_home" +} + +test_project_exists () { + mkproject myproject4 >/dev/null 2>&1 + output=`mkproject myproject4 2>&1` + assertTrue "Did not see expected message 'already exists' in: $output" "echo $output | grep 'already exists'" +} + +test_same_workon_and_project_home () { + old_project_home="$PROJECT_HOME" + export PROJECT_HOME="$WORKON_HOME" + mkproject myproject5 >/dev/null 2>&1 + assertTrue "env directory not created" "[ -d $WORKON_HOME/myproject1 ]" + assertTrue "project directory was created" "[ -d $old_project_home/myproject1 ]" + PROJECT_HOME="$old_project_home" +} + +. "$test_dir/shunit2" diff --git a/tests/test_project_templates.sh b/tests/test_project_templates.sh new file mode 100755 index 0000000..58f7d82 --- /dev/null +++ b/tests/test_project_templates.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +#set -x + +test_dir=$(dirname $0) + +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +export PROJECT_HOME="$(echo ${TMPDIR:-/tmp}/PROJECT_HOME | sed 's|//|/|g')" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + rm -rf "$PROJECT_HOME" + mkdir -p "$PROJECT_HOME" + source "$test_dir/../virtualenvwrapper.sh" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" + rm -rf "$PROJECT_HOME" +} + +setUp () { + echo + rm -f "$TMPDIR/catch_output" +} + +test_list_templates () { + mkproject myproject >/dev/null 2>&1 + output=`mkproject myproject 2>&1` + assertTrue "Did not see expected message" "echo $output | grep 'already exists'" + deactivate +} + + +. "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 2bfaf76..fb9678e 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -157,6 +157,7 @@ function virtualenvwrapper_run_hook { echo "ERROR: virtualenvwrapper_run_hook could not find temporary file $hook_script" 1>&2 return 2 fi + # cat "$hook_script" source "$hook_script" fi \rm -f "$hook_script" >/dev/null 2>&1 @@ -653,6 +654,162 @@ function cpvirtualenv { virtualenvwrapper_run_hook "post_cpvirtualenv" } +# +# virtualenvwrapper project functions +# + +# Verify that the PROJECT_HOME directory exists +function virtualenvwrapper_verify_project_home { + if [ -z "$PROJECT_HOME" ] + then + echo "ERROR: Set the PROJECT_HOME shell variable to the name of the directory where projects should be created." >&2 + return 1 + fi + if [ ! -d "$PROJECT_HOME" ] + then + [ "$1" != "-q" ] && echo "ERROR: Project directory '$PROJECT_HOME' does not exist. Create it or set PROJECT_HOME to an existing directory." >&2 + return 1 + fi + return 0 +} + +# Given a virtualenv directory and a project directory, +# set the virtualenv up to be associated with the +# project +function setvirtualenvproject { + typeset venv="$1" + typeset prj="$2" + if [ -z "$venv" ] + then + venv="$VIRTUAL_ENV" + fi + if [ -z "$prj" ] + then + prj="$(pwd)" + fi + echo "Setting project for $(basename $venv) to $prj" + echo "$prj" > "$venv/.project" +} + +# Show help for mkproject +function mkproject_help { + echo "Usage: mkproject [-t template] [virtualenv options] project_name" + echo "" + echo "Multiple templates may be selected. They are applied in the order" + echo "specified on the command line." + echo + echo "Available templates:" + echo + "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader -l project.template +} + +# Create a new project directory and its associated virtualenv. +function mkproject { + typeset -a in_args + typeset -a out_args + typeset -i i + typeset tst + typeset a + typeset t + typeset templates + + in_args=( "$@" ) + + if [ -n "$ZSH_VERSION" ] + then + i=1 + tst="-le" + else + i=0 + tst="-lt" + fi + while [ $i $tst $# ] + do + a="${in_args[$i]}" + # echo "arg $i : $a" + case "$a" in + -h) + echo 'mkproject help:'; + echo; + mkproject_help; + echo; + echo 'mkvirtualenv help:'; + echo; + mkvirtualenv -h; + return;; + -t) + templates="$templates $a"; + i=$(( $i + 1 ));; + *) + if [ ${#out_args} -gt 0 ] + then + out_args=( "${out_args[@]-}" "$a" ) + else + out_args=( "$a" ) + fi;; + esac + i=$(( $i + 1 )) + done + + set -- "${out_args[@]}" + + # echo "templates $templates" + # echo "remainder $@" + # return 0 + + eval "typeset envname=\$$#" + virtualenvwrapper_verify_project_home || return 1 + + if [ -d "$PROJECT_HOME/$envname" ] + then + echo "Project $envname already exists." >&2 + return 1 + fi + + mkvirtualenv "$@" || return 1 + + cd "$PROJECT_HOME" + + virtualenvwrapper_run_hook project.pre_mkproject $envname + + echo "Creating $PROJECT_HOME/$envname" + mkdir -p "$PROJECT_HOME/$envname" + setvirtualenvproject "$VIRTUAL_ENV" "$PROJECT_HOME/$envname" + + cd "$PROJECT_HOME/$envname" + + for t in $templates + do + echo + echo "Applying template $t" + virtualenvwrapper_run_hook --name $t project.template $envname + done + + virtualenvwrapper_run_hook project.post_mkproject +} + +# Change directory to the active project +function cdproject { + virtualenvwrapper_verify_workon_home || return 1 + virtualenvwrapper_verify_active_environment || return 1 + if [ -f "$VIRTUAL_ENV/.project" ] + then + project_dir=$(cat "$VIRTUAL_ENV/.project") + if [ ! -z "$project_dir" ] + then + cd "$project_dir" + else + echo "Project directory $project_dir does not exist" 1>&2 + return 1 + fi + else + echo "No project set in $VIRTUAL_ENV/.project" 1>&2 + return 1 + fi + return 0 +} + + # # Invoke the initialization hooks # diff --git a/virtualenvwrapper/project.py b/virtualenvwrapper/project.py new file mode 100644 index 0000000..fb47f8b --- /dev/null +++ b/virtualenvwrapper/project.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python +# encoding: utf-8 +# +# Copyright (c) 2010 Doug Hellmann. All rights reserved. +# +"""virtualenvwrapper.project +""" + +import logging +import os + +import pkg_resources + +from virtualenvwrapper.user_scripts import make_hook, run_global + +log = logging.getLogger(__name__) + +GLOBAL_HOOKS = [ + # mkproject + ("premkproject", + "This hook is run after a new project is created and before it is activated."), + ("postmkproject", + "This hook is run after a new project is activated."), + + # rmproject + ("prermproject", + "This hook is run before a project is deleted."), + ("postrmproject", + "This hook is run after a project is deleted."), + ] + +def initialize(args): + """Set up user hooks + """ + for filename, comment in GLOBAL_HOOKS: + make_hook(os.path.join('$VIRTUALENVWRAPPER_HOOK_DIR', filename), comment) + return + + +def pre_mkproject(args): + log.debug('pre_mkproject %s', str(args)) + envname=args[0] + run_global('premkproject', *args) + return + +def post_mkproject_source(args): + return """ +# +# Run user-provided scripts +# +[ -f "$WORKON_HOME/postmkproject" ] && source "$WORKON_HOME/postmkproject" +""" + +def post_activate_source(args): + return """ +# +# Change to the project directory +# +[ -f "$VIRTUAL_ENV/.project" ] && cd "$(cat \"$VIRTUAL_ENV/.project\")" +""" From 0530f6724637ed17a0b4bfd96b13ac282645b40c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 5 Sep 2011 11:48:13 -0400 Subject: [PATCH 423/947] Add -r option to mkvirtualenv to install base requirements after the environment is created. Fix argument processing in mkproject so the correct template names are preserved. --- tests/test_mkvirtualenv_requirements.sh | 32 ++++++++++++ virtualenvwrapper.sh | 68 ++++++++++++++++++++++++- 2 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 tests/test_mkvirtualenv_requirements.sh diff --git a/tests/test_mkvirtualenv_requirements.sh b/tests/test_mkvirtualenv_requirements.sh new file mode 100644 index 0000000..88f8f26 --- /dev/null +++ b/tests/test_mkvirtualenv_requirements.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +#set -x + +test_dir=$(cd $(dirname $0) && pwd) + +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" + rm -f "$test_dir/requirements.txt" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +test_requirements_file () { + echo "commandlineapp" > "$test_dir/requirements.txt" + mkvirtualenv -r "$test_dir/requirements.txt" "env3" >/dev/null 2>&1 + installed=$(pip freeze) + assertTrue "CommandLineApp not found in $installed" "echo $installed | grep CommandLineApp" +} + +. "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index fb9678e..bc791d5 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -269,12 +269,70 @@ function virtualenvwrapper_verify_active_environment { return 0 } +# Help text for mkvirtualenv +function mkvirtualenv_help { + echo "Usage: mkvirtualenv [-r requirements_file] [virtualenv options] env_name" + echo + echo " -r requirements_file" + echo + echo " Provide a pip requirements file to install a base set of packages" + echo " into the new environment." +} + # Create a new environment, in the WORKON_HOME. # # Usage: mkvirtualenv [options] ENVNAME # (where the options are passed directly to virtualenv) # function mkvirtualenv { + typeset -a in_args + typeset -a out_args + typeset -i i + typeset tst + typeset a + typeset envname + typeset requirements + + in_args=( "$@" ) + + if [ -n "$ZSH_VERSION" ] + then + i=1 + tst="-le" + else + i=0 + tst="-lt" + fi + while [ $i $tst $# ] + do + a="${in_args[$i]}" + # echo "arg $i : $a" + case "$a" in + -h) + echo 'mkvirtualenv help:'; + echo; + mkvirtualenv_help; + echo; + echo 'virtualenv help:'; + echo; + virtualenv -h; + return;; + -r) + i=$(( $i + 1 )); + requirements="${in_args[$i]}";; + *) + if [ ${#out_args} -gt 0 ] + then + out_args=( "${out_args[@]-}" "$a" ) + else + out_args=( "$a" ) + fi;; + esac + i=$(( $i + 1 )) + done + + set -- "${out_args[@]}" + eval "envname=\$$#" virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_virtualenv || return 1 @@ -294,6 +352,12 @@ function mkvirtualenv { [ ! -d "$WORKON_HOME/$envname" ] && return 0 # Now activate the new environment workon "$envname" + + if [ ! -z "$requirements" ] + then + pip install -r "$requirements" + fi + virtualenvwrapper_run_hook "post_mkvirtualenv" } @@ -738,8 +802,8 @@ function mkproject { mkvirtualenv -h; return;; -t) - templates="$templates $a"; - i=$(( $i + 1 ));; + i=$(( $i + 1 )); + templates="$templates ${in_args[$i]}";; *) if [ ${#out_args} -gt 0 ] then From d7e97873868e9149709169deaf809c3f31e8e841 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 5 Sep 2011 11:54:44 -0400 Subject: [PATCH 424/947] Clean up help functions. Add documentation for new -r option to mkvirtualenv. --- docs/en/command_ref.rst | 14 +++++++++++--- docs/en/history.rst | 2 ++ virtualenvwrapper.sh | 22 +++++++++------------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/docs/en/command_ref.rst b/docs/en/command_ref.rst index ca697ad..42b3d92 100644 --- a/docs/en/command_ref.rst +++ b/docs/en/command_ref.rst @@ -22,10 +22,11 @@ Create a new environment, in the WORKON_HOME. Syntax:: - mkvirtualenv [options] ENVNAME + mkvirtualenv [-r requirements_file] [virtualenv options] ENVNAME -All command line options are passed directly to ``virtualenv``. The -new environment is automatically activated after being initialized. +All command line options except ``-r`` and ``-h`` are passed directly +to ``virtualenv``. The new environment is automatically activated +after being initialized. :: @@ -40,10 +41,17 @@ new environment is automatically activated after being initialized. mynewenv (mynewenv)$ +The ``-r`` option can be used to specify a text file listing packages +to be installed. The argument value is passed to ``pip -r`` to be +installed. + .. seealso:: * :ref:`scripts-premkvirtualenv` * :ref:`scripts-postmkvirtualenv` + * `requirements file format`_ + +.. _requirements file format: http://www.pip-installer.org/en/latest/requirement-format.html .. _command-lsvirtualenv: diff --git a/docs/en/history.rst b/docs/en/history.rst index 8f9142a..1047e06 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -10,6 +10,8 @@ dev ``virtualenvwrapper.project`` plugin into the main project, adding :ref:`command-mkproject`, :ref:`command-cdproject`, and :ref:`command-setvirtualenvproject` commands. + - Add ``-r`` option to :ref:`command-mkvirtualenv` to install + dependencies using a pip requirements file. 2.8 diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index bc791d5..7ac9f45 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -277,6 +277,10 @@ function mkvirtualenv_help { echo echo " Provide a pip requirements file to install a base set of packages" echo " into the new environment." + echo; + echo 'virtualenv help:'; + echo; + virtualenv -h; } # Create a new environment, in the WORKON_HOME. @@ -309,13 +313,7 @@ function mkvirtualenv { # echo "arg $i : $a" case "$a" in -h) - echo 'mkvirtualenv help:'; - echo; mkvirtualenv_help; - echo; - echo 'virtualenv help:'; - echo; - virtualenv -h; return;; -r) i=$(( $i + 1 )); @@ -761,8 +759,12 @@ function mkproject_help { echo "" echo "Multiple templates may be selected. They are applied in the order" echo "specified on the command line." + echo; + echo "mkvirtualenv help:" echo - echo "Available templates:" + mkvirtualenv -h; + echo + echo "Available project templates:" echo "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader -l project.template } @@ -793,13 +795,7 @@ function mkproject { # echo "arg $i : $a" case "$a" in -h) - echo 'mkproject help:'; - echo; mkproject_help; - echo; - echo 'mkvirtualenv help:'; - echo; - mkvirtualenv -h; return;; -t) i=$(( $i + 1 )); From 34c7c2480647a5e87bea899efdff1480492a53c8 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 5 Sep 2011 12:06:32 -0400 Subject: [PATCH 425/947] Upgrade instructions. --- docs/en/install.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/en/install.rst b/docs/en/install.rst index c0dfcdb..04ed3fc 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -252,6 +252,13 @@ users of that shell will have virtualenvwrapper enabled, and they cannot disable it. Refer to the documentation for the shell to identify the appropriate file to edit. +Upgrading to 2.9 +================ + +Version 2.9 includes the features previously delivered separately by +``virtualenvwrapper.project``. If you have an older verison of the +project extensions installed, remove them before upgrading. + Upgrading from 1.x ================== From a9e1c8c29febfbe6780daad2e427f720868d0274 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 5 Sep 2011 12:10:34 -0400 Subject: [PATCH 426/947] update announcement file --- announce.rst | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/announce.rst b/announce.rst index dd1b01e..cc1b430 100644 --- a/announce.rst +++ b/announce.rst @@ -1,5 +1,5 @@ ======================= - virtualenvwrapper 2.8 + virtualenvwrapper 2.9 ======================= What is virtualenvwrapper @@ -11,14 +11,25 @@ virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. -What's New in 2.8 +What's New in 2.9 ================= -This release includes a fix to make ``cpvirtualenv`` use the copy of -``virtualenv`` specified by the ``VIRTUALENVWRAPPER_VIRTUALENV`` -variable. It also adds support for running the wrapper commands under -the MSYS environment on Microsoft Windows systems (contributed by -noirbizarre). +This release merges in the project directory management features +previously delivered separately as ``virtualenvwrapper.project``. The +new command ``mkproject`` creates a working directory associated with +a virtualenv, and can apply templates to populate the directory (for +example, to create a new Django site). + +This release also adds a ``-r`` option to ``mkvirtualenv`` to specify +a pip requirements file for packages that should be installed into the +new environment after is is created. + +Upgrading to 2.9 +================ + +Version 2.9 includes the features previously delivered separately by +``virtualenvwrapper.project``. If you have an older verison of the +project extensions installed, remove them before upgrading. .. _virtualenv: http://pypi.python.org/pypi/virtualenv From 5b6033a45d01fbb66a00dcc8533a5ebc2d0e2616 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 5 Sep 2011 13:45:56 -0400 Subject: [PATCH 427/947] fix version number in history --- docs/en/history.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 1047e06..2f73968 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,7 +2,7 @@ Release History =============== -dev +2.9 - Change the shell function shell definition syntax so that ksh will treat typeset-declared variables as local. No kidding. From 4090c2d2f22aab0e30c33b72737709a1969e3cee Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 5 Sep 2011 13:48:21 -0400 Subject: [PATCH 428/947] add link to changelog in readme --- README.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.txt b/README.txt index 4d7f422..1cbb3d1 100644 --- a/README.txt +++ b/README.txt @@ -58,6 +58,13 @@ Python Versions virtualenvwrapper is tested under Python 2.4 - 2.7. +Upgrading to 2.9 +================ + +Version 2.9 includes the features previously delivered separately by +``virtualenvwrapper.project``. If you have an older verison of the +project extensions installed, remove them before upgrading. + Upgrading from 1.x ================== @@ -99,6 +106,14 @@ issues. Before reporting bugs in the bug tracker, please test *without* your aliases enabled. If you can identify the alias causing the problem, that will help make virtualenvwrapper more robust. +========== +Change Log +========== + +The `release history`_ is part of the project documentation. + +.. _release history: http://www.doughellmann.com/docs/virtualenvwrapper/history.html + ======= License ======= From f58a712aede6137e8b0a0457043a6b5ef3c50c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Elsd=C3=B6rfer?= Date: Sun, 11 Sep 2011 21:33:37 +0200 Subject: [PATCH 429/947] Update lssitepackages to work with new pth filename. I forgot this initially, the tests revealed the oversight. --- virtualenvwrapper.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 5f17e3c..eae834b 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -662,11 +662,11 @@ function lssitepackages { typeset site_packages="`virtualenvwrapper_get_site_packages_dir`" ls $@ $site_packages - path_file="$site_packages/virtualenv_path_extensions.pth" + path_file="$site_packages/_virtualenv_path_extensions.pth" if [ -f "$path_file" ] then echo - echo "virtualenv_path_extensions.pth:" + echo "_virtualenv_path_extensions.pth:" cat "$path_file" fi } From 7b08805df7ae963d00ebba86ba9a7f98aca2ca6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Elsd=C3=B6rfer?= Date: Sun, 11 Sep 2011 21:34:20 +0200 Subject: [PATCH 430/947] Make add2virtualenv tests work again, add new test code for new features. --- tests/test_add2virtualenv.sh | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/tests/test_add2virtualenv.sh b/tests/test_add2virtualenv.sh index 4076a2f..d856eb8 100755 --- a/tests/test_add2virtualenv.sh +++ b/tests/test_add2virtualenv.sh @@ -23,10 +23,17 @@ setUp () { test_add2virtualenv () { mkvirtualenv "pathtest" - add2virtualenv "/full/path" + full_path=$(pwd) + add2virtualenv "$full_path" cdsitepackages - path_file="./virtualenv_path_extensions.pth" - assertTrue "No /full/path in `cat $path_file`" "grep /full/path $path_file" + # Check contents of path file + path_file="./_virtualenv_path_extensions.pth" + assertTrue "No $full_path in `cat $path_file`" "grep $full_path $path_file" + assertTrue "No path insert code in `cat $path_file`" "grep sys.__egginsert $path_file" + # Check the path we inserted is actually at the top + expected=$full_path + actual=$($WORKON_HOME/pathtest/bin/python -c "import sys; print sys.path[1]") + assertSame "$expected" "$actual" cd - } @@ -36,10 +43,21 @@ test_add2virtualenv_relative () { base_dir=$(basename $(pwd)) add2virtualenv "../$base_dir" cdsitepackages - path_file="./virtualenv_path_extensions.pth" + path_file="./_virtualenv_path_extensions.pth" assertTrue "No $parent_dir/$base_dir in \"`cat $path_file`\"" "grep \"$parent_dir/$base_dir\" $path_file" cd - >/dev/null 2>&1 } +test_add2virtualenv_delete () { + mkvirtualenv "pathtest" + add2virtualenv "/full/path" + add2virtualenv -d "/full/path" + cdsitepackages + # Check contents of path file + path_file="./_virtualenv_path_extensions.pth" + assertFalse "/full/path in `cat $path_file`" "grep /full/path $path_file" + cd - +} + . "$test_dir/shunit2" From 0db691183a4c2011556dc9e24064a26ce3749d37 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 12 Sep 2011 09:07:35 -0400 Subject: [PATCH 431/947] run each test script in every shell before moving to the next script --- tests/run_tests | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/run_tests b/tests/run_tests index a773fb1..9745cb7 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -44,16 +44,17 @@ unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS # Run the test scripts with a little formatting around them to make it # easier to find where each script output starts. -for test_shell in bash ksh zsh +for test_script in $scripts do - test_shell_opts= - if [ $test_shell = "zsh" ]; then - test_shell_opts="-o shwordsplit" - fi - test_shell=$(which $test_shell) - for test_script in $scripts + for test_shell in bash ksh zsh do + test_shell_opts= + if [ $test_shell = "zsh" ]; then + test_shell_opts="-o shwordsplit" + fi + export test_shell=$(which $test_shell) + echo echo '********************************************************************************' echo "Running $test_script" From dd6ecc74e044d4b0f7c81d195ab06d63c3e94e76 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 12 Sep 2011 09:08:10 -0400 Subject: [PATCH 432/947] variable name changes and other cleanup so the script does not bomb under ksh on ubunutu 11.04 --- tests/test.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index c751f1c..319e39c 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -22,11 +22,11 @@ setUp () { } test_virtualenvwrapper_initialize() { - virtualenvwrapper_initialize + assertTrue "Initialized" virtualenvwrapper_initialize for hook in premkvirtualenv postmkvirtualenv prermvirtualenv postrmvirtualenv preactivate postactivate predeactivate postdeactivate do - assertTrue "Global $hook was not created" "[ -f $WORKON_HOME/$hook ]" - assertTrue "Global $hook is not executable" "[ -x $WORKON_HOME/$hook ]" + assertTrue "Global $WORKON_HOME/$hook was not created" "[ -f $WORKON_HOME/$hook ]" + assertTrue "Global $WORKON_HOME/$hook is not executable" "[ -x $WORKON_HOME/$hook ]" done assertTrue "Log file was not created" "[ -f $WORKON_HOME/hook.log ]" export pre_test_dir=$(cd "$test_dir"; pwd) @@ -94,10 +94,17 @@ test_python_interpreter_set_incorrectly() { cd "$WORKON_HOME" mkvirtualenv --no-site-packages no_wrappers expected="ImportError: No module named virtualenvwrapper.hook_loader" - output=$(VIRTUALENVWRAPPER_PYTHON=$(which python) $SHELL $return_to/virtualenvwrapper.sh 2>&1) - echo "$output" | grep -q "$expected" 2>&1 - found=$? - assertTrue "Expected \"$expected\", got: \"$output\"" "[ $found -eq 0 ]" + # test_shell is set by tests/run_tests + if [ "$test_shell" = "" ] + then + export test_shell=$SHELL + fi + subshell_output=$(VIRTUALENVWRAPPER_PYTHON="$WORKON_HOME/no_wrappers/bin/python" $test_shell -x $return_to/virtualenvwrapper.sh 2>&1) + echo "$subshell_output" + echo "$subshell_output" | grep -q "$expected" 2>&1 + found_it=$? + echo "$found_it" + assertTrue "Expected \'$expected\', got: \'$subshell_output\'" "[ $found_it -eq 0 ]" assertFalse "Failed to detect invalid Python location" "VIRTUALENVWRAPPER_PYTHON=$VIRTUAL_ENV/bin/python $SHELL $return_to/virtualenvwrapper.sh >/dev/null 2>&1" cd "$return_to" deactivate From 1eed635ad78b736c29258cf689f326584bf7bf43 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 12 Sep 2011 09:08:23 -0400 Subject: [PATCH 433/947] ignore temporary files created by editor --- .hgignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgignore b/.hgignore index 61dc40e..5226866 100644 --- a/.hgignore +++ b/.hgignore @@ -1,4 +1,5 @@ syntax: glob +*~ *.pyc README.html build From 3d152cb0554e2d6f4c0dafbaa955468a850f8465 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 16 Sep 2011 06:54:29 -0400 Subject: [PATCH 434/947] quiet test --- tests/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test.sh b/tests/test.sh index 319e39c..acadf67 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -99,7 +99,7 @@ test_python_interpreter_set_incorrectly() { then export test_shell=$SHELL fi - subshell_output=$(VIRTUALENVWRAPPER_PYTHON="$WORKON_HOME/no_wrappers/bin/python" $test_shell -x $return_to/virtualenvwrapper.sh 2>&1) + subshell_output=$(VIRTUALENVWRAPPER_PYTHON="$WORKON_HOME/no_wrappers/bin/python" $test_shell $return_to/virtualenvwrapper.sh 2>&1) echo "$subshell_output" echo "$subshell_output" | grep -q "$expected" 2>&1 found_it=$? From 1bfc94ab5eb199597eb15d475ef17ef49eba662c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 16 Sep 2011 06:55:02 -0400 Subject: [PATCH 435/947] fix use of sed in add2virtualenv to be more portable --- docs/en/history.rst | 5 +++++ tests/test_add2virtualenv.sh | 9 +++++++-- virtualenvwrapper.sh | 8 +++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 2f73968..f5eff57 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,11 @@ Release History =============== +dev + + - Incorporated patch to add ``-d`` option to + :ref:`command-add2virtualenv`, contributed by :bbuser:`miracle2k`. + 2.9 - Change the shell function shell definition syntax so that ksh will diff --git a/tests/test_add2virtualenv.sh b/tests/test_add2virtualenv.sh index d856eb8..7bd0478 100755 --- a/tests/test_add2virtualenv.sh +++ b/tests/test_add2virtualenv.sh @@ -28,12 +28,17 @@ test_add2virtualenv () { cdsitepackages # Check contents of path file path_file="./_virtualenv_path_extensions.pth" - assertTrue "No $full_path in `cat $path_file`" "grep $full_path $path_file" - assertTrue "No path insert code in `cat $path_file`" "grep sys.__egginsert $path_file" + assertTrue "No $full_path in $(cat $path_file)" "grep $full_path $path_file" + assertTrue "No path insert code in $(cat $path_file)" "grep sys.__egginsert $path_file" # Check the path we inserted is actually at the top expected=$full_path actual=$($WORKON_HOME/pathtest/bin/python -c "import sys; print sys.path[1]") assertSame "$expected" "$actual" + + # Make sure the temporary file created + # during the edit was removed + assertFalse "Temporary file ${path_file}.tmp still exists" "[ -f ${path_file}.tmp ]" + cd - } diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index eae834b..183f850 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -579,7 +579,6 @@ function virtualenvwrapper_get_site_packages_dir { # site-packages directory; if this file does not exist, it will be # created first. function add2virtualenv { - virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 @@ -630,10 +629,13 @@ function add2virtualenv { if [ $remove -eq 1 ] then - sed -i "\:^$absolute_path$: d" "$path_file" + sed -i.tmp "\:^$absolute_path$: d" "$path_file" else - sed -i "1a $absolute_path" "$path_file" + sed -i.tmp '1 a\ +'$absolute_path' +' "$path_file" fi + rm -f "${path_file}.tmp" done return 0 } From e41624334862bec473293bff09e1a4d0d2a0e7be Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 16 Sep 2011 07:00:55 -0400 Subject: [PATCH 436/947] quiet tests and add intermediate check for delete --- tests/test_add2virtualenv.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/test_add2virtualenv.sh b/tests/test_add2virtualenv.sh index 7bd0478..5e5f57b 100755 --- a/tests/test_add2virtualenv.sh +++ b/tests/test_add2virtualenv.sh @@ -22,45 +22,45 @@ setUp () { } test_add2virtualenv () { - mkvirtualenv "pathtest" + mkvirtualenv "pathtest" >/dev/null 2>&1 full_path=$(pwd) add2virtualenv "$full_path" cdsitepackages # Check contents of path file path_file="./_virtualenv_path_extensions.pth" - assertTrue "No $full_path in $(cat $path_file)" "grep $full_path $path_file" - assertTrue "No path insert code in $(cat $path_file)" "grep sys.__egginsert $path_file" + assertTrue "No $full_path in $(cat $path_file)" "grep -q $full_path $path_file" + assertTrue "No path insert code in $(cat $path_file)" "grep -q sys.__egginsert $path_file" # Check the path we inserted is actually at the top - expected=$full_path + expected="$full_path" actual=$($WORKON_HOME/pathtest/bin/python -c "import sys; print sys.path[1]") assertSame "$expected" "$actual" - # Make sure the temporary file created # during the edit was removed assertFalse "Temporary file ${path_file}.tmp still exists" "[ -f ${path_file}.tmp ]" - - cd - + cd - >/dev/null 2>&1 } test_add2virtualenv_relative () { - mkvirtualenv "pathtest" + mkvirtualenv "pathtest" >/dev/null 2>&1 parent_dir=$(dirname $(pwd)) base_dir=$(basename $(pwd)) add2virtualenv "../$base_dir" cdsitepackages path_file="./_virtualenv_path_extensions.pth" - assertTrue "No $parent_dir/$base_dir in \"`cat $path_file`\"" "grep \"$parent_dir/$base_dir\" $path_file" + assertTrue "No $parent_dir/$base_dir in \"`cat $path_file`\"" "grep -q \"$parent_dir/$base_dir\" $path_file" cd - >/dev/null 2>&1 } test_add2virtualenv_delete () { - mkvirtualenv "pathtest" + path_file="./_virtualenv_path_extensions.pth" + mkvirtualenv "pathtest" >/dev/null 2>&1 + cdsitepackages + # Make sure it was added add2virtualenv "/full/path" + assertTrue "No $full_path in $(cat $path_file)" "grep -q $full_path $path_file" + # Remove it and verify that change add2virtualenv -d "/full/path" - cdsitepackages - # Check contents of path file - path_file="./_virtualenv_path_extensions.pth" - assertFalse "/full/path in `cat $path_file`" "grep /full/path $path_file" + assertFalse "/full/path in `cat $path_file`" "grep -q /full/path $path_file" cd - } From 41e066136fb0c5ffcfa5213101eec470d83787aa Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 16 Sep 2011 07:02:15 -0400 Subject: [PATCH 437/947] more test quieting --- tests/test_add2virtualenv.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_add2virtualenv.sh b/tests/test_add2virtualenv.sh index 5e5f57b..2701488 100755 --- a/tests/test_add2virtualenv.sh +++ b/tests/test_add2virtualenv.sh @@ -61,7 +61,7 @@ test_add2virtualenv_delete () { # Remove it and verify that change add2virtualenv -d "/full/path" assertFalse "/full/path in `cat $path_file`" "grep -q /full/path $path_file" - cd - + cd - >/dev/null 2>&1 } From 8a9a11c061981ca99f308c28b43e6286316980b8 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 16 Sep 2011 07:14:25 -0400 Subject: [PATCH 438/947] add -i option to mkvirtualenv --- docs/en/command_ref.rst | 11 +++++---- docs/en/history.rst | 1 + tests/test_mkvirtualenv_install.sh | 38 ++++++++++++++++++++++++++++++ virtualenvwrapper.sh | 16 ++++++++++++- 4 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 tests/test_mkvirtualenv_install.sh diff --git a/docs/en/command_ref.rst b/docs/en/command_ref.rst index 42b3d92..2df2c2a 100644 --- a/docs/en/command_ref.rst +++ b/docs/en/command_ref.rst @@ -22,11 +22,11 @@ Create a new environment, in the WORKON_HOME. Syntax:: - mkvirtualenv [-r requirements_file] [virtualenv options] ENVNAME + mkvirtualenv [-i package] [-r requirements_file] [virtualenv options] ENVNAME -All command line options except ``-r`` and ``-h`` are passed directly -to ``virtualenv``. The new environment is automatically activated -after being initialized. +All command line options except ``-i``, ``-r``, and ``-h`` are passed +directly to ``virtualenv``. The new environment is automatically +activated after being initialized. :: @@ -41,6 +41,9 @@ after being initialized. mynewenv (mynewenv)$ +The ``-i`` option can be used to install one or more packages (by +repeating the option) after the environment is created. + The ``-r`` option can be used to specify a text file listing packages to be installed. The argument value is passed to ``pip -r`` to be installed. diff --git a/docs/en/history.rst b/docs/en/history.rst index f5eff57..bdb79f6 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -6,6 +6,7 @@ dev - Incorporated patch to add ``-d`` option to :ref:`command-add2virtualenv`, contributed by :bbuser:`miracle2k`. + - Add ``-i`` option to :ref:`command-mkvirtualenv`. 2.9 diff --git a/tests/test_mkvirtualenv_install.sh b/tests/test_mkvirtualenv_install.sh new file mode 100644 index 0000000..003905d --- /dev/null +++ b/tests/test_mkvirtualenv_install.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +#set -x + +test_dir=$(cd $(dirname $0) && pwd) + +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" + rm -f "$test_dir/requirements.txt" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +test_single_package () { + mkvirtualenv -i commandlineapp "env4" >/dev/null 2>&1 + installed=$(pip freeze) + assertTrue "CommandLineApp not found in $installed" "echo $installed | grep CommandLineApp" +} + +test_multiple_packages () { + mkvirtualenv -i commandlineapp -i csvcat "env4" >/dev/null 2>&1 + installed=$(pip freeze) + assertTrue "CommandLineApp not found in $installed" "echo $installed | grep CommandLineApp" + assertTrue "csvcat not found in $installed" "echo $installed | grep csvcat" +} + +. "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 183f850..02824c2 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -271,7 +271,12 @@ function virtualenvwrapper_verify_active_environment { # Help text for mkvirtualenv function mkvirtualenv_help { - echo "Usage: mkvirtualenv [-r requirements_file] [virtualenv options] env_name" + echo "Usage: mkvirtualenv [-i package] [-r requirements_file] [virtualenv options] env_name" + echo + echo " -i package" + echo + echo " Install a package after the environment is created." + echo " This option may be repeated." echo echo " -r requirements_file" echo @@ -296,6 +301,7 @@ function mkvirtualenv { typeset a typeset envname typeset requirements + typeset packages in_args=( "$@" ) @@ -315,6 +321,9 @@ function mkvirtualenv { -h) mkvirtualenv_help; return;; + -i) + i=$(( $i + 1 )); + packages="$packages ${in_args[$i]}";; -r) i=$(( $i + 1 )); requirements="${in_args[$i]}";; @@ -356,6 +365,11 @@ function mkvirtualenv { pip install -r "$requirements" fi + for a in $packages + do + pip install $a + done + virtualenvwrapper_run_hook "post_mkvirtualenv" } From 8a94c97d0316a248f3d73ccd3ce52de7c451ed00 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 16 Sep 2011 08:28:16 -0400 Subject: [PATCH 439/947] add mktmpenv command from virtualenvwrapper.tmpenv --- docs/en/command_ref.rst | 26 +++++++++++++++++++++++ docs/en/history.rst | 3 +++ tests/test_mktmpenv.sh | 46 +++++++++++++++++++++++++++++++++++++++++ virtualenvwrapper.sh | 40 +++++++++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+) create mode 100644 tests/test_mktmpenv.sh diff --git a/docs/en/command_ref.rst b/docs/en/command_ref.rst index 2df2c2a..227795d 100644 --- a/docs/en/command_ref.rst +++ b/docs/en/command_ref.rst @@ -56,6 +56,32 @@ installed. .. _requirements file format: http://www.pip-installer.org/en/latest/requirement-format.html +.. _command-mktmpenv: + +mktmpenv +-------- + +Create a new virtualenv in the ``WORKON_HOME`` directory. + +Syntax:: + + mktmpenv [ENVNAME] + +If no environment name is given, a temporary unique name is generated. + +:: + + $ mktmpenv + Using real prefix '/Library/Frameworks/Python.framework/Versions/2.7' + New python executable in 1e513ac6-616e-4d56-9aa5-9d0a3b305e20/bin/python + Overwriting 1e513ac6-616e-4d56-9aa5-9d0a3b305e20/lib/python2.7/distutils/__init__.py + with new content + Installing distribute............................................... + .................................................................... + .................................................................done. + This is a temporary environment. It will be deleted when deactivated. + (1e513ac6-616e-4d56-9aa5-9d0a3b305e20) $ + .. _command-lsvirtualenv: lsvirtualenv diff --git a/docs/en/history.rst b/docs/en/history.rst index bdb79f6..025de25 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -7,6 +7,9 @@ dev - Incorporated patch to add ``-d`` option to :ref:`command-add2virtualenv`, contributed by :bbuser:`miracle2k`. - Add ``-i`` option to :ref:`command-mkvirtualenv`. + - Add :ref:`command-mktmpenv` command for creating temporary + environments that are automatically removed when they are + deactivated. 2.9 diff --git a/tests/test_mktmpenv.sh b/tests/test_mktmpenv.sh new file mode 100644 index 0000000..03bc6ca --- /dev/null +++ b/tests/test_mktmpenv.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +test_dir=$(cd $(dirname $0) && pwd) + +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" + + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +test_mktmpenv_no_name() { + before=$(lsvirtualenv -b) + mktmpenv >/dev/null 2>&1 + after=$(lsvirtualenv -b) + assertFalse "Environment was not created" "[ \"$before\" = \"$after\" ]" +} + +test_mktmpenv_name() { + assertFalse "Environment already exists" "[ -d \"$WORKON_HOME/name-given-by-user\" ]" + mktmpenv name-given-by-user >/dev/null 2>&1 + assertTrue "Environment was not created" "[ -d \"$WORKON_HOME/name-given-by-user\" ]" + assertSame $(basename "$VIRTUAL_ENV") "name-given-by-user" +} + +test_deactivate() { + assertFalse "Environment already exists" "[ -d \"$WORKON_HOME/automatically-deleted\" ]" + mktmpenv automatically-deleted >/dev/null 2>&1 + assertSame $(basename "$VIRTUAL_ENV") "automatically-deleted" + assertTrue "Environment was not created" "[ -d \"$WORKON_HOME/automatically-deleted\" ]" + deactivate >/dev/null 2>&1 + assertFalse "Environment still exists" "[ -d \"$WORKON_HOME/automatically-deleted\" ]" +} + +. "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 02824c2..31332bd 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -905,6 +905,46 @@ function cdproject { return 0 } +# +# Temporary virtualenv +# +# Originally part of virtualenvwrapper.tmpenv plugin +# +mktmpenv() { + typeset tmpenvname + + # Generate a unique temporary name, if one is not given. + if [ $# -eq 0 ] + then + tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import uuid; print uuid.uuid4()') + mkvirtualenv "$tmpenvname" + else + mkvirtualenv "$@" + fi + + # Create the environment + RC=$? + if [ $RC -ne 0 ] + then + return $RC + fi + + # Change working directory + cdvirtualenv + + # Create the tmpenv marker file + echo "This is a temporary environment. It will be deleted when you run 'deactivate'." | tee "$VIRTUAL_ENV/README.tmpenv" + + # Update the postdeactivate script + cat - >> "$VIRTUAL_ENV/bin/postdeactivate" < Date: Sat, 17 Sep 2011 08:57:48 -0400 Subject: [PATCH 440/947] get the version number from the packaging scripts --- docs/sphinx/conf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/sphinx/conf.py b/docs/sphinx/conf.py index f941841..63f2fbb 100644 --- a/docs/sphinx/conf.py +++ b/docs/sphinx/conf.py @@ -12,6 +12,7 @@ # serve to show the default. import sys, os +import subprocess # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -47,7 +48,8 @@ # built documents. # # The short X.Y version. -version = '2.9' +version = subprocess.check_output(['sh', '-c', 'cd ../..; python setup.py --version']) +version = version.strip() # The full version, including alpha/beta/rc tags. release = version From efb17bb2a546bed92846745779f5b24a6eb3bf4e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 17 Sep 2011 09:33:17 -0400 Subject: [PATCH 441/947] add test to ensure templates are applied correctly --- .hgignore | 3 + tests/test_project_templates.sh | 12 +- tests/testtemplate/distribute_setup.py | 477 +++++++++++++++++++++ tests/testtemplate/mytemplates/__init__.py | 0 tests/testtemplate/mytemplates/main.py | 26 ++ tests/testtemplate/setup.py | 150 +++++++ 6 files changed, 664 insertions(+), 4 deletions(-) create mode 100644 tests/testtemplate/distribute_setup.py create mode 100644 tests/testtemplate/mytemplates/__init__.py create mode 100644 tests/testtemplate/mytemplates/main.py create mode 100644 tests/testtemplate/setup.py diff --git a/.hgignore b/.hgignore index 5226866..ab738ed 100644 --- a/.hgignore +++ b/.hgignore @@ -13,6 +13,9 @@ tests/catch_output tests/testpackage/build tests/testpackage/dist tests/testpackage/testpackage.egg-info +tests/testtemplate/build +tests/testtemplate/dist +tests/testtemplate/testtemplate.egg-info trace.txt virtualenvwrapper.egg-info virtualenvwrapper/docs diff --git a/tests/test_project_templates.sh b/tests/test_project_templates.sh index 58f7d82..dbb1cfd 100755 --- a/tests/test_project_templates.sh +++ b/tests/test_project_templates.sh @@ -8,6 +8,7 @@ export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" export PROJECT_HOME="$(echo ${TMPDIR:-/tmp}/PROJECT_HOME | sed 's|//|/|g')" oneTimeSetUp() { + (cd "$test_dir/testtemplate" && python setup.py install) rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" rm -rf "$PROJECT_HOME" @@ -26,11 +27,14 @@ setUp () { } test_list_templates () { - mkproject myproject >/dev/null 2>&1 - output=`mkproject myproject 2>&1` - assertTrue "Did not see expected message" "echo $output | grep 'already exists'" - deactivate + output=$(mkproject -h 2>&1) + assertTrue "Did not find test template in \"$output\"" "echo \"$output\" | grep -q test" } +test_apply_template () { + mkproject -t test proj1 + assertTrue "Test file not created" "[ -f TEST_FILE ]" + assertTrue "project name not found" "grep -q proj1 TEST_FILE" +} . "$test_dir/shunit2" diff --git a/tests/testtemplate/distribute_setup.py b/tests/testtemplate/distribute_setup.py new file mode 100644 index 0000000..0021336 --- /dev/null +++ b/tests/testtemplate/distribute_setup.py @@ -0,0 +1,477 @@ +#!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 sys +import time +import fnmatch +import tempfile +import tarfile +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.10" +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): + # 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'): + log.warn('Something went wrong during the installation.') + log.warn('See the error message above.') + finally: + os.chdir(old_wd) + + +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) + # 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 _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 + + +def _same_content(path, content): + return open(path).read() == content + +def _no_sandbox(function): + def __no_sandbox(*args, **kw): + try: + from setuptools.sandbox import DirectorySandbox + def violation(*args): + pass + DirectorySandbox._old = DirectorySandbox._violation + DirectorySandbox._violation = violation + patched = True + except ImportError: + patched = False + + try: + return function(*args, **kw) + finally: + if patched: + DirectorySandbox._violation = DirectorySandbox._old + del DirectorySandbox._old + + return __no_sandbox + +@_no_sandbox +def _rename_path(path): + new_name = path + '.OLD.%s' % time.time() + log.warn('Renaming %s into %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('Removing 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 + + +def _after_install(dist): + log.warn('After install bootstrap.') + placeholder = dist.get_command_obj('install').install_purelib + _create_fake_setuptools_pkg_info(placeholder) + +@_no_sandbox +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) + f = open(pkg_info, 'w') + 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() + +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 + + +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) + elif option == '--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('Patched done.') + _relaunch() + + +def _relaunch(): + log.warn('Relaunching...') + # we have to relaunch the process + 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 main(argv, version=DEFAULT_VERSION): + """Install or upgrade setuptools and EasyInstall""" + tarball = download_setuptools() + _install(tarball) + + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/tests/testtemplate/mytemplates/__init__.py b/tests/testtemplate/mytemplates/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/testtemplate/mytemplates/main.py b/tests/testtemplate/mytemplates/main.py new file mode 100644 index 0000000..9d07f72 --- /dev/null +++ b/tests/testtemplate/mytemplates/main.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# encoding: utf-8 +# +# Copyright (c) 2010 Doug Hellmann. All rights reserved. +# +"""virtualenvwrapper.project plugin for tests +""" + +import logging +import os + +log = logging.getLogger(__name__) + +def template(args): + """Creates a test file containing the args passed to us + """ + log.info('Running test template with args %r', args) + project = args[0] + filename = 'TEST_FILE' + log.info('Writing to %s', filename) + output = open(filename, 'w') + try: + output.write('\n'.join(args)) + finally: + output.close() + return diff --git a/tests/testtemplate/setup.py b/tests/testtemplate/setup.py new file mode 100644 index 0000000..75032c1 --- /dev/null +++ b/tests/testtemplate/setup.py @@ -0,0 +1,150 @@ +#!/usr/bin/env python + +PROJECT = 'testtemplate' +VERSION = '1.0' + +# Bootstrap installation of Distribute +import distribute_setup +distribute_setup.use_setuptools() + +from setuptools import setup, find_packages + +from distutils.util import convert_path +from fnmatch import fnmatchcase + +import os +import sys + +################################################################################ +# find_package_data is an Ian Bicking creation. + +# Provided as an attribute, so you can append to these instead +# of replicating them: +standard_exclude = ('*.py', '*.pyc', '*~', '.*', '*.bak', '*.swp*') +standard_exclude_directories = ('.*', 'CVS', '_darcs', './build', + './dist', 'EGG-INFO', '*.egg-info') + +def find_package_data( + where='.', package='', + exclude=standard_exclude, + exclude_directories=standard_exclude_directories, + only_in_packages=True, + show_ignored=False): + """ + Return a dictionary suitable for use in ``package_data`` + in a distutils ``setup.py`` file. + + The dictionary looks like:: + + {'package': [files]} + + Where ``files`` is a list of all the files in that package that + don't match anything in ``exclude``. + + If ``only_in_packages`` is true, then top-level directories that + are not packages won't be included (but directories under packages + will). + + Directories matching any pattern in ``exclude_directories`` will + be ignored; by default directories with leading ``.``, ``CVS``, + and ``_darcs`` will be ignored. + + If ``show_ignored`` is true, then all the files that aren't + included in package data are shown on stderr (for debugging + purposes). + + Note patterns use wildcards, or can be exact paths (including + leading ``./``), and all searching is case-insensitive. + + This function is by Ian Bicking. + """ + + out = {} + stack = [(convert_path(where), '', package, only_in_packages)] + while stack: + where, prefix, package, only_in_packages = stack.pop(0) + for name in os.listdir(where): + fn = os.path.join(where, name) + if os.path.isdir(fn): + bad_name = False + for pattern in exclude_directories: + if (fnmatchcase(name, pattern) + or fn.lower() == pattern.lower()): + bad_name = True + if show_ignored: + print >> sys.stderr, ( + "Directory %s ignored by pattern %s" + % (fn, pattern)) + break + if bad_name: + continue + if os.path.isfile(os.path.join(fn, '__init__.py')): + if not package: + new_package = name + else: + new_package = package + '.' + name + stack.append((fn, '', new_package, False)) + else: + stack.append((fn, prefix + name + '/', package, only_in_packages)) + elif package or not only_in_packages: + # is a file + bad_name = False + for pattern in exclude: + if (fnmatchcase(name, pattern) + or fn.lower() == pattern.lower()): + bad_name = True + if show_ignored: + print >> sys.stderr, ( + "File %s ignored by pattern %s" + % (fn, pattern)) + break + if bad_name: + continue + out.setdefault(package, []).append(prefix+name) + return out +################################################################################ + +setup( + name = PROJECT, + version = VERSION, + + description = 'template for testing mkproject', + + author = 'Doug Hellmann', + author_email = 'doug.hellmann@gmail.com', + + url = 'http://www.doughellmann.com/projects/virtualenvwrapper/', + + classifiers = [ 'Development Status :: 5 - Production/Stable', + 'License :: OSI Approved :: BSD License', + 'Programming Language :: Python', + 'Intended Audience :: Developers', + 'Environment :: Console', + ], + + platforms = ['Any'], + + provides=['testtemplate', + ], + requires=['virtualenv', + 'virtualenvwrapper (>=2.9)', + ], + + packages = find_packages(), + include_package_data = True, + # Scan the input for package information + # to grab any data files (text, images, etc.) + # associated with sub-packages. + package_data = find_package_data('mytemplates', + package='mytemplates', + only_in_packages=False, + ), + + entry_points = { + 'virtualenvwrapper.project.template': [ + 'test = mytemplates.main:template', + ], + }, + + zip_safe=False, + ) From e34bd362c1e97ad4f9af3ad0333228eb1b5cf4fc Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 17 Sep 2011 11:17:28 -0400 Subject: [PATCH 442/947] Use old style string formatting instead of the format method to retain python 2.4 and 2.5 support --- docs/en/history.rst | 2 ++ virtualenvwrapper/hook_loader.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 025de25..798f681 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -10,6 +10,8 @@ dev - Add :ref:`command-mktmpenv` command for creating temporary environments that are automatically removed when they are deactivated. + - Fixed a problem with hook_loader that prevented it from working + under Python 2.5 and 2.4. 2.9 diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 9d7c785..4bc9b47 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -125,7 +125,7 @@ def run_hooks(hook, options, args, output=None): continue plugin = ep.load() if options.listing: - print ' {0:10} -- {1}'.format(ep.name, inspect.getdoc(plugin) or '') + print ' %-10s -- %s' % (ep.name, inspect.getdoc(plugin) or '') continue if options.sourcing: # Show the shell commands so they can From 17e145c430fe4a62a8cd226cfa0d1456b9682f94 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 17 Sep 2011 11:23:45 -0400 Subject: [PATCH 443/947] if uuid is not available, use random to generate a name for the new environment --- virtualenvwrapper.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 31332bd..cf1a50b 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -916,7 +916,12 @@ mktmpenv() { # Generate a unique temporary name, if one is not given. if [ $# -eq 0 ] then - tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import uuid; print uuid.uuid4()') + tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import uuid; print uuid.uuid4()' 2>/dev/null) + if [ -z "$tmpenvname" ] + then + # This python does not support uuid + tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import random; print hex(random.getrandbits(64))[2:-1]' 2>/dev/null) + fi mkvirtualenv "$tmpenvname" else mkvirtualenv "$@" From 6fd972b94b92fb2ffd27b41b426f4aba64bc6f37 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 17 Sep 2011 14:56:46 -0400 Subject: [PATCH 444/947] fix template listing for python 2.4, which does not support the -m option with namespace packages --- tests/test_project_templates.sh | 2 +- virtualenvwrapper.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_project_templates.sh b/tests/test_project_templates.sh index dbb1cfd..4f61d3c 100755 --- a/tests/test_project_templates.sh +++ b/tests/test_project_templates.sh @@ -28,7 +28,7 @@ setUp () { test_list_templates () { output=$(mkproject -h 2>&1) - assertTrue "Did not find test template in \"$output\"" "echo \"$output\" | grep -q test" + assertTrue "Did not find test template in \"$output\"" "echo \"$output\" | grep -q 'Creates a test file'" } test_apply_template () { diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index cf1a50b..4c296ef 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -802,7 +802,7 @@ function mkproject_help { echo echo "Available project templates:" echo - "$VIRTUALENVWRAPPER_PYTHON" -m virtualenvwrapper.hook_loader -l project.template + "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' -l project.template } # Create a new project directory and its associated virtualenv. From fa1b2a888cfb1277212914e61d81480fbe869db8 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 17 Sep 2011 15:45:03 -0400 Subject: [PATCH 445/947] strip spaces from template names; fixes #111 --- virtualenvwrapper.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 4c296ef..588658c 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -878,7 +878,10 @@ function mkproject { do echo echo "Applying template $t" - virtualenvwrapper_run_hook --name $t project.template $envname + # For some reason zsh insists on prefixing the template + # names with a space, so strip them out before passing + # the value to the hook loader. + virtualenvwrapper_run_hook --name $(echo $t | sed 's/^ //') project.template $envname done virtualenvwrapper_run_hook project.post_mkproject From 2051c135eac85f513f3d0d892c25c8524fa23153 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 17 Sep 2011 15:46:44 -0400 Subject: [PATCH 446/947] document previous fix in history --- docs/en/history.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index 798f681..e022b5c 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -12,6 +12,8 @@ dev deactivated. - Fixed a problem with hook_loader that prevented it from working under Python 2.5 and 2.4. + - Fix a problem with the way template names were processed under + zsh. (:bbissue:`111`) 2.9 From f239e8216f9385e7c7f668947a8d2c0354ee05f8 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 17 Sep 2011 16:56:16 -0400 Subject: [PATCH 447/947] bump version number --- docs/en/history.rst | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index e022b5c..914ffe9 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,7 +2,7 @@ Release History =============== -dev +2.10 - Incorporated patch to add ``-d`` option to :ref:`command-add2virtualenv`, contributed by :bbuser:`miracle2k`. diff --git a/setup.py b/setup.py index f2702e2..6332208 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ PROJECT = 'virtualenvwrapper' # Change docs/sphinx/conf.py too! -VERSION = '2.9' +VERSION = '2.10' # Bootstrap installation of Distribute import distribute_setup From deae8d63afee9949613f14b4223aba3eb3e41e10 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 17 Sep 2011 17:01:20 -0400 Subject: [PATCH 448/947] update announcement text --- announce.rst | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/announce.rst b/announce.rst index cc1b430..87a0d8c 100644 --- a/announce.rst +++ b/announce.rst @@ -1,6 +1,6 @@ -======================= - virtualenvwrapper 2.9 -======================= +======================== + virtualenvwrapper 2.10 +======================== What is virtualenvwrapper ========================= @@ -11,25 +11,27 @@ virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. -What's New in 2.9 +What's New in 2.10 +================== + +- Incorporated patch to add ``-d`` option to + ``add2virtualenv``, contributed by ``miracle2k``. +- Add ``-i`` option to ``mkvirtualenv``. +- Add ``mktmpenv`` command for creating temporary + environments that are automatically removed when they are + deactivated. +- Fixed a problem with hook_loader that prevented it from working + under Python 2.5 and 2.4. +- Fix a problem with the way template names were processed under + zsh. (issue #111) + +Upgrading to 2.10 ================= -This release merges in the project directory management features -previously delivered separately as ``virtualenvwrapper.project``. The -new command ``mkproject`` creates a working directory associated with -a virtualenv, and can apply templates to populate the directory (for -example, to create a new Django site). - -This release also adds a ``-r`` option to ``mkvirtualenv`` to specify -a pip requirements file for packages that should be installed into the -new environment after is is created. - -Upgrading to 2.9 -================ - -Version 2.9 includes the features previously delivered separately by -``virtualenvwrapper.project``. If you have an older verison of the -project extensions installed, remove them before upgrading. +Version 2.10 includes the features previously delivered separately by +``virtualenvwrapper.tmpenv``. If you have an older verison of the +temporary environment extensions installed, remove it before +upgrading. .. _virtualenv: http://pypi.python.org/pypi/virtualenv From 9fca2b51a7089b383fdf3d1245e24163e4b0b833 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 3 Oct 2011 08:26:41 -0400 Subject: [PATCH 449/947] change mktmpenv to always create an env name for the user; addresses #114 --- docs/en/command_ref.rst | 4 ++-- docs/en/history.rst | 5 +++++ tests/test_mktmpenv.sh | 20 ++++++++++++-------- virtualenvwrapper.sh | 18 +++++++----------- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/docs/en/command_ref.rst b/docs/en/command_ref.rst index 227795d..4af940b 100644 --- a/docs/en/command_ref.rst +++ b/docs/en/command_ref.rst @@ -65,9 +65,9 @@ Create a new virtualenv in the ``WORKON_HOME`` directory. Syntax:: - mktmpenv [ENVNAME] + mktmpenv [VIRTUALENV_OPTIONS] -If no environment name is given, a temporary unique name is generated. +A unique virtualenv name is generated. :: diff --git a/docs/en/history.rst b/docs/en/history.rst index 914ffe9..33a76df 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,11 @@ Release History =============== +dev + + - Changed arguments to :ref:`command-mktmpenv` so it always creates + an environment name for you. (:bbissue:`114`) + 2.10 - Incorporated patch to add ``-d`` option to diff --git a/tests/test_mktmpenv.sh b/tests/test_mktmpenv.sh index 03bc6ca..d3ff812 100644 --- a/tests/test_mktmpenv.sh +++ b/tests/test_mktmpenv.sh @@ -28,19 +28,23 @@ test_mktmpenv_no_name() { } test_mktmpenv_name() { - assertFalse "Environment already exists" "[ -d \"$WORKON_HOME/name-given-by-user\" ]" mktmpenv name-given-by-user >/dev/null 2>&1 - assertTrue "Environment was not created" "[ -d \"$WORKON_HOME/name-given-by-user\" ]" - assertSame $(basename "$VIRTUAL_ENV") "name-given-by-user" + RC=$? + assertTrue "Error was not detected" "[ $RC -ne 0 ]" +} + +test_mktmpenv_virtualenv_args() { + mktmpenv --no-site-packages >/dev/null 2>&1 + RC=$? + assertTrue "Error was detected" "[ $RC -eq 0 ]" } test_deactivate() { - assertFalse "Environment already exists" "[ -d \"$WORKON_HOME/automatically-deleted\" ]" - mktmpenv automatically-deleted >/dev/null 2>&1 - assertSame $(basename "$VIRTUAL_ENV") "automatically-deleted" - assertTrue "Environment was not created" "[ -d \"$WORKON_HOME/automatically-deleted\" ]" + mktmpenv >/dev/null 2>&1 + assertTrue "Environment was not created" "[ ! -z \"$VIRTUAL_ENV\" ]" + env_name=$(basename "$VIRTUAL_ENV") deactivate >/dev/null 2>&1 - assertFalse "Environment still exists" "[ -d \"$WORKON_HOME/automatically-deleted\" ]" + assertFalse "Environment still exists" "[ -d \"$WORKON_HOME/$env_name\" ]" } . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 588658c..8981e1a 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -915,22 +915,18 @@ function cdproject { # mktmpenv() { typeset tmpenvname + typeset RC - # Generate a unique temporary name, if one is not given. - if [ $# -eq 0 ] + # Generate a unique temporary name + tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import uuid; print uuid.uuid4()' 2>/dev/null) + if [ -z "$tmpenvname" ] then - tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import uuid; print uuid.uuid4()' 2>/dev/null) - if [ -z "$tmpenvname" ] - then - # This python does not support uuid - tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import random; print hex(random.getrandbits(64))[2:-1]' 2>/dev/null) - fi - mkvirtualenv "$tmpenvname" - else - mkvirtualenv "$@" + # This python does not support uuid + tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import random; print hex(random.getrandbits(64))[2:-1]' 2>/dev/null) fi # Create the environment + mkvirtualenv "$@" "$tmpenvname" RC=$? if [ $RC -ne 0 ] then From 65dc79fd653dcc1e0aa85c051eb9be1279a06876 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 3 Oct 2011 08:37:42 -0400 Subject: [PATCH 450/947] improve test for mktmpenv with options; addresses #114 --- tests/test_mktmpenv.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_mktmpenv.sh b/tests/test_mktmpenv.sh index d3ff812..f6a4884 100644 --- a/tests/test_mktmpenv.sh +++ b/tests/test_mktmpenv.sh @@ -35,8 +35,8 @@ test_mktmpenv_name() { test_mktmpenv_virtualenv_args() { mktmpenv --no-site-packages >/dev/null 2>&1 - RC=$? - assertTrue "Error was detected" "[ $RC -eq 0 ]" + ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" + assertTrue "$ngsp_file does not exist" "[ -f \"$ngsp_file\" ]" } test_deactivate() { From ce9715061869b2ccc5a6ff222e4d074229477a6d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 4 Oct 2011 08:50:20 -0400 Subject: [PATCH 451/947] bump version to 2.10.1; closes #114 --- announce.rst | 40 ++++++++++++++++------------------------ docs/en/history.rst | 5 +++-- setup.py | 2 +- 3 files changed, 20 insertions(+), 27 deletions(-) diff --git a/announce.rst b/announce.rst index 87a0d8c..207abc8 100644 --- a/announce.rst +++ b/announce.rst @@ -1,6 +1,6 @@ -======================== - virtualenvwrapper 2.10 -======================== +========================== + virtualenvwrapper 2.10.1 +========================== What is virtualenvwrapper ========================= @@ -11,27 +11,19 @@ virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. -What's New in 2.10 -================== - -- Incorporated patch to add ``-d`` option to - ``add2virtualenv``, contributed by ``miracle2k``. -- Add ``-i`` option to ``mkvirtualenv``. -- Add ``mktmpenv`` command for creating temporary - environments that are automatically removed when they are - deactivated. -- Fixed a problem with hook_loader that prevented it from working - under Python 2.5 and 2.4. -- Fix a problem with the way template names were processed under - zsh. (issue #111) - -Upgrading to 2.10 -================= - -Version 2.10 includes the features previously delivered separately by -``virtualenvwrapper.tmpenv``. If you have an older verison of the -temporary environment extensions installed, remove it before -upgrading. +What's New in 2.10.1 +==================== + +This bug-fix release includes a change to ``mktmpenv`` to resolve a +problem with the way command line arguments were being handled. All +temporary environments are now given automatically-generated names and +the ability to name a temporary environment has been removed. + +Installing +========== + +Visit the virtualenvwrapper_ project page for download links and +installation instructions. .. _virtualenv: http://pypi.python.org/pypi/virtualenv diff --git a/docs/en/history.rst b/docs/en/history.rst index 33a76df..d19da29 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,10 +2,11 @@ Release History =============== -dev +2.10.1 - Changed arguments to :ref:`command-mktmpenv` so it always creates - an environment name for you. (:bbissue:`114`) + an environment name for you. (:bbissue:`114` reported by + :bbuser:`alex_gaynor`) 2.10 diff --git a/setup.py b/setup.py index 6332208..7b1a7bc 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ PROJECT = 'virtualenvwrapper' # Change docs/sphinx/conf.py too! -VERSION = '2.10' +VERSION = '2.10.1' # Bootstrap installation of Distribute import distribute_setup From 3379dba33bd154fd1f11ba3794bb5003f7d3f47e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 4 Oct 2011 08:50:24 -0400 Subject: [PATCH 452/947] Added tag 2.10.1 for changeset 9e10c201a500 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 5ba322c..63b53ab 100644 --- a/.hgtags +++ b/.hgtags @@ -75,3 +75,4 @@ b20cf787d8e1c167853709ca01731a3efb4b5fe8 2.7.1 7e0abe005937033aaf5d00fe3db3c94addecef7b 2.8 7e0abe005937033aaf5d00fe3db3c94addecef7b 2.8 279244c0fa41a327cc534fc40e9e7fadea180c23 2.8 +9e10c201a5005cc2d6c6728dfb0cda56deb4339d 2.10.1 From 4e8a9f5eb490364e60f8fb1590dcf4d0d50509ee Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 4 Nov 2011 07:28:34 -0400 Subject: [PATCH 453/947] fix link to Justin Lily's helper post --- docs/en/tips.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/tips.rst b/docs/en/tips.rst index 4b77f57..2d08521 100644 --- a/docs/en/tips.rst +++ b/docs/en/tips.rst @@ -83,7 +83,7 @@ Automatically Run workon When Entering a Directory ================================================== `Justin Lily posted -`__ +`__ about some code he added to his shell environment to look at the directory each time he runs ``cd``. If it finds a ``.venv`` file, it activates the environment named within. On leaving that directory, From 2ce771abe95844fe6e878130a55b0106725d700f Mon Sep 17 00:00:00 2001 From: Mike Fogel Date: Fri, 18 Nov 2011 21:42:32 -0800 Subject: [PATCH 454/947] associate a project with a venv at creation --- virtualenvwrapper.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 8981e1a..4fbe871 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -273,6 +273,11 @@ function virtualenvwrapper_verify_active_environment { function mkvirtualenv_help { echo "Usage: mkvirtualenv [-i package] [-r requirements_file] [virtualenv options] env_name" echo + echo " -a project_path" + echo + echo " Provide a full path to a project directory to associate with" + echo " the new environment." + echo echo " -i package" echo echo " Install a package after the environment is created." @@ -318,6 +323,9 @@ function mkvirtualenv { a="${in_args[$i]}" # echo "arg $i : $a" case "$a" in + -a) + i=$(( $i + 1 )); + project="${in_args[$i]}";; -h) mkvirtualenv_help; return;; @@ -370,6 +378,11 @@ function mkvirtualenv { pip install $a done + if [ ! -z "$project" ] + then + setvirtualenvproject "" "$project" + fi + virtualenvwrapper_run_hook "post_mkvirtualenv" } From ca54320c159a79b1c93a90da49bad3ec055122fa Mon Sep 17 00:00:00 2001 From: Mike Fogel Date: Wed, 23 Nov 2011 13:50:06 -0800 Subject: [PATCH 455/947] add -a project_path to mkvirtualenv usage summary --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 4fbe871..2cf7d31 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -271,7 +271,7 @@ function virtualenvwrapper_verify_active_environment { # Help text for mkvirtualenv function mkvirtualenv_help { - echo "Usage: mkvirtualenv [-i package] [-r requirements_file] [virtualenv options] env_name" + echo "Usage: mkvirtualenv [-a project_path] [-i package] [-r requirements_file] [virtualenv options] env_name" echo echo " -a project_path" echo From c209d1f452e9410de3b4bfaddae7e6231feab961 Mon Sep 17 00:00:00 2001 From: Mike Fogel Date: Thu, 24 Nov 2011 14:16:49 -0800 Subject: [PATCH 456/947] test for 'mkvirtualenv -a ' --- tests/test_mkvirtualenv_associate.sh | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tests/test_mkvirtualenv_associate.sh diff --git a/tests/test_mkvirtualenv_associate.sh b/tests/test_mkvirtualenv_associate.sh new file mode 100644 index 0000000..d52de00 --- /dev/null +++ b/tests/test_mkvirtualenv_associate.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +#set -x + +test_dir=$(cd $(dirname $0) && pwd) + +export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" + rm -f "$test_dir/requirements.txt" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +test_associate() { + project="/dev/null" + env="env1" + ptrfile="$WORKON_HOME/$env/.project" + mkvirtualenv -a "$project" "$env" >/dev/null 2>&1 + assertTrue ".project not found" "[ -f $ptrfile ]" + assertEquals "$ptrfile contains wrong content" "$project" "$(cat $ptrfile)" +} + +. "$test_dir/shunit2" From 0a4c26837a69c1801f8014c43c189daae0898db2 Mon Sep 17 00:00:00 2001 From: Mike Fogel Date: Fri, 9 Dec 2011 23:45:59 -0800 Subject: [PATCH 457/947] documentation for -a flag --- docs/en/command_ref.rst | 6 ++++-- docs/en/scripts.rst | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/en/command_ref.rst b/docs/en/command_ref.rst index 4af940b..76736d3 100644 --- a/docs/en/command_ref.rst +++ b/docs/en/command_ref.rst @@ -22,9 +22,9 @@ Create a new environment, in the WORKON_HOME. Syntax:: - mkvirtualenv [-i package] [-r requirements_file] [virtualenv options] ENVNAME + mkvirtualenv [-a project_path] [-i package] [-r requirements_file] [virtualenv options] ENVNAME -All command line options except ``-i``, ``-r``, and ``-h`` are passed +All command line options except ``-a``, ``-i``, ``-r``, and ``-h`` are passed directly to ``virtualenv``. The new environment is automatically activated after being initialized. @@ -41,6 +41,8 @@ activated after being initialized. mynewenv (mynewenv)$ +The ``-a`` option can be used to associate a project with the new environment. + The ``-i`` option can be used to install one or more packages (by repeating the option) after the environment is created. diff --git a/docs/en/scripts.rst b/docs/en/scripts.rst index 2a046b7..1b6eafc 100644 --- a/docs/en/scripts.rst +++ b/docs/en/scripts.rst @@ -65,7 +65,8 @@ postmkvirtualenv :Sourced/Run: sourced ``$VIRTUALENVWRAPPER_HOOK_DIR/postmkvirtualenv`` is sourced after the new environment -is created and activated. +is created and activated. If the ``-a`` flag was used, +the link to the project directory is set up before this script is sourced. .. _scripts-precpvirtualenv: From cd77c94e88168473141c642926876c9fe98dbaab Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 28 Dec 2011 08:26:33 -0500 Subject: [PATCH 458/947] Add note about -a option to history file and clarify its description in the docs a bit. --- docs/en/command_ref.rst | 3 ++- docs/en/history.rst | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/en/command_ref.rst b/docs/en/command_ref.rst index 76736d3..5981df3 100644 --- a/docs/en/command_ref.rst +++ b/docs/en/command_ref.rst @@ -41,7 +41,8 @@ activated after being initialized. mynewenv (mynewenv)$ -The ``-a`` option can be used to associate a project with the new environment. +The ``-a`` option can be used to associate an existing project +directory with the new environment. The ``-i`` option can be used to install one or more packages (by repeating the option) after the environment is created. diff --git a/docs/en/history.rst b/docs/en/history.rst index d19da29..e7834b1 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,12 @@ Release History =============== +dev + + - Add ``-a`` option to :ref:`command-mkvirtualenv` to associate a + new virtualenv with an existing project directory. Contributed by + Mike Fogel (:bbuser:`mfogel`). + 2.10.1 - Changed arguments to :ref:`command-mktmpenv` so it always creates From deae3d51a4adca27119e5356225aada25fab1df0 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 28 Dec 2011 10:38:10 -0500 Subject: [PATCH 459/947] Remove support for Python 2.4 and 2.5. Update tests to work with virtualenv 1.7, where --no-site-packages is now the default. --- docs/en/history.rst | 3 +++ tests/test.sh | 8 ++++---- tests/test_cp.sh | 9 +++++++++ tests/test_toggleglobalsitepackages.sh | 2 +- tox.ini | 2 +- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index e7834b1..b181cf3 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -7,6 +7,9 @@ dev - Add ``-a`` option to :ref:`command-mkvirtualenv` to associate a new virtualenv with an existing project directory. Contributed by Mike Fogel (:bbuser:`mfogel`). + - Drops support for Python 2.4 and 2.5. The tools may still work, + but I no longer have a development environment set up for testing + them, so I do not officially support them. 2.10.1 diff --git a/tests/test.sh b/tests/test.sh index acadf67..edd1f49 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -92,18 +92,18 @@ test_get_python_version() { test_python_interpreter_set_incorrectly() { return_to="$(pwd)" cd "$WORKON_HOME" - mkvirtualenv --no-site-packages no_wrappers + mkvirtualenv no_wrappers expected="ImportError: No module named virtualenvwrapper.hook_loader" # test_shell is set by tests/run_tests if [ "$test_shell" = "" ] then - export test_shell=$SHELL + export test_shell=$SHELL fi subshell_output=$(VIRTUALENVWRAPPER_PYTHON="$WORKON_HOME/no_wrappers/bin/python" $test_shell $return_to/virtualenvwrapper.sh 2>&1) - echo "$subshell_output" + #echo "$subshell_output" echo "$subshell_output" | grep -q "$expected" 2>&1 found_it=$? - echo "$found_it" + #echo "$found_it" assertTrue "Expected \'$expected\', got: \'$subshell_output\'" "[ $found_it -eq 0 ]" assertFalse "Failed to detect invalid Python location" "VIRTUALENVWRAPPER_PYTHON=$VIRTUAL_ENV/bin/python $SHELL $return_to/virtualenvwrapper.sh >/dev/null 2>&1" cd "$return_to" diff --git a/tests/test_cp.sh b/tests/test_cp.sh index 88953e4..2567d93 100755 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -129,5 +129,14 @@ test_no_site_packages_default_args () { unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS } +test_no_site_packages_default_behavior () { + # See issue #102 + # virtualenv 1.7 changed to make --no-site-packages the default + mkvirtualenv "source" >/dev/null 2>&1 + cpvirtualenv "source" "destination" + ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" + assertTrue "$ngsp_file does not exist in copied env" "[ -f \"$ngsp_file\" ]" +} + . "$test_dir/shunit2" diff --git a/tests/test_toggleglobalsitepackages.sh b/tests/test_toggleglobalsitepackages.sh index 4c78467..87e2ebf 100755 --- a/tests/test_toggleglobalsitepackages.sh +++ b/tests/test_toggleglobalsitepackages.sh @@ -19,7 +19,7 @@ oneTimeTearDown() { setUp () { echo rm -f "$test_dir/catch_output" - mkvirtualenv --no-site-packages "globaltest" + mkvirtualenv --system-site-packages "globaltest" } tearDown () { diff --git a/tox.ini b/tox.ini index 56e9ebc..6faebb1 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py26,py25,py24 +envlist = py27,py26 [testenv] commands = bash ./tests/run_tests {envdir} [] From 963ea3f7d5741676b13f7bffd1bccd8fd02f803c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 28 Dec 2011 11:16:41 -0500 Subject: [PATCH 460/947] shortcut initialization if it has run before --- docs/en/history.rst | 1 + tests/test.sh | 1 + tests/test_project.sh | 1 + virtualenvwrapper.sh | 7 +++++++ 4 files changed, 10 insertions(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index b181cf3..67b74a1 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -10,6 +10,7 @@ dev - Drops support for Python 2.4 and 2.5. The tools may still work, but I no longer have a development environment set up for testing them, so I do not officially support them. + - Shortcut initialization if it has run before. 2.10.1 diff --git a/tests/test.sh b/tests/test.sh index edd1f49..a0db3f7 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -19,6 +19,7 @@ oneTimeTearDown() { setUp () { echo rm -f "$test_dir/catch_output" + unset VIRTUALENVWRAPPER_INITIALIZED } test_virtualenvwrapper_initialize() { diff --git a/tests/test_project.sh b/tests/test_project.sh index 2a71331..ef8f509 100755 --- a/tests/test_project.sh +++ b/tests/test_project.sh @@ -22,6 +22,7 @@ oneTimeTearDown() { setUp () { echo rm -f "$test_dir/catch_output" + unset VIRTUALENVWRAPPER_INITIALIZED } test_initialize() { diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 2cf7d31..eef274a 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -204,6 +204,10 @@ function virtualenvwrapper_setup_tab_completion { # Set up virtualenvwrapper properly function virtualenvwrapper_initialize { + if [ ! -z "$VIRTUALENVWRAPPER_INITIALIZED" ] + then + return 0 + fi export WORKON_HOME="$(virtualenvwrapper_derive_workon_home)" virtualenvwrapper_verify_workon_home -q || return 1 @@ -229,6 +233,9 @@ function virtualenvwrapper_initialize { virtualenvwrapper_setup_tab_completion + export VIRTUALENVWRAPPER_INITIALIZED=1 + + return 0 } From 6495c52a339ceee8621c0353547fcfe6502a0893 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 28 Dec 2011 11:51:42 -0500 Subject: [PATCH 461/947] make log files group writable; resolves #62 --- docs/en/history.rst | 2 ++ tests/test_log_dir.sh | 9 +++++++++ virtualenvwrapper/hook_loader.py | 11 ++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 67b74a1..ef49a8e 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -11,6 +11,8 @@ dev but I no longer have a development environment set up for testing them, so I do not officially support them. - Shortcut initialization if it has run before. + - Set hook log file permissions to be group-writable. (:bbissue:`62` + reported by :bbuser:`hedgeddown`) 2.10.1 diff --git a/tests/test_log_dir.sh b/tests/test_log_dir.sh index 2a1fc45..4661f50 100644 --- a/tests/test_log_dir.sh +++ b/tests/test_log_dir.sh @@ -17,6 +17,15 @@ test_set_by_user() { assertTrue "Log file was not created" "[ -f $WORKON_HOME/logs/hook.log ]" } +test_file_permissions() { + export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME/logs" + mkdir -p "$VIRTUALENVWRAPPER_LOG_DIR" + source "$test_dir/../virtualenvwrapper.sh" + perms=$(ls -l "$WORKON_HOME/logs/hook.log" | cut -f1 -d' ') + #echo $perms + assertTrue "Log file permissions are wrong: $perms" "echo $perms | grep '^-rw-rw'" +} + test_not_set_by_user() { unset WORKON_HOME unset VIRTUALENVWRAPPER_LOG_DIR diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 4bc9b47..b25e7bd 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -15,6 +15,15 @@ import pkg_resources +class GroupWriteRotatingFileHandler(logging.handlers.RotatingFileHandler): + """Taken from http://stackoverflow.com/questions/1407474/does-python-logging-handlers-rotatingfilehandler-allow-creation-of-a-group-writa + """ + def _open(self): + prevumask = os.umask(0o002) + rtv = logging.handlers.RotatingFileHandler._open(self) + os.umask(prevumask) + return rtv + def main(): parser = optparse.OptionParser( usage='usage: %prog [options] []', @@ -66,7 +75,7 @@ def main(): # Set up logging to a file root_logger.setLevel(logging.DEBUG) - file_handler = logging.handlers.RotatingFileHandler( + file_handler = GroupWriteRotatingFileHandler( os.path.expandvars(os.path.join('$VIRTUALENVWRAPPER_LOG_DIR', 'hook.log')), maxBytes=10240, backupCount=1, From 62bfaf88bd90e872a7df1ae9ba1ec3b204463734 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 28 Dec 2011 12:13:48 -0500 Subject: [PATCH 462/947] add VIRTUALENVWRAPPER_PROJECT_FILENAME; resolves issue 120 --- docs/en/history.rst | 4 ++++ docs/en/install.rst | 13 +++++++++++++ docs/en/projects.rst | 2 ++ tests/test_project_mk.sh | 8 ++++++++ virtualenvwrapper.sh | 15 +++++++++++---- virtualenvwrapper/project.py | 2 +- 6 files changed, 39 insertions(+), 5 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index ef49a8e..731cd75 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -13,6 +13,10 @@ dev - Shortcut initialization if it has run before. - Set hook log file permissions to be group-writable. (:bbissue:`62` reported by :bbuser:`hedgeddown`) + - Add ``VIRTUALENVWRAPPER_PROJECT_FILENAME`` variable so the + ``.project`` file used to link a virtualenv to a project can be + renamed to avoid conflicts with other tools. (:bbissue:`120` + reported by :bbuser:`arthuralvim`) 2.10.1 diff --git a/docs/en/install.rst b/docs/en/install.rst index 04ed3fc..9b679a1 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -154,6 +154,19 @@ The variable ``PROJECT_HOME`` tells virtualenvwrapper where to place your project working directories. The variable must be set and the directory created before :ref:`command-mkproject` is used. +.. seealso:: + + * :ref:`project-management` + +.. _variable-VIRTUALENVWRAPPER_PROJECT_FILENAME: + +Project Linkage Filename +------------------------ + +The variable ``VIRTUALENVWRAPPER_PROJECT_FILENAME`` tells +virtualenvwrapper how to name the file linking a virtualenv to a +project working directory. The default is ``.project``. + .. seealso:: * :ref:`project-management` diff --git a/docs/en/projects.rst b/docs/en/projects.rst index 5a5ae89..66a8b54 100644 --- a/docs/en/projects.rst +++ b/docs/en/projects.rst @@ -34,3 +34,5 @@ site, combine the :ref:`templates-bitbucket` and .. seealso:: * :ref:`extensions-templates` + * :ref:`variable-PROJECT_HOME` + * :ref:`variable-VIRTUALENVWRAPPER_PROJECT_FILENAME` diff --git a/tests/test_project_mk.sh b/tests/test_project_mk.sh index 4f50ab4..11ad35c 100755 --- a/tests/test_project_mk.sh +++ b/tests/test_project_mk.sh @@ -81,4 +81,12 @@ test_same_workon_and_project_home () { PROJECT_HOME="$old_project_home" } +test_alternate_linkage_filename () { + export VIRTUALENVWRAPPER_PROJECT_FILENAME=".not-project" + mkproject myproject6 >/dev/null 2>&1 + assertSame "myproject6" $(basename "$VIRTUAL_ENV") + assertSame "$PROJECT_HOME/myproject6" "$(cat $VIRTUAL_ENV/.not-project)" + export VIRTUALENVWRAPPER_PROJECT_FILENAME=".project" +} + . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index eef274a..a046be4 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -65,6 +65,13 @@ then VIRTUALENVWRAPPER_ENV_BIN_DIR="Scripts" fi +# Let the user override the name of the file that holds the project +# directory name. +if [ "$VIRTUALENVWRAPPER_PROJECT_FILENAME" = "" ] +then + export VIRTUALENVWRAPPER_PROJECT_FILENAME=".project" +fi + function virtualenvwrapper_derive_workon_home { typeset workon_home_dir="$WORKON_HOME" @@ -806,7 +813,7 @@ function setvirtualenvproject { prj="$(pwd)" fi echo "Setting project for $(basename $venv) to $prj" - echo "$prj" > "$venv/.project" + echo "$prj" > "$venv/$VIRTUALENVWRAPPER_PROJECT_FILENAME" } # Show help for mkproject @@ -911,9 +918,9 @@ function mkproject { function cdproject { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 - if [ -f "$VIRTUAL_ENV/.project" ] + if [ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" ] then - project_dir=$(cat "$VIRTUAL_ENV/.project") + project_dir=$(cat "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME") if [ ! -z "$project_dir" ] then cd "$project_dir" @@ -922,7 +929,7 @@ function cdproject { return 1 fi else - echo "No project set in $VIRTUAL_ENV/.project" 1>&2 + echo "No project set in $VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" 1>&2 return 1 fi return 0 diff --git a/virtualenvwrapper/project.py b/virtualenvwrapper/project.py index fb47f8b..5dd7c2e 100644 --- a/virtualenvwrapper/project.py +++ b/virtualenvwrapper/project.py @@ -56,5 +56,5 @@ def post_activate_source(args): # # Change to the project directory # -[ -f "$VIRTUAL_ENV/.project" ] && cd "$(cat \"$VIRTUAL_ENV/.project\")" +[ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" ] && cd "$(cat \"$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME\")" """ From ba7777c32c51723fa6df815d48cbccf78ea6adad Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 28 Dec 2011 12:35:38 -0500 Subject: [PATCH 463/947] bump version number for release --- docs/en/history.rst | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 731cd75..1117b15 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,7 +2,7 @@ Release History =============== -dev +2.11 - Add ``-a`` option to :ref:`command-mkvirtualenv` to associate a new virtualenv with an existing project directory. Contributed by diff --git a/setup.py b/setup.py index 7b1a7bc..9a72b21 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ PROJECT = 'virtualenvwrapper' # Change docs/sphinx/conf.py too! -VERSION = '2.10.1' +VERSION = '2.11' # Bootstrap installation of Distribute import distribute_setup From 918f5dd234b6038c05e00a502af7be440ce0ef86 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 28 Dec 2011 12:35:45 -0500 Subject: [PATCH 464/947] Added tag 2.11 for changeset ff4d492c873c --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 63b53ab..a36a3a9 100644 --- a/.hgtags +++ b/.hgtags @@ -76,3 +76,4 @@ b20cf787d8e1c167853709ca01731a3efb4b5fe8 2.7.1 7e0abe005937033aaf5d00fe3db3c94addecef7b 2.8 279244c0fa41a327cc534fc40e9e7fadea180c23 2.8 9e10c201a5005cc2d6c6728dfb0cda56deb4339d 2.10.1 +ff4d492c873c324ccfb71bc71118a67aa6195ad2 2.11 From a45e466644a6e669c6330a6e8bfad5c722dc1de2 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 28 Dec 2011 12:39:20 -0500 Subject: [PATCH 465/947] announcement for 2.11 release --- announce.rst | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/announce.rst b/announce.rst index 207abc8..924d8b7 100644 --- a/announce.rst +++ b/announce.rst @@ -1,6 +1,6 @@ -========================== - virtualenvwrapper 2.10.1 -========================== +======================== + virtualenvwrapper 2.11 +======================== What is virtualenvwrapper ========================= @@ -11,13 +11,20 @@ virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. -What's New in 2.10.1 -==================== - -This bug-fix release includes a change to ``mktmpenv`` to resolve a -problem with the way command line arguments were being handled. All -temporary environments are now given automatically-generated names and -the ability to name a temporary environment has been removed. +What's New in 2.11 +================== + +- Add ``-a`` option to ``mkvirtualenv`` to associate a + new virtualenv with an existing project directory. Contributed by + Mike Fogel. +- Drops support for Python 2.4 and 2.5. The tools may still work, + but I no longer have a development environment set up for testing + them, so I do not officially support them. +- Shortcut initialization if it has run before. +- Set hook log file permissions to be group-writable. (issue 62) +- Add ``VIRTUALENVWRAPPER_PROJECT_FILENAME`` variable so the + ``.project`` file used to link a virtualenv to a project can be + renamed to avoid conflicts with other tools. (issue 120) Installing ========== From 44c816bc42041c3b5c958b2d1232b2cf0f8cb841 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 8 Jan 2012 09:58:35 -0500 Subject: [PATCH 466/947] quiet some tests --- tests/test_dir_stack.sh | 11 ++++++++++- tests/test_ls.sh | 6 +++--- tests/test_project_activate.sh | 2 +- tests/test_project_templates.sh | 4 ++-- tests/test_toggleglobalsitepackages.sh | 6 +++--- tests/test_workon.sh | 4 ++-- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/tests/test_dir_stack.sh b/tests/test_dir_stack.sh index 514349d..5151954 100644 --- a/tests/test_dir_stack.sh +++ b/tests/test_dir_stack.sh @@ -8,6 +8,14 @@ export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" #unset HOOK_VERBOSE_OPTION +oneTimeSetUp() { + test_begin_dir=$(pwd) +} + +oneTimeTearDown() { + cd "$test_begin_dir" +} + setUp () { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" @@ -31,7 +39,7 @@ test_ticket_101 () { cd "$WORKON_HOME/start_here" pushd "$WORKON_HOME/on_the_stack" rmvirtualenv some_env - mkvirtualenv --no-site-packages some_env + mkvirtualenv some_env >/dev/null 2>&1 #echo "After mkvirtualenv: `pwd`" deactivate #echo "After deactivate: `pwd`" @@ -39,6 +47,7 @@ test_ticket_101 () { #echo "After popd: `pwd`" current_dir=$(pwd) assertSame "$WORKON_HOME/start_here" "$current_dir" + } . "$test_dir/shunit2" diff --git a/tests/test_ls.sh b/tests/test_ls.sh index 6dea47d..fb171b6 100755 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -22,7 +22,7 @@ setUp () { } test_get_site_packages_dir () { - mkvirtualenv "lssitepackagestest" + mkvirtualenv "lssitepackagestest" >/dev/null 2>&1 d=$(virtualenvwrapper_get_site_packages_dir) echo "site-packages in $d" assertTrue "site-packages dir $d does not exist" "[ -d $d ]" @@ -30,7 +30,7 @@ test_get_site_packages_dir () { } test_lssitepackages () { - mkvirtualenv "lssitepackagestest" + mkvirtualenv "lssitepackagestest" >/dev/null 2>&1 contents="$(lssitepackages)" actual=$(echo $contents | grep easy-install.pth) expected=$(echo $contents) @@ -39,7 +39,7 @@ test_lssitepackages () { } test_lssitepackages_add2virtualenv () { - mkvirtualenv "lssitepackagestest" + mkvirtualenv "lssitepackagestest" >/dev/null 2>&1 parent_dir=$(dirname $(pwd)) base_dir=$(basename $(pwd)) add2virtualenv "../$base_dir" diff --git a/tests/test_project_activate.sh b/tests/test_project_activate.sh index 95fa1d0..8e43632 100755 --- a/tests/test_project_activate.sh +++ b/tests/test_project_activate.sh @@ -26,7 +26,7 @@ setUp () { } test_activate () { - mkproject myproject + mkproject myproject >/dev/null 2>&1 deactivate cd $TMPDIR assertSame "" "$VIRTUAL_ENV" diff --git a/tests/test_project_templates.sh b/tests/test_project_templates.sh index 4f61d3c..347d56e 100755 --- a/tests/test_project_templates.sh +++ b/tests/test_project_templates.sh @@ -8,7 +8,7 @@ export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" export PROJECT_HOME="$(echo ${TMPDIR:-/tmp}/PROJECT_HOME | sed 's|//|/|g')" oneTimeSetUp() { - (cd "$test_dir/testtemplate" && python setup.py install) + (cd "$test_dir/testtemplate" && rm -rf build && python setup.py install) rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" rm -rf "$PROJECT_HOME" @@ -32,7 +32,7 @@ test_list_templates () { } test_apply_template () { - mkproject -t test proj1 + mkproject -t test proj1 >/dev/null 2>&1 assertTrue "Test file not created" "[ -f TEST_FILE ]" assertTrue "project name not found" "grep -q proj1 TEST_FILE" } diff --git a/tests/test_toggleglobalsitepackages.sh b/tests/test_toggleglobalsitepackages.sh index 87e2ebf..7d5a526 100755 --- a/tests/test_toggleglobalsitepackages.sh +++ b/tests/test_toggleglobalsitepackages.sh @@ -19,12 +19,12 @@ oneTimeTearDown() { setUp () { echo rm -f "$test_dir/catch_output" - mkvirtualenv --system-site-packages "globaltest" + mkvirtualenv --system-site-packages "globaltest" >/dev/null 2>&1 } tearDown () { - deactivate - rmvirtualenv "globaltest" + deactivate >/dev/null 2>&1 + rmvirtualenv "globaltest" >/dev/null 2>&1 } test_toggleglobalsitepackages () { diff --git a/tests/test_workon.sh b/tests/test_workon.sh index 1a8a911..38af59b 100755 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -10,8 +10,8 @@ oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" source "$test_dir/../virtualenvwrapper.sh" - mkvirtualenv "env1" - mkvirtualenv "env2" + mkvirtualenv "env1" >/dev/null 2>&1 + mkvirtualenv "env2" >/dev/null 2>&1 deactivate >/dev/null 2>&1 } From 187d11adfb5131368b2cf11ae0987d543ad29927 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 8 Jan 2012 10:07:49 -0500 Subject: [PATCH 467/947] Skiping re-initialization in subshells breaks tab completion, so go ahead and take the performance hit. Closes #121 --- virtualenvwrapper.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index a046be4..d05262d 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -211,10 +211,6 @@ function virtualenvwrapper_setup_tab_completion { # Set up virtualenvwrapper properly function virtualenvwrapper_initialize { - if [ ! -z "$VIRTUALENVWRAPPER_INITIALIZED" ] - then - return 0 - fi export WORKON_HOME="$(virtualenvwrapper_derive_workon_home)" virtualenvwrapper_verify_workon_home -q || return 1 @@ -240,8 +236,6 @@ function virtualenvwrapper_initialize { virtualenvwrapper_setup_tab_completion - export VIRTUALENVWRAPPER_INITIALIZED=1 - return 0 } From a797402e2a04e382063b24484b2ee361833ed791 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 8 Jan 2012 10:11:04 -0500 Subject: [PATCH 468/947] update history and version number for bug release --- announce.rst | 25 ++++++++----------------- docs/en/history.rst | 6 ++++++ setup.py | 2 +- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/announce.rst b/announce.rst index 924d8b7..544a3a7 100644 --- a/announce.rst +++ b/announce.rst @@ -1,6 +1,6 @@ -======================== - virtualenvwrapper 2.11 -======================== +========================== + virtualenvwrapper 2.11.1 +========================== What is virtualenvwrapper ========================= @@ -11,20 +11,11 @@ virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. -What's New in 2.11 -================== - -- Add ``-a`` option to ``mkvirtualenv`` to associate a - new virtualenv with an existing project directory. Contributed by - Mike Fogel. -- Drops support for Python 2.4 and 2.5. The tools may still work, - but I no longer have a development environment set up for testing - them, so I do not officially support them. -- Shortcut initialization if it has run before. -- Set hook log file permissions to be group-writable. (issue 62) -- Add ``VIRTUALENVWRAPPER_PROJECT_FILENAME`` variable so the - ``.project`` file used to link a virtualenv to a project can be - renamed to avoid conflicts with other tools. (issue 120) +What's New in 2.11.1 +==================== + +- Fixes a bug with tab completion in sub-shell environments such as + screen and tmux introduced in 2.11. Installing ========== diff --git a/docs/en/history.rst b/docs/en/history.rst index 1117b15..71015a6 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,12 @@ Release History =============== +2.11.1 + + - Remove the initialization shortcut because it breaks tab + completion in sub-shell environments like screen and + tmux. (:bbissue:`121`) + 2.11 - Add ``-a`` option to :ref:`command-mkvirtualenv` to associate a diff --git a/setup.py b/setup.py index 9a72b21..dc608a0 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ PROJECT = 'virtualenvwrapper' # Change docs/sphinx/conf.py too! -VERSION = '2.11' +VERSION = '2.11.1' # Bootstrap installation of Distribute import distribute_setup From 605c785b7866cd1e5e4e731c287a149ef24782d2 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 8 Jan 2012 10:11:08 -0500 Subject: [PATCH 469/947] Added tag 2.11.1 for changeset 12a1e0b65313 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index a36a3a9..6b50605 100644 --- a/.hgtags +++ b/.hgtags @@ -77,3 +77,4 @@ b20cf787d8e1c167853709ca01731a3efb4b5fe8 2.7.1 279244c0fa41a327cc534fc40e9e7fadea180c23 2.8 9e10c201a5005cc2d6c6728dfb0cda56deb4339d 2.10.1 ff4d492c873c324ccfb71bc71118a67aa6195ad2 2.11 +12a1e0b65313944c3a28d9e71fdef1c7cd41b930 2.11.1 From 7100f9daaf834b48799428432f404756a9121fb4 Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Tue, 10 Jan 2012 14:30:41 +0100 Subject: [PATCH 470/947] py3k compatibility --- virtualenvwrapper/hook_loader.py | 2 +- virtualenvwrapper/user_scripts.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index b25e7bd..ac70ac4 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -134,7 +134,7 @@ def run_hooks(hook, options, args, output=None): continue plugin = ep.load() if options.listing: - print ' %-10s -- %s' % (ep.name, inspect.getdoc(plugin) or '') + sys.stdout.write(' %-10s -- %s' % (ep.name, inspect.getdoc(plugin) or '') continue if options.sourcing: # Show the shell commands so they can diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 44d9016..12d33aa 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -37,7 +37,8 @@ def run_script(script_path, *args): log.debug('running %s', str(cmd)) try: return_code = subprocess.call(cmd) - except OSError, msg: + except OSError: + _, msg, _ = sys.exc_info() log.error('could not run "%s": %s', script_path, str(msg)) #log.debug('Returned %s', return_code) return From 6f678bb1d704e2bd1afd66df1cbe902eb01e8923 Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Tue, 10 Jan 2012 14:50:07 +0100 Subject: [PATCH 471/947] py3k compatibility --- virtualenvwrapper/hook_loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index ac70ac4..175f137 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -134,7 +134,7 @@ def run_hooks(hook, options, args, output=None): continue plugin = ep.load() if options.listing: - sys.stdout.write(' %-10s -- %s' % (ep.name, inspect.getdoc(plugin) or '') + sys.stdout.write(' %-10s -- %s' % (ep.name, inspect.getdoc(plugin) or '')) continue if options.sourcing: # Show the shell commands so they can From eb84f826e45067beb5e325df2b92356d18d9e6b1 Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Wed, 11 Jan 2012 12:09:35 +0100 Subject: [PATCH 472/947] py3k compatibility --- tests/test_add2virtualenv.sh | 2 +- tests/test_support.sh | 2 +- tox.ini | 2 +- virtualenvwrapper.sh | 8 ++++---- virtualenvwrapper/hook_loader.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/test_add2virtualenv.sh b/tests/test_add2virtualenv.sh index 2701488..2247d41 100755 --- a/tests/test_add2virtualenv.sh +++ b/tests/test_add2virtualenv.sh @@ -32,7 +32,7 @@ test_add2virtualenv () { assertTrue "No path insert code in $(cat $path_file)" "grep -q sys.__egginsert $path_file" # Check the path we inserted is actually at the top expected="$full_path" - actual=$($WORKON_HOME/pathtest/bin/python -c "import sys; print sys.path[1]") + actual=$($WORKON_HOME/pathtest/bin/python -c "import sys; sys.stdout.write(sys.path[1]+'\n')") assertSame "$expected" "$actual" # Make sure the temporary file created # during the edit was removed diff --git a/tests/test_support.sh b/tests/test_support.sh index a8e223d..313a59a 100755 --- a/tests/test_support.sh +++ b/tests/test_support.sh @@ -22,7 +22,7 @@ setUp () { } test_get_python_version () { - expected="$(python -c 'import sys; print ".".join([str(p) for p in sys.version_info[:2]])')" + expected="$(python -c 'import sys; sys.stdout.write(".".join([str(p) for p in sys.version_info[:2]])+'\n')')" echo "Expecting: $expected" vers=$(virtualenvwrapper_get_python_version) echo "Got : $vers" diff --git a/tox.ini b/tox.ini index 6faebb1..8e6656e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py26 +envlist = py32,py27,py26 [testenv] commands = bash ./tests/run_tests {envdir} [] diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index d05262d..7481d05 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -99,7 +99,7 @@ function virtualenvwrapper_derive_workon_home { # - Removing extra slashes (e.g., when TMPDIR ends in a slash) # - Expanding variables (e.g., $foo) # - Converting ~s to complete paths (e.g., ~/ to /home/brian/ and ~arthur to /home/arthur) - workon_home_dir=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os; print os.path.expandvars(os.path.expanduser(\"$workon_home_dir\"))") + workon_home_dir=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.expandvars(os.path.expanduser(\"$workon_home_dir\"))+'\n')") fi echo "$workon_home_dir" @@ -656,7 +656,7 @@ function add2virtualenv { for pydir in "$@" do - absolute_path=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os; print os.path.abspath(\"$pydir\")") + absolute_path=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.abspath(\"$pydir\")+'\n')") if [ "$absolute_path" != "$pydir" ] then echo "Warning: Converting \"$pydir\" to \"$absolute_path\"" 1>&2 @@ -939,11 +939,11 @@ mktmpenv() { typeset RC # Generate a unique temporary name - tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import uuid; print uuid.uuid4()' 2>/dev/null) + tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import uuid,sys; sys.stdout.write(uuid.uuid4()+"\n")' 2>/dev/null) if [ -z "$tmpenvname" ] then # This python does not support uuid - tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import random; print hex(random.getrandbits(64))[2:-1]' 2>/dev/null) + tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import random,sys; sys.stdout.write(hex(random.getrandbits(64))[2:-1]+"\n")' 2>/dev/null) fi # Create the environment diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 175f137..cf25b2c 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -134,7 +134,7 @@ def run_hooks(hook, options, args, output=None): continue plugin = ep.load() if options.listing: - sys.stdout.write(' %-10s -- %s' % (ep.name, inspect.getdoc(plugin) or '')) + sys.stdout.write(' %-10s -- %s\n' % (ep.name, inspect.getdoc(plugin) or '')) continue if options.sourcing: # Show the shell commands so they can From f1eded5dbc7db8eec79652faa209ce7bce428c89 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 29 Jan 2012 11:15:08 -0500 Subject: [PATCH 473/947] fix indentation --- tests/run_tests | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/run_tests b/tests/run_tests index 9745cb7..2bd039e 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -49,11 +49,11 @@ do for test_shell in bash ksh zsh do - test_shell_opts= - if [ $test_shell = "zsh" ]; then + test_shell_opts= + if [ $test_shell = "zsh" ]; then test_shell_opts="-o shwordsplit" - fi - export test_shell=$(which $test_shell) + fi + export test_shell=$(which $test_shell) echo echo '********************************************************************************' From d917d2ffbfd578b7a0a876bff4d6d2022de7241d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 29 Jan 2012 11:15:36 -0500 Subject: [PATCH 474/947] fix shell expression to get the python version --- tests/test_support.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_support.sh b/tests/test_support.sh index 313a59a..d63147e 100755 --- a/tests/test_support.sh +++ b/tests/test_support.sh @@ -22,7 +22,7 @@ setUp () { } test_get_python_version () { - expected="$(python -c 'import sys; sys.stdout.write(".".join([str(p) for p in sys.version_info[:2]])+'\n')')" + expected="$($VIRTUALENVWRAPPER_PYTHON -c 'import sys; sys.stdout.write("%s.%s\n" % sys.version_info[:2])')" echo "Expecting: $expected" vers=$(virtualenvwrapper_get_python_version) echo "Got : $vers" From 7ac201d2816e32e2cc6f5d76c3f0b37481669e1c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 29 Jan 2012 13:21:57 -0500 Subject: [PATCH 475/947] include virtualenv in the test dependencies --- tox.ini | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 8e6656e..b244e2e 100644 --- a/tox.ini +++ b/tox.ini @@ -3,9 +3,11 @@ envlist = py32,py27,py26 [testenv] commands = bash ./tests/run_tests {envdir} [] +deps = virtualenv # Not sure why this is needed, but on my system if it isn't included then # the python version picked up for 2.6 is actually 2.7. # IF THIS CAUSES YOU A PROBLEM COMMENT IT OUT BEFORE RUNNING THE TESTS. -#[testenv:py26] +[testenv:py26] #basepython=/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 +basepython=python2.6 From 2aa7970854506fc31d40a033e28346f3d3101956 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 29 Jan 2012 13:22:16 -0500 Subject: [PATCH 476/947] get the output in a way that makes it work properly with grep --- tests/test_mkvirtualenv.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index a1f5f47..27da3bc 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -81,7 +81,7 @@ test_no_workon_home () { export WORKON_HOME="$WORKON_HOME/not_there" mkvirtualenv should_be_created >"$old_home/output" 2>&1 output=$(cat "$old_home/output") - assertTrue "Did not see expected message" "echo $output | grep 'does not exist'" + assertTrue "Did not see expected message in \"$output\"" "cat \"$old_home/output\" | grep 'does not exist'" assertTrue "Did not create environment" "[ -d \"$WORKON_HOME/should_be_created\" ]" WORKON_HOME="$old_home" } From de6eaecf49b98b677d1b52db6b47c70c85dfc459 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 29 Jan 2012 13:47:53 -0500 Subject: [PATCH 477/947] use packages that can be installed under python 3 to test the -i option to mkvirtualenv --- tests/test_mkvirtualenv_install.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_mkvirtualenv_install.sh b/tests/test_mkvirtualenv_install.sh index 003905d..1098cfb 100644 --- a/tests/test_mkvirtualenv_install.sh +++ b/tests/test_mkvirtualenv_install.sh @@ -23,16 +23,16 @@ setUp () { } test_single_package () { - mkvirtualenv -i commandlineapp "env4" >/dev/null 2>&1 + mkvirtualenv -i IPy "env4" installed=$(pip freeze) - assertTrue "CommandLineApp not found in $installed" "echo $installed | grep CommandLineApp" + assertTrue "IPy not found in $installed" "pip freeze | grep IPy" } test_multiple_packages () { - mkvirtualenv -i commandlineapp -i csvcat "env4" >/dev/null 2>&1 + mkvirtualenv -i IPy -i WebTest "env5" installed=$(pip freeze) - assertTrue "CommandLineApp not found in $installed" "echo $installed | grep CommandLineApp" - assertTrue "csvcat not found in $installed" "echo $installed | grep csvcat" + assertTrue "IPy not found in $installed" "pip freeze | grep IPy" + assertTrue "WebTest not found in $installed" "pip freeze | grep WebTest" } . "$test_dir/shunit2" From 77929e835a5a191048b353c01afe449c1a2617b3 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 29 Jan 2012 17:09:38 -0500 Subject: [PATCH 478/947] use packages available for python 3 --- tests/test_mkvirtualenv_requirements.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_mkvirtualenv_requirements.sh b/tests/test_mkvirtualenv_requirements.sh index 88f8f26..12ac7d4 100644 --- a/tests/test_mkvirtualenv_requirements.sh +++ b/tests/test_mkvirtualenv_requirements.sh @@ -23,10 +23,10 @@ setUp () { } test_requirements_file () { - echo "commandlineapp" > "$test_dir/requirements.txt" + echo "IPy" > "$test_dir/requirements.txt" mkvirtualenv -r "$test_dir/requirements.txt" "env3" >/dev/null 2>&1 installed=$(pip freeze) - assertTrue "CommandLineApp not found in $installed" "echo $installed | grep CommandLineApp" + assertTrue "IPy not found in $installed" "pip freeze | grep IPy" } . "$test_dir/shunit2" From bd479fb33f7e116e9e985a32b72eed9c0f66283c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 29 Jan 2012 17:10:09 -0500 Subject: [PATCH 479/947] use the version of python in the virtualenv instead of depending on the PATH --- tests/test_support.sh | 2 +- virtualenvwrapper.sh | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/test_support.sh b/tests/test_support.sh index d63147e..5b2c6c7 100755 --- a/tests/test_support.sh +++ b/tests/test_support.sh @@ -22,7 +22,7 @@ setUp () { } test_get_python_version () { - expected="$($VIRTUALENVWRAPPER_PYTHON -c 'import sys; sys.stdout.write("%s.%s\n" % sys.version_info[:2])')" + expected="$($VIRTUAL_ENV/bin/python -c 'import sys; sys.stdout.write("%s.%s\n" % sys.version_info[:2])')" echo "Expecting: $expected" vers=$(virtualenvwrapper_get_python_version) echo "Got : $vers" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 7481d05..17f04bf 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -591,10 +591,11 @@ function workon { # Prints the Python version string for the current interpreter. function virtualenvwrapper_get_python_version { - # Uses the Python from the virtualenv because we're trying to - # determine the version installed there so we can build - # up the path to the site-packages directory. - python -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d. + # Uses the Python from the virtualenv rather than + # VIRTUALENVWRAPPER_PYTHON because we're trying to determine the + # version installed there so we can build up the path to the + # site-packages directory. + "$VIRTUAL_ENV/bin/python" -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d. } # Prints the path to the site-packages directory for the current environment. From ba0c542ceda3d62a4c7074524cea772459a71907 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 29 Jan 2012 18:17:29 -0500 Subject: [PATCH 480/947] remove redundant test --- tests/test.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index a0db3f7..c172276 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -84,12 +84,6 @@ test_virtualenvwrapper_verify_workon_home_missing_dir_grep_options() { unset GREP_OPTIONS } -test_get_python_version() { - expected=$(python -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d.) - actual=$(virtualenvwrapper_get_python_version) - assertSame "$expected" "$actual" -} - test_python_interpreter_set_incorrectly() { return_to="$(pwd)" cd "$WORKON_HOME" From a5745f2b0bc04e68702b957798b1780980e3c524 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 29 Jan 2012 18:22:19 -0500 Subject: [PATCH 481/947] bump version number, update history, prepare announcement --- announce.rst | 21 ++++++--------------- docs/en/history.rst | 6 ++++++ setup.py | 2 +- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/announce.rst b/announce.rst index 924d8b7..3519828 100644 --- a/announce.rst +++ b/announce.rst @@ -1,5 +1,5 @@ ======================== - virtualenvwrapper 2.11 + virtualenvwrapper 3.0 ======================== What is virtualenvwrapper @@ -11,20 +11,11 @@ virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. -What's New in 2.11 -================== - -- Add ``-a`` option to ``mkvirtualenv`` to associate a - new virtualenv with an existing project directory. Contributed by - Mike Fogel. -- Drops support for Python 2.4 and 2.5. The tools may still work, - but I no longer have a development environment set up for testing - them, so I do not officially support them. -- Shortcut initialization if it has run before. -- Set hook log file permissions to be group-writable. (issue 62) -- Add ``VIRTUALENVWRAPPER_PROJECT_FILENAME`` variable so the - ``.project`` file used to link a virtualenv to a project can be - renamed to avoid conflicts with other tools. (issue 120) +What's New in 3.0 +================= + +- Add Python 3 support, thanks in large part to the efforts of Daniel + Kraus. Tested under Python 2.6, 2.7, and 3.2. Installing ========== diff --git a/docs/en/history.rst b/docs/en/history.rst index 1117b15..c13e5f1 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,12 @@ Release History =============== +3.0 + + - Add Python 3 support, thanks in large part to the efforts of + Daniel Kraus (:bbuser:`dakra`). Tested under Python 2.6, 2.7, and + 3.2. + 2.11 - Add ``-a`` option to :ref:`command-mkvirtualenv` to associate a diff --git a/setup.py b/setup.py index 9a72b21..f32b2c6 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ PROJECT = 'virtualenvwrapper' # Change docs/sphinx/conf.py too! -VERSION = '2.11' +VERSION = '3.0' # Bootstrap installation of Distribute import distribute_setup From e7670175c2856645deecce5facf69b4faa4ae268 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 30 Jan 2012 10:25:46 -0500 Subject: [PATCH 482/947] use the version of python in the current virtualenv to install the template project into the tox virtualenv during the test --- tests/test_project_templates.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_project_templates.sh b/tests/test_project_templates.sh index 347d56e..366247f 100755 --- a/tests/test_project_templates.sh +++ b/tests/test_project_templates.sh @@ -8,7 +8,7 @@ export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" export PROJECT_HOME="$(echo ${TMPDIR:-/tmp}/PROJECT_HOME | sed 's|//|/|g')" oneTimeSetUp() { - (cd "$test_dir/testtemplate" && rm -rf build && python setup.py install) + (cd "$test_dir/testtemplate" && rm -rf build && "$VIRTUAL_ENV/bin/python" setup.py install) rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" rm -rf "$PROJECT_HOME" From 66261507696b471d2e366f53e6111e303a39f25d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 30 Jan 2012 10:46:07 -0500 Subject: [PATCH 483/947] fix version info in trove classifiers --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index f32b2c6..55591e6 100644 --- a/setup.py +++ b/setup.py @@ -129,10 +129,9 @@ def find_package_data( 'License :: OSI Approved :: BSD License', 'Programming Language :: Python', '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.2', 'Intended Audience :: Developers', 'Environment :: Console', ], From dffa5fd278f7e704aef166cbfbc358ac3017852c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 30 Jan 2012 10:46:59 -0500 Subject: [PATCH 484/947] fix version info in trove classifiers, take 2 --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 55591e6..7d55a80 100644 --- a/setup.py +++ b/setup.py @@ -131,6 +131,7 @@ def find_package_data( 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.2', 'Intended Audience :: Developers', 'Environment :: Console', From 270c09ee562dbeccf3e7e8f0138d90634eef8e61 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 21 Feb 2012 09:17:45 -0500 Subject: [PATCH 485/947] Added tag 3.0 for changeset 434b87ebc24a --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 6b50605..6fd0c65 100644 --- a/.hgtags +++ b/.hgtags @@ -78,3 +78,4 @@ b20cf787d8e1c167853709ca01731a3efb4b5fe8 2.7.1 9e10c201a5005cc2d6c6728dfb0cda56deb4339d 2.10.1 ff4d492c873c324ccfb71bc71118a67aa6195ad2 2.11 12a1e0b65313944c3a28d9e71fdef1c7cd41b930 2.11.1 +434b87ebc24ae24e6928c72d79764379aae87130 3.0 From f8e7b9251aabceecf83d0f310c9b363595348bfc Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 21 Feb 2012 09:27:42 -0500 Subject: [PATCH 486/947] Remove /usr/bin since apparently there are times when virtualenv is installed there due to vendor packages. Fixes #127 --- tests/test_mkvirtualenv.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index 27da3bc..5c4541f 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -59,7 +59,7 @@ GLOBAL postmkvirtualenv" test_no_virtualenv () { old_path="$PATH" - PATH="/usr/bin:/bin:/usr/sbin:/sbin" + PATH="/bin:/usr/sbin:/sbin" assertFalse "Found virtualenv in $(which virtualenv)" "which virtualenv" mkvirtualenv should_not_be_created 2>/dev/null RC=$? From 493fa7d7deffdb6a49c5e47c4e18ef5f4e930e0d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 21 Feb 2012 09:29:47 -0500 Subject: [PATCH 487/947] Add test files to the sdist package. Addresses #126 --- MANIFEST.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MANIFEST.in b/MANIFEST.in index 85a36ab..06238d2 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,5 +1,11 @@ include setup.py include distribute_setup.py include tests/* +include tests/testpackage/setup.py +include tests/testpackage/testscript.py +include tests/testtemplate/distribute_setup.py +include tests/testtemplate/setup.py +include tests/testtemplate/mytemplates/*.py recursive-include docs *.rst *.py *.html *.css *.js *.png *.txt +include tox.ini From ce15812c67f2d80a66bcdc4c782478afa17df76c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 22 Feb 2012 09:37:57 -0500 Subject: [PATCH 488/947] package release 3.0.1; fixes #126 --- announce.rst | 14 +++++++------- docs/en/history.rst | 5 +++++ setup.py | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/announce.rst b/announce.rst index 3519828..c787bff 100644 --- a/announce.rst +++ b/announce.rst @@ -1,6 +1,6 @@ -======================== - virtualenvwrapper 3.0 -======================== +========================= + virtualenvwrapper 3.0.1 +========================= What is virtualenvwrapper ========================= @@ -11,11 +11,11 @@ virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. -What's New in 3.0 -================= +What's New in 3.0.1 +=================== -- Add Python 3 support, thanks in large part to the efforts of Daniel - Kraus. Tested under Python 2.6, 2.7, and 3.2. +- Fix some packaging issues that made it more difficult to run the + tests directly from the sdist package. Installing ========== diff --git a/docs/en/history.rst b/docs/en/history.rst index 5fa1138..5ed90b5 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,11 @@ Release History =============== +3.0.1 + + - Fix some packaging issues that made it more difficult to run the + tests directly from the sdist package. (:bbissue:`126`) + 3.0 - Add Python 3 support, thanks in large part to the efforts of diff --git a/setup.py b/setup.py index 7d55a80..fe7f5c7 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ PROJECT = 'virtualenvwrapper' # Change docs/sphinx/conf.py too! -VERSION = '3.0' +VERSION = '3.0.1' # Bootstrap installation of Distribute import distribute_setup From eefa4c99a1660bf31a9a1a5dd4f39607578c0f27 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 22 Feb 2012 09:38:04 -0500 Subject: [PATCH 489/947] Added tag 3.0.1 for changeset 14cf7e58d321 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 6fd0c65..512e5b1 100644 --- a/.hgtags +++ b/.hgtags @@ -79,3 +79,4 @@ b20cf787d8e1c167853709ca01731a3efb4b5fe8 2.7.1 ff4d492c873c324ccfb71bc71118a67aa6195ad2 2.11 12a1e0b65313944c3a28d9e71fdef1c7cd41b930 2.11.1 434b87ebc24ae24e6928c72d79764379aae87130 3.0 +14cf7e58d32174c8e90cf6914a6604f3cff9f279 3.0.1 From 45a5f145f5951bac82e6c9fbbd821467f8bcc08b Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 28 Feb 2012 18:48:43 -0500 Subject: [PATCH 490/947] add a couple of debugging lines to the generated scripts --- virtualenvwrapper/hook_loader.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index cf25b2c..6139a3c 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -119,6 +119,8 @@ def main(): output = open(options.script_filename, "w") try: output.write('# %s\n' % hook) + # output.write('echo %s\n' % hook) + # output.write('set -x\n') run_hooks(hook + '_source', options, args, output) finally: output.close() From 80cf4cde6594dbad15cf7051b75ebc4d50af59cb Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 4 Mar 2012 18:40:49 -0500 Subject: [PATCH 491/947] add tags to announce.rst --- announce.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/announce.rst b/announce.rst index c787bff..16a1883 100644 --- a/announce.rst +++ b/announce.rst @@ -2,6 +2,8 @@ virtualenvwrapper 3.0.1 ========================= +.. tags:: virtualenvwrapper release python + What is virtualenvwrapper ========================= From 3a195c63fc10cbb508a251d52ca880e8c0f0f1c2 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 10 Mar 2012 10:43:05 -0500 Subject: [PATCH 492/947] associate project before enabling the new virtualenv; fixes #122 --- tests/test_mkvirtualenv_associate.sh | 38 ++++++++++++++++++++++++++++ virtualenvwrapper.sh | 13 ++++++---- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/tests/test_mkvirtualenv_associate.sh b/tests/test_mkvirtualenv_associate.sh index d52de00..7425741 100644 --- a/tests/test_mkvirtualenv_associate.sh +++ b/tests/test_mkvirtualenv_associate.sh @@ -20,6 +20,8 @@ oneTimeTearDown() { setUp () { echo rm -f "$test_dir/catch_output" + echo "#!/bin/sh" > "$WORKON_HOME/preactivate" + echo "#!/bin/sh" > "$WORKON_HOME/postactivate" } test_associate() { @@ -31,4 +33,40 @@ test_associate() { assertEquals "$ptrfile contains wrong content" "$project" "$(cat $ptrfile)" } +test_preactivate() { + project="/dev/null" + env="env2" + ptrfile="$WORKON_HOME/$env/.project" + cat - >"$WORKON_HOME/preactivate" <> "$test_dir/catch_output" +else + echo noexists >> "$test_dir/catch_output" +fi +EOF + chmod +x "$WORKON_HOME/preactivate" + mkvirtualenv -a "$project" "$env" >/dev/null 2>&1 + assertSame "preactivate did not find file" "exists" "$(cat $test_dir/catch_output)" +} + +test_postactivate() { + project="/dev/null" + env="env3" + ptrfile="$WORKON_HOME/$env/.project" +cat - >"$WORKON_HOME/postactivate" <> "$test_dir/catch_output" +else + echo noexists >> "$test_dir/catch_output" +fi +EOF + chmod +x "$WORKON_HOME/postactivate" + mkvirtualenv -a "$project" "$env" >/dev/null 2>&1 + assertSame "postactivate did not find file" "exists" "$(cat $test_dir/catch_output)" +} + . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 17f04bf..199a44c 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -373,6 +373,14 @@ function mkvirtualenv { # the environment won't exist. Use that to tell whether # we should switch to the environment and run the hook. [ ! -d "$WORKON_HOME/$envname" ] && return 0 + + # If they gave us a project directory, set it up now + # so the activate hooks can find it. + if [ ! -z "$project" ] + then + setvirtualenvproject "$WORKON_HOME/$envname" "$project" + fi + # Now activate the new environment workon "$envname" @@ -386,11 +394,6 @@ function mkvirtualenv { pip install $a done - if [ ! -z "$project" ] - then - setvirtualenvproject "" "$project" - fi - virtualenvwrapper_run_hook "post_mkvirtualenv" } From 16bdb77cb328bb3b3e586dd67569ee18dcac03f6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 10 Mar 2012 11:01:05 -0500 Subject: [PATCH 493/947] update history file for previous change --- docs/en/history.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index 5ed90b5..2bf5bc5 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,11 @@ Release History =============== +dev + + - Fix a problem with activation hooks when associating a new + virtualenv with an existing project directory. (:bbissue:`122`) + 3.0.1 - Fix some packaging issues that made it more difficult to run the From 71b5e6d8366a4fcd4fc01d23752c852432296d71 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 10 Mar 2012 11:24:06 -0500 Subject: [PATCH 494/947] quote the path as we are editing the pth file; fixes #132 --- docs/en/history.rst | 2 ++ tests/test_add2virtualenv.sh | 60 +++++++++++++++++++++++++++++++++--- virtualenvwrapper.sh | 2 +- 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 2bf5bc5..61adcd9 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -6,6 +6,8 @@ dev - Fix a problem with activation hooks when associating a new virtualenv with an existing project directory. (:bbissue:`122`) + - Fix a problem with :ref:`command-add2virtualenv` and paths + containing "special" characters such as ``&``. (:bbissue:`132`) 3.0.1 diff --git a/tests/test_add2virtualenv.sh b/tests/test_add2virtualenv.sh index 2247d41..0e39a33 100755 --- a/tests/test_add2virtualenv.sh +++ b/tests/test_add2virtualenv.sh @@ -9,7 +9,7 @@ export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" + source "$test_dir/../virtualenvwrapper.sh" >/dev/null 2>&1 } oneTimeTearDown() { @@ -41,7 +41,7 @@ test_add2virtualenv () { } test_add2virtualenv_relative () { - mkvirtualenv "pathtest" >/dev/null 2>&1 + mkvirtualenv "pathtest_relative" >/dev/null 2>&1 parent_dir=$(dirname $(pwd)) base_dir=$(basename $(pwd)) add2virtualenv "../$base_dir" @@ -51,18 +51,70 @@ test_add2virtualenv_relative () { cd - >/dev/null 2>&1 } +test_add2virtualenv_space () { + # see #132 + mkvirtualenv "pathtest_space" >/dev/null 2>&1 + parent_dir=$(dirname $(pwd)) + cdvirtualenv + mkdir 'a b' + add2virtualenv 'a b' + cdsitepackages + path_file="./_virtualenv_path_extensions.pth" + assertTrue "No 'a b' in \"`cat $path_file`\"" "grep -q 'a b' $path_file" + cd - >/dev/null 2>&1 +} + +test_add2virtualenv_ampersand () { + # see #132 + mkvirtualenv "pathtest_ampersand" >/dev/null 2>&1 + parent_dir=$(dirname $(pwd)) + cdvirtualenv + mkdir 'a & b' + add2virtualenv 'a & b' + cdsitepackages + path_file="./_virtualenv_path_extensions.pth" + assertTrue "No 'a & b' in \"`cat $path_file`\"" "grep -q 'a & b' $path_file" + cd - >/dev/null 2>&1 +} + test_add2virtualenv_delete () { path_file="./_virtualenv_path_extensions.pth" - mkvirtualenv "pathtest" >/dev/null 2>&1 + mkvirtualenv "pathtest_delete" >/dev/null 2>&1 cdsitepackages # Make sure it was added add2virtualenv "/full/path" - assertTrue "No $full_path in $(cat $path_file)" "grep -q $full_path $path_file" + assertTrue "No /full/path in $(cat $path_file)" "grep -q /full/path $path_file" # Remove it and verify that change add2virtualenv -d "/full/path" assertFalse "/full/path in `cat $path_file`" "grep -q /full/path $path_file" cd - >/dev/null 2>&1 } +test_add2virtualenv_delete_space () { + path_file="./_virtualenv_path_extensions.pth" + mkvirtualenv "pathtest_delete_space" >/dev/null 2>&1 + cdsitepackages + # Make sure it was added + add2virtualenv "/full/path with spaces" + assertTrue "No /full/path with spaces in $(cat $path_file)" "grep -q '/full/path with spaces' $path_file" + # Remove it and verify that change + add2virtualenv -d "/full/path with spaces" + assertFalse "/full/path with spaces in `cat $path_file`" "grep -q '/full/path with spaces' $path_file" + cd - >/dev/null 2>&1 +} + +test_add2virtualenv_delete_ampersand () { + path_file="./_virtualenv_path_extensions.pth" + mkvirtualenv "pathtest_delete_ampersand" >/dev/null 2>&1 + cdsitepackages + # Make sure it was added + add2virtualenv "/full/path & dir" + assertTrue "No /full/path & dir in $(cat $path_file)" "grep -q '/full/path & dir' $path_file" + # Remove it and verify that change + add2virtualenv -d "/full/path & dir" + assertFalse "/full/path & dir in `cat $path_file`" "grep -q '/full/path & dir' $path_file" + cd - >/dev/null 2>&1 +} + . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 199a44c..584431b 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -671,7 +671,7 @@ function add2virtualenv { sed -i.tmp "\:^$absolute_path$: d" "$path_file" else sed -i.tmp '1 a\ -'$absolute_path' +'"$absolute_path"' ' "$path_file" fi rm -f "${path_file}.tmp" From 9e29992416710d25c34c7fa775d82f12e26300dc Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 10 Mar 2012 11:38:29 -0500 Subject: [PATCH 495/947] prepare release 3.1 --- announce.rst | 16 +++++++++------- docs/en/history.rst | 2 +- setup.py | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/announce.rst b/announce.rst index 16a1883..d623024 100644 --- a/announce.rst +++ b/announce.rst @@ -1,6 +1,6 @@ -========================= - virtualenvwrapper 3.0.1 -========================= +======================= + virtualenvwrapper 3.1 +======================= .. tags:: virtualenvwrapper release python @@ -13,11 +13,13 @@ virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. -What's New in 3.0.1 -=================== +What's New in 3.1 +================= -- Fix some packaging issues that made it more difficult to run the - tests directly from the sdist package. +- Fix a problem with activation hooks when associating a new + virtualenv with an existing project directory. +- Fix a problem with ``add2virtualenv`` and paths containing "special" + characters such as ``&``. Installing ========== diff --git a/docs/en/history.rst b/docs/en/history.rst index 61adcd9..4a41617 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,7 +2,7 @@ Release History =============== -dev +3.1 - Fix a problem with activation hooks when associating a new virtualenv with an existing project directory. (:bbissue:`122`) diff --git a/setup.py b/setup.py index fe7f5c7..925d678 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ PROJECT = 'virtualenvwrapper' # Change docs/sphinx/conf.py too! -VERSION = '3.0.1' +VERSION = '3.1' # Bootstrap installation of Distribute import distribute_setup From a5dc88aa1b736f9880ea7a37a62037349fc04331 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 10 Mar 2012 11:38:38 -0500 Subject: [PATCH 496/947] Added tag 3.1 for changeset ebbb3ba81687 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 512e5b1..5b2628d 100644 --- a/.hgtags +++ b/.hgtags @@ -80,3 +80,4 @@ ff4d492c873c324ccfb71bc71118a67aa6195ad2 2.11 12a1e0b65313944c3a28d9e71fdef1c7cd41b930 2.11.1 434b87ebc24ae24e6928c72d79764379aae87130 3.0 14cf7e58d32174c8e90cf6914a6604f3cff9f279 3.0.1 +ebbb3ba8168703861c016ed66f443fb898f0b06b 3.1 From f094391a10610055adbcf86e76df2060493a01b2 Mon Sep 17 00:00:00 2001 From: "seth@seth-ec-laptop" Date: Fri, 16 Mar 2012 09:56:11 -0700 Subject: [PATCH 497/947] Make project_dir local so it doesn't clobber other variables. --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 584431b..2142cd4 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -918,7 +918,7 @@ function cdproject { virtualenvwrapper_verify_active_environment || return 1 if [ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" ] then - project_dir=$(cat "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME") + local project_dir=$(cat "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME") if [ ! -z "$project_dir" ] then cd "$project_dir" From fdf36a6c17418112b251f29d0ef922f214331952 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 16 Mar 2012 16:12:15 -0400 Subject: [PATCH 498/947] use typeset instead of local and provide attribution for the original fix --- docs/en/history.rst | 6 ++++++ virtualenvwrapper.sh | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 4a41617..c5e757d 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,12 @@ Release History =============== +dev + + - Make ``project_dir`` a local variable so that + :ref:`command-cdproject` does not interfere with other variables + the user might have set. (contributed by :bbuser:`slackorama`) + 3.1 - Fix a problem with activation hooks when associating a new diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 2142cd4..597034d 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -918,7 +918,7 @@ function cdproject { virtualenvwrapper_verify_active_environment || return 1 if [ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" ] then - local project_dir=$(cat "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME") + typeset project_dir=$(cat "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME") if [ ! -z "$project_dir" ] then cd "$project_dir" From c662a5905bae34e880ae8bd055f63ca785b0b5a9 Mon Sep 17 00:00:00 2001 From: "Bernardo B. Marques" Date: Tue, 3 Apr 2012 16:28:17 -0300 Subject: [PATCH 499/947] remove blank spaces --- virtualenvwrapper.sh | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 597034d..be72e0c 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -61,7 +61,7 @@ VIRTUALENVWRAPPER_ENV_BIN_DIR="bin" if [ "$OS" = "Windows_NT" ] && [ "$MSYSTEM" = "MINGW32" ] then # Only assign this for msys, cygwin use standard Unix paths - # and its own python installation + # and its own python installation VIRTUALENVWRAPPER_ENV_BIN_DIR="Scripts" fi @@ -156,7 +156,7 @@ function virtualenvwrapper_run_hook { fi "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' $HOOK_VERBOSE_OPTION --script "$hook_script" "$@" result=$? - + if [ $result -eq 0 ] then if [ ! -f "$hook_script" ] @@ -171,7 +171,7 @@ function virtualenvwrapper_run_hook { return $result } -# Set up tab completion. (Adapted from Arthur Koziel's version at +# Set up tab completion. (Adapted from Arthur Koziel's version at # http://arthurkoziel.com/2008/10/11/virtualenvwrapper-bash-completion/) function virtualenvwrapper_setup_tab_completion { if [ -n "$BASH" ] ; then @@ -203,7 +203,7 @@ function virtualenvwrapper_setup_tab_completion { _cdsitepackages_complete () { reply=( $(cdsitepackages && ls -d ${1}*) ) } - compctl -K _virtualenvs workon rmvirtualenv cpvirtualenv showvirtualenv + compctl -K _virtualenvs workon rmvirtualenv cpvirtualenv showvirtualenv compctl -K _cdvirtualenv_complete cdvirtualenv compctl -K _cdsitepackages_complete cdsitepackages fi @@ -452,9 +452,9 @@ function _lsvirtualenv_usage { # # Usage: lsvirtualenv [-l] function lsvirtualenv { - + typeset long_mode=true - if command -v "getopts" &> /dev/null + if command -v "getopts" &> /dev/null then # Use getopts when possible OPTIND=1 @@ -535,14 +535,14 @@ function workon { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_workon_environment $env_name || return 1 - + activate="$WORKON_HOME/$env_name/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate" if [ ! -f "$activate" ] then echo "ERROR: Environment '$WORKON_HOME/$env_name' does not contain an activate script." >&2 return 1 fi - + # Deactivate any current environment "destructively" # before switching so we use our override function, # if it exists. @@ -554,9 +554,9 @@ function workon { fi virtualenvwrapper_run_hook "pre_activate" "$env_name" - + source "$activate" - + # Save the deactivate function from virtualenv under a different name virtualenvwrapper_original_deactivate=`typeset -f deactivate | sed 's/deactivate/virtualenv_deactivate/g'` eval "$virtualenvwrapper_original_deactivate" @@ -568,10 +568,10 @@ function workon { # Call the local hook before the global so we can undo # any settings made by the local postactivate first. virtualenvwrapper_run_hook "pre_deactivate" - + env_postdeactivate_hook="$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/postdeactivate" old_env=$(basename "$VIRTUAL_ENV") - + # Call the original function. virtualenv_deactivate $1 @@ -585,9 +585,9 @@ function workon { fi }' - + virtualenvwrapper_run_hook "post_activate" - + return 0 } @@ -603,7 +603,7 @@ function virtualenvwrapper_get_python_version { # Prints the path to the site-packages directory for the current environment. function virtualenvwrapper_get_site_packages_dir { - echo "$VIRTUAL_ENV/lib/python`virtualenvwrapper_get_python_version`/site-packages" + echo "$VIRTUAL_ENV/lib/python`virtualenvwrapper_get_python_version`/site-packages" } # Path management for packages outside of the virtual env. @@ -620,15 +620,15 @@ function virtualenvwrapper_get_site_packages_dir { function add2virtualenv { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 - + site_packages="`virtualenvwrapper_get_site_packages_dir`" - + if [ ! -d "${site_packages}" ] then echo "ERROR: currently-active virtualenv does not appear to have a site-packages directory" >&2 return 1 fi - + # Prefix with _ to ensure we are loaded as early as possible, # and at least before easy_install.pth. path_file="$site_packages/_virtualenv_path_extensions.pth" @@ -702,7 +702,7 @@ function lssitepackages { virtualenvwrapper_verify_active_environment || return 1 typeset site_packages="`virtualenvwrapper_get_site_packages_dir`" ls $@ $site_packages - + path_file="$site_packages/_virtualenv_path_extensions.pth" if [ -f "$path_file" ] then @@ -749,7 +749,7 @@ function cpvirtualenv { fi typeset source_env="$env_home$env_name" typeset target_env="$env_home$new_env" - + if [ ! -e "$source_env" ] then echo "$env_name virtualenv doesn't exist" @@ -768,7 +768,7 @@ function cpvirtualenv { "$VIRTUALENVWRAPPER_VIRTUALENV" "$target_env" --relocatable \sed "s/VIRTUAL_ENV\(.*\)$env_name/VIRTUAL_ENV\1$new_env/g" < "$source_env/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate" > "$target_env/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate" - (\cd "$WORKON_HOME" && ( + (\cd "$WORKON_HOME" && ( virtualenvwrapper_run_hook "pre_cpvirtualenv" "$env_name" "$new_env"; virtualenvwrapper_run_hook "pre_mkvirtualenv" "$new_env" )) @@ -797,7 +797,7 @@ function virtualenvwrapper_verify_project_home { } # Given a virtualenv directory and a project directory, -# set the virtualenv up to be associated with the +# set the virtualenv up to be associated with the # project function setvirtualenvproject { typeset venv="$1" From 31729beed626a7d770c54ea6261bc77d70c02cc1 Mon Sep 17 00:00:00 2001 From: "Bernardo B. Marques" Date: Tue, 3 Apr 2012 16:35:26 -0300 Subject: [PATCH 500/947] support to remove several environments at once --- virtualenvwrapper.sh | 48 +++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index be72e0c..f288d16 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -399,35 +399,41 @@ function mkvirtualenv { # Remove an environment, in the WORKON_HOME. function rmvirtualenv { - typeset env_name="$1" virtualenvwrapper_verify_workon_home || return 1 - if [ "$env_name" = "" ] + if [ ${#@} = 0 ] then echo "Please specify an enviroment." >&2 return 1 fi - env_dir="$WORKON_HOME/$env_name" - if [ "$VIRTUAL_ENV" = "$env_dir" ] - then - echo "ERROR: You cannot remove the active environment ('$env_name')." >&2 - echo "Either switch to another environment, or run 'deactivate'." >&2 - return 1 - fi - # Move out of the current directory to one known to be - # safe, in case we are inside the environment somewhere. - typeset prior_dir="$(pwd)" - \cd "$WORKON_HOME" + # support to remove several environments + typeset env_name + for env_name in $@ + do + echo "Erasing $env_name..." + typeset env_dir="$WORKON_HOME/$env_name" + if [ "$VIRTUAL_ENV" = "$env_dir" ] + then + echo "ERROR: You cannot remove the active environment ('$env_name')." >&2 + echo "Either switch to another environment, or run 'deactivate'." >&2 + return 1 + fi - virtualenvwrapper_run_hook "pre_rmvirtualenv" "$env_name" - \rm -rf "$env_dir" - virtualenvwrapper_run_hook "post_rmvirtualenv" "$env_name" + # Move out of the current directory to one known to be + # safe, in case we are inside the environment somewhere. + typeset prior_dir="$(pwd)" + \cd "$WORKON_HOME" - # If the directory we used to be in still exists, move back to it. - if [ -d "$prior_dir" ] - then - \cd "$prior_dir" - fi + virtualenvwrapper_run_hook "pre_rmvirtualenv" "$env_name" + \rm -rf "$env_dir" + virtualenvwrapper_run_hook "post_rmvirtualenv" "$env_name" + + # If the directory we used to be in still exists, move back to it. + if [ -d "$prior_dir" ] + then + \cd "$prior_dir" + fi + done } # List the available environments. From 10674eb623967888a03053c5cfb33c3970e204ae Mon Sep 17 00:00:00 2001 From: "Bernardo B. Marques" Date: Tue, 3 Apr 2012 16:54:52 -0300 Subject: [PATCH 501/947] changing rmvirtualenv message: Erasing --> Removing --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index f288d16..d1cd0a7 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -410,7 +410,7 @@ function rmvirtualenv { typeset env_name for env_name in $@ do - echo "Erasing $env_name..." + echo "Removing $env_name..." typeset env_dir="$WORKON_HOME/$env_name" if [ "$VIRTUAL_ENV" = "$env_dir" ] then From 0e9d170dd47dbe3db70dc53404bb84746223084e Mon Sep 17 00:00:00 2001 From: "Bernardo B. Marques" Date: Tue, 3 Apr 2012 16:57:06 -0300 Subject: [PATCH 502/947] add test for removing several environments --- tests/test_rmvirtualenv.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_rmvirtualenv.sh b/tests/test_rmvirtualenv.sh index 5327953..1c2919a 100755 --- a/tests/test_rmvirtualenv.sh +++ b/tests/test_rmvirtualenv.sh @@ -29,6 +29,18 @@ test_remove () { assertFalse "[ -d $WORKON_HOME/deleteme ]" } +test_remove_several_envs () { + mkvirtualenv "deleteme" >/dev/null 2>&1 + assertTrue "[ -d $WORKON_HOME/deleteme ]" + deactivate + mkvirtualenv "deleteme2" >/dev/null 2>&1 + assertTrue "[ -d $WORKON_HOME/deleteme2 ]" + deactivate + rmvirtualenv "deleteme deleteme2" + assertFalse "[ -d $WORKON_HOME/deleteme ]" + assertFalse "[ -d $WORKON_HOME/deleteme2 ]" +} + test_within_virtualenv () { mkvirtualenv "deleteme" >/dev/null 2>&1 assertTrue "[ -d $WORKON_HOME/deleteme ]" From 0dc8e0f6d563283a7e66d5085e321ae54c10050e Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Wed, 4 Apr 2012 21:00:47 -0400 Subject: [PATCH 503/947] Changed trove classifiers from BSD to MIT (like the README indicates.) --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 925d678..278ba0d 100644 --- a/setup.py +++ b/setup.py @@ -126,7 +126,7 @@ def find_package_data( # (PROJECT, VERSION), classifiers = [ 'Development Status :: 5 - Production/Stable', - 'License :: OSI Approved :: BSD License', + 'License :: OSI Approved :: MIT License', 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.6', From 51120984def021ebfcedd631e7ff1f8b096849c6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 8 Apr 2012 13:50:37 -0400 Subject: [PATCH 504/947] Fix typo in documentation reported by Nick Martin. --- docs/en/install.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/install.rst b/docs/en/install.rst index 9b679a1..0397cce 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -108,7 +108,7 @@ Shell Startup File Add three lines to your shell startup file (``.bashrc``, ``.profile``, etc.) to set the location where the virtual environments should live, -the location of your development project directorkes, and the location +the location of your development project directories, and the location of the script installed with this package:: export WORKON_HOME=$HOME/.virtualenvs From a6e2c2e4194e796c633556ab9b9b889bf273d853 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 8 Apr 2012 13:52:35 -0400 Subject: [PATCH 505/947] attribution for previous commit --- docs/en/history.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index c5e757d..9659818 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -7,6 +7,7 @@ dev - Make ``project_dir`` a local variable so that :ref:`command-cdproject` does not interfere with other variables the user might have set. (contributed by :bbuser:`slackorama`) + - Fix typo in documentation reported by Nick Martin. 3.1 From 55451275ae0892f910cac827b1eb027f0fd49bd5 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 8 Apr 2012 14:06:14 -0400 Subject: [PATCH 506/947] add history details about license classification change --- docs/en/history.rst | 5 +++++ docs/en/index.rst | 2 ++ 2 files changed, 7 insertions(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index 9659818..edb6a77 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -8,6 +8,11 @@ dev :ref:`command-cdproject` does not interfere with other variables the user might have set. (contributed by :bbuser:`slackorama`) - Fix typo in documentation reported by Nick Martin. + - Change trove classifier for license "MIT" to reflect the license + text presented in the documentation. *This does not indicate a + change in the license, just a correction to the expression of that + intent. See :ref:`license`* (contributed by :bbuser:`ralphbean` as + fix for :bbissue:`134`) 3.1 diff --git a/docs/en/index.rst b/docs/en/index.rst index d1aa204..14b4cfe 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -226,6 +226,8 @@ issues. Before reporting bugs in the bug tracker, please test *without* your aliases enabled. If you can identify the alias causing the problem, that will help make virtualenvwrapper more robust. +.. _license: + ======= License ======= From 18268cc6df8db41108e1a8b7062eb1ddaeabd0f3 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 8 Apr 2012 14:39:42 -0400 Subject: [PATCH 507/947] update history for previous merge --- docs/en/history.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index edb6a77..48b8a58 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -13,6 +13,8 @@ dev change in the license, just a correction to the expression of that intent. See :ref:`license`* (contributed by :bbuser:`ralphbean` as fix for :bbissue:`134`) + - Extend :ref:`command-rmvirtualenv` to allow removing more than one + environment at a time. (contributed by :bbuser:`ciberglo`) 3.1 From adbfd8bf7d0ed31d29d3000d5fd27bf80543f271 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 8 Apr 2012 14:40:42 -0400 Subject: [PATCH 508/947] Centralize setup of variables for tests. Change WORKON_HOME and PROJECT_HOME for tests to make them unique across runs, allowing simultaneous test runs in different sandboxes. --- tests/setup.sh | 6 ++++++ tests/test.sh | 3 +-- tests/test_add2virtualenv.sh | 3 +-- tests/test_cd.sh | 3 +-- tests/test_cp.sh | 3 +-- tests/test_deactivate.sh | 3 +-- tests/test_derive_workon_home.sh | 3 +-- tests/test_dir_stack.sh | 3 +-- tests/test_hook_dir.sh | 3 +-- tests/test_log_dir.sh | 3 +-- tests/test_ls.sh | 3 +-- tests/test_mktmpenv.sh | 3 +-- tests/test_mkvirtualenv.sh | 3 +-- tests/test_mkvirtualenv_associate.sh | 3 +-- tests/test_mkvirtualenv_install.sh | 3 +-- tests/test_mkvirtualenv_requirements.sh | 3 +-- tests/test_project.sh | 4 +--- tests/test_project_activate.sh | 4 +--- tests/test_project_cd.sh | 4 +--- tests/test_project_mk.sh | 4 +--- tests/test_project_templates.sh | 4 +--- tests/test_rmvirtualenv.sh | 3 +-- tests/test_run_hook.sh | 3 +-- tests/test_support.sh | 3 +-- tests/test_tempfile.sh | 6 ++---- tests/test_toggleglobalsitepackages.sh | 3 +-- tests/test_workon.sh | 3 +-- 27 files changed, 33 insertions(+), 59 deletions(-) create mode 100644 tests/setup.sh diff --git a/tests/setup.sh b/tests/setup.sh new file mode 100644 index 0000000..ac0e9fd --- /dev/null +++ b/tests/setup.sh @@ -0,0 +1,6 @@ +# Setup globals used by the tests + +tmplocation=${TMPDIR:-/tmp} + +export WORKON_HOME="$(echo ${tmplocation}/WORKON_HOME.$$ | sed 's|//|/|g')" +export PROJECT_HOME="$(echo ${tmplocation}/PROJECT_HOME.$$ | sed 's|//|/|g')" diff --git a/tests/test.sh b/tests/test.sh index c172276..38666d6 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -3,8 +3,7 @@ #set -x test_dir=$(cd $(dirname $0) && pwd) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_add2virtualenv.sh b/tests/test_add2virtualenv.sh index 0e39a33..8a29eea 100755 --- a/tests/test_add2virtualenv.sh +++ b/tests/test_add2virtualenv.sh @@ -3,8 +3,7 @@ #set -x test_dir=$(cd $(dirname $0) && pwd) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_cd.sh b/tests/test_cd.sh index cd12fa6..44bdf85 100755 --- a/tests/test_cd.sh +++ b/tests/test_cd.sh @@ -3,8 +3,7 @@ #set -x test_dir=$(cd $(dirname $0) && pwd) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_cp.sh b/tests/test_cp.sh index 2567d93..65329a1 100755 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -3,8 +3,7 @@ #set -x test_dir=$(cd $(dirname $0) && pwd) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" #unset HOOK_VERBOSE_OPTION diff --git a/tests/test_deactivate.sh b/tests/test_deactivate.sh index aa3da19..d81dded 100755 --- a/tests/test_deactivate.sh +++ b/tests/test_deactivate.sh @@ -3,8 +3,7 @@ #set -x test_dir=$(cd $(dirname $0) && pwd) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_derive_workon_home.sh b/tests/test_derive_workon_home.sh index 5cf06ec..24077c7 100755 --- a/tests/test_derive_workon_home.sh +++ b/tests/test_derive_workon_home.sh @@ -3,8 +3,7 @@ #set -x test_dir=$(cd $(dirname $0) && pwd) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" TMP_WORKON_HOME="$WORKON_HOME" oneTimeSetUp() { diff --git a/tests/test_dir_stack.sh b/tests/test_dir_stack.sh index 5151954..c4969f0 100644 --- a/tests/test_dir_stack.sh +++ b/tests/test_dir_stack.sh @@ -3,8 +3,7 @@ #set -x test_dir=$(cd $(dirname $0) && pwd) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" #unset HOOK_VERBOSE_OPTION diff --git a/tests/test_hook_dir.sh b/tests/test_hook_dir.sh index 9849bef..38ece5b 100644 --- a/tests/test_hook_dir.sh +++ b/tests/test_hook_dir.sh @@ -3,8 +3,7 @@ #set -x test_dir=$(cd $(dirname $0) && pwd) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_log_dir.sh b/tests/test_log_dir.sh index 4661f50..a6bb970 100644 --- a/tests/test_log_dir.sh +++ b/tests/test_log_dir.sh @@ -3,8 +3,7 @@ #set -x test_dir=$(cd $(dirname $0) && pwd) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" setUp () { echo diff --git a/tests/test_ls.sh b/tests/test_ls.sh index fb171b6..01e44b9 100755 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -3,8 +3,7 @@ #set -x test_dir=$(cd $(dirname $0) && pwd) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_mktmpenv.sh b/tests/test_mktmpenv.sh index f6a4884..a781798 100644 --- a/tests/test_mktmpenv.sh +++ b/tests/test_mktmpenv.sh @@ -1,8 +1,7 @@ #!/bin/sh test_dir=$(cd $(dirname $0) && pwd) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index 5c4541f..bf2f08f 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -3,8 +3,7 @@ #set -x test_dir=$(cd $(dirname $0) && pwd) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_mkvirtualenv_associate.sh b/tests/test_mkvirtualenv_associate.sh index 7425741..d28644a 100644 --- a/tests/test_mkvirtualenv_associate.sh +++ b/tests/test_mkvirtualenv_associate.sh @@ -3,8 +3,7 @@ #set -x test_dir=$(cd $(dirname $0) && pwd) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_mkvirtualenv_install.sh b/tests/test_mkvirtualenv_install.sh index 1098cfb..9526aff 100644 --- a/tests/test_mkvirtualenv_install.sh +++ b/tests/test_mkvirtualenv_install.sh @@ -3,8 +3,7 @@ #set -x test_dir=$(cd $(dirname $0) && pwd) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_mkvirtualenv_requirements.sh b/tests/test_mkvirtualenv_requirements.sh index 12ac7d4..250d23e 100644 --- a/tests/test_mkvirtualenv_requirements.sh +++ b/tests/test_mkvirtualenv_requirements.sh @@ -3,8 +3,7 @@ #set -x test_dir=$(cd $(dirname $0) && pwd) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_project.sh b/tests/test_project.sh index ef8f509..c319f35 100755 --- a/tests/test_project.sh +++ b/tests/test_project.sh @@ -3,9 +3,7 @@ #set -x test_dir=$(dirname $0) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" -export PROJECT_HOME="$(echo ${TMPDIR:-/tmp}/PROJECT_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_project_activate.sh b/tests/test_project_activate.sh index 8e43632..21a80f4 100755 --- a/tests/test_project_activate.sh +++ b/tests/test_project_activate.sh @@ -3,9 +3,7 @@ #set -x test_dir=$(dirname $0) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" -export PROJECT_HOME="$(echo ${TMPDIR:-/tmp}/PROJECT_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_project_cd.sh b/tests/test_project_cd.sh index 05940a2..7486963 100755 --- a/tests/test_project_cd.sh +++ b/tests/test_project_cd.sh @@ -3,9 +3,7 @@ #set -x test_dir=$(dirname $0) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" -export PROJECT_HOME="$(echo ${TMPDIR:-/tmp}/PROJECT_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_project_mk.sh b/tests/test_project_mk.sh index 11ad35c..a5bd01f 100755 --- a/tests/test_project_mk.sh +++ b/tests/test_project_mk.sh @@ -3,9 +3,7 @@ #set -x test_dir=$(dirname $0) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" -export PROJECT_HOME="$(echo ${TMPDIR:-/tmp}/PROJECT_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_project_templates.sh b/tests/test_project_templates.sh index 366247f..953cd1e 100755 --- a/tests/test_project_templates.sh +++ b/tests/test_project_templates.sh @@ -3,9 +3,7 @@ #set -x test_dir=$(dirname $0) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" -export PROJECT_HOME="$(echo ${TMPDIR:-/tmp}/PROJECT_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { (cd "$test_dir/testtemplate" && rm -rf build && "$VIRTUAL_ENV/bin/python" setup.py install) diff --git a/tests/test_rmvirtualenv.sh b/tests/test_rmvirtualenv.sh index 1c2919a..afb5fc0 100755 --- a/tests/test_rmvirtualenv.sh +++ b/tests/test_rmvirtualenv.sh @@ -3,8 +3,7 @@ #set -x test_dir=$(cd $(dirname $0) && pwd) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_run_hook.sh b/tests/test_run_hook.sh index 29b1430..bc1e73d 100755 --- a/tests/test_run_hook.sh +++ b/tests/test_run_hook.sh @@ -3,8 +3,7 @@ #set -x test_dir=$(cd $(dirname $0) && pwd) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_support.sh b/tests/test_support.sh index 5b2c6c7..5b5d36d 100755 --- a/tests/test_support.sh +++ b/tests/test_support.sh @@ -3,8 +3,7 @@ #set -x test_dir=$(cd $(dirname $0) && pwd) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_tempfile.sh b/tests/test_tempfile.sh index 017193a..aaa1ae1 100755 --- a/tests/test_tempfile.sh +++ b/tests/test_tempfile.sh @@ -3,11 +3,9 @@ #set -x test_dir=$(cd $(dirname $0) && pwd) +source "$test_dir/setup.sh" -tmplocation=${TMPDIR:-/tmp} -export WORKON_HOME="$(echo ${tmplocation}/WORKON_HOME | sed 's|//|/|g')" - -export HOOK_VERBOSE_OPTION=-v +#export HOOK_VERBOSE_OPTION=-v oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_toggleglobalsitepackages.sh b/tests/test_toggleglobalsitepackages.sh index 7d5a526..4077ca8 100755 --- a/tests/test_toggleglobalsitepackages.sh +++ b/tests/test_toggleglobalsitepackages.sh @@ -3,8 +3,7 @@ #set -x test_dir=$(cd $(dirname $0) && pwd) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" diff --git a/tests/test_workon.sh b/tests/test_workon.sh index 38af59b..54f9ba0 100755 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -3,8 +3,7 @@ #set -x test_dir=$(cd $(dirname $0) && pwd) - -export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')" +source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" From 6fdb2e38c8647382ec35815c18062354a505e451 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 8 Apr 2012 14:50:45 -0400 Subject: [PATCH 509/947] more global test header cleanup --- tests/setup.sh | 4 ++++ tests/test.sh | 2 -- tests/test_add2virtualenv.sh | 2 -- tests/test_cd.sh | 2 -- tests/test_cp.sh | 2 -- tests/test_deactivate.sh | 2 -- tests/test_derive_workon_home.sh | 2 -- tests/test_dir_stack.sh | 4 ---- tests/test_hook_dir.sh | 2 -- tests/test_log_dir.sh | 2 -- tests/test_ls.sh | 2 -- tests/test_mkvirtualenv.sh | 2 -- tests/test_mkvirtualenv_associate.sh | 2 -- tests/test_mkvirtualenv_install.sh | 2 -- tests/test_mkvirtualenv_requirements.sh | 2 -- tests/test_project.sh | 2 -- tests/test_project_activate.sh | 2 -- tests/test_project_cd.sh | 2 -- tests/test_project_mk.sh | 2 -- tests/test_project_templates.sh | 2 -- tests/test_rmvirtualenv.sh | 2 -- tests/test_run_hook.sh | 2 -- tests/test_support.sh | 2 -- tests/test_tempfile.sh | 2 -- tests/test_toggleglobalsitepackages.sh | 2 -- tests/test_workon.sh | 2 -- 26 files changed, 4 insertions(+), 52 deletions(-) diff --git a/tests/setup.sh b/tests/setup.sh index ac0e9fd..402f0d5 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -1,6 +1,10 @@ # Setup globals used by the tests +#set -x + tmplocation=${TMPDIR:-/tmp} export WORKON_HOME="$(echo ${tmplocation}/WORKON_HOME.$$ | sed 's|//|/|g')" export PROJECT_HOME="$(echo ${tmplocation}/PROJECT_HOME.$$ | sed 's|//|/|g')" + +#unset HOOK_VERBOSE_OPTION diff --git a/tests/test.sh b/tests/test.sh index 38666d6..5705cc2 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_add2virtualenv.sh b/tests/test_add2virtualenv.sh index 8a29eea..5b68cb8 100755 --- a/tests/test_add2virtualenv.sh +++ b/tests/test_add2virtualenv.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_cd.sh b/tests/test_cd.sh index 44bdf85..56dc05c 100755 --- a/tests/test_cd.sh +++ b/tests/test_cd.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_cp.sh b/tests/test_cp.sh index 65329a1..2a2347a 100755 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_deactivate.sh b/tests/test_deactivate.sh index d81dded..7a7fd9c 100755 --- a/tests/test_deactivate.sh +++ b/tests/test_deactivate.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_derive_workon_home.sh b/tests/test_derive_workon_home.sh index 24077c7..b2b38fb 100755 --- a/tests/test_derive_workon_home.sh +++ b/tests/test_derive_workon_home.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" TMP_WORKON_HOME="$WORKON_HOME" diff --git a/tests/test_dir_stack.sh b/tests/test_dir_stack.sh index c4969f0..c807e7f 100644 --- a/tests/test_dir_stack.sh +++ b/tests/test_dir_stack.sh @@ -1,12 +1,8 @@ #!/bin/sh -#set -x - test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" -#unset HOOK_VERBOSE_OPTION - oneTimeSetUp() { test_begin_dir=$(pwd) } diff --git a/tests/test_hook_dir.sh b/tests/test_hook_dir.sh index 38ece5b..70d23f0 100644 --- a/tests/test_hook_dir.sh +++ b/tests/test_hook_dir.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_log_dir.sh b/tests/test_log_dir.sh index a6bb970..60ec4dc 100644 --- a/tests/test_log_dir.sh +++ b/tests/test_log_dir.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_ls.sh b/tests/test_ls.sh index 01e44b9..4b71e4a 100755 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index bf2f08f..b148167 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_mkvirtualenv_associate.sh b/tests/test_mkvirtualenv_associate.sh index d28644a..d825e5c 100644 --- a/tests/test_mkvirtualenv_associate.sh +++ b/tests/test_mkvirtualenv_associate.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_mkvirtualenv_install.sh b/tests/test_mkvirtualenv_install.sh index 9526aff..2f99dab 100644 --- a/tests/test_mkvirtualenv_install.sh +++ b/tests/test_mkvirtualenv_install.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_mkvirtualenv_requirements.sh b/tests/test_mkvirtualenv_requirements.sh index 250d23e..c08fe2c 100644 --- a/tests/test_mkvirtualenv_requirements.sh +++ b/tests/test_mkvirtualenv_requirements.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_project.sh b/tests/test_project.sh index c319f35..883a607 100755 --- a/tests/test_project.sh +++ b/tests/test_project.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(dirname $0) source "$test_dir/setup.sh" diff --git a/tests/test_project_activate.sh b/tests/test_project_activate.sh index 21a80f4..055cb15 100755 --- a/tests/test_project_activate.sh +++ b/tests/test_project_activate.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(dirname $0) source "$test_dir/setup.sh" diff --git a/tests/test_project_cd.sh b/tests/test_project_cd.sh index 7486963..dd8d53b 100755 --- a/tests/test_project_cd.sh +++ b/tests/test_project_cd.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(dirname $0) source "$test_dir/setup.sh" diff --git a/tests/test_project_mk.sh b/tests/test_project_mk.sh index a5bd01f..5ee3491 100755 --- a/tests/test_project_mk.sh +++ b/tests/test_project_mk.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(dirname $0) source "$test_dir/setup.sh" diff --git a/tests/test_project_templates.sh b/tests/test_project_templates.sh index 953cd1e..c6250cc 100755 --- a/tests/test_project_templates.sh +++ b/tests/test_project_templates.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(dirname $0) source "$test_dir/setup.sh" diff --git a/tests/test_rmvirtualenv.sh b/tests/test_rmvirtualenv.sh index afb5fc0..717d1e2 100755 --- a/tests/test_rmvirtualenv.sh +++ b/tests/test_rmvirtualenv.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_run_hook.sh b/tests/test_run_hook.sh index bc1e73d..bcee1be 100755 --- a/tests/test_run_hook.sh +++ b/tests/test_run_hook.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_support.sh b/tests/test_support.sh index 5b5d36d..2c5f226 100755 --- a/tests/test_support.sh +++ b/tests/test_support.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_tempfile.sh b/tests/test_tempfile.sh index aaa1ae1..4543fd2 100755 --- a/tests/test_tempfile.sh +++ b/tests/test_tempfile.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_toggleglobalsitepackages.sh b/tests/test_toggleglobalsitepackages.sh index 4077ca8..ef73a22 100755 --- a/tests/test_toggleglobalsitepackages.sh +++ b/tests/test_toggleglobalsitepackages.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_workon.sh b/tests/test_workon.sh index 54f9ba0..15b6de7 100755 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -1,7 +1,5 @@ #!/bin/sh -#set -x - test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" From 06f4dd39f2be78feb18a9b4e73e1feeecc6a625a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 8 Apr 2012 15:16:19 -0400 Subject: [PATCH 510/947] Use distutils to get the site-packages directory. Fixes #112 --- docs/en/history.rst | 7 +++++++ tests/test_cp.sh | 2 -- virtualenvwrapper.sh | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 48b8a58..d069b81 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -15,6 +15,13 @@ dev fix for :bbissue:`134`) - Extend :ref:`command-rmvirtualenv` to allow removing more than one environment at a time. (contributed by :bbuser:`ciberglo`) + - Change the definition of + ``virtualenvwrapper_get_site_packages_dir`` to ask ``distutils`` + for the ``site-packages`` directory instead of trying to build the + path ourselves in the shell script. This should resolve + :bbissue:`112` and improve support for Python interpreters other + than C Python. Thanks to Carl Meyer and Dario Bertini for their + contributions toward the fix. 3.1 diff --git a/tests/test_cp.sh b/tests/test_cp.sh index 2a2347a..2c5e778 100755 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -3,8 +3,6 @@ test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" -#unset HOOK_VERBOSE_OPTION - setUp () { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index d1cd0a7..b44fe61 100755 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -609,7 +609,7 @@ function virtualenvwrapper_get_python_version { # Prints the path to the site-packages directory for the current environment. function virtualenvwrapper_get_site_packages_dir { - echo "$VIRTUAL_ENV/lib/python`virtualenvwrapper_get_python_version`/site-packages" + "$VIRTUAL_ENV/bin/python" -c "import distutils; print(distutils.sysconfig.get_python_lib())" } # Path management for packages outside of the virtual env. From 587ecc1eae3ba362a19358ab3908c18236fc6daf Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 8 Apr 2012 15:19:07 -0400 Subject: [PATCH 511/947] Add a link target name for the rmvritualenv command --- docs/en/command_ref.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/en/command_ref.rst b/docs/en/command_ref.rst index 5981df3..1bab615 100644 --- a/docs/en/command_ref.rst +++ b/docs/en/command_ref.rst @@ -122,6 +122,8 @@ Syntax:: * :ref:`scripts-get_env_details` +.. _command-rmvirtualenv: + rmvirtualenv ------------ From 83d1b14d6cfff6eca51fd0f1d0335943edf89940 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 8 Apr 2012 15:19:52 -0400 Subject: [PATCH 512/947] bump version number --- docs/en/history.rst | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index d069b81..69f1796 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,7 +2,7 @@ Release History =============== -dev +3.2 - Make ``project_dir`` a local variable so that :ref:`command-cdproject` does not interfere with other variables diff --git a/setup.py b/setup.py index 278ba0d..9fe444a 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ PROJECT = 'virtualenvwrapper' # Change docs/sphinx/conf.py too! -VERSION = '3.1' +VERSION = '3.2' # Bootstrap installation of Distribute import distribute_setup From 30c30d6573f6a18a16007da7e9c902e0ea463603 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 8 Apr 2012 15:20:02 -0400 Subject: [PATCH 513/947] Added tag 3.2 for changeset dccf1a1abf4e --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 5b2628d..40c531f 100644 --- a/.hgtags +++ b/.hgtags @@ -81,3 +81,4 @@ ff4d492c873c324ccfb71bc71118a67aa6195ad2 2.11 434b87ebc24ae24e6928c72d79764379aae87130 3.0 14cf7e58d32174c8e90cf6914a6604f3cff9f279 3.0.1 ebbb3ba8168703861c016ed66f443fb898f0b06b 3.1 +dccf1a1abf4ea97589e9fa141167771049f031e0 3.2 From 14989f88414af01b2e73c8bb42fadfbfd1a3e0f2 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 8 Apr 2012 15:23:38 -0400 Subject: [PATCH 514/947] update announcement blog post for 3.2 --- announce.rst | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/announce.rst b/announce.rst index d623024..5588ea6 100644 --- a/announce.rst +++ b/announce.rst @@ -1,5 +1,5 @@ ======================= - virtualenvwrapper 3.1 + virtualenvwrapper 3.2 ======================= .. tags:: virtualenvwrapper release python @@ -13,13 +13,25 @@ virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. -What's New in 3.1 +What's New in 3.2 ================= -- Fix a problem with activation hooks when associating a new - virtualenv with an existing project directory. -- Fix a problem with ``add2virtualenv`` and paths containing "special" - characters such as ``&``. +- Make ``project_dir`` a local variable so that + ``cdproject`` does not interfere with other variables + the user might have set. (contributed by ``slackorama``) +- Fix typo in documentation reported by Nick Martin. +- Change trove classifier for license "MIT" to reflect the license + text presented in the documentation. *This does not indicate a + change in the license, just a correction to the expression of that + intent.* (contributed by ``ralphbean`` as fix for issue 134) +- Extend ``rmvirtualenv`` to allow removing more than one + environment at a time. (contributed by ``ciberglo``) +- Change the definition of ``virtualenvwrapper_get_site_packages_dir`` + to ask ``distutils`` for the ``site-packages`` directory instead of + trying to build the path ourselves in the shell script. This should + resolve issue 112 and improve support for Python interpreters other + than C Python. Thanks to Carl Meyer and Dario Bertini for their + contributions toward the fix. Installing ========== From 377a808cb79d49e8cbe70a0949093a325b3d0ec1 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Tue, 10 Apr 2012 10:23:44 -0400 Subject: [PATCH 515/947] Removed execution bit on virtualenvwrapper.sh It doesn't include a #! at the top and so wouldn't be executable anyways. --- virtualenvwrapper.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 virtualenvwrapper.sh diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh old mode 100755 new mode 100644 From 387e7c142d26730e61673377085a91c6afbb43db Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Tue, 10 Apr 2012 10:24:35 -0400 Subject: [PATCH 516/947] Removed shebangs from scripts non-executable site-packages files. These files look like they were never meant to be scripts. Their shebangs are likely leftover artifacts from the time they were first written. --- virtualenvwrapper/hook_loader.py | 1 - virtualenvwrapper/project.py | 1 - virtualenvwrapper/user_scripts.py | 1 - 3 files changed, 3 deletions(-) diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 6139a3c..264739b 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # encoding: utf-8 # # Copyright (c) 2010 Doug Hellmann. All rights reserved. diff --git a/virtualenvwrapper/project.py b/virtualenvwrapper/project.py index 5dd7c2e..65a9695 100644 --- a/virtualenvwrapper/project.py +++ b/virtualenvwrapper/project.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # encoding: utf-8 # # Copyright (c) 2010 Doug Hellmann. All rights reserved. diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 12d33aa..a2e881c 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # encoding: utf-8 # # Copyright (c) 2010 Doug Hellmann. All rights reserved. From f03b4efeceb3ac58a2c8115c00c5d89ea59015b1 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Apr 2012 18:56:27 -0400 Subject: [PATCH 517/947] Bypass the test for missing virtualenv if the user has it installed to the subset of the path needed for the shunit2 framework to function properly. Add a test for having VIRTUALENVWRAPER_VIRTUALENV set to a program that does not exist. --- tests/test_mkvirtualenv.sh | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index b148167..e1ae9c0 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -55,10 +55,18 @@ GLOBAL postmkvirtualenv" } test_no_virtualenv () { + # Find "which" before we change the path + which=$(which which) old_path="$PATH" PATH="/bin:/usr/sbin:/sbin" - assertFalse "Found virtualenv in $(which virtualenv)" "which virtualenv" - mkvirtualenv should_not_be_created 2>/dev/null + venv=$($which virtualenv 2>/dev/null) + if [ ! -z "$venv" ] + then + echo "FOUND \"$venv\" in PATH so skipping this test" + export PATH="$old_path" + return 0 + fi + mkvirtualenv should_not_be_created >/dev/null 2>&1 RC=$? # Restore the path before testing because # the test script depends on commands in the @@ -111,6 +119,25 @@ test_mkvirtualenv_args () { unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS } +test_no_such_virtualenv () { + VIRTUALENVWRAPPER_VIRTUALENV=/path/to/missing/program + + echo "#!/bin/sh" > "$WORKON_HOME/premkvirtualenv" + echo "echo GLOBAL premkvirtualenv \`pwd\` \"\$@\" >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" + chmod +x "$WORKON_HOME/premkvirtualenv" + + echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" + mkvirtualenv "env3" >/dev/null 2>&1 + output=$(cat "$test_dir/catch_output" 2>/dev/null) + workon_home_as_pwd=$(cd $WORKON_HOME; pwd) + expected="" + assertSame "$expected" "$output" + rm -f "$WORKON_HOME/premkvirtualenv" + rm -f "$WORKON_HOME/postmkvirtualenv" + + VIRTUALENVWRAPPER_VIRTUALENV=virtualenv +} + test_virtualenv_fails () { # Test to reproduce the conditions in issue #76 # https://bitbucket.org/dhellmann/virtualenvwrapper/issue/76/ From 3441f914058929359712abc3e092eea5edec90ea Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 16 Apr 2012 05:09:45 -0700 Subject: [PATCH 518/947] add attribution to history file for ralphbean's changes --- docs/en/history.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index 69f1796..c70a445 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,13 @@ Release History =============== +dev + + - Clean up file permissions and remove shebangs from scripts not + intended to be executed on the command line. (contributed by + :bbuser:`ralphbean`) + - Worked on some brittle tests. + 3.2 - Make ``project_dir`` a local variable so that From 799d6797f24edbcfc21dda99a4c9f209bbab3651 Mon Sep 17 00:00:00 2001 From: t2y Date: Sat, 28 Apr 2012 09:56:17 +0900 Subject: [PATCH 519/947] changed LANGUAGE settings "en" to "ja" --- docs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Makefile b/docs/Makefile index 50cb69f..32267b1 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -2,7 +2,7 @@ # # If doc language is English you don't need to set this variable -LANGUAGE = en +LANGUAGE = ja # You can set these variables from the command line. SPHINXOPTS = -c sphinx From 0c88e4fefc2aed17d2df184ec8f63e44d5c5d119 Mon Sep 17 00:00:00 2001 From: t2y Date: Sat, 28 Apr 2012 09:58:38 +0900 Subject: [PATCH 520/947] merged the changes (r369:550) for Japanese translation --- docs/ja/command_ref.rst | 240 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 236 insertions(+), 4 deletions(-) diff --git a/docs/ja/command_ref.rst b/docs/ja/command_ref.rst index 0dbc132..9c62c1c 100644 --- a/docs/ja/command_ref.rst +++ b/docs/ja/command_ref.rst @@ -41,13 +41,14 @@ WORKON_HOME に新たな仮想環境を作成します。 構文:: - mkvirtualenv [options] ENVNAME + mkvirtualenv [-a project_path] [-i package] [-r requirements_file] [virtualenv options] ENVNAME .. - All command line options are passed directly to ``virtualenv``. The - new environment is automatically activated after being initialized. + All command line options except ``-a``, ``-i``, ``-r``, and ``-h`` are passed + directly to ``virtualenv``. The new environment is automatically + activated after being initialized. -全てのコマンドラインオプションは ``virtualenv`` へ直接渡されます。新しい仮想環境は初期化された後に自動的にアクティブ化されます。 +``-a``, ``-i``, ``-r``, ``-h`` を除いた全てのコマンドラインオプションは ``virtualenv`` へ直接的に渡されます。新しい仮想環境は初期化された後に自動的にアクティブ化されます。 :: @@ -62,10 +63,68 @@ WORKON_HOME に新たな仮想環境を作成します。 mynewenv (mynewenv)$ +.. + The ``-a`` option can be used to associate an existing project + directory with the new environment. + +``-a`` オプションは、既存のプロジェクトディレクトリに新しい環境を関連付けるのに使います。 + +.. + The ``-i`` option can be used to install one or more packages (by + repeating the option) after the environment is created. + +``-i`` オプションは、その環境を作成した後に指定したパッケージをインストールできます (このオプションを繰り返し使うことで複数のパッケージもインストールできます) 。 + +.. + The ``-r`` option can be used to specify a text file listing packages + to be installed. The argument value is passed to ``pip -r`` to be + installed. + +``-r`` オプションは、インストールしたいパッケージ一覧を保存したテキストファイルを指定するのに使います。この引数のファイル名は ``pip -r`` へ渡されてインストールが行われます。 + .. seealso:: * :ref:`scripts-premkvirtualenv` * :ref:`scripts-postmkvirtualenv` + * `requirements ファイルのフォーマット`_ + +.. _requirements file format: http://www.pip-installer.org/en/latest/requirement-format.html +.. _requirements ファイルのフォーマット: http://www.pip-installer.org/en/latest/requirements.html#the-requirements-file-format + +.. _command-mktmpenv: + +mktmpenv +-------- + +.. + Create a new virtualenv in the ``WORKON_HOME`` directory. + +``WORKON_HOME`` ディレクトリに新しい環境を作成します。 + +.. + Syntax:: + +構文:: + + mktmpenv [VIRTUALENV_OPTIONS] + +.. + A unique virtualenv name is generated. + +一意な名前をもつ virtualenv 環境が生成されます。 + +:: + + $ mktmpenv + Using real prefix '/Library/Frameworks/Python.framework/Versions/2.7' + New python executable in 1e513ac6-616e-4d56-9aa5-9d0a3b305e20/bin/python + Overwriting 1e513ac6-616e-4d56-9aa5-9d0a3b305e20/lib/python2.7/distutils/__init__.py + with new content + Installing distribute............................................... + .................................................................... + .................................................................done. + This is a temporary environment. It will be deleted when deactivated. + (1e513ac6-616e-4d56-9aa5-9d0a3b305e20) $ .. _command-lsvirtualenv: @@ -124,6 +183,8 @@ showvirtualenv * :ref:`scripts-get_env_details` +.. _command-rmvirtualenv: + rmvirtualenv ------------ @@ -503,3 +564,174 @@ site-packages ディレクトリ内の ``virtualenv_path_extensions.pth`` と名 *Based on a contribution from James Bennett and Jannis Leidel.* *James Bennett と Jannis Leidel から提供されたものに基づいています。* + +.. _command-toggleglobalsitepackages: + +toggleglobalsitepackages +------------------------ + +.. + Controls whether the active virtualenv will access the packages in the + global Python ``site-packages`` directory. + +アクティブな virtualenv が、グローバルの Python ``site-packages`` ディレクトリにあるパッケージにアクセスさせるかどうかを制御します。 + +.. + Syntax:: + +構文:: + + toggleglobalsitepackages [-q] + +.. + Outputs the new state of the virtualenv. Use the ``-q`` switch to turn off all + output. + +実行すると virtualenv の更新後の状態を表示します。非表示にするには ``-q`` を指定してください。 + +:: + + $ mkvirtualenv env1 + New python executable in env1/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + (env1)$ toggleglobalsitepackages + Disabled global site-packages + (env1)$ toggleglobalsitepackages + Enabled global site-packages + (env1)$ toggleglobalsitepackages -q + (env1)$ + +.. + ============================ + Project Directory Management + ============================ + +============================== +プロジェクトディレクトリの管理 +============================== + +.. seealso:: + + :ref:`project-management` + +.. _command-mkproject: + +mkproject +--------- + +.. + Create a new virtualenv in the WORKON_HOME and project directory in + PROJECT_HOME. + +PROJECT_HOME にプロジェクトディレクトリと WORKON_HOME に新しい virtualenv を作成します。 + +.. + Syntax:: + +構文:: + + mkproject [-t template] [virtualenv_options] ENVNAME + +.. + The template option may be repeated to have several templates used to + create a new project. The templates are applied in the order named on + the command line. All other options are passed to ``mkvirtualenv`` to + create a virtual environment with the same name as the project. + +テンプレートオプションは、新しいプロジェクトを作成するのに使うテンプレートを複数指定できます。テンプレートはコマンドラインで指定した順番で適用されます。その他の全てのオプションは、プロジェクトと同じ名前をもつ仮想環境を作成するために ``mkvirtualenv`` に渡されます。 + +:: + + $ mkproject myproj + New python executable in myproj/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + Creating /Users/dhellmann/Devel/myproj + (myproj)$ pwd + /Users/dhellmann/Devel/myproj + (myproj)$ echo $VIRTUAL_ENV + /Users/dhellmann/Envs/myproj + (myproj)$ + +.. seealso:: + + * :ref:`scripts-premkproject` + * :ref:`scripts-postmkproject` + +setvirtualenvproject +-------------------- + +.. + Bind an existing virtualenv to an existing project. + +既存の virtualenv を既存のプロジェクトに束縛します。 + +.. + Syntax:: + +構文:: + + setvirtualenvproject [virtualenv_path project_path] + +.. + The arguments to ``setvirtualenvproject`` are the full paths to the + virtualenv and project directory. An association is made so that when + ``workon`` activates the virtualenv the project is also activated. + +``setvirtualenvproject`` への引数は、virtualenv とプロジェクトディレクトリへのフルパスです。仮想環境のアクティブ化を ``workon`` で行うときに、そのプロジェクトもアクティブ化されるように連携します。 + +:: + + $ mkproject myproj + New python executable in myproj/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + Creating /Users/dhellmann/Devel/myproj + (myproj)$ mkvirtualenv myproj_new_libs + New python executable in myproj/bin/python + Installing distribute............................................. + .................................................................. + .................................................................. + done. + Creating /Users/dhellmann/Devel/myproj + (myproj_new_libs)$ setvirtualenvproject $VIRTUAL_ENV $(pwd) + +.. + When no arguments are given, the current virtualenv and current + directory are assumed. + +引数を指定しない場合は、カレントの virtualenv とカレントディレクトリが指定されたと見なします。 + +.. + Any number of virtualenvs can refer to the same project directory, + making it easy to switch between versions of Python or other + dependencies for testing. + +任意の数の virtualenv が、Python またはその他のテスト向けの依存関係をもったバージョン間で切り替えやすいように、同じプロジェクトディレクトリを参照できます。 + +.. _command-cdproject: + +cdproject +--------- + +.. + Change the current working directory to the one specified as the + project directory for the active virtualenv. + +カレントのワークディレクトリから、アクティブな virtualenv のプロジェクトディレクトリとして指定したディレクトリに変更します。 + +.. + Syntax:: + +構文:: + + + cdproject + From 867e01712375943ce1c6018f7511d30d47c642d6 Mon Sep 17 00:00:00 2001 From: t2y Date: Sat, 28 Apr 2012 14:26:03 +0900 Subject: [PATCH 521/947] merged the changes (r369:550) for Japanese translation --- docs/ja/install.rst | 386 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 320 insertions(+), 66 deletions(-) diff --git a/docs/ja/install.rst b/docs/ja/install.rst index d008fe0..16a9663 100644 --- a/docs/ja/install.rst +++ b/docs/ja/install.rst @@ -18,15 +18,76 @@ .. virtualenvwrapper is a set of shell *functions* defined in Bourne - shell compatible syntax. It is tested under `bash`, `ksh`, and `zsh`. + shell compatible syntax. Its automated tests run under these + shells on OS X and Linux: + +virtualenvwrapper は Bourne シェル互換の構文をもつ一連のシェル *関数* です。Mac OS X と Linux 環境の、次のシェルで自動テストを行っています。 + +* ``bash`` +* ``ksh`` +* ``zsh`` + +.. It may work with other shells, so if you find that it does work with a shell not listed here please let me know. If you can modify it to - work with another shell, without completely rewriting it, send a pull - request through the bitbucket project page. If you write a clone to + work with another shell without completely rewriting it, then send a pull + request through the `bitbucket project page`_. If you write a clone to work with an incompatible shell, let me know and I will link to it from this page. -virtualenvwrapper は Bourne シェル互換の構文で定義されたシェル *関数* のセットです。それは `bash`, `ksh` と `zsh` でテストされています。その他のシェルでも動作するかもしれませんが、ここに記載されていないシェルで動作することを発見したら私に教えてください。もしあなたがその他のシェルで動作させるために virtualenvwrapper を完全に書き直すことなく修正できるなら、bitbucket のプロジェクトページを通じて pull リクエストを送ってください。あなたが非互換なシェル上で動作させるクローンを作成するなら、このページでリンクを張るので私に連絡してください。 +その他のシェルでも動作するかもしれません。ここに記載されていないシェルで動作するのを発見したら私に教えてください。また、その他のシェルでも動作するように virtualenvwrapper を全く違うものに書き換えずに修正できるなら、 `bitbucket のプロジェクトページ`_ から pull リクエストを送ってください。あなたが非互換なシェル上で動作させるクローンを作成するなら、このページでリンクを張るので私に連絡してください。 + +.. _bitbucket project page: https://bitbucket.org/dhellmann/virtualenvwrapper/ +.. _bitbucket のプロジェクトページ: https://bitbucket.org/dhellmann/virtualenvwrapper/ + +MSYS +---- + +.. + It is possible to use virtualenv wrapper under `MSYS + `_ with a native Windows Python + installation. In order to make it work, you need to define an extra + environment variable named ``MSYS_HOME`` containing the root path to + the MSYS installation. + +Python を Windows ネイティブにインストールした `MSYS `_ 環境でも virtualenvwrapper が使えます。そのためには、インストールした MSYS 環境へのルートパスを ``MSYS_HOME`` という環境変数で定義する必要があります。 + +:: + + export WORKON_HOME=$HOME/.virtualenvs + export MSYS_HOME=/c/msys/1.0 + source /usr/local/bin/virtualenvwrapper.sh + +.. + or:: + +または:: + + export WORKON_HOME=$HOME/.virtualenvs + export MSYS_HOME=C:\msys\1.0 + source /usr/local/bin/virtualenvwrapper.sh + +.. + Depending on your MSYS setup, you may need to install the `MSYS mktemp + binary`_ in the ``MSYS_HOME/bin`` folder. + +MSYS の設定によります。 ``MSYS_HOME/bin`` フォルダーに `MSYS mktemp binary`_ をインストールする必要があるかもしれません。 + +.. _MSYS mktemp binary: http://sourceforge.net/projects/mingw/files/MSYS/mktemp/ + +PowerShell +---------- + +.. + Guillermo López-Anglada has ported virtualenvwrapper to run under + Microsoft's PowerShell. We have agreed that since it is not compatible + with the rest of the extensions, and is largely a re-implementation + (rather than an adaptation), it should be distributed separately. You + can download virtualenvwrapper-powershell_ from PyPI. + +Guillermo López-Anglada は、Microsoft の PowerShell 環境で実行できるように virtualenvwrapper を移植しました。それは他の拡張機能と互換性がなく、(機能拡張というよりは) 大幅な再実装であることから、別に配布するようにしました。 virtualenvwrapper-powershell_ は、PyPI からダウンロードできます。 + +.. _virtualenvwrapper-powershell: http://pypi.python.org/pypi/virtualenvwrapper-powershell/2.7.1 .. Python Versions @@ -46,91 +107,234 @@ virtualenvwrapper は Python 2.4 - 2.7 でテストされています。 Basic Installation ================== +.. _install-basic: + 基本的なインストール ==================== .. - virtualenvwrapper should be installed using pip_:: + virtualenvwrapper should be installed into the same global + site-packages area where virtualenv is installed. You may need + administrative privileges to do that. The easiest way to install it + is using pip_:: -virtualenvwrapper は pip_ でインストールすべきです。 +virtualenvwrapper は、virtualenv がインストールされているグローバルな site-packages ディレクトリと同じところにインストールする必要があります。それを行うには、管理者特権が必要になるかもしれません。最も簡単なインストール方法は pip_ を使うことです。 :: $ pip install virtualenvwrapper -.. - You will want to install it into the global Python site-packages area, - along with virtualenv. You may need administrative privileges to do - that. +または:: + + $ sudo pip install virtualenvwrapper + +.. warning:: -virtualenv と同様にグローバルな Python site-packages にインストールしたくなるでしょう。そうするには管理者権限が必要になるかもしれません。 + .. + virtualenv lets you create many different Python environments. You + should only ever install virtualenv and virtualenvwrapper on your + base Python installation (i.e. NOT while a virtualenv is active) + so that the same release is shared by all Python environments that + depend on it. + + virtualenv を使うと、たくさんの独立した Python 環境を作成できます。システム環境に依存する全ての Python 環境から同じパッケージを共有できるように、システムにインストールされている Python (virtualenv がアクティブではない) に virtualenv と virtualenvwrapper の2つだけはインストールする必要があります。 .. An alternative to installing it into the global site-packages is to - add it to your user local directory (usually `~/.local`). + add it to `your user local directory + `__ + (usually `~/.local`). -グローバルな site-packages にインストールに対する代替案は、ユーザのローカルディレクトリ (普通は `~/.local`) に追加することです。 +グローバルの site-packages ディレクトリにインストールする代わりに `ユーザーのローカルディレクトリ `__ (普通は `~/.local`) にインストールできます。 :: $ pip install --install-option="--user" virtualenvwrapper -WORKON_HOME -=========== - -.. - The variable ``WORKON_HOME`` tells virtualenvwrapper where to place - your virtual environments. The default is ``$HOME/.virtualenvs``. - This directory must be created before using any virtualenvwrapper - commands. - -変数 ``WORKON_HOME`` は 仮想環境の作成場所を virtualenvwrapper に伝えます。デフォルトは ``$HOME/.virtualenvs`` です。このディレクトリは virtualenvwrapper のコマンドを使用する前に作成しなければなりません。 - -.. _install-shell-config: - .. Shell Startup File ================== +.. _install-shell-config: + シェルの起動ファイル ==================== .. - Add two lines to your shell startup file (``.bashrc``, ``.profile``, - etc.) to set the location where the virtual environments should live - and the location of the script installed with this package:: + Add three lines to your shell startup file (``.bashrc``, ``.profile``, + etc.) to set the location where the virtual environments should live, + the location of your development project directories, and the location + of the script installed with this package:: -シェルの起動ファイル(``.bashrc``, ``.profile`` 等)に、仮想環境が構築される場所と virtualenvwrapper がインストールしたシェルスクリプトの場所の2行追加してください。 +シェルの起動ファイル (``.bashrc``, ``.profile`` など) に、仮想環境を構築する場所、開発中のプロジェクトディレクトリの場所、virtualenvwrapper がインストールしたシェルスクリプトの場所の3行を追加してください。 :: export WORKON_HOME=$HOME/.virtualenvs + export PROJECT_HOME=$HOME/Devel source /usr/local/bin/virtualenvwrapper.sh .. - After editing it, reload the startup file (e.g., run: ``source + After editing it, reload the startup file (e.g., run ``source ~/.bashrc``). -編集後に起動ファイルを再読み込みしてください(例えば ``source ~/.bashrc`` を実行する)。 +編集後に起動ファイルを再読み込みしてください (例えば ``source ~/.bashrc`` を実行する) 。 .. - Python Interpreter and $PATH - ============================ + Quick-Start + =========== -Python インタープリタと $PATH -============================= +クイックスタート +================ .. - During startup, ``virtualenvwrapper.sh`` finds the first ``python`` on - the ``$PATH`` and remembers it to use later. This eliminates any - conflict as the ``$PATH`` changes, enabling interpreters inside - virtual environments where virtualenvwrapper is not installed. - Because of this behavior, it is important for the ``$PATH`` to be set - **before** sourcing ``virtualenvwrapper.sh``. For example:: + 1. Run: ``workon`` + 2. A list of environments, empty, is printed. + 3. Run: ``mkvirtualenv temp`` + 4. A new environment, ``temp`` is created and activated. + 5. Run: ``workon`` + 6. This time, the ``temp`` environment is included. -起動ファイルの読み込み時に ``virtualenvwrapper.sh`` は最初に ``$PATH`` 上の ``python`` を見つけて、後で使うために覚えておきます。これは virtualenvwrapper がインストールされていない仮想環境内部でインタープリタを有効にして ``$PATH`` 変更による競合が起こらないようにします。この動作の理由は ``virtualenvwrapper.sh`` を source する **前に** セットされた ``$PATH`` が重要だからです。 +1. ``workon`` を実行する +2. 仮想環境のリストが表示されるか、何も表示されない +3. ``mkvirtualenv temp`` を実行する +4. 新たな仮想環境 ``temp`` が作成されてアクティブ化される +5. ``workon`` を実行する +6. このときに ``temp`` の仮想環境が提供される -:: +.. + Configuration + ============= + +設定 +==== + +.. + virtualenvwrapper can be customized by changing environment + variables. Set the variables in your shell startup file *before* + loading ``virtualenvwrapper.sh``. + +virtualenvwrapper は、環境変数を変更することでカスタマイズできます。 ``virtualenvwrapper.sh`` が読み込まれる *前の* シェルの起動ファイルで環境変数を設定してください。 + +.. + Location of Environments + ------------------------ + +.. _variable-WORKON_HOME: + +仮想環境の場所 +-------------- + +.. + The variable ``WORKON_HOME`` tells virtualenvwrapper where to place + your virtual environments. The default is ``$HOME/.virtualenvs``. If + the directory does not exist when virtualenvwrapper is loaded, it will + be created automatically. + +環境変数 ``WORKON_HOME`` は、virtualenvwrapper が使う仮想環境の場所を指定します。デフォルト設定は ``$HOME/.virtualenvs`` です。virtualenvwrapper が読み込まれたときにそのディレクトリが存在しない場合は、自動的に作成されます。 + +.. + Location of Project Directories + ------------------------------- + +.. _variable-PROJECT_HOME: + +プロジェクトディレクトリの場所 +------------------------------ + +.. + The variable ``PROJECT_HOME`` tells virtualenvwrapper where to place + your project working directories. The variable must be set and the + directory created before :ref:`command-mkproject` is used. + +環境変数 ``PROJECT_HOME`` は、virtualenvwrapper が使うプロジェクトのワークディレクトリの場所を指定します。この環境変数は :ref:`command-mkproject` を利用する前に設定して、そのディレクトリを作成しておく必要があります。 + +.. seealso:: + + * :ref:`project-management` + +.. + Project Linkage Filename + ------------------------ + +.. _variable-VIRTUALENVWRAPPER_PROJECT_FILENAME: + +プロジェクトのリンクファイル名 +------------------------------ + +.. + The variable ``VIRTUALENVWRAPPER_PROJECT_FILENAME`` tells + virtualenvwrapper how to name the file linking a virtualenv to a + project working directory. The default is ``.project``. + +環境変数 ``VIRTUALENVWRAPPER_PROJECT_FILENAME`` は、virtualenvwrapper が使う、プロジェクトのワークディレクトリに対して virtualenv をリンクするファイル名を指定します。 + +.. seealso:: + + * :ref:`project-management` + +.. + Location of Hook Scripts + ------------------------ + +.. _variable-VIRTUALENVWRAPPER_HOOK_DIR: + +フックスクリプトの場所 +---------------------- + +.. + The variable ``VIRTUALENVWRAPPER_HOOK_DIR`` tells virtualenvwrapper + where the :ref:`user-defined hooks ` should be placed. The + default is ``$WORKON_HOME``. + +環境変数 ``VIRTUALENVWRAPPER_HOOK_DIR`` は、virtualenvwrapper が使う :ref:`ユーザー定義のフック ` が保存される場所を指定します。デフォルト設定 ``$WORKON_HOME`` です。 + +.. seealso:: + + * :ref:`scripts` + +.. + Location of Hook Logs + --------------------- + +.. _variable-VIRTUALENVWRAPPER_LOG_DIR: + +フックログの場所 +---------------- + +.. + The variable ``VIRTUALENVWRAPPER_LOG_DIR`` tells virtualenvwrapper + where the logs for the hook loader should be written. The default is + ``$WORKON_HOME``. + +環境変数 ``VIRTUALENVWRAPPER_LOG_DIR`` は、virtualenvwrapper のフックローダーが書き込むログの場所を指定します。デフォルト設定 ``$WORKON_HOME`` です。 + +.. _variable-VIRTUALENVWRAPPER_VIRTUALENV: + +.. _variable-VIRTUALENVWRAPPER_VIRTUALENV_ARGS: + +.. _variable-VIRTUALENVWRAPPER_PYTHON: + +Python インタープリターと virtualenv と $PATH +--------------------------------------------- + +.. + Python Interpreter, virtualenv, and $PATH + ----------------------------------------- + +.. + During startup, ``virtualenvwrapper.sh`` finds the first ``python`` + and ``virtualenv`` programs on the ``$PATH`` and remembers them to use + later. This eliminates any conflict as the ``$PATH`` changes, + enabling interpreters inside virtual environments where + virtualenvwrapper is not installed or where different versions of + virtualenv are installed. Because of this behavior, it is important + for the ``$PATH`` to be set **before** sourcing + ``virtualenvwrapper.sh``. For example:: + +起動ファイルの読み込み時に ``virtualenvwrapper.sh`` は、最初に ``$PATH`` 上の ``python`` と ``virtualenv`` を見つけて、後で使うためにその情報を覚えておきます。これは virtualenvwrapper がインストールされていない、または別のバージョンの virtualenv がインストールされた仮想環境内部でインタープリタを有効にしていながら ``$PATH`` 変更による競合が起こらないようにします。この動作の理由は ``virtualenvwrapper.sh`` を source する **前に** 設定された ``$PATH`` が重要だからです。 + +例えば:: export PATH=/usr/local/bin:$PATH source /usr/local/bin/virtualenvwrapper.sh @@ -138,44 +342,48 @@ Python インタープリタと $PATH .. To override the ``$PATH`` search, set the variable ``VIRTUALENVWRAPPER_PYTHON`` to the full path of the interpreter to - use (also **before** sourcing ``virtualenvwrapper.sh``). For - example:: + use and ``VIRTUALENVWRAPPER_VIRTUALENV`` to the full path of the + ``virtualenv`` binary to use. Both variables *must* be set before + sourcing ``virtualenvwrapper.sh``. For example:: -``$PATH`` 探索を上書きするには、使用するインタープリタのフルパスを(``virtualenvwrapper.sh`` を source する **前に** )変数 ``VIRTUALENVWRAPPER_PYTHON`` にセットしてください。 +``$PATH`` の探索を上書きするには、 +利用するインタープリターのフルパスを指定した ``VIRTUALENVWRAPPER_PYTHON`` と、 +利用する ``virtualenv`` バイナリ指定した ``VIRTUALENVWRAPPER_VIRTUALENV`` のフルパスを設定してください。 +両方の環境変数は ``virtualenvwrapper.sh`` が source される前に *設定する必要があります* 。 -:: +例えば:: export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python + export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv source /usr/local/bin/virtualenvwrapper.sh .. - Quick-Start - =========== + Default Arguments for virtualenv + -------------------------------- -クイックスタート -================ +virtualenv のデフォルト引数 +--------------------------- .. - 1. Run: ``workon`` - 2. A list of environments, empty, is printed. - 3. Run: ``mkvirtualenv temp`` - 4. A new environment, ``temp`` is created and activated. - 5. Run: ``workon`` - 6. This time, the ``temp`` environment is included. + If the application identified by ``VIRTUALENVWRAPPER_VIRTUALENV`` + needs arguments, they can be set in + ``VIRTUALENVWRAPPER_VIRTUALENV_ARGS``. The same variable can be used + to set default arguments to be passed to ``virtualenv``. For example, + set the value to ``--no-site-packages`` to ensure that all new + environments are isolated from the system ``site-packages`` directory. -1. ``workon`` を実行する -2. 仮想環境のリストが表示されるか、何も表示されない -3. ``mkvirtualenv temp`` を実行する -4. 新たな仮想環境 ``temp`` が作成されてアクティブ化される -5. ``workon`` を実行する -6. このときに ``temp`` の仮想環境が提供される +``VIRTUALENVWRAPPER_VIRTUALENV`` で指定されたアプリケーションが引数を取るなら、その引数を ``VIRTUALENVWRAPPER_VIRTUALENV_ARGS`` に設定できます。この環境変数は ``virtualenv`` に渡すデフォルト引数を設定するのにも使えます。例えば、システムの ``site-packages`` ディレクトリと独立した仮想環境を毎回新たに作成するには、 ``--no-site-packages`` をその値として設定します。 + +:: + + export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages' .. Temporary Files - =============== + --------------- 一時ファイル -============ +------------ .. virtualenvwrapper creates temporary files in ``$TMPDIR``. If the @@ -185,6 +393,52 @@ Python インタープリタと $PATH virtualenvwrapper は ``$TMPDIR`` に一時ファイルを作成します。その環境変数がセットされていない場合は ``/tmp`` を使用します。virtualenvwrapper 向けだけの一時ファイルの作成場所を変更するには ``VIRTUALENVWRAPPER_TMPDIR`` をセットしてください。 +.. + Site-wide Configuration + ----------------------- + +サイト全体の設定 +---------------- + +.. + Most UNIX systems include the ability to change the configuration for + all users. This typically takes one of two forms: editing the + *skeleton* files for new accounts or editing the global startup file + for a shell. + +ほとんどの UNIX システムは、全てのユーザーに設定を適用する機能を提供します。これは典型的に2つの方法のいずれかを取ります。新しいアカウントの作成時の *skeleton* ファイルを編集するか、シェルのグローバルな起動ファイルを編集するかです。 + +.. + Editing the skeleton files for new accounts means that each new user + will have their private startup files preconfigured to load + virtualenvwrapper. They can disable it by commenting out or removing + those lines. Refer to the documentation for the shell and operating + system to identify the appropriate file to edit. + +新しいアカウントの作成時にスケルトンファイルを編集する方法は、各ユーザーが virtualenvwrapper を読み込むようにあらかじめ設定された自分たちの起動ファイルをもちます。各ユーザーは、起動ファイルの該当行をコメントアウトしたり、削除することで設定を無効にできます。編集する必要のある適切なファイルを把握するには、オペレーティングシステム、またはシェルのドキュメントを参照してください。 + +.. + Modifying the global startup file for a given shell means that all + users of that shell will have virtualenvwrapper enabled, and they + cannot disable it. Refer to the documentation for the shell to + identify the appropriate file to edit. + +特定シェルのグローバルの起動ファイルを変更する方法は、そのシェルの全ユーザーに対して virtualenvwrapper が有効となり、各ユーザーが無効にすることはできません。編集する必要のある適切なファイルを把握するには、オペレーティングシステム、またはシェルのドキュメントを参照してください。 + +.. + Upgrading to 2.9 + ================ + +2.9 へのアップグレード +====================== + +.. + Version 2.9 includes the features previously delivered separately by + ``virtualenvwrapper.project``. If you have an older verison of the + project extensions installed, remove them before upgrading. + +バージョン 2.9 は、それまで別で配布していた ``virtualenvwrapper.project`` の機能を提供します。そのプロジェクト拡張の古いバージョンをインストールしているなら、アップグレード前にそれらを削除してください。 + .. Upgrading from 1.x ================== From ec246801afb4389085823e7d11b026de7b828e65 Mon Sep 17 00:00:00 2001 From: t2y Date: Sat, 28 Apr 2012 14:59:39 +0900 Subject: [PATCH 522/947] merged the changes (r369:550) for Japanese translation in scripts.rst --- docs/ja/scripts.rst | 100 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 77 insertions(+), 23 deletions(-) diff --git a/docs/ja/scripts.rst b/docs/ja/scripts.rst index 1213c51..d50dbac 100644 --- a/docs/ja/scripts.rst +++ b/docs/ja/scripts.rst @@ -16,6 +16,14 @@ エンドユーザのカスタマイズスクリプトは *読み込み* (シェル環境を変更できる) されるか、適切な条件で外部プログラムのように *実行* されるかのどちらかです。 +.. + The global scripts applied to all environments should be placed in the + directory named by :ref:`VIRTUALENVWRAPPER_HOOK_DIR + `. The local scripts should be + placed in the ``bin`` directory of the virtualenv. + +全ての環境に適用されるグローバルスクリプトは、 :ref:`VIRTUALENVWRAPPER_HOOK_DIR ` で指定したディレクトリに置きます。ローカルスクリプトは virtualenv の ``bin`` ディレクトリに置きます。 + .. _scripts-get_env_details: get_env_details @@ -30,12 +38,12 @@ get_env_details :読み込み/実行: 実行 .. - ``$WORKON_HOME/get_env_details`` is run when ``workon`` is run with no + ``$VIRTUALENVWRAPPER_HOOK_DIR/get_env_details`` is run when ``workon`` is run with no arguments and a list of the virtual environments is printed. The hook is run once for each environment, after the name is printed, and can print additional information about that environment. -``$WORKON_HOME/get_env_details`` は ``workon`` が引数無しで実行されるときに実行されます。そして、仮想環境のリストを表示します。仮想環境の名前が表示された後で、そのフックは環境毎に一度実行されて、その環境に関する追加情報を表示します。 +``$VIRTUALENVWRAPPER_HOOK_DIR/get_env_details`` は ``workon`` が引数無しで実行されるときに実行されます。そして、仮想環境のリストを表示します。仮想環境の名前が表示された後で、そのフックは環境毎に一度実行されて、その環境に関する追加情報を表示します。 .. _scripts-initialize: @@ -51,11 +59,11 @@ initialize :読み込み/実行: 読み込み .. - ``$WORKON_HOME/initialize`` is sourced when ``virtualenvwrapper.sh`` + ``$VIRTUALENVWRAPPER_HOOK_DIR/initialize`` is sourced when ``virtualenvwrapper.sh`` is loaded into your environment. Use it to adjust global settings when virtualenvwrapper is enabled. -あなたの環境に ``virtualenvwrapper.sh`` を読み込むときに ``$WORKON_HOME/initialize`` が読み込まれます。virtualenvwrapper が有効になるときにグローバルな設定を調整するために使用してください。 +あなたの環境に ``virtualenvwrapper.sh`` を読み込むときに ``$VIRTUALENVWRAPPER_HOOK_DIR/initialize`` が読み込まれます。virtualenvwrapper が有効になるときにグローバルな設定を調整するために使用してください。 .. _scripts-premkvirtualenv: @@ -71,13 +79,13 @@ premkvirtualenv :読み込み/実行: 実行 .. - ``$WORKON_HOME/premkvirtualenv`` is run as an external program after + ``$VIRTUALENVWRAPPER_HOOK_DIR/premkvirtualenv`` is run as an external program after the virtual environment is created but before the current environment is switched to point to the new env. The current working directory for the script is ``$WORKON_HOME`` and the name of the new environment is passed as an argument to the script. -``$WORKON_HOME/premkvirtualenv`` は仮想環境が作成された後で外部プログラムのように実行されますが、カレントの環境が新しい環境へ切り替わる前に実行されます。そのスクリプトのカレントワークディレクトリは ``$WORKON_HOME`` で、そのスクリプトへの引数として新しい環境の名前が渡されます。 +``$VIRTUALENVWRAPPER_HOOK_DIR/premkvirtualenv`` は仮想環境が作成された後で外部プログラムのように実行されますが、カレントの環境が新しい環境へ切り替わる前に実行されます。そのスクリプトのカレントワークディレクトリは ``$WORKON_HOME`` で、そのスクリプトへの引数として新しい環境の名前が渡されます。 .. _scripts-postmkvirtualenv: @@ -93,10 +101,11 @@ postmkvirtualenv :読み込み/実行: 読み込み .. - ``$WORKON_HOME/postmkvirtualenv`` is sourced after the new environment - is created and activated. + ``$VIRTUALENVWRAPPER_HOOK_DIR/postmkvirtualenv`` is sourced after the new environment + is created and activated. If the ``-a`` flag was used, + the link to the project directory is set up before this script is sourced. -``$WORKON_HOME/postmkvirtualenv`` は新しい環境が作成されてアクティブ化された後で読み込まれます。 +``$VIRTUALENVWRAPPER_HOOK_DIR/postmkvirtualenv`` は、新しい環境が作成されてアクティブ化された後で読み込まれます。 ``-a`` フラグを指定された場合、このスクリプトを読み込む前にプロジェクトディレクトリへのリンクを設定します。 .. _scripts-precpvirtualenv: @@ -112,14 +121,14 @@ precpvirtualenv :読み込み/実行: 実行 .. - ``$WORKON_HOME/precpvirtualenv`` is run as an external program after + ``$VIRTUALENVWRAPPER_HOOK_DIR/precpvirtualenv`` is run as an external program after the source environment is duplicated and made relocatable, but before the ``premkvirtualenv`` hook is run or the current environment is switched to point to the new env. The current working directory for the script is ``$WORKON_HOME`` and the names of the source and new environments are passed as arguments to the script. -``$WORKON_HOME/precpvirtualenv`` は元の環境が複製されて再配置可能になるときに外部プログラムのように実行されますが、 ``premkvirtualenv`` フックが実行される前、もしくはカレントの環境が新しい環境へ切り替わる前に実行されます。そのスクリプトのカレントワークディレクトリは ``$WORKON_HOME`` で、そのスクリプトへの引数として元の環境名と新しい環境名が渡されます。 +``$VIRTUALENVWRAPPER_HOOK_DIR/precpvirtualenv`` は元の環境が複製されて再配置可能になるときに外部プログラムのように実行されますが、 ``premkvirtualenv`` フックが実行される前、もしくはカレントの環境が新しい環境へ切り替わる前に実行されます。そのスクリプトのカレントワークディレクトリは ``$WORKON_HOME`` で、そのスクリプトへの引数として元の環境名と新しい環境名が渡されます。 .. _scripts-postcpvirtualenv: @@ -135,10 +144,10 @@ postcpvirtualenv :読み込み/実行: 読み込み .. - ``$WORKON_HOME/postmkvirtualenv`` is sourced after the new environment + ``$VIRTUALENVWRAPPER_HOOK_DIR/postcpvirtualenv`` is sourced after the new environment is created and activated. -``$WORKON_HOME/postmkvirtualenv`` は新しい環境が作成されてアクティブ化された後で読み込まれます。 +``$VIRTUALENVWRAPPER_HOOK_DIR/postcpvirtualenv`` は新しい環境が作成されてアクティブ化された後で読み込まれます。 .. _scripts-preactivate: @@ -154,11 +163,11 @@ preactivate :読み込み/実行: 実行 .. - The global ``$WORKON_HOME/preactivate`` script is run before the new + The global ``$VIRTUALENVWRAPPER_HOOK_DIR/preactivate`` script is run before the new environment is enabled. The environment name is passed as the first argument. -グローバルの ``$WORKON_HOME/preactivate`` スクリプトは新しい仮想環境が有効になる前に実行されます。その環境名は1番目の引数として渡されます。 +グローバルの ``$VIRTUALENVWRAPPER_HOOK_DIR/preactivate`` スクリプトは新しい仮想環境が有効になる前に実行されます。その環境名は1番目の引数として渡されます。 .. The local ``$VIRTUAL_ENV/bin/preactivate`` hook is run before the new @@ -181,11 +190,11 @@ postactivate :読み込み/実行: 読み込み .. - The global ``$WORKON_HOME/postactivate`` script is sourced after the + The global ``$VIRTUALENVWRAPPER_HOOK_DIR/postactivate`` script is sourced after the new environment is enabled. ``$VIRTUAL_ENV`` refers to the new environment at the time the script runs. -グローバルの ``$WORKON_HOME/postactivate`` スクリプトは新しい仮想環境が有効になった後で読み込まれます。 ``$VIRTUAL_ENV`` はそのスクリプトが実行されるときに新しい環境を参照します。 +グローバルの ``$VIRTUALENVWRAPPER_HOOK_DIR/postactivate`` スクリプトは新しい仮想環境が有効になった後で読み込まれます。 ``$VIRTUAL_ENV`` はそのスクリプトが実行されるときに新しい環境を参照します。 .. This example script adds a space between the virtual environment name @@ -239,11 +248,11 @@ predeactivate ローカルの ``$VIRTUAL_ENV/bin/predeactivate`` スクリプトはカレントの仮想環境が非アクティブ化される前に読み込まれます。そして、あなたの環境の設定をクリアしたり、無効にするために使用されます。 ``$VIRTUAL_ENV`` はそのスクリプトが実行されるときに古い環境を参照します。 .. - The global ``$WORKON_HOME/predeactivate`` script is sourced before the + The global ``$VIRTUALENVWRAPPER_HOOK_DIR/predeactivate`` script is sourced before the current environment is deactivated. ``$VIRTUAL_ENV`` refers to the old environment at the time the script runs. -グローバルの ``$WORKON_HOME/predeactivate`` スクリプトはカレントの仮想環境が非アクティブ化される前に読み込まれます。 ``$VIRTUAL_ENV`` はそのスクリプトが実行されるときに古い環境を参照します。 +グローバルの ``$VIRTUALENVWRAPPER_HOOK_DIR/predeactivate`` スクリプトはカレントの仮想環境が非アクティブ化される前に読み込まれます。 ``$VIRTUAL_ENV`` はそのスクリプトが実行されるときに古い環境を参照します。 .. _scripts-postdeactivate: @@ -280,11 +289,11 @@ prermvirtualenv :読み込み/実行: 実行 .. - The ``$WORKON_HOME/prermvirtualenv`` script is run as an external + The ``$VIRTUALENVWRAPPER_HOOK_DIR/prermvirtualenv`` script is run as an external program before the environment is removed. The full path to the environment directory is passed as an argument to the script. -``$WORKON_HOME/prermvirtualenv`` スクリプトは仮想環境が削除される前に外部コマンドのように実行されます。そのスクリプトへの引数としてその環境のディレクトリに対するフルパスが渡されます。 +``$VIRTUALENVWRAPPER_HOOK_DIR/prermvirtualenv`` スクリプトは仮想環境が削除される前に外部コマンドのように実行されます。そのスクリプトへの引数としてその環境のディレクトリに対するフルパスが渡されます。 .. _scripts-postrmvirtualenv: @@ -300,8 +309,53 @@ postrmvirtualenv :読み込み/実行: 実行 .. - The ``$WORKON_HOME/postrmvirtualenv`` script is run as an external + The ``$VIRTUALENVWRAPPER_HOOK_DIR/postrmvirtualenv`` script is run as an external program after the environment is removed. The full path to the environment directory is passed as an argument to the script. -``$WORKON_HOME/postrmvirtualenv`` スクリプトは仮想環境が削除された後で外部コマンドのように実行されます。そのスクリプトへの引数としてその環境のディレクトリに対するフルパスが渡されます。 +``$VIRTUALENVWRAPPER_HOOK_DIR/postrmvirtualenv`` スクリプトは仮想環境が削除された後で外部コマンドのように実行されます。そのスクリプトへの引数としてその環境のディレクトリに対するフルパスが渡されます。 + +.. _scripts-premkproject: + +premkproject +=============== + + .. :Global/Local: global + :Argument(s): name of new project + :Sourced/Run: run + + :グローバル/ローカル: グローバル + :引数: 新しいプロジェクト名 + :読み込み/実行: 実行 + +.. + ``$WORKON_HOME/premkproject`` is run as an external program after the + virtual environment is created and after the current environment is + switched to point to the new env, but before the new project directory + is created. The current working directory for the script is + ``$PROJECT_HOME`` and the name of the new project is passed as an + argument to the script. + +``$WORKON_HOME/premkproject`` は、仮想環境が作成されてカレントの環境が新しい環境を指すように切り替わった後で、外部プログラムとして実行されます。 +但し、そのタイミングは新しいプロジェクトディレクトリが作成される前です。 +このスクリプトのカレントのワークディレクトリは ``$PROJECT_HOME`` となり、新しいプロジェクト名がこのスクリプトの引数として渡されます。 + +.. _scripts-postmkproject: + +postmkproject +================ + + .. :Global/Local: global + :Argument(s): none + :Sourced/Run: sourced + + :グローバル/ローカル: グローバル + :引数: 無し + :読み込み/実行: 読み込み + +.. + ``$WORKON_HOME/postmkproject`` is sourced after the new environment + and project directories are created and the virtualenv is activated. + The current working directory is the project directory. + +``$WORKON_HOME/postmkproject`` は、新しい環境とプロジェクトディレクトリが作成されて virtualenv がアクティブ化された後で読み込まれます。カレントのワークディレクトリはプロジェクトディレクトリです。 From 0f11faa093f50274c15a4517d63628350ea6795b Mon Sep 17 00:00:00 2001 From: t2y Date: Sat, 28 Apr 2012 15:02:41 +0900 Subject: [PATCH 523/947] merged the changes (r369:550) for Japanese translation in tips.rst --- docs/ja/tips.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/ja/tips.rst b/docs/ja/tips.rst index 5a66da6..4ee6b34 100644 --- a/docs/ja/tips.rst +++ b/docs/ja/tips.rst @@ -160,13 +160,13 @@ Python パスへそのディレクトリを追加してからそこへ移動し .. `Justin Lily posted - `__ + `__ about some code he added to his shell environment to look at the directory each time he runs ``cd``. If it finds a ``.venv`` file, it activates the environment named within. On leaving that directory, the current virtualenv is automatically deactivated. -``cd`` を実行する毎にそのディレクトリでシェル環境を調べるように追加したコードを `Justin Lily が投稿しました `__ 。 ``.venv`` ファイルを見つけたら、そのファイルに含まれる環境の名前でアクティブ化します。そのディレクトリから移動すると、カレントの仮想環境は自動的に非アクティブ化します。 +``cd`` を実行する毎にそのディレクトリでシェル環境を調べるように追加したコードを `Justin Lily が投稿しました `__ 。 ``.venv`` ファイルを見つけたら、そのファイルに含まれる環境の名前でアクティブ化します。そのディレクトリから移動すると、カレントの仮想環境は自動的に非アクティブ化します。 .. `Harry Marr `__ From 49d8c5e3709f9c857643bdf50f62fa7ae1717897 Mon Sep 17 00:00:00 2001 From: t2y Date: Sat, 28 Apr 2012 15:05:46 +0900 Subject: [PATCH 524/947] merged the changes (r369:550) for Japanese translation in developers.rst --- docs/ja/developers.rst | 110 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 102 insertions(+), 8 deletions(-) diff --git a/docs/ja/developers.rst b/docs/ja/developers.rst index 9b927b1..bf1b99a 100644 --- a/docs/ja/developers.rst +++ b/docs/ja/developers.rst @@ -94,11 +94,105 @@ virtualenvwrapper のドキュメントは reStructuredText で書かれてい ================ .. - The test suite for virtualenvwrapper uses `shunit2 - `_ and `tox - `_. To run the tests under bash, sh, and - zsh, use ``make test`` or just ``tox``. In order to add new tests, - you will need to modify or create an appropriate script in the - ``tests`` directory. - -virtualenvwrapper のテストセットは `shunit2 `_ と `tox `_ を使用します。bash, sh や zsh でテストを実行するには ``make test`` か、ただ ``tox`` を実行してください。新しくテストを追加するには、 ``tests`` ディレクトリの適切なスクリプトを作成したり、修正する必要があります。 + The test suite for virtualenvwrapper uses shunit2_ and tox_. The + shunit2 source is included in the ``tests`` directory, but tox must be + installed separately (``pip install tox``). + +virtualenvwrapper のテストスイートは shunit2_ と tox_ を使います。shunit2 のソースは ``tests`` ディレクトリに含まれていますが、tox は別途インストールする必要があります (``pip install tox``) 。 + +.. + To run the tests under bash, zsh, and ksh for Python 2.4 through 2.7, + run ``tox`` from the top level directory of the hg repository. + +bash, zsh, ksh 環境で Python 2.4 - 2.7 のテストを実行するには、hg リポジトリの最上位ディレクトリから ``tox`` を実行してください。 + +.. + To run individual test scripts, use a command like:: + +個別のテストスクリプトを実行するには、次のように実行します。 + +:: + + $ tox tests/test_cd.sh + +.. + To run tests under a single version of Python, specify the appropriate + environment when running tox:: + +Python のあるバージョンでテストを実行するには、tox を実行するときに適切な環境を指定します。 + +:: + + + $ tox -e py27 + +.. + Combine the two modes to run specific tests with a single version of + Python:: + +前述した特定テストと Python バージョンのテストを実行するには、2つの方法を組み合わせてください。 + +:: + + $ tox -e py27 tests/test_cd.sh + +.. + Add new tests by modifying an existing file or creating new script in + the ``tests`` directory. + +既存のファイルを変更して新しいテストを追加するか、 ``tests`` ディレクトリに新しいスクリプトを作成してください。 + +.. _shunit2: http://shunit2.googlecode.com/ + +.. _tox: http://codespeak.net/tox + +.. _developer-templates: + +.. + Creating a New Template + ======================= + +新しいテンプレートの作成 +======================== + +.. + virtualenvwrapper.project templates work like `virtualenvwrapper + plugins + `__. + The *entry point* group name is + ``virtualenvwrapper.project.template``. Configure your entry point to + refer to a function that will **run** (source hooks are not supported + for templates). + +virtualenvwrapper.project テンプレートは `virtualenvwrapper plugins `__ と同じように動作します。 +*entry point* グループの名前は ``virtualenvwrapper.project.template`` です。 +**run** を実行する関数を参照する独自のエントリーポイントを設定してください +(ソースフックはテンプレートをサポートしていません) 。 + +.. + The argument to the template function is the name of the project being + created. The current working directory is the directory created to + hold the project files (``$PROJECT_HOME/$envname``). + +テンプレート関数の引数は、作成するプロジェクトの名前です。 +カレントワークディレクトリは、プロジェクトのファイルを保持するために作成されたディレクトリです (``$PROJECT_HOME/$envname``) 。 + +.. + Help Text + --------- + +ヘルプテキスト +-------------- + +.. + One difference between project templates and other virtualenvwrapper + extensions is that only the templates specified by the user are run. + The ``mkproject`` command has a help option to give the user a list of + the available templates. The names are taken from the registered + entry point names, and the descriptions are taken from the docstrings + for the template functions. + +プロジェクトテンプレートとその他の virtualenvwrapper 拡張との違いは、ユーザーが指定したテンプレートのみが実行されることです。 +``mkproject`` コマンドは、ユーザーへ利用できるテンプレート一覧表示するヘルプオプションがあります。 +テンプレート名は、登録されたエントリーポイントから取得される名前です。 +そして、テンプレートの説明は、テンプレート関数の docstrings を表示します。 From e7492d015a743fb6f95ed727c9b3b10ca7494e1f Mon Sep 17 00:00:00 2001 From: t2y Date: Sat, 28 Apr 2012 15:20:57 +0900 Subject: [PATCH 525/947] merged the changes (r369:550) for Japanese translation in extensions.rst --- docs/ja/developers.rst | 4 +- docs/ja/extensions.rst | 84 +++++++++++++++++++++++++++++------------- 2 files changed, 61 insertions(+), 27 deletions(-) diff --git a/docs/ja/developers.rst b/docs/ja/developers.rst index bf1b99a..ab099e4 100644 --- a/docs/ja/developers.rst +++ b/docs/ja/developers.rst @@ -146,12 +146,12 @@ Python のあるバージョンでテストを実行するには、tox を実行 .. _tox: http://codespeak.net/tox -.. _developer-templates: - .. Creating a New Template ======================= +.. _developer-templates: + 新しいテンプレートの作成 ======================== diff --git a/docs/ja/extensions.rst b/docs/ja/extensions.rst index fde65f4..19cbada 100644 --- a/docs/ja/extensions.rst +++ b/docs/ja/extensions.rst @@ -13,31 +13,6 @@ 次に virtualenvwrapper で利用できる拡張機能を紹介します。 -.. _extensions-user_scripts: - -project -======= - -.. - The project_ extension adds development directory management with - templates to virtualenvwrapper. - -project_ 拡張は virtualenvwrapper にテンプレートで開発ディレクトリ管理機能を追加します。 - -bitbucket ---------- - -.. - The bitbucket_ project template creates a working directory and - automatically clones the repository from BitBucket. Requires - project_. - -bitbucket_ プロジェクトテンプレートはワークディレクトリを作成して Bitbucket から自動的にクローンします。使用するには project_ が必要です。 - -.. _project: http://www.doughellmann.com/projects/virtualenvwrapper.project/ - -.. _bitbucket: http://www.doughellmann.com/projects/virtualenvwrapper.bitbucket/ - emacs-desktop ============= @@ -54,6 +29,8 @@ emacs desktop-mode_ はセッション間で emacs の状態(バッファのオ .. _emacs-desktop: http://www.doughellmann.com/projects/virtualenvwrapper-emacs-desktop/ +.. _extensions-user_scripts: + user_scripts ============ @@ -63,3 +40,60 @@ user_scripts features described in :ref:`scripts`. ``user_scripts`` 拡張は virtualenvwrapper で提供され、デフォルトで有効です。それは :ref:`scripts` で説明したユーザのカスタマイズスクリプト機能を実装します。 + +vim-virtualenv +============== + +.. + `vim-virtualenv`_ is Jeremey Cantrell's plugin for controlling + virtualenvs from within vim. When used together with + virtualenvwrapper, vim-virtualenv identifies the virtualenv to + activate based on the name of the file being edited. + +`vim-virtualenv`_ は、Jeremey Cantrell によるプラグインで vim から virtualenvs を制御します。virtualenvwrapper と一緒に使う場合は、vim-virtualenv が編集するファイル名に対応してアクティブ化する virtualenv を識別します。 + +.. _vim-virtualenv: https://github.com/jmcantrell/vim-virtualenv + +.. + Templates + ========= + +.. _extensions-templates: + +テンプレート +============ + +.. + Below is a list of some of the templates available for use with + :ref:`command-mkproject`. + +:ref:`command-mkproject` で利用できるテンプレートの一覧を紹介します。 + +.. _templates-bitbucket: + +bitbucket +--------- + +.. + The bitbucket_ extension automatically clones a mercurial repository + from the specified bitbucket project. + +bitbucket_ 拡張は、指定した bitbucket プロジェクトから自動的に mercurial のリポジトリをクローンします。 + +.. _bitbucket: http://www.doughellmann.com/projects/virtualenvwrapper.bitbucket/ + +.. _templates-django: + +django +------ + +.. + The django_ extension automatically creates a new Django project. + +django_ 拡張は、自動的に新しい Django プロジェクトを作成します。 + +.. _django: http://www.doughellmann.com/projects/virtualenvwrapper.django/ + +.. seealso:: + + * :ref:`developer-templates` From ff0ddc2aef9372bd7a5009bca27a18eaa2beac7c Mon Sep 17 00:00:00 2001 From: t2y Date: Sat, 28 Apr 2012 15:50:57 +0900 Subject: [PATCH 526/947] merged the changes (r369:550) for Japanese translation in projects.rst --- docs/ja/command_ref.rst | 2 ++ docs/ja/index.rst | 3 +++ docs/ja/projects.rst | 56 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 docs/ja/projects.rst diff --git a/docs/ja/command_ref.rst b/docs/ja/command_ref.rst index 9c62c1c..2ac9fcc 100644 --- a/docs/ja/command_ref.rst +++ b/docs/ja/command_ref.rst @@ -663,6 +663,8 @@ PROJECT_HOME にプロジェクトディレクトリと WORKON_HOME に新しい * :ref:`scripts-premkproject` * :ref:`scripts-postmkproject` +.. _command-setvirtualenvproject: + setvirtualenvproject -------------------- diff --git a/docs/ja/index.rst b/docs/ja/index.rst index 74f37aa..2a1cc5f 100644 --- a/docs/ja/index.rst +++ b/docs/ja/index.rst @@ -234,6 +234,7 @@ virtualenvwrapper が提供する機能を説明する最善の方法は実際 install command_ref hooks + projects tips developers extensions @@ -329,6 +330,8 @@ virtualenvwrapper は大きなシェルスクリプトなので、多くのア License ======= +.. _license: + ========== ライセンス ========== diff --git a/docs/ja/projects.rst b/docs/ja/projects.rst new file mode 100644 index 0000000..90c65a8 --- /dev/null +++ b/docs/ja/projects.rst @@ -0,0 +1,56 @@ +.. _project-management: + +================== + プロジェクト管理 +================== + +.. + ==================== + Project Management + ==================== + +.. + A :term:`project directory` is associated with a virtualenv, but + usually contains the source code under active development rather than + the installed components needed to support the development. For + example, the project directory may contain the source code checked out + from a version control system, temporary artifacts created by testing, + experimental files not committed to version control, etc. + +:term:`project directory` は virtualenv に関連付けられますが、開発を支援するために必要とされるコンポーネントをインストールするというより、普通は活発に開発中のソースコードを含みます。例えば、プロジェクトディレクトリは、バージョン管理システムからチェックアウトされたソースコード、まだバージョン管理システムにコミットされていないテストや実験的なファイルから作成された一時的なファイルを含むかもしれません。 + +.. + A project directory is created and bound to a virtualenv when + :ref:`command-mkproject` is run instead of + :ref:`command-mkvirtualenv`. To bind an existing project directory to + a virtualenv, use :ref:`command-setvirtualenvproject`. + +プロジェクトディレクトリが作成して、 :ref:`command-mkvirtualenv` の代わりに :ref:`command-mkproject` を実行するときに virtualenv を束縛します。既存のプロジェクトディレクトリを virtualenv に束縛するには :ref:`command-setvirtualenvproject` を使ってください。 + +.. + Using Templates + =============== + +テンプレートの利用 +================== + +.. + A new project directory can be created empty, or populated using one + or more :term:`template` plugins. Templates should be specified as + arguments to :ref:`command-mkproject`. Multiple values can be provided + to apply more than one template. For example, to check out a Mercurial + repository from on a project on bitbucket and create a new Django + site, combine the :ref:`templates-bitbucket` and + :ref:`templates-django` templates. + +新しいプロジェクトディレクトリは、空のディレクトリ、または :term:`template` プラグインを使って作成されます。テンプレートは :ref:`command-mkproject` の引数として指定します。複数のテンプレートも適用できます。例えば、bitbucket のプロジェクトから Mercurial リポジトリをチェックアウトして新たに Django サイトを作成するには、 :ref:`templates-bitbucket` と :ref:`templates-django` のテンプレートを組み合わせて使います。 + +:: + + $ mkproject -t bitbucket -t django my_site + +.. seealso:: + + * :ref:`extensions-templates` + * :ref:`variable-PROJECT_HOME` + * :ref:`variable-VIRTUALENVWRAPPER_PROJECT_FILENAME` From 1114a1d7cb27d0e21f6053703ce0cef43de53bfe Mon Sep 17 00:00:00 2001 From: t2y Date: Sat, 28 Apr 2012 15:51:30 +0900 Subject: [PATCH 527/947] merged the changes (r369:550) in extensions.rst --- docs/ja/history.rst | 158 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 156 insertions(+), 2 deletions(-) diff --git a/docs/ja/history.rst b/docs/ja/history.rst index 606917d..1d13430 100644 --- a/docs/ja/history.rst +++ b/docs/ja/history.rst @@ -7,6 +7,160 @@ リリース履歴 ============ +dev + + - Clean up file permissions and remove shebangs from scripts not + intended to be executed on the command line. (contributed by + :bbuser:`ralphbean`) + - Worked on some brittle tests. + +3.2 + + - Make ``project_dir`` a local variable so that + :ref:`command-cdproject` does not interfere with other variables + the user might have set. (contributed by :bbuser:`slackorama`) + - Fix typo in documentation reported by Nick Martin. + - Change trove classifier for license "MIT" to reflect the license + text presented in the documentation. *This does not indicate a + change in the license, just a correction to the expression of that + intent. See :ref:`license`* (contributed by :bbuser:`ralphbean` as + fix for :bbissue:`134`) + - Extend :ref:`command-rmvirtualenv` to allow removing more than one + environment at a time. (contributed by :bbuser:`ciberglo`) + - Change the definition of + ``virtualenvwrapper_get_site_packages_dir`` to ask ``distutils`` + for the ``site-packages`` directory instead of trying to build the + path ourselves in the shell script. This should resolve + :bbissue:`112` and improve support for Python interpreters other + than C Python. Thanks to Carl Meyer and Dario Bertini for their + contributions toward the fix. + +3.1 + + - Fix a problem with activation hooks when associating a new + virtualenv with an existing project directory. (:bbissue:`122`) + - Fix a problem with :ref:`command-add2virtualenv` and paths + containing "special" characters such as ``&``. (:bbissue:`132`) + +3.0.1 + + - Fix some packaging issues that made it more difficult to run the + tests directly from the sdist package. (:bbissue:`126`) + +3.0 + + - Add Python 3 support, thanks in large part to the efforts of + Daniel Kraus (:bbuser:`dakra`). Tested under Python 2.6, 2.7, and + 3.2. + +2.11.1 + + - Remove the initialization shortcut because it breaks tab + completion in sub-shell environments like screen and + tmux. (:bbissue:`121`) + +2.11 + + - Add ``-a`` option to :ref:`command-mkvirtualenv` to associate a + new virtualenv with an existing project directory. Contributed by + Mike Fogel (:bbuser:`mfogel`). + - Drops support for Python 2.4 and 2.5. The tools may still work, + but I no longer have a development environment set up for testing + them, so I do not officially support them. + - Shortcut initialization if it has run before. + - Set hook log file permissions to be group-writable. (:bbissue:`62` + reported by :bbuser:`hedgeddown`) + - Add ``VIRTUALENVWRAPPER_PROJECT_FILENAME`` variable so the + ``.project`` file used to link a virtualenv to a project can be + renamed to avoid conflicts with other tools. (:bbissue:`120` + reported by :bbuser:`arthuralvim`) + +2.10.1 + + - Changed arguments to :ref:`command-mktmpenv` so it always creates + an environment name for you. (:bbissue:`114` reported by + :bbuser:`alex_gaynor`) + +2.10 + + - Incorporated patch to add ``-d`` option to + :ref:`command-add2virtualenv`, contributed by :bbuser:`miracle2k`. + - Add ``-i`` option to :ref:`command-mkvirtualenv`. + - Add :ref:`command-mktmpenv` command for creating temporary + environments that are automatically removed when they are + deactivated. + - Fixed a problem with hook_loader that prevented it from working + under Python 2.5 and 2.4. + - Fix a problem with the way template names were processed under + zsh. (:bbissue:`111`) + +2.9 + + - Change the shell function shell definition syntax so that ksh will + treat typeset-declared variables as local. No kidding. + - Merge the "project directory" features of the + ``virtualenvwrapper.project`` plugin into the main project, adding + :ref:`command-mkproject`, :ref:`command-cdproject`, and + :ref:`command-setvirtualenvproject` commands. + - Add ``-r`` option to :ref:`command-mkvirtualenv` to install + dependencies using a pip requirements file. + +2.8 + + - Use VIRTUALENVWRAPPER_VIRTUALENV in `cpvirtualenv` (:bbissue:`104`). + - Add support for `MSYS `_ + environment under Windows. Contributed by Axel + H. (:bbuser:`noirbizarre`). + +2.7.2 + + - Move setup code for tab completion later in the startup code so + all of the needed variables are configured. (:bbissue:`97`) + - Expand tab completion for zsh to work for all commands. + +2.7.1 + + - When testing for WORKON_HOME during startup, dereference any + symlink to make sure it is a directory. + - Set VIRTUALENVWRAPPER_HOOK_DIR and VIRTUALENV_WRAPPER_LOG DIR in + virtualenvwrapper_initialize after WORKON_HOME is set + (:bbissue:`94`). + - Update the :ref:`install-basic` instructions to be more explicit + about needing to install virtualenvwrapper globally (or at least + outside of a virtualenv). + +2.7 + + - Fix problem with space in WORKON_HOME path (:bbissue:`79`). + - Fix problem with argument processing in lsvirtualenv under zsh + (:bbissue:`86`). Thanks to Nat Williams (:bbuser:`natw`) for the + bug report and patch. + - If WORKON_HOME does not exist, create it. Patch from Carl Karsten + (:bbuser:`CarlFK`). Test updates based on patches from Matt Austin + (:bbuser:`maafy6`) and Hugo Lopes Tavares (:bbuser:`hltbra`). + - Merge in contributions from Paul McLanahan (:bbuser:`pmclanahan`) + to fix the test harness to ensure that the test scripts are + actually running under the expected shell. + - Merge in new shell command :ref:`command-toggleglobalsitepackages` + from Paul McLanahan (:bbuser:`pmclanahan`). The new command + changes the configuration of the active virtualenv to enable or + disable the global ``site-packages`` directory. + - Fixed some tests that were failing under ksh on Ubuntu 10.10. + - Document the :ref:`VIRTUALENVWRAPPER_VIRTUALENV + ` variable. + - Implement suggestion by Van Lindberg to have + :ref:`VIRTUALENVWRAPPER_HOOK_DIR + ` and + :ref:`VIRTUALENVWRAPPER_LOG_DIR + ` variables to control the + locations of hooks and logs. + - Enabled tab completion for :ref:`command-showvirtualenv` + (:bbissue:`78`). + - Fixed a problem with running :ref:`command-rmvirtualenv` from + within the environment being removed (:bbissue:`83`). + - Removed use of -e option in calls to grep for better portability + (:bbissue:`85`). + 2.6.3 .. - Hard-code the version information in the setup.py and conf.py @@ -22,11 +176,11 @@ Tetsuya Morimoto. - Incorporate a suggestion from Ales Zoulek to let the user specify the virtualenv binary through an environment variable - (``VIRTUALENVWRAPPER_VIRTUALENV``). + (:ref:`VIRTUALENVWRAPPER_VIRTUALENV `). - http://readthedocs.org でドキュメントを生成してみました。 - Tetsuya Morimoto からの `日本語の翻訳ドキュメント `__ を取り込みました。 - - 環境変数(``VIRTUALENVWRAPPER_VIRTUALENV``)で virtualenv バイナリをユーザが指定できるように Ales Zoulek からの提案を取り入れました。 + - 環境変数 (:ref:`VIRTUALENVWRAPPER_VIRTUALENV `) で virtualenv バイナリをユーザが指定できるように Ales Zoulek からの提案を取り入れました。 2.6.1 From 9bed097c6d3938ad6b5b3027db13db129b2798e3 Mon Sep 17 00:00:00 2001 From: t2y Date: Sat, 28 Apr 2012 16:08:25 +0900 Subject: [PATCH 528/947] revised the Japanese translation in index.rst --- docs/ja/index.rst | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/ja/index.rst b/docs/ja/index.rst index 2a1cc5f..c2b2159 100644 --- a/docs/ja/index.rst +++ b/docs/ja/index.rst @@ -15,7 +15,7 @@ virtualenvwrapper |release| on more than one project at a time without introducing conflicts in their dependencies. -virtualenvwrapper は Ian Bicking の `virtualenv `_ ツールの拡張機能です。この拡張機能は仮想環境の作成・削除を行ったり、開発ワークフローを管理するラッパーを提供します。このラッパーを使用することで、開発環境の依存による競合を発生させず、1つ以上のプロジェクトで同時に作業し易くなります。 +virtualenvwrapper は Ian Bicking の `virtualenv `_ ツールの拡張機能です。この拡張機能は仮想環境の作成・削除を行ったり、開発ワークフローを管理するラッパーを提供します。このラッパーを使うことで、開発環境の依存関係による競合を起こさず、同時に複数のプロジェクトで作業しやすくなります。 .. ======== @@ -37,12 +37,12 @@ virtualenvwrapper は Ian Bicking の `virtualenv Date: Sat, 28 Apr 2012 16:25:09 +0900 Subject: [PATCH 529/947] revised the Japanese translation in plugins.rst --- docs/ja/plugins.rst | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/ja/plugins.rst b/docs/ja/plugins.rst index f1a4169..7662942 100644 --- a/docs/ja/plugins.rst +++ b/docs/ja/plugins.rst @@ -18,7 +18,7 @@ virtualenvwrapper を拡張する to modify their tools to work the way they want, rather than the other way around. -開発環境をカスタマイズするために自作で解決してきた長い経験から、共通タスクを自動化して何度も繰り返す苛々する作業を取り除く機能はどれだけ価値があるかが分かりました。大工は治具を組み立て、ソフトウェア開発者はシェルスクリプトを書きます。virtualenvwrapper は逆になりますが、求める方法で動作するようにツールを修正する職人を励ます伝統を受け継いでいます。 +開発環境をカスタマイズするために自作で解決してきた長い経験から、共通タスクを自動化して、何度も繰り返す苛々するような作業を取り除く機能がどれほどの価値をもつか分かりました。大工は治具を組み立て、ソフトウェア開発者はシェルスクリプトを書きます。virtualenvwrapper は逆になりますが、求める方法で動作するようにツールを修正する職人を励ます伝統を受け継いでいます。 .. Use the hooks provided to eliminate repetitive manual operations and @@ -43,7 +43,7 @@ virtualenvwrapper を拡張する implemented in Python by using Distribute_ *entry points*, making it possible to share common behaviors between systems and developers. -virtualenvwrapper がそういったことを実行できるようにあなたのコードをアタッチする方法が2つあります。エンドユーザはシェルスクリプトか、個人的なカスタマイズを施したプログラムを使用することができます(:ref:`scripts` を参照)。さらに拡張機能は、システムと開発者間で共通の振る舞いを共有できるようにする Distribute_ *エントリポイント* を使用して Python で実装することもできます。 +virtualenvwrapper がそういったことを実行できるようにあなたのコードをアタッチする方法が2つあります。エンドユーザはシェルスクリプトか、個人的なカスタマイズを施したプログラムを使用できます(:ref:`scripts` を参照)。さらに拡張機能は、システムと開発者間で共通の振る舞いを共有できるようにする Distribute_ *エントリポイント* を使用して Python で実装することもできます。 .. Defining an Extension @@ -75,7 +75,7 @@ virtualenvwrapper がそういったことを実行できるようにあなた directory. Extensions can (optionally) use the ``virtualenvwrapper`` namespace by setting up their source tree like: -``virtualenvwrapper`` の Python パッケージは *名前空間パッケージ* です。複数のライブラリが一緒に配布されていなかったり同じディレクトリ内にインストールされていなかったとしても、そのパッケージ内へインストールすることができます。拡張機能は次のようにソースツリーを設定することで ``virtualenvwrapper`` の名前空間を(オプションで)使用することが出来ます。 +``virtualenvwrapper`` の Python パッケージは *名前空間パッケージ* です。複数のライブラリが一緒に配布されていなかったり同じディレクトリ内にインストールされていなかったとしても、そのパッケージ内へインストールできます。拡張機能は次のようにソースツリーを設定することで ``virtualenvwrapper`` の名前空間を(オプションで)使用することが出来ます。 * virtualenvwrapper/ @@ -116,7 +116,7 @@ virtualenvwrapper がそういったことを実行できるようにあなた imported from elsewhere using standard Python code organization techniques. -パッケージを作成した次のステップは拡張コードを保持するモジュールを作成することです。例えば ``virtualenvwrapper/user_scripts.py`` です。そのモジュールは実際の拡張機能のエントリポイントを含むべきです。サポートするコードが含められるか、標準の Python コードの構成テクニックを使用してどこかからインポートされます。 +パッケージを作成した後の次のステップとして、拡張コードを保持するモジュールを作成します。例えば ``virtualenvwrapper/user_scripts.py`` です。そのモジュールは実際の拡張機能のエントリポイントを含みます。サポートするコードが含められるか、標準の Python コードの構成テクニックを利用してインポートされます。 .. The API is the same for every extension point. Each uses a Python @@ -242,7 +242,7 @@ API は全ての拡張ポイントで同じです。それぞれは1つの引数 package by mapping the entry point name to the function in the package that implements it. -プラグインで定義された関数は virtualenvwrapper のフックローダが見つけられるために *エントリポイント* として登録される必要があります。 Distribute_ エントリポイントは関数を実装するパッケージでその関数に対するエントリポイントの名前をマッピングすることにより、そのパッケージの ``setup.py`` で設定されます。 +プラグインで定義された関数は virtualenvwrapper のフックローダが見つけられるために *エントリポイント* として登録する必要があります。 Distribute_ エントリポイントは関数を実装するパッケージでその関数に対するエントリポイントの名前をマッピングすることにより、そのパッケージの ``setup.py`` で設定されます。 .. This partial copy of virtualenvwrapper's ``setup.py`` illustrates how @@ -295,8 +295,7 @@ API は全ての拡張ポイントで同じです。それぞれは1つの引数 point is the plugin name, but that is not required (the names are not used). -エントリポイント指定子は ``name = package.module:function`` という構文の文字列です。 -慣例により、それぞれのエントリポイントの *名前* はプラグインの名前ですが、それが必要ではありません(その名前は使用されない)。 +エントリポイント指定子は ``name = package.module:function`` という構文の文字列です。慣例からエントリポイントの *名前* はプラグインの名前を付けますが、必須だというわけではありません (その名前を使わなくても構いません) 。 .. seealso:: @@ -576,7 +575,7 @@ post_rmvirtualenv ``virtualenvwrapper_run_hook`` is sufficient to cause them to be invoked. -さらに新しい操作を定義するプラグインは新しい拡張ポイントを定義することもできます。フックローダが拡張機能を見つけるために行う設定は必要ありません。名前を記述して ``virtualenvwrapper_run_hook`` の呼び出しを追加することで、追加した拡張機能が実行されるようになります。 +さらに新しい操作を定義するプラグインは新しい拡張ポイントも定義できます。フックローダが拡張機能を見つけるために行う設定は必要ありません。名前を記述して ``virtualenvwrapper_run_hook`` の呼び出しを追加することで、追加した拡張機能が実行されるようになります。 .. The hook loader assumes all extension point names start with From 740b0e8bccfdd2f85b8d91ca74a6910d5f742d3b Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 28 Apr 2012 07:23:53 -0400 Subject: [PATCH 530/947] reset the default language --- docs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Makefile b/docs/Makefile index 32267b1..50cb69f 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -2,7 +2,7 @@ # # If doc language is English you don't need to set this variable -LANGUAGE = ja +LANGUAGE = en # You can set these variables from the command line. SPHINXOPTS = -c sphinx From 8ebd00ff52ee060daecf31f3421aef749bad45b7 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 28 Apr 2012 07:24:55 -0400 Subject: [PATCH 531/947] attribution for documentation work --- docs/en/history.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index c70a445..0037a8a 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -8,6 +8,8 @@ dev intended to be executed on the command line. (contributed by :bbuser:`ralphbean`) - Worked on some brittle tests. + - Received updates to Japanese translation of the documentation from + :bbuser:`t2y`. 3.2 From 6377db3b77e82199bcfb0e736dd8be1105fa560f Mon Sep 17 00:00:00 2001 From: bwanamarko Date: Mon, 30 Apr 2012 11:24:51 -0700 Subject: [PATCH 532/947] update shell function virtualenvwrapper_get_site_packages_dir * let MSYS users use lssitepackages & cdsitepackages * replace $VIRTUAL_ENV/bin with $VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index b44fe61..103f180 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -609,7 +609,7 @@ function virtualenvwrapper_get_python_version { # Prints the path to the site-packages directory for the current environment. function virtualenvwrapper_get_site_packages_dir { - "$VIRTUAL_ENV/bin/python" -c "import distutils; print(distutils.sysconfig.get_python_lib())" + "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/python" -c "import distutils; print(distutils.sysconfig.get_python_lib())" } # Path management for packages outside of the virtual env. From 33bef3348dc3e815871d8da0be666bc1337d8b36 Mon Sep 17 00:00:00 2001 From: bwanamarko Date: Mon, 30 Apr 2012 13:33:58 -0700 Subject: [PATCH 533/947] fix bug for MSYS users - makes several folders, fails on shell startup * if $WORKON_HOME not defined, or folder missing, then when mkdir called must * pass $WORKON_HOME in double-quotes "$WORKON_HOME" because there might be * spaces that will be interpretted separately * e.g. C:\Documents and Settings\.virtualenv makes 3 folders: * "C:\Documents", "~/and" & "~/Settings/.virtualenv" --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 103f180..6504cb3 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -118,7 +118,7 @@ function virtualenvwrapper_verify_workon_home { then echo "NOTE: Virtual environments directory $WORKON_HOME does not exist. Creating..." 1>&2 fi - mkdir -p $WORKON_HOME + mkdir -p "$WORKON_HOME" RC=$? fi return $RC From e588eab989f5e443aaaf2526a961472ad71b0aa7 Mon Sep 17 00:00:00 2001 From: bwanamarko Date: Mon, 30 Apr 2012 14:09:28 -0700 Subject: [PATCH 534/947] another fix for msys users * using lssitepackages * keep $site_packages in quotes in case of spaces --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 6504cb3..90dd5f6 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -707,7 +707,7 @@ function lssitepackages { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 typeset site_packages="`virtualenvwrapper_get_site_packages_dir`" - ls $@ $site_packages + ls $@ "$site_packages" path_file="$site_packages/_virtualenv_path_extensions.pth" if [ -f "$path_file" ] From c6809216100286fd95fc0d492de4f8dde34ab50e Mon Sep 17 00:00:00 2001 From: Aron Griffis Date: Sat, 5 May 2012 17:48:28 -0400 Subject: [PATCH 535/947] Enforce running run_tests under tox by setting/checking an env var --HG-- extra : rebase_source : c7d4e82a995e79c35152190c2847aea53ee8e3cf --- tests/run_tests | 10 ++++++---- tox.ini | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/run_tests b/tests/run_tests index 2bd039e..e7c1bde 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -1,11 +1,13 @@ #!/bin/sh -## -## ONLY RUN THIS VIA TOX -## - #set -x +if [ -z "$TOXIC" ] +then + echo "Only run this via tox" 1>&2 + exit 1 +fi + envdir="$1" shift scripts="$*" diff --git a/tox.ini b/tox.ini index e299620..3601856 100644 --- a/tox.ini +++ b/tox.ini @@ -4,6 +4,8 @@ envlist = py27,py26,py32 [testenv] commands = bash ./tests/run_tests {envdir} [] deps = virtualenv +setenv = + TOXIC = true # Not sure why this is needed, but on my system if it isn't included then # the python version picked up for 2.6 is actually 2.7. From 92d265588ca44cfe94edc9a52a0a3a08a174204a Mon Sep 17 00:00:00 2001 From: Aron Griffis Date: Sat, 5 May 2012 18:32:16 -0400 Subject: [PATCH 536/947] Check that required test shells are available ahead of running tests. This avoids accidentally running tests with /bin/sh (dash) on Debian, which eventually deletes the ~/.virtualenvs directory. (Whoops.) --- tests/run_tests | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/tests/run_tests b/tests/run_tests index e7c1bde..1e7a66b 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -21,6 +21,24 @@ then fi fi +# Make sure the test shells exist before proceeding, otherwise tests are +# going to fail later. +missing_shells="" +test_shells="" +for shell in bash ksh zsh +do + if test_shell=$(which $shell); then + test_shells="$test_shells $test_shell" + else + missing_shells="$missing_shells $shell" + fi +done +if [ -n "$missing_shells" ] +then + echo "Couldn't find the following shells: $missing_shells" 1>&2 + exit 1 +fi + # Force the tox virtualenv to be active. # # Since this script runs from within a separate shell created by tox, @@ -49,13 +67,13 @@ unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS for test_script in $scripts do - for test_shell in bash ksh zsh + for test_shell in $test_shells do test_shell_opts= - if [ $test_shell = "zsh" ]; then - test_shell_opts="-o shwordsplit" - fi - export test_shell=$(which $test_shell) + case /$test_shell in + */zsh) test_shell_opts="-o shwordsplit" ;; + esac + export test_shell echo echo '********************************************************************************' From f00418b8641b3502afabb33ec1f5273502b41fa9 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 5 May 2012 19:26:40 -0400 Subject: [PATCH 537/947] attribution for previous merges --- docs/en/history.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index 0037a8a..aed381a 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -10,6 +10,9 @@ dev - Worked on some brittle tests. - Received updates to Japanese translation of the documentation from :bbuser:`t2y`. + - Fix the test script and runner so the user's ``$WORKON_HOME`` is + not erased if they do not have some test shells installed. + (big thanks to :bbuser:`agriffis`). 3.2 From 285851cb62ea6f10d656dd85ccca55597bea08df Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 6 May 2012 08:30:22 -0400 Subject: [PATCH 538/947] print the list of core hooks if no hook name is given in list mode --- docs/en/history.rst | 2 ++ virtualenvwrapper.sh | 6 +++--- virtualenvwrapper/hook_loader.py | 34 ++++++++++++++++++++++++++++++-- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index aed381a..14280c6 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -13,6 +13,8 @@ dev - Fix the test script and runner so the user's ``$WORKON_HOME`` is not erased if they do not have some test shells installed. (big thanks to :bbuser:`agriffis`). + - If the hook loader is told to list plugins but is not given a hook + name, it prints the list of core hooks. 3.2 diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index b44fe61..ba172fb 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -897,7 +897,7 @@ function mkproject { cd "$PROJECT_HOME" - virtualenvwrapper_run_hook project.pre_mkproject $envname + virtualenvwrapper_run_hook "project.pre_mkproject" $envname echo "Creating $PROJECT_HOME/$envname" mkdir -p "$PROJECT_HOME/$envname" @@ -912,10 +912,10 @@ function mkproject { # For some reason zsh insists on prefixing the template # names with a space, so strip them out before passing # the value to the hook loader. - virtualenvwrapper_run_hook --name $(echo $t | sed 's/^ //') project.template $envname + virtualenvwrapper_run_hook --name $(echo $t | sed 's/^ //') "project.template" $envname done - virtualenvwrapper_run_hook project.post_mkproject + virtualenvwrapper_run_hook "project.post_mkproject" } # Change directory to the active project diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 264739b..1ed5d91 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -6,6 +6,7 @@ """ import inspect +import itertools import logging import logging.handlers import optparse @@ -98,7 +99,11 @@ def main(): # Determine which hook we're running if not args: - parser.error('Please specify the hook to run') + if options.listing: + list_hooks() + return 0 + else: + parser.error('Please specify the hook to run') hook = args[0] if options.sourcing and options.script_filename: @@ -126,6 +131,7 @@ def main(): return 0 + def run_hooks(hook, options, args, output=None): if output is None: output = sys.stdout @@ -135,7 +141,7 @@ def run_hooks(hook, options, args, output=None): continue plugin = ep.load() if options.listing: - sys.stdout.write(' %-10s -- %s\n' % (ep.name, inspect.getdoc(plugin) or '')) + output.write(' %-10s -- %s\n' % (ep.name, inspect.getdoc(plugin) or '')) continue if options.sourcing: # Show the shell commands so they can @@ -149,5 +155,29 @@ def run_hooks(hook, options, args, output=None): # Just run the plugin ourselves plugin(args[1:]) + +def list_hooks(output=None): + if output is None: + output = sys.stdout + for hook in itertools.chain( + ('_'.join(h) + for h in itertools.product(['pre', 'post'], + ['mkvirtualenv', + 'rmvirtualenv', + 'activate', + 'deactivate', + 'cpvirtualenv', + ]) + ), + ['initialize', + 'get_env_details', + 'project.pre_mkproject', + 'project.post_mkproject', + 'project.template', + ] + ): + output.write(hook + '\n') + + if __name__ == '__main__': main() From f71c435b37217d2e0ac5f3e3a8740e91e40d635f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 6 May 2012 09:10:27 -0400 Subject: [PATCH 539/947] pep8 changes --- virtualenvwrapper/hook_loader.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 1ed5d91..419efec 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -15,6 +15,7 @@ import pkg_resources + class GroupWriteRotatingFileHandler(logging.handlers.RotatingFileHandler): """Taken from http://stackoverflow.com/questions/1407474/does-python-logging-handlers-rotatingfilehandler-allow-creation-of-a-group-writa """ @@ -24,6 +25,7 @@ def _open(self): os.umask(prevumask) return rtv + def main(): parser = optparse.OptionParser( usage='usage: %prog [options] []', @@ -68,7 +70,7 @@ def main(): dest='names', default=[], ) - parser.disable_interspersed_args() # stop when we hit an option without an '-' + parser.disable_interspersed_args() # stop when we hit an option without an '-' options, args = parser.parse_args() root_logger = logging.getLogger('') @@ -86,10 +88,10 @@ def main(): # Send higher-level messages to the console, too console = logging.StreamHandler() - console_level = [ logging.WARNING, - logging.INFO, - logging.DEBUG, - ][options.verbose_level] + console_level = [logging.WARNING, + logging.INFO, + logging.DEBUG, + ][options.verbose_level] console.setLevel(console_level) formatter = logging.Formatter('%(name)s %(message)s') console.setFormatter(formatter) From e8221843262446e49097251f1dd8591bca98cc70 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 6 May 2012 09:35:23 -0400 Subject: [PATCH 540/947] attribution for merging pull request 17 --- docs/en/history.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index 14280c6..290eaf7 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -15,6 +15,8 @@ dev (big thanks to :bbuser:`agriffis`). - If the hook loader is told to list plugins but is not given a hook name, it prints the list of core hooks. + - Merge several fixes for path and variable handling for MSYS users + from :bbuser:`bwanamarko`. Includes a fix for :bbissue:`138`. 3.2 From b60d9300c193006e217e94bfc5c7b5229b320f9a Mon Sep 17 00:00:00 2001 From: Aron Griffis Date: Sun, 6 May 2012 10:15:01 -0400 Subject: [PATCH 541/947] Remove the trap from virtualenvwrapper_tempfile; the function is called in a command substitution, so the trap fires immediately to remove the file. There are ways to accomplish this, but they're complex and the caller is already explicitly rm'ing the file. diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -130,25 +130,24 @@ function virtualenvwrapper_verify_workon function virtualenvwrapper_tempfile { --- tests/test_tempfile.sh | 1 + virtualenvwrapper.sh | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_tempfile.sh b/tests/test_tempfile.sh index 4543fd2..30f3af8 100755 --- a/tests/test_tempfile.sh +++ b/tests/test_tempfile.sh @@ -24,6 +24,7 @@ setUp () { test_tempfile () { filename=$(virtualenvwrapper_tempfile hook) assertTrue "Filename is empty" "[ ! -z \"$filename\" ]" + assertTrue "File doesn't exist" "[ -f \"$filename\" ]" rm -f $filename comparable_tmpdir=$(echo $tmplocation | sed 's|/$||') comparable_dirname=$(dirname $filename | sed 's|/$||') diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index b44fe61..29b72bc 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -136,7 +136,6 @@ function virtualenvwrapper_tempfile { echo "ERROR: virtualenvwrapper could not create a temporary file name." 1>&2 return 1 fi - trap "\rm -f '$file' >/dev/null 2>&1" EXIT echo $file return 0 } From 7a98b7254d374636ebdaf6ae71cc3331b986258f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 6 May 2012 10:39:04 -0400 Subject: [PATCH 542/947] catch --help option to mkvirtualenv; fixes #136 --- docs/en/history.rst | 2 ++ virtualenvwrapper.sh | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 290eaf7..e1e8a82 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -17,6 +17,8 @@ dev name, it prints the list of core hooks. - Merge several fixes for path and variable handling for MSYS users from :bbuser:`bwanamarko`. Includes a fix for :bbissue:`138`. + - Change :ref:`command-mkvirtualenv` so it catches both ``-h`` and + ``--help``. 3.2 diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 8b9e94f..de54d08 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -298,7 +298,7 @@ function mkvirtualenv_help { echo; echo 'virtualenv help:'; echo; - virtualenv -h; + virtualenv $@; } # Create a new environment, in the WORKON_HOME. @@ -334,8 +334,8 @@ function mkvirtualenv { -a) i=$(( $i + 1 )); project="${in_args[$i]}";; - -h) - mkvirtualenv_help; + -h|--help) + mkvirtualenv_help $a; return;; -i) i=$(( $i + 1 )); From 2d02918868dde9e0bd596161dec7b82f3709605a Mon Sep 17 00:00:00 2001 From: Aron Griffis Date: Sun, 6 May 2012 10:45:15 -0400 Subject: [PATCH 543/947] Fix error handling in virtualenvwrapper_tempfile; the typeset builtin will return success even if the command-substitution fails, so put them on separate lines. --- tests/test_tempfile.sh | 19 +++++++++++++++++++ virtualenvwrapper.sh | 17 +++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/tests/test_tempfile.sh b/tests/test_tempfile.sh index 30f3af8..ca4bae4 100755 --- a/tests/test_tempfile.sh +++ b/tests/test_tempfile.sh @@ -32,6 +32,25 @@ test_tempfile () { assertTrue "virtualenvwrapper-hook not in filename." "echo $filename | grep virtualenvwrapper-hook" } +test_bad_mktemp() { + # All of the following bogus mktemp programs should cause + # virtualenvwrapper_tempfile to return non-zero status + mktemp_nonzero() { return 1; } + mktemp_empty_string() { return 0; } + mktemp_missing_executable() { /foo/bar/baz/qux 2>/dev/null; } # returns status 127 + mktemp_missing_result() { echo /foo/bar/baz/qux; } + + for mktemp_func in mktemp_nonzero mktemp_empty_string \ + mktemp_missing_executable mktemp_missing_result + do + mktemp() { $mktemp_func "$@"; } + filename=$(virtualenvwrapper_tempfile hook) + assertSame "($mktemp_func) Unexpected exit code $?" "1" "$?" + done + + unset -f mktemp +} + test_no_such_tmpdir () { old_tmpdir="$TMPDIR" export TMPDIR="$tmplocation/does-not-exist" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 29b72bc..d4577b7 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -130,8 +130,10 @@ function virtualenvwrapper_verify_workon_home { function virtualenvwrapper_tempfile { # Note: the 'X's must come last typeset suffix=${1:-hook} - typeset file="`\mktemp -t virtualenvwrapper-$suffix-XXXXXXXXXX`" - if [ $? -ne 0 ] + typeset file + + file="`\mktemp -t virtualenvwrapper-$suffix-XXXXXXXXXX`" + if [ $? -ne 0 ] || [ -z "$file" ] || [ ! -f "$file" ] then echo "ERROR: virtualenvwrapper could not create a temporary file name." 1>&2 return 1 @@ -142,12 +144,11 @@ function virtualenvwrapper_tempfile { # Run the hooks function virtualenvwrapper_run_hook { - typeset hook_script="$(virtualenvwrapper_tempfile ${1}-hook)" - if [ -z "$hook_script" ] - then - echo "ERROR: Could not create temporary file name. Make sure TMPDIR is set." 1>&2 - return 1 - fi + typeset hook_script + typeset result + + hook_script="$(virtualenvwrapper_tempfile ${1}-hook)" || return 1 + if [ -z "$VIRTUALENVWRAPPER_LOG_DIR" ] then echo "ERROR: VIRTUALENVWRAPPER_LOG_DIR is not set." 1>&2 From 3ca7ba19670b9cceafb7983a27836d626716ddfa Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 6 May 2012 15:09:58 -0400 Subject: [PATCH 544/947] attribution for previous merge --- docs/en/history.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index e1e8a82..74961fd 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -19,6 +19,8 @@ dev from :bbuser:`bwanamarko`. Includes a fix for :bbissue:`138`. - Change :ref:`command-mkvirtualenv` so it catches both ``-h`` and ``--help``. + - Fix some issues with the way temporary files are used for hook + scripts. (contributed by :bbuser:`agriffis`) 3.2 From 515d9eb1114bf6a5afd06cdc767f121efeb0b6c7 Mon Sep 17 00:00:00 2001 From: Aron Griffis Date: Sun, 6 May 2012 15:10:13 -0400 Subject: [PATCH 545/947] Clean up the temporary file in the virtualenvwrapper_run_hook error returns. --- virtualenvwrapper.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index d4577b7..562c9aa 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -152,6 +152,7 @@ function virtualenvwrapper_run_hook { if [ -z "$VIRTUALENVWRAPPER_LOG_DIR" ] then echo "ERROR: VIRTUALENVWRAPPER_LOG_DIR is not set." 1>&2 + \rm -f "$hook_script" return 1 fi "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' $HOOK_VERBOSE_OPTION --script "$hook_script" "$@" @@ -162,12 +163,13 @@ function virtualenvwrapper_run_hook { if [ ! -f "$hook_script" ] then echo "ERROR: virtualenvwrapper_run_hook could not find temporary file $hook_script" 1>&2 + \rm -f "$hook_script" return 2 fi # cat "$hook_script" source "$hook_script" fi - \rm -f "$hook_script" >/dev/null 2>&1 + \rm -f "$hook_script" return $result } From 185f5cf5b2edc2d9a8e688b5205c793d57cbe4ee Mon Sep 17 00:00:00 2001 From: Justin Barber Date: Sun, 6 May 2012 16:24:18 -0400 Subject: [PATCH 546/947] Update to get fully qualified path of requirments in case a directory change occurs before pip is called. --HG-- branch : fix_installing_requirements_after_cd --- tests/test_expandpath.sh | 28 ++++++++++++++++++++++++++++ virtualenvwrapper.sh | 14 ++++++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100755 tests/test_expandpath.sh diff --git a/tests/test_expandpath.sh b/tests/test_expandpath.sh new file mode 100755 index 0000000..fbdfefd --- /dev/null +++ b/tests/test_expandpath.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +test_dir=$(cd $(dirname $0) && pwd) +source "$test_dir/setup.sh" +TMP_WORKON_HOME="$WORKON_HOME" + +oneTimeSetUp() { + source "$test_dir/../virtualenvwrapper.sh" + echo $PYTHONPATH +} + +oneTimeTearDown() { + return 0 +} + +test_tilde() { + assertSame "$HOME" "$(virtualenvwrapper_expandpath ~)" +} + +test_vars() { + assertSame "$HOME" "$(virtualenvwrapper_expandpath '$HOME')" +} + +test_tilde_vars() { + assertSame "$HOME" "$(virtualenvwrapper_expandpath '~$USER')" +} + +. "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index de54d08..31b0585 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -72,6 +72,15 @@ then export VIRTUALENVWRAPPER_PROJECT_FILENAME=".project" fi +function virtualenvwrapper_expandpath { + if [ "$1" = "" ]; then + return 1 + else + "$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.realpath(os.path.expanduser(os.path.expandvars(\"$1\")))+'\n')" + return 0 + fi +} + function virtualenvwrapper_derive_workon_home { typeset workon_home_dir="$WORKON_HOME" @@ -99,7 +108,7 @@ function virtualenvwrapper_derive_workon_home { # - Removing extra slashes (e.g., when TMPDIR ends in a slash) # - Expanding variables (e.g., $foo) # - Converting ~s to complete paths (e.g., ~/ to /home/brian/ and ~arthur to /home/arthur) - workon_home_dir=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.expandvars(os.path.expanduser(\"$workon_home_dir\"))+'\n')") + workon_home_dir=$(virtualenvwrapper_expandpath $workon_home_dir) fi echo "$workon_home_dir" @@ -342,7 +351,8 @@ function mkvirtualenv { packages="$packages ${in_args[$i]}";; -r) i=$(( $i + 1 )); - requirements="${in_args[$i]}";; + requirements="${in_args[$i]}"; + requirements=$(virtualenvwrapper_expandpath $requirements);; *) if [ ${#out_args} -gt 0 ] then From 5b35a17e168514678d8038c4084cd43d9a3aab13 Mon Sep 17 00:00:00 2001 From: Justin Barber Date: Sun, 6 May 2012 18:06:51 -0400 Subject: [PATCH 547/947] Quoting arguments to expandpath to allow for spaces in the arguments. --HG-- branch : fix_installing_requirements_after_cd --- virtualenvwrapper.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 31b0585..847e27f 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -108,7 +108,7 @@ function virtualenvwrapper_derive_workon_home { # - Removing extra slashes (e.g., when TMPDIR ends in a slash) # - Expanding variables (e.g., $foo) # - Converting ~s to complete paths (e.g., ~/ to /home/brian/ and ~arthur to /home/arthur) - workon_home_dir=$(virtualenvwrapper_expandpath $workon_home_dir) + workon_home_dir=$(virtualenvwrapper_expandpath "$workon_home_dir") fi echo "$workon_home_dir" @@ -352,7 +352,7 @@ function mkvirtualenv { -r) i=$(( $i + 1 )); requirements="${in_args[$i]}"; - requirements=$(virtualenvwrapper_expandpath $requirements);; + requirements=$(virtualenvwrapper_expandpath "$requirements");; *) if [ ${#out_args} -gt 0 ] then From 896cfeb0551d71c337aa892734dd0ecf258333d5 Mon Sep 17 00:00:00 2001 From: Aron Griffis Date: Sun, 6 May 2012 22:20:57 -0400 Subject: [PATCH 548/947] Use spaces for indentation consistently instead of mixed spaces/tabs. No functional changes. --- virtualenvwrapper.sh | 86 ++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 562c9aa..d5441a0 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -60,9 +60,9 @@ fi VIRTUALENVWRAPPER_ENV_BIN_DIR="bin" if [ "$OS" = "Windows_NT" ] && [ "$MSYSTEM" = "MINGW32" ] then - # Only assign this for msys, cygwin use standard Unix paths - # and its own python installation - VIRTUALENVWRAPPER_ENV_BIN_DIR="Scripts" + # Only assign this for msys, cygwin use standard Unix paths + # and its own python installation + VIRTUALENVWRAPPER_ENV_BIN_DIR="Scripts" fi # Let the user override the name of the file that holds the project @@ -131,7 +131,7 @@ function virtualenvwrapper_tempfile { # Note: the 'X's must come last typeset suffix=${1:-hook} typeset file - + file="`\mktemp -t virtualenvwrapper-$suffix-XXXXXXXXXX`" if [ $? -ne 0 ] || [ -z "$file" ] || [ ! -f "$file" ] then @@ -146,13 +146,13 @@ function virtualenvwrapper_tempfile { function virtualenvwrapper_run_hook { typeset hook_script typeset result - + hook_script="$(virtualenvwrapper_tempfile ${1}-hook)" || return 1 if [ -z "$VIRTUALENVWRAPPER_LOG_DIR" ] then echo "ERROR: VIRTUALENVWRAPPER_LOG_DIR is not set." 1>&2 - \rm -f "$hook_script" + \rm -f "$hook_script" return 1 fi "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' $HOOK_VERBOSE_OPTION --script "$hook_script" "$@" @@ -163,7 +163,7 @@ function virtualenvwrapper_run_hook { if [ ! -f "$hook_script" ] then echo "ERROR: virtualenvwrapper_run_hook could not find temporary file $hook_script" 1>&2 - \rm -f "$hook_script" + \rm -f "$hook_script" return 2 fi # cat "$hook_script" @@ -376,8 +376,8 @@ function mkvirtualenv { # we should switch to the environment and run the hook. [ ! -d "$WORKON_HOME/$envname" ] && return 0 - # If they gave us a project directory, set it up now - # so the activate hooks can find it. + # If they gave us a project directory, set it up now + # so the activate hooks can find it. if [ ! -z "$project" ] then setvirtualenvproject "$WORKON_HOME/$envname" "$project" @@ -464,38 +464,38 @@ function lsvirtualenv { typeset long_mode=true if command -v "getopts" &> /dev/null then - # Use getopts when possible - OPTIND=1 - while getopts ":blh" opt "$@" - do - case "$opt" in - l) long_mode=true;; - b) long_mode=false;; - h) _lsvirtualenv_usage; - return 1;; - ?) echo "Invalid option: -$OPTARG" >&2; - _lsvirtualenv_usage; - return 1;; - esac - done + # Use getopts when possible + OPTIND=1 + while getopts ":blh" opt "$@" + do + case "$opt" in + l) long_mode=true;; + b) long_mode=false;; + h) _lsvirtualenv_usage; + return 1;; + ?) echo "Invalid option: -$OPTARG" >&2; + _lsvirtualenv_usage; + return 1;; + esac + done else - # fallback on getopt for other shell - typeset -a args - args=($(getopt blh "$@")) - if [ $? != 0 ] - then - _lsvirtualenv_usage - return 1 - fi - for opt in $args - do - case "$opt" in - -l) long_mode=true;; - -b) long_mode=false;; - -h) _lsvirtualenv_usage; - return 1;; - esac - done + # fallback on getopt for other shell + typeset -a args + args=($(getopt blh "$@")) + if [ $? != 0 ] + then + _lsvirtualenv_usage + return 1 + fi + for opt in $args + do + case "$opt" in + -l) long_mode=true;; + -b) long_mode=false;; + -h) _lsvirtualenv_usage; + return 1;; + esac + done fi if $long_mode @@ -534,8 +534,8 @@ function showvirtualenv { # Usage: workon [environment_name] # function workon { - typeset env_name="$1" - if [ "$env_name" = "" ] + typeset env_name="$1" + if [ "$env_name" = "" ] then lsvirtualenv -b return 1 @@ -596,7 +596,7 @@ function workon { virtualenvwrapper_run_hook "post_activate" - return 0 + return 0 } From 69a55fe148570f3ea6dabb2b2d8668207cd9c45c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 8 May 2012 09:43:04 -0400 Subject: [PATCH 549/947] attribution for previous merge --- docs/en/history.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index 74961fd..06b358f 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -21,6 +21,8 @@ dev ``--help``. - Fix some issues with the way temporary files are used for hook scripts. (contributed by :bbuser:`agriffis`) + - Allow relative path to requirements file with + :ref:`command-mkvirtualenv` and ``-r`` option. (:bbuser:`barberj`) 3.2 From 2866557b0e1b99716b2728bf87da7eb3b91a0e83 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 8 May 2012 09:43:22 -0400 Subject: [PATCH 550/947] clean up RST formatting --- docs/en/scripts.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/scripts.rst b/docs/en/scripts.rst index 1b6eafc..a54bd57 100644 --- a/docs/en/scripts.rst +++ b/docs/en/scripts.rst @@ -208,7 +208,7 @@ environment directory is passed as an argument to the script. .. _scripts-premkproject: premkproject -=============== +============ :Global/Local: global :Argument(s): name of new project @@ -224,7 +224,7 @@ argument to the script. .. _scripts-postmkproject: postmkproject -================ +============= :Global/Local: global :Argument(s): none From c78f7537c9cb61c588b4391c4aa7162842d8a4a1 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 8 May 2012 09:44:39 -0400 Subject: [PATCH 551/947] attribution for previous merge --- docs/en/history.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index 06b358f..8dc2b9c 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -23,6 +23,7 @@ dev scripts. (contributed by :bbuser:`agriffis`) - Allow relative path to requirements file with :ref:`command-mkvirtualenv` and ``-r`` option. (:bbuser:`barberj`) + - Make whitespace consistent. (:bbuser:`agriffis`) 3.2 From 9c9f04e438fd4276b050f5e5111819f7e767f38a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 12 May 2012 14:32:19 -0400 Subject: [PATCH 552/947] prepare 3.3 release --- docs/en/history.rst | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 8dc2b9c..5d98a3a 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,7 +2,7 @@ Release History =============== -dev +3.3 - Clean up file permissions and remove shebangs from scripts not intended to be executed on the command line. (contributed by diff --git a/setup.py b/setup.py index 9fe444a..4b55d0b 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ PROJECT = 'virtualenvwrapper' # Change docs/sphinx/conf.py too! -VERSION = '3.2' +VERSION = '3.3' # Bootstrap installation of Distribute import distribute_setup From 62c45af5d6d8391ab1baf3a00d240280c2ff546a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 12 May 2012 14:32:48 -0400 Subject: [PATCH 553/947] Added tag 3.3 for changeset 45877370548e --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 40c531f..7fd2649 100644 --- a/.hgtags +++ b/.hgtags @@ -82,3 +82,4 @@ ff4d492c873c324ccfb71bc71118a67aa6195ad2 2.11 14cf7e58d32174c8e90cf6914a6604f3cff9f279 3.0.1 ebbb3ba8168703861c016ed66f443fb898f0b06b 3.1 dccf1a1abf4ea97589e9fa141167771049f031e0 3.2 +45877370548ee7c2581a6c81df22b12fcc3f4891 3.3 From b11459d97a66c015d9397488370041e82c294609 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 12 May 2012 14:36:58 -0400 Subject: [PATCH 554/947] add requirements file to try readthedocs again --- docs/requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/requirements.txt diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..ccb1b73 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1 @@ +sphinxcontrib.bitbucket From 15968616c2d21c380a2d09e311571f040004a145 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 12 May 2012 14:37:32 -0400 Subject: [PATCH 555/947] remove old copy of requirements file --- docs/sphinx/requirements.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 docs/sphinx/requirements.txt diff --git a/docs/sphinx/requirements.txt b/docs/sphinx/requirements.txt deleted file mode 100644 index a35bfac..0000000 --- a/docs/sphinx/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -sphinxcontrib-bitbucket From ad36cb36dca8bf10e010986d267817ade3ac9af3 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 12 May 2012 14:40:02 -0400 Subject: [PATCH 556/947] fix the requirement name --- docs/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index ccb1b73..a35bfac 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1 +1 @@ -sphinxcontrib.bitbucket +sphinxcontrib-bitbucket From a84cda48bfea4082272679243a82f794c22461d1 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 12 May 2012 14:47:21 -0400 Subject: [PATCH 557/947] update announcement file for 3.3 release --- announce.rst | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/announce.rst b/announce.rst index 5588ea6..6e9f2b7 100644 --- a/announce.rst +++ b/announce.rst @@ -1,5 +1,5 @@ ======================= - virtualenvwrapper 3.2 + virtualenvwrapper 3.3 ======================= .. tags:: virtualenvwrapper release python @@ -16,22 +16,26 @@ introducing conflicts in their dependencies. What's New in 3.2 ================= -- Make ``project_dir`` a local variable so that - ``cdproject`` does not interfere with other variables - the user might have set. (contributed by ``slackorama``) -- Fix typo in documentation reported by Nick Martin. -- Change trove classifier for license "MIT" to reflect the license - text presented in the documentation. *This does not indicate a - change in the license, just a correction to the expression of that - intent.* (contributed by ``ralphbean`` as fix for issue 134) -- Extend ``rmvirtualenv`` to allow removing more than one - environment at a time. (contributed by ``ciberglo``) -- Change the definition of ``virtualenvwrapper_get_site_packages_dir`` - to ask ``distutils`` for the ``site-packages`` directory instead of - trying to build the path ourselves in the shell script. This should - resolve issue 112 and improve support for Python interpreters other - than C Python. Thanks to Carl Meyer and Dario Bertini for their - contributions toward the fix. +- Clean up file permissions and remove shebangs from scripts not + intended to be executed on the command line. (contributed by + ``ralphbean``) +- Worked on some brittle tests. +- Received updates to Japanese translation of the documentation from + ``t2y``. +- Fix the test script and runner so the user's ``$WORKON_HOME`` is + not erased if they do not have some test shells installed. + (big thanks to ``agriffis``). +- If the hook loader is told to list plugins but is not given a hook + name, it prints the list of core hooks. +- Merge several fixes for path and variable handling for MSYS users + from ``bwanamarko``. Includes a fix for issue 138. +- Change ``mkvirtualenv`` so it catches both ``-h`` and + ``--help``. +- Fix some issues with the way temporary files are used for hook + scripts. (contributed by ``agriffis``) +- Allow relative path to requirements file with + ``mkvirtualenv`` and ``-r`` option. (``barberj``) +- Make whitespace consistent. (``agriffis``) Installing ========== From 1fc730438481a2f9b783114375f20c61162ce9f0 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 13 May 2012 07:47:41 -0400 Subject: [PATCH 558/947] fix section heading in announce blog post so the version number does not appear twice --- announce.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/announce.rst b/announce.rst index 6e9f2b7..aa67b9f 100644 --- a/announce.rst +++ b/announce.rst @@ -13,8 +13,8 @@ virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. -What's New in 3.2 -================= +What's New +========== - Clean up file permissions and remove shebangs from scripts not intended to be executed on the command line. (contributed by From 6fe5029d4b11f9e55494a2b2dd930b7f2d3edce2 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 20 May 2012 10:05:46 -0400 Subject: [PATCH 559/947] hide error messages --- tests/test_tempfile.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_tempfile.sh b/tests/test_tempfile.sh index ca4bae4..28effcd 100755 --- a/tests/test_tempfile.sh +++ b/tests/test_tempfile.sh @@ -44,7 +44,7 @@ test_bad_mktemp() { mktemp_missing_executable mktemp_missing_result do mktemp() { $mktemp_func "$@"; } - filename=$(virtualenvwrapper_tempfile hook) + filename=$(virtualenvwrapper_tempfile hook 2>/dev/null) assertSame "($mktemp_func) Unexpected exit code $?" "1" "$?" done From d12294789c0665b98cbc041582992ab44914d5d6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 20 May 2012 10:06:30 -0400 Subject: [PATCH 560/947] Invoke the initialization hooks directly when testing for error with Python --- tests/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test.sh b/tests/test.sh index 5705cc2..93b979b 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -97,7 +97,7 @@ test_python_interpreter_set_incorrectly() { found_it=$? #echo "$found_it" assertTrue "Expected \'$expected\', got: \'$subshell_output\'" "[ $found_it -eq 0 ]" - assertFalse "Failed to detect invalid Python location" "VIRTUALENVWRAPPER_PYTHON=$VIRTUAL_ENV/bin/python $SHELL $return_to/virtualenvwrapper.sh >/dev/null 2>&1" + assertFalse "Failed to detect invalid Python location" "VIRTUALENVWRAPPER_PYTHON=$VIRTUAL_ENV/bin/python virtualenvwrapper_run_hook initialize >/dev/null 2>&1" cd "$return_to" deactivate } From af7e3deb67f4274be0ddcad5f6372abe63e3cc7e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 20 May 2012 10:07:15 -0400 Subject: [PATCH 561/947] move error reporting for bad python interpreter closer to where the error occurs --- virtualenvwrapper.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 63b2fc2..0f2ef00 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -177,6 +177,16 @@ function virtualenvwrapper_run_hook { fi # cat "$hook_script" source "$hook_script" + elif [ "${1}" = "initialize" ] + then + cat - 1>&2 <&2 - return 1 - fi virtualenvwrapper_setup_tab_completion @@ -994,6 +999,6 @@ EOF # -# Invoke the initialization hooks +# Invoke the initialization functions # virtualenvwrapper_initialize From fc6ff16e2e4789ce88bd792864c962c836f20606 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 20 May 2012 10:17:02 -0400 Subject: [PATCH 562/947] add lazy loader --- docs/en/history.rst | 4 ++ docs/en/install.rst | 25 ++++++++ setup.py | 3 +- tests/test_lazy.sh | 108 ++++++++++++++++++++++++++++++++++ tests/test_lazy_loaded.sh | 109 +++++++++++++++++++++++++++++++++++ trace.log | 118 ++++++++++++++++++++++++++++++++++++++ virtualenvwrapper_lazy.sh | 34 +++++++++++ 7 files changed, 400 insertions(+), 1 deletion(-) create mode 100644 tests/test_lazy.sh create mode 100644 tests/test_lazy_loaded.sh create mode 100644 trace.log create mode 100644 virtualenvwrapper_lazy.sh diff --git a/docs/en/history.rst b/docs/en/history.rst index 5d98a3a..33cf9e8 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,10 @@ Release History =============== +3.4 + + - Add :ref:`install-lazy-loader` option. + 3.3 - Clean up file permissions and remove shebangs from scripts not diff --git a/docs/en/install.rst b/docs/en/install.rst index 0397cce..4387d99 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -118,6 +118,31 @@ of the script installed with this package:: After editing it, reload the startup file (e.g., run ``source ~/.bashrc``). +.. _install-lazy-loader: + +Lazy Loading +------------ + +An alternative initialization script is provided for loading +virtualenvwrapper lazily. Instead of sourcing ``virtualenvwrapper.sh`` +directly, use ``virtualenvwrapper_lazy.sh``. If +``virtualenvwrapper.sh`` is not on your ``$PATH``, set +``VIRTUALENVWRAPPER_SCRIPT`` to point to it. + +:: + + export WORKON_HOME=$HOME/.virtualenvs + export PROJECT_HOME=$HOME/Devel + export VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh + source /usr/local/bin/virtualenvwrapper_lazy.sh + +.. warning:: + + When the lazy-loading version of the startup script is used, + tab-completion does not work until after the first + virtualenvwrapper command has been run. For example, tab completion + does not work for the first instance of :ref:`command-workon`. + Quick-Start =========== diff --git a/setup.py b/setup.py index 4b55d0b..64b90a0 100644 --- a/setup.py +++ b/setup.py @@ -139,7 +139,8 @@ def find_package_data( platforms = ['Any'], - scripts = ['virtualenvwrapper.sh', + scripts = ['virtualenvwrapper.sh', + 'virtualenvwrapper_lazy.sh', ], provides=['virtualenvwrapper', diff --git a/tests/test_lazy.sh b/tests/test_lazy.sh new file mode 100644 index 0000000..a87a1b0 --- /dev/null +++ b/tests/test_lazy.sh @@ -0,0 +1,108 @@ +#!/bin/sh + +test_dir=$(cd $(dirname $0) && pwd) +source "$test_dir/setup.sh" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper_lazy.sh" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +function_defined_lazy() { + name="$1" + assertTrue "$name not defined" "type $name" + assertTrue "$name does not load virtualenvwrapper" "typeset -f $name | grep 'virtualenvwrapper_load'" +} + +test_mkvirtualenv_defined_lazy() { + function_defined_lazy mkvirtualenv +} + +test_rmvirtualenv_defined_lazy() { + function_defined_lazy rmvirtualenv +} + +test_lsvirtualenv_defined_lazy() { + function_defined_lazy lsvirtualenv +} + +test_showvirtualenv_defined_lazy() { + function_defined_lazy showvirtualenv +} + +test_workon_defined_lazy() { + function_defined_lazy workon +} + +test_add2virtualenv_defined_lazy() { + function_defined_lazy add2virtualenv +} + +test_cdsitepackages_defined_lazy() { + function_defined_lazy cdsitepackages +} + +test_cdvirtualenv_defined_lazy() { + function_defined_lazy cdvirtualenv +} + +test_cdvirtualenv_defined_lazy() { + function_defined_lazy cdvirtualenv +} + +test_lssitepackages_defined_lazy() { + function_defined_lazy lssitepackages +} + +test_toggleglobalsitepackages_defined_lazy() { + function_defined_lazy toggleglobalsitepackages +} + +test_cpvirtualenv_defined_lazy() { + function_defined_lazy cpvirtualenv +} + +test_setvirtualenvproject_defined_lazy() { + function_defined_lazy setvirtualenvproject +} + +test_mkproject_defined_lazy() { + function_defined_lazy mkproject +} + +test_cdproject_defined_lazy() { + function_defined_lazy cdproject +} + +test_mktmpenv_defined_lazy() { + function_defined_lazy mktmpenv +} + + +# test_virtualenvwrapper_initialize() { +# assertTrue "Initialized" virtualenvwrapper_initialize +# for hook in premkvirtualenv postmkvirtualenv prermvirtualenv postrmvirtualenv preactivate postactivate predeactivate postdeactivate +# do +# assertTrue "Global $WORKON_HOME/$hook was not created" "[ -f $WORKON_HOME/$hook ]" +# assertTrue "Global $WORKON_HOME/$hook is not executable" "[ -x $WORKON_HOME/$hook ]" +# done +# assertTrue "Log file was not created" "[ -f $WORKON_HOME/hook.log ]" +# export pre_test_dir=$(cd "$test_dir"; pwd) +# echo "echo GLOBAL initialize >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/initialize" +# virtualenvwrapper_initialize +# output=$(cat "$test_dir/catch_output") +# expected="GLOBAL initialize" +# assertSame "$expected" "$output" +# } + +. "$test_dir/shunit2" diff --git a/tests/test_lazy_loaded.sh b/tests/test_lazy_loaded.sh new file mode 100644 index 0000000..b71e68e --- /dev/null +++ b/tests/test_lazy_loaded.sh @@ -0,0 +1,109 @@ +#!/bin/sh + +test_dir=$(cd $(dirname $0) && pwd) +source "$test_dir/setup.sh" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper_lazy.sh" + virtualenvwrapper_load +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +function_defined_normal() { + name="$1" + assertTrue "$name not defined" "type $name" + assertFalse "$name still set to run lazy loader" "typeset -f $name | grep 'virtualenvwrapper_load'" +} + +test_mkvirtualenv_defined_normal() { + function_defined_normal mkvirtualenv +} + +test_rmvirtualenv_defined_normal() { + function_defined_normal rmvirtualenv +} + +test_lsvirtualenv_defined_normal() { + function_defined_normal lsvirtualenv +} + +test_showvirtualenv_defined_normal() { + function_defined_normal showvirtualenv +} + +test_workon_defined_normal() { + function_defined_normal workon +} + +test_add2virtualenv_defined_normal() { + function_defined_normal add2virtualenv +} + +test_cdsitepackages_defined_normal() { + function_defined_normal cdsitepackages +} + +test_cdvirtualenv_defined_normal() { + function_defined_normal cdvirtualenv +} + +test_cdvirtualenv_defined_normal() { + function_defined_normal cdvirtualenv +} + +test_lssitepackages_defined_normal() { + function_defined_normal lssitepackages +} + +test_toggleglobalsitepackages_defined_normal() { + function_defined_normal toggleglobalsitepackages +} + +test_cpvirtualenv_defined_normal() { + function_defined_normal cpvirtualenv +} + +test_setvirtualenvproject_defined_normal() { + function_defined_normal setvirtualenvproject +} + +test_mkproject_defined_normal() { + function_defined_normal mkproject +} + +test_cdproject_defined_normal() { + function_defined_normal cdproject +} + +test_mktmpenv_defined_normal() { + function_defined_normal mktmpenv +} + + +# test_virtualenvwrapper_initialize() { +# assertTrue "Initialized" virtualenvwrapper_initialize +# for hook in premkvirtualenv postmkvirtualenv prermvirtualenv postrmvirtualenv preactivate postactivate predeactivate postdeactivate +# do +# assertTrue "Global $WORKON_HOME/$hook was not created" "[ -f $WORKON_HOME/$hook ]" +# assertTrue "Global $WORKON_HOME/$hook is not executable" "[ -x $WORKON_HOME/$hook ]" +# done +# assertTrue "Log file was not created" "[ -f $WORKON_HOME/hook.log ]" +# export pre_test_dir=$(cd "$test_dir"; pwd) +# echo "echo GLOBAL initialize >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/initialize" +# virtualenvwrapper_initialize +# output=$(cat "$test_dir/catch_output") +# expected="GLOBAL initialize" +# assertSame "$expected" "$output" +# } + +. "$test_dir/shunit2" diff --git a/trace.log b/trace.log new file mode 100644 index 0000000..8795e79 --- /dev/null +++ b/trace.log @@ -0,0 +1,118 @@ +_________________________________ [tox sdist] __________________________________ +[TOX] ***creating sdist package +[TOX] /Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup$ /Users/dhellmann/Envs/virtualenvwrapper/bin/python setup.py sdist --formats=zip --dist-dir .tox/dist >.tox/log/0.log +[TOX] ***copying new sdistfile to '/Users/dhellmann/.tox/distshare/virtualenvwrapper-3.3.zip' +______________________________ [tox testenv:py27] ______________________________ +[TOX] ***reusing existing matching virtualenv py27 +[TOX] ***upgrade-installing sdist +[TOX] /Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/py27/log$ ../bin/pip install --download-cache=/Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/_download /Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/dist/virtualenvwrapper-3.3.zip -U --no-deps >21.log +[TOX] WARNING:test command found but not installed in testenv + cmd: /bin/bash + env: /Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/py27 +Maybe forgot to specify a dependency? +[TOX] /Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup$ /bin/bash ./tests/run_tests /Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/py27 tests/test.sh + +******************************************************************************** +Running tests/test.sh + VIRTUAL_ENV=/Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/py27 + VIRTUALENVWRAPPER_PYTHON=/Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/py27/bin/python + Python 2.7.2 + PYTHONPATH= + SHELL=/bin/bash + + +test_virtualenvwrapper_initialize + +test_virtualenvwrapper_run_init_hooks + +test_virtualenvwrapper_space_in_workon_home + +test_virtualenvwrapper_verify_workon_home + +test_virtualenvwrapper_verify_workon_home_missing_dir + +test_virtualenvwrapper_verify_workon_home_missing_dir_quiet + +test_virtualenvwrapper_verify_workon_home_missing_dir_grep_options + +test_python_interpreter_set_incorrectly +Using real prefix '/Library/Frameworks/Python.framework/Versions/2.7' +New python executable in no_wrappers/bin/python +Installing distribute.............................................................................................................................................................................................done. +Installing pip...............done. + +Ran 8 tests. + +OK + + +******************************************************************************** +Running tests/test.sh + VIRTUAL_ENV=/Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/py27 + VIRTUALENVWRAPPER_PYTHON=/Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/py27/bin/python + Python 2.7.2 + PYTHONPATH= + SHELL=/bin/ksh + + +test_virtualenvwrapper_initialize + +test_virtualenvwrapper_run_init_hooks + +test_virtualenvwrapper_space_in_workon_home + +test_virtualenvwrapper_verify_workon_home + +test_virtualenvwrapper_verify_workon_home_missing_dir + +test_virtualenvwrapper_verify_workon_home_missing_dir_quiet + +test_virtualenvwrapper_verify_workon_home_missing_dir_grep_options + +test_python_interpreter_set_incorrectly +Using real prefix '/Library/Frameworks/Python.framework/Versions/2.7' +New python executable in no_wrappers/bin/python +Installing distribute.............................................................................................................................................................................................done. +Installing pip...............done. + +Ran 8 tests. + +OK + + +******************************************************************************** +Running tests/test.sh + VIRTUAL_ENV=/Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/py27 + VIRTUALENVWRAPPER_PYTHON=/Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/py27/bin/python + Python 2.7.2 + PYTHONPATH= + SHELL=/bin/zsh + + +test_virtualenvwrapper_initialize + +test_virtualenvwrapper_run_init_hooks + +test_virtualenvwrapper_space_in_workon_home + +test_virtualenvwrapper_verify_workon_home + +test_virtualenvwrapper_verify_workon_home_missing_dir + +test_virtualenvwrapper_verify_workon_home_missing_dir_quiet + +test_virtualenvwrapper_verify_workon_home_missing_dir_grep_options + +test_python_interpreter_set_incorrectly +Using real prefix '/Library/Frameworks/Python.framework/Versions/2.7' +New python executable in no_wrappers/bin/python +Installing distribute.............................................................................................................................................................................................done. +Installing pip...............done. + +Ran 8 tests. + +OK + +________________________________ [tox summary] _________________________________ +[TOX] py27: commands succeeded +[TOX] congratulations :) diff --git a/virtualenvwrapper_lazy.sh b/virtualenvwrapper_lazy.sh new file mode 100644 index 0000000..e603d11 --- /dev/null +++ b/virtualenvwrapper_lazy.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Alternative startup script for faster login times. + +export _VIRTUALENVWRAPPER_API="mkvirtualenv rmvirtualenv lsvirtualenv showvirtualenv workon add2virtualenv cdsitepackages cdvirtualenv lssitepackages toggleglobalsitepackages cpvirtualenv setvirtualenvproject mkproject cdproject mktmpenv" + +if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ] +then + export VIRTUALENVWRAPPER_SCRIPT="$(which virtualenvwrapper.sh)" +fi +if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ] +then + echo "ERROR: virtualenvwrapper_quick.sh: Could not find virtualenvwrapper.sh" 1>&2 +fi + +# Load the real implementation of the API from virtualenvwrapper.sh +function virtualenvwrapper_load { + source "$VIRTUALENVWRAPPER_SCRIPT" +} + +# Set up "alias" functions based on the API definition. +function virtualenvwrapper_setup_lazy_loader { + typeset venvw_name + for venvw_name in $_VIRTUALENVWRAPPER_API + do + eval " +function $venvw_name { + virtualenvwrapper_load + $venvw_name \"\$@\" +} +" + done +} + +virtualenvwrapper_setup_lazy_loader From fd6269f4f96f572a630188e92f20eb9c4002a950 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 20 May 2012 10:21:14 -0400 Subject: [PATCH 563/947] clarify warning on tab completion --- docs/en/install.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/en/install.rst b/docs/en/install.rst index 4387d99..bbe0e0d 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -139,9 +139,10 @@ directly, use ``virtualenvwrapper_lazy.sh``. If .. warning:: When the lazy-loading version of the startup script is used, - tab-completion does not work until after the first - virtualenvwrapper command has been run. For example, tab completion - does not work for the first instance of :ref:`command-workon`. + tab-completion of arguments to virtualenvwrapper commands (such as + environment names) is not enabled until after the first command has + been run. For example, tab completion of environments does not work + for the first instance of :ref:`command-workon`. Quick-Start =========== From bd17c7237b193ec96f63ed39a94527e526408bb9 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 20 May 2012 10:25:10 -0400 Subject: [PATCH 564/947] update announcement --- announce.rst | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/announce.rst b/announce.rst index aa67b9f..635bb0b 100644 --- a/announce.rst +++ b/announce.rst @@ -1,5 +1,5 @@ ======================= - virtualenvwrapper 3.3 + virtualenvwrapper 3.4 ======================= .. tags:: virtualenvwrapper release python @@ -16,26 +16,10 @@ introducing conflicts in their dependencies. What's New ========== -- Clean up file permissions and remove shebangs from scripts not - intended to be executed on the command line. (contributed by - ``ralphbean``) -- Worked on some brittle tests. -- Received updates to Japanese translation of the documentation from - ``t2y``. -- Fix the test script and runner so the user's ``$WORKON_HOME`` is - not erased if they do not have some test shells installed. - (big thanks to ``agriffis``). -- If the hook loader is told to list plugins but is not given a hook - name, it prints the list of core hooks. -- Merge several fixes for path and variable handling for MSYS users - from ``bwanamarko``. Includes a fix for issue 138. -- Change ``mkvirtualenv`` so it catches both ``-h`` and - ``--help``. -- Fix some issues with the way temporary files are used for hook - scripts. (contributed by ``agriffis``) -- Allow relative path to requirements file with - ``mkvirtualenv`` and ``-r`` option. (``barberj``) -- Make whitespace consistent. (``agriffis``) +- Add a "lazy loading" option for startup scripts. Refer to the + `installation instructions + `_ + for more details. Installing ========== From 4cb78628cccee668c56ecf74a9aa7bf487ad62f1 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 20 May 2012 10:25:41 -0400 Subject: [PATCH 565/947] bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 64b90a0..0dbce95 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ PROJECT = 'virtualenvwrapper' # Change docs/sphinx/conf.py too! -VERSION = '3.3' +VERSION = '3.4' # Bootstrap installation of Distribute import distribute_setup From e6c7203e2c64d768338f584b399230758d4d6b1b Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 20 May 2012 10:25:51 -0400 Subject: [PATCH 566/947] Added tag 3.4 for changeset 07905d9135ac --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 7fd2649..9985117 100644 --- a/.hgtags +++ b/.hgtags @@ -83,3 +83,4 @@ ff4d492c873c324ccfb71bc71118a67aa6195ad2 2.11 ebbb3ba8168703861c016ed66f443fb898f0b06b 3.1 dccf1a1abf4ea97589e9fa141167771049f031e0 3.2 45877370548ee7c2581a6c81df22b12fcc3f4891 3.3 +07905d9135ac3ca8460143b40dc39aa8823d3691 3.4 From 30c36636b2dd6b82c1a6dccd7449edaa42bf6dec Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 20 May 2012 10:31:36 -0400 Subject: [PATCH 567/947] fix xref endpoint used in install.rst --- docs/en/command_ref.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/en/command_ref.rst b/docs/en/command_ref.rst index 1bab615..7bfaa4d 100644 --- a/docs/en/command_ref.rst +++ b/docs/en/command_ref.rst @@ -197,6 +197,8 @@ Syntax:: Controlling the Active Environment ================================== +.. _command-workon: + workon ------ From 4f5c84cb5f4bfc954f9d64fa8515a2c963fc873c Mon Sep 17 00:00:00 2001 From: Justin Barber Date: Sun, 20 May 2012 18:15:45 -0400 Subject: [PATCH 568/947] Update cpvirtualenv utilizing virtualenv-clone and allowing for external virutalenvs to be added to WORKON_HOME. --- docs/en/command_ref.rst | 9 +- setup.py | 4 +- tests/test.sh | 14 +++ tests/test_cp.sh | 76 ++++++++---- tests/test_cpvirtualenv.sh | 232 +++++++++++++++++++++++++++++++++++++ tox.ini | 2 + virtualenvwrapper.sh | 124 +++++++++++++------- 7 files changed, 392 insertions(+), 69 deletions(-) create mode 100755 tests/test_cpvirtualenv.sh diff --git a/docs/en/command_ref.rst b/docs/en/command_ref.rst index 7bfaa4d..c686a91 100644 --- a/docs/en/command_ref.rst +++ b/docs/en/command_ref.rst @@ -153,16 +153,17 @@ environment. cpvirtualenv ------------ -Duplicate an environment, in the WORKON_HOME. +In the WORKON_HOME, duplicate an environment or clone an external environment. Syntax:: - cpvirtualenv ENVNAME TARGETENVNAME + cpvirtualenv ENVNAME [TARGETENVNAME] + + .. note:: - The environment created by the copy operation is made `relocatable - `__. + Target environment name is required for WORKON_HOME duplications. However, target environment name can be ommited for external copies, causing the new environment to have the name of the original within the WORKON_HOME. :: diff --git a/setup.py b/setup.py index 0dbce95..cb5fb55 100644 --- a/setup.py +++ b/setup.py @@ -147,7 +147,9 @@ def find_package_data( 'virtualenvwrapper.user_scripts', 'virtualenvwrapper.project', ], - install_requires=['virtualenv'], + install_requires=['virtualenv', + 'virtualenv-clone', + ], namespace_packages = [ 'virtualenvwrapper' ], packages = find_packages(), diff --git a/tests/test.sh b/tests/test.sh index 93b979b..c8fe6ba 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -102,4 +102,18 @@ test_python_interpreter_set_incorrectly() { deactivate } +test_virtualenvwrapper_verify_virtualenv(){ + assertTrue "Verified unable to verify virtualenv" virtualenvwrapper_verify_virtualenv + + VIRTUALENVWRAPPER_VIRTUALENV="thiscannotpossiblyexist123" + assertFalse "Incorrectly verified virtualenv" virtualenvwrapper_verify_virtualenv +} + +test_virtualenvwrapper_verify_virtualenv_clone(){ + assertTrue "Verified unable to verify virtualenv_clone" virtualenvwrapper_verify_virtualenv_clone + + VIRTUALENVWRAPPER_VIRTUALENV_CLONE="thiscannotpossiblyexist123" + assertFalse "Incorrectly verified virtualenv_clone" virtualenvwrapper_verify_virtualenv_clone +} + . "$test_dir/shunit2" diff --git a/tests/test_cp.sh b/tests/test_cp.sh index 2c5e778..0cec617 100755 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -20,10 +20,10 @@ tearDown() { } test_new_env_activated () { - mkvirtualenv "source" + mkvirtualenv "source" >/dev/null 2>&1 (cd tests/testpackage && python setup.py install) >/dev/null 2>&1 - cpvirtualenv "source" "destination" - rmvirtualenv "source" + cpvirtualenv "source" "destination" >/dev/null 2>&1 + rmvirtualenv "source" >/dev/null 2>&1 testscript="$(which testscript.py)" assertTrue "Environment test script not found in path" "[ $WORKON_HOME/destination/bin/testscript.py -ef $testscript ]" testscriptcontent="$(cat $testscript)" @@ -32,31 +32,66 @@ test_new_env_activated () { } test_virtual_env_variable () { - mkvirtualenv "source" - cpvirtualenv "source" "destination" + mkvirtualenv "source" >/dev/null 2>&1 + cpvirtualenv "source" "destination" >/dev/null 2>&1 assertSame "Wrong virtualenv name" "destination" $(basename "$VIRTUAL_ENV") assertTrue "$WORKON_HOME not in $VIRTUAL_ENV" "echo $VIRTUAL_ENV | grep -q $WORKON_HOME" } -fake_virtualenv () { +fake_venv () { + ### + # create a silly file to ensure copy happens + ### typeset envname="$1" - touch "$envname/fake_virtualenv_was_here" virtualenv $@ + touch "$WORKON_HOME/$envname/fake_virtualenv_was_here" +} + +fake_venv_clone () { + ### + # create a silly file to ensure copy happens + ### + typeset src_path="$1" + touch "$src_path/fake_virtualenv_clone_was_here" + virtualenv-clone $@ } test_virtualenvwrapper_virtualenv_variable () { - mkvirtualenv "source" - export VIRTUALENVWRAPPER_VIRTUALENV=fake_virtualenv - cpvirtualenv "source" "destination" + + eval 'virtualenvwrapper_verify_virtualenv () { + return 0 + }' + + VIRTUALENVWRAPPER_VIRTUALENV=fake_venv + assertSame "VIRTUALENVWRAPPER_VIRTUALENV is not set correctly" "$VIRTUALENVWRAPPER_VIRTUALENV" "fake_venv" + + mkvirtualenv "source" >/dev/null 2>&1 + assertTrue "Fake file not made in fake_venv" "[ -f "$VIRTUAL_ENV/fake_virtualenv_was_here" ]" + cpvirtualenv "source" "destination" >/dev/null 2>&1 unset VIRTUALENVWRAPPER_VIRTUALENV - assertTrue "wrapper was not run" "[ -f $VIRTUAL_ENV/fake_virtualenv_was_here ]" + assertTrue "VIRTUALENVWRAPPER_CLONE did not clone fake file" "[ -f $WORKON_HOME/destination/fake_virtualenv_was_here ]" +} + +test_virtualenvwrapper_virtualenv_clone_variable () { + + eval 'virtualenvwrapper_verify_virtualenv_clone () { + return 0 + }' + + VIRTUALENVWRAPPER_VIRTUALENV_CLONE=fake_venv_clone + assertSame "VIRTUALENVWRAPPER_VIRTUALENV_CLONE is not set correctly" "$VIRTUALENVWRAPPER_VIRTUALENV_CLONE" "fake_venv_clone" + + mkvirtualenv "source" >/dev/null 2>&1 + cpvirtualenv "source" "destination" >/dev/null 2>&1 + unset VIRTUALENVWRAPPER_VIRTUALENV_CLONE + assertTrue "VIRTUALENVWRAPPER_CLONE did not clone fake file" "[ -f $WORKON_HOME/destination/fake_virtualenv_clone_was_here ]" } test_source_relocatable () { - mkvirtualenv "source" + mkvirtualenv "source" >/dev/null 2>&1 (cd tests/testpackage && python setup.py install) >/dev/null 2>&1 assertTrue "virtualenv --relocatable \"$WORKON_HOME/source\"" - cpvirtualenv "source" "destination" + cpvirtualenv "source" "destination" >/dev/null 2>&1 testscript="$(which testscript.py)" assertTrue "Environment test script not the same as copy" "[ $WORKON_HOME/destination/bin/testscript.py -ef $testscript ]" assertTrue virtualenvwrapper_verify_active_environment @@ -64,12 +99,11 @@ test_source_relocatable () { } test_source_does_not_exist () { - out="$(cpvirtualenv virtualenvthatdoesntexist foo)" - assertSame "$out" "virtualenvthatdoesntexist virtualenv doesn't exist" + assertSame "Please provide a valid virtualenv to copy." "$(cpvirtualenv virtualenvthatdoesntexist foo)" } test_hooks () { - mkvirtualenv "source" + mkvirtualenv "source" >/dev/null 2>&1 export pre_test_dir=$(cd "$test_dir"; pwd) @@ -89,12 +123,12 @@ test_hooks () { echo "#!/bin/sh" > "$WORKON_HOME/postcpvirtualenv" echo "echo GLOBAL postcpvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postcpvirtualenv" - cpvirtualenv "source" "destination" + cpvirtualenv "source" "destination" >/dev/null 2>&1 output=$(cat "$test_dir/catch_output") workon_home_as_pwd=$(cd $WORKON_HOME; pwd) - expected="GLOBAL precpvirtualenv $workon_home_as_pwd source destination + expected="GLOBAL precpvirtualenv $workon_home_as_pwd $workon_home_as_pwd/source destination GLOBAL premkvirtualenv $workon_home_as_pwd destination GLOBAL postmkvirtualenv GLOBAL postcpvirtualenv" @@ -108,7 +142,7 @@ GLOBAL postcpvirtualenv" test_no_site_packages () { # See issue #102 mkvirtualenv "source" --no-site-packages >/dev/null 2>&1 - cpvirtualenv "source" "destination" + cpvirtualenv "source" "destination" >/dev/null 2>&1 ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" assertTrue "$ngsp_file does not exist in copied env" "[ -f \"$ngsp_file\" ]" } @@ -118,7 +152,7 @@ test_no_site_packages_default_args () { VIRTUALENVWRAPPER_VIRTUALENV_ARGS="--no-site-packages" # With the argument, verify that they are not copied. mkvirtualenv "source" >/dev/null 2>&1 - cpvirtualenv "source" "destination" + cpvirtualenv "source" "destination" >/dev/null 2>&1 ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" assertTrue "$ngsp_file does not exist" "[ -f \"$ngsp_file\" ]" unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS @@ -128,7 +162,7 @@ test_no_site_packages_default_behavior () { # See issue #102 # virtualenv 1.7 changed to make --no-site-packages the default mkvirtualenv "source" >/dev/null 2>&1 - cpvirtualenv "source" "destination" + cpvirtualenv "source" "destination" >/dev/null 2>&1 ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" assertTrue "$ngsp_file does not exist in copied env" "[ -f \"$ngsp_file\" ]" } diff --git a/tests/test_cpvirtualenv.sh b/tests/test_cpvirtualenv.sh new file mode 100755 index 0000000..b6121d9 --- /dev/null +++ b/tests/test_cpvirtualenv.sh @@ -0,0 +1,232 @@ +#venv!/bin/sh + +test_dir=$(cd $(dirname $0) && pwd) +source "$test_dir/setup.sh" + +setUp () { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" + rm -f "$test_dir/catch_output" + echo +} + +tearDown () { + if type deactivate >/dev/null 2>&1 + then + deactivate + fi + #rm -rf "$WORKON_HOME" +} + +test_no_arguments () { + assertSame "Please provide a valid virtualenv to copy." "$(cpvirtualenv)" +} + +test_venv_already_exists_in_workon () { + mkvirtualenv "cpvenv_test" >/dev/null 2>&1 + assertSame "cpvenv_test virtualenv already exists." "$(cpvirtualenv 'cpvenv_test')" +} + +test_bad_path () { + assertSame "Please provide a valid virtualenv to copy." "$(cpvirtualenv '~/cpvenv_test')" +} + +test_copy_venv () { + # verify venvs don't exist + assertTrue "Virtualenv to copy already exists" "[ ! -d $WORKON_HOME/cpvenv_test ]" + assertTrue "Copied virtualenv already exists" "[ ! -d $WORKON_HOME/copied_venv ]" + mkvirtualenv "cpvenv_test" >/dev/null 2>&1 + touch "$WORKON_HOME/cpvenv_test/mytestpackage" + + assertTrue "Virtualenv to copy didn't get created" "[ -d $WORKON_HOME/cpvenv_test ]" + assertTrue "Copied virtualenv already exists" "[ ! -d $WORKON_HOME/copied_venv ]" + + cpvirtualenv "cpvenv_test" "copied_venv" >/dev/null 2>&1 + + # verify copied venv exist + assertTrue "Copied virtualenv doesn't exist" "[ -d $WORKON_HOME/copied_venv ]" + # verify test package exists + assertTrue "Test package is missing" "[ -f $WORKON_HOME/copied_venv/mytestpackage ]" +} + +test_copy_venv_activate () { + # verify venvs don't exist + assertTrue "Virtualenv to copy already exists" "[ ! -d $WORKON_HOME/cpvenv_test ]" + assertTrue "Copied virtualenv already exists" "[ ! -d $WORKON_HOME/copied_venv ]" + mkvirtualenv "cpvenv_test" >/dev/null 2>&1 + + assertTrue "Virtualenv to copy didn't get created" "[ -d $WORKON_HOME/cpvenv_test ]" + assertTrue "Copied virtualenv already exists" "[ ! -d $WORKON_HOME/copied_venv ]" + + cpvirtualenv "cpvenv_test" "copied_venv" >/dev/null 2>&1 + + # verify copied venv exist + assertTrue "Copied virtualenv doesn't exist" "[ -d $WORKON_HOME/copied_venv ]" + + assertSame "copied_venv" "$(basename $VIRTUAL_ENV)" + assertTrue "Virtualenv not active" virtualenvwrapper_verify_active_environment +} + +test_copy_venv_is_listed () { + # verify venvs don't exist + assertTrue "Virtualenv to copy already exists" "[ ! -d $WORKON_HOME/cpvenv_test ]" + assertTrue "Copied virtualenv already exists" "[ ! -d $WORKON_HOME/copied_venv ]" + mkvirtualenv "cpvenv_test" >/dev/null 2>&1 + + typeset listed=$(lsvirtualenv) + [[ "$listed" != *copied_venv* ]] + RC=$? + assertTrue "Copied virtualenv found in virtualenv list" $RC + + cpvirtualenv "cpvenv_test" "copied_venv" >/dev/null 2>&1 + + listed=$(lsvirtualenv -b) + [[ "$listed" == *copied_venv* ]] + RC=$? + assertTrue "Copied virtualenv not found in virtualenv list" $RC +} + +test_clone_venv () { + typeset tmplocation=$(dirname $WORKON_HOME) + + # verify venvs don't exist + assertTrue "Virtualenv to clone already exists" "[ ! -d $tmplocation/cpvenv_test ]" + assertTrue "Cloned virtualenv already exists" "[ ! -d $WORKON_HOME/cloned_venv ]" + + $VIRTUALENVWRAPPER_VIRTUALENV "$tmplocation/cpvenv_test" >/dev/null 2>&1 + touch "$tmplocation/cpvenv_test/mytestpackage" + + assertTrue "Virtualenv to clone didn't get created" "[ -d $tmplocation/cpvenv_test ]" + assertTrue "Cloned virtualenv already exists" "[ ! -d $WORKON_HOME/cloned_venv ]" + + cpvirtualenv "$tmplocation/cpvenv_test" "cloned_venv" >/dev/null 2>&1 + + # verify cloned venv exist + assertTrue "Cloned virtualenv doesn't exist" "[ -d $WORKON_HOME/cloned_venv ]" + # verify test package exists + assertTrue "Test package is missing" "[ -f $WORKON_HOME/cloned_venv/mytestpackage ]" + + rm -rf "$tmplocation/cpvenv_test" +} + +test_clone_venv_activate () { + typeset tmplocation=$(dirname $WORKON_HOME) + + # verify venvs don't exist + assertTrue "Virtualenv to clone already exists" "[ ! -d $tmplocation/cpvenv_test ]" + assertTrue "Virtualenv with same name as clone source already exists" "[ ! -d $WORKON_HOME/cpvenv_test ]" + assertTrue "Cloned virtualenv already exists" "[ ! -d $WORKON_HOME/cloned_venv ]" + + $VIRTUALENVWRAPPER_VIRTUALENV "$tmplocation/cpvenv_test" >/dev/null 2>&1 + + assertTrue "Virtualenv to clone didn't get created" "[ -d $tmplocation/cpvenv_test ]" + assertTrue "Cloned virtualenv already exists" "[ ! -d $WORKON_HOME/cloned_venv ]" + + #cpvirtualenv "$tmplocation/cpvenv_test" "cloned_venv" >/dev/null 2>&1 + cpvirtualenv "$tmplocation/cpvenv_test" "cloned_venv" >/dev/null 2/>&1 + + # verify cloned venv exist + assertTrue "Cloned virtualenv doesn't exist" "[ -d $WORKON_HOME/cloned_venv ]" + + assertSame "cloned_venv" "$(basename $VIRTUAL_ENV)" + assertTrue "Virtualenv not active" virtualenvwrapper_verify_active_environment + + rm -rf "$tmplocation/cpvenv_test" +} + +test_clone_venv_is_listed (){ + typeset tmplocation=$(dirname $WORKON_HOME) + + # verify venvs don't exist + assertTrue "Virtualenv to clone already exists" "[ ! -d $tmplocation/cpvenv_test ]" + assertTrue "Virtualenv with same name as clone source already exists" "[ ! -d $WORKON_HOME/cpvenv_test ]" + assertTrue "Cloned virtualenv already exists" "[ ! -d $WORKON_HOME/cloned_venv ]" + + typeset listed=$(lsvirtualenv) + [[ "$listed" != *cloned_venv* ]] + RC=$? + assertTrue "Cloned virtualenv found in virtualenv list" $RC + + $VIRTUALENVWRAPPER_VIRTUALENV "$tmplocation/cpvenv_test" >/dev/null 2>&1 + cpvirtualenv "$tmplocation/cpvenv_test" "cloned_venv" >/dev/null 2>&1 + + listed=$(lsvirtualenv -b) + [[ "$listed" == *cloned_venv* ]] + RC=$? + assertTrue "Cloned virtualenv not found in virtualenv list" $RC + + rm -rf "$tmplocation/cpvenv_test" + +} + +test_clone_venv_using_same_name () { + typeset tmplocation=$(dirname $WORKON_HOME) + + # verify venvs don't exist + assertTrue "Virtualenv to clone already exists" "[ ! -d $tmplocation/cpvenv_test ]" + assertTrue "Cloned virtualenv already exists" "[ ! -d $WORKON_HOME/cpvenv_test ]" + + $VIRTUALENVWRAPPER_VIRTUALENV "$tmplocation/cpvenv_test" >/dev/null 2>&1 + touch "$tmplocation/cpvenv_test/mytestpackage" + + assertTrue "Virtualenv to clone didn't get created" "[ -d $tmplocation/cpvenv_test ]" + assertTrue "Cloned virtualenv already exists" "[ ! -d $WORKON_HOME/cpvenv_test ]" + + typeset listed=$(lsvirtualenv) + [[ "$listed" != *cpvenv_test* ]] + RC=$? + assertTrue "Cloned virtualenv found in virtualenv list" $RC + + cpvirtualenv "$tmplocation/cpvenv_test" >/dev/null 2>&1 >/dev/null 2>&1 + + # verify cloned venv exist + assertTrue "Cloned virtualenv doesn't exist" "[ -d $WORKON_HOME/cpvenv_test ]" + assertTrue "Test package is missing" "[ -f $WORKON_HOME/cpvenv_test/mytestpackage ]" + + listed=$(lsvirtualenv -b) + [[ "$listed" == *cpvenv_test* ]] + RC=$? + assertTrue "Cloned virtualenv not found in virtualenv list" $RC + + assertSame "cpvenv_test" "$(basename $VIRTUAL_ENV)" + assertTrue "Virtualenv not active" virtualenvwrapper_verify_active_environment + + rm -rf "$tmplocation/cpvenv_test" +} + +test_clone_venv_using_vars () { + + # verify venvs don't exist + assertTrue "Virtualenv to clone already exists" "[ ! -d $TMPDIR/cpvenv_test ]" + assertTrue "Cloned virtualenv already exists" "[ ! -d $WORKON_HOME/cpvenv_test ]" + + $VIRTUALENVWRAPPER_VIRTUALENV "$TMPDIR/cpvenv_test" >/dev/null 2>&1 + touch "$tmplocation/cpvenv_test/mytestpackage" + + assertTrue "Virtualenv to clone didn't get created" "[ -d $TMPDIR/cpvenv_test ]" + assertTrue "Cloned virtualenv already exists" "[ ! -d $WORKON_HOME/cpvenv_test ]" + + typeset listed=$(lsvirtualenv) + [[ "$listed" != *cpvenv_test* ]] + RC=$? + assertTrue "Cloned virtualenv found in virtualenv list" $RC + + cpvirtualenv '$TMPDIR/cpvenv_test' >/dev/null 2>&1 >/dev/null 2>&1 + + # verify cloned venv exist + assertTrue "Cloned virtualenv doesn't exist" "[ -d $WORKON_HOME/cpvenv_test ]" + assertTrue "Test package is missing" "[ -f $WORKON_HOME/cpvenv_test/mytestpackage ]" + + listed=$(lsvirtualenv -b) + [[ "$listed" == *cpvenv_test* ]] + RC=$? + assertTrue "Cloned virtualenv not found in virtualenv list" $RC + + assertSame "cpvenv_test" "$(basename $VIRTUAL_ENV)" + assertTrue "Virtualenv not active" virtualenvwrapper_verify_active_environment + + rm -rf "$TMPDIR/cpvenv_test" +} + +source "$test_dir/shunit2" diff --git a/tox.ini b/tox.ini index 3601856..8aabed2 100644 --- a/tox.ini +++ b/tox.ini @@ -4,8 +4,10 @@ envlist = py27,py26,py32 [testenv] commands = bash ./tests/run_tests {envdir} [] deps = virtualenv + virtualenv-clone setenv = TOXIC = true +isitepackages=True # Not sure why this is needed, but on my system if it isn't included then # the python version picked up for 2.6 is actually 2.7. diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 0f2ef00..e9fe74b 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -56,6 +56,12 @@ then VIRTUALENVWRAPPER_VIRTUALENV="virtualenv" fi +# Set the name of the virtualenv-clone app to use. +if [ "$VIRTUALENVWRAPPER_VIRTUALENV_CLONE" = "" ] +then + VIRTUALENVWRAPPER_VIRTUALENV_CLONE="virtualenv-clone" +fi + # Define script folder depending on the platorm (Win32/Unix) VIRTUALENVWRAPPER_ENV_BIN_DIR="bin" if [ "$OS" = "Windows_NT" ] && [ "$MSYSTEM" = "MINGW32" ] @@ -76,7 +82,7 @@ function virtualenvwrapper_expandpath { if [ "$1" = "" ]; then return 1 else - "$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.realpath(os.path.expanduser(os.path.expandvars(\"$1\")))+'\n')" + "$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.normpath(os.path.expanduser(os.path.expandvars(\"$1\")))+'\n')" return 0 fi } @@ -255,23 +261,34 @@ function virtualenvwrapper_initialize { return 0 } - -# Verify that virtualenv is installed and visible -function virtualenvwrapper_verify_virtualenv { - typeset venv=$(\which "$VIRTUALENVWRAPPER_VIRTUALENV" | (unset GREP_OPTIONS; \grep -v "not found")) - if [ "$venv" = "" ] +# Verify that the passed resource is in path and exists +function virtualenvwrapper_verify_resource { + typeset exe_path=$(\which "$1" | (unset GREP_OPTIONS; \grep -v "not found")) + if [ "$exe_path" = "" ] then - echo "ERROR: virtualenvwrapper could not find $VIRTUALENVWRAPPER_VIRTUALENV in your path" >&2 + echo "ERROR: virtualenvwrapper could not find $1 in your path" >&2 return 1 fi - if [ ! -e "$venv" ] + if [ ! -e "$exe_path" ] then - echo "ERROR: Found $VIRTUALENVWRAPPER_VIRTUALENV in path as \"$venv\" but that does not exist" >&2 + echo "ERROR: Found $1 in path as \"$exe_path\" but that does not exist" >&2 return 1 fi return 0 } + +# Verify that virtualenv is installed and visible +function virtualenvwrapper_verify_virtualenv { + virtualenvwrapper_verify_resource $VIRTUALENVWRAPPER_VIRTUALENV +} + + +function virtualenvwrapper_verify_virtualenv_clone { + virtualenvwrapper_verify_resource $VIRTUALENVWRAPPER_VIRTUALENV_CLONE +} + + # Verify that the requested environment exists function virtualenvwrapper_verify_workon_environment { typeset env_name="$1" @@ -752,50 +769,71 @@ function toggleglobalsitepackages { # Duplicate the named virtualenv to make a new one. function cpvirtualenv { - typeset env_name="$1" - if [ "$env_name" = "" ] - then - virtualenvwrapper_show_workon_options - return 1 - fi - typeset new_env="$2" - if [ "$new_env" = "" ] - then - echo "Please specify target virtualenv" + virtualenvwrapper_verify_workon_home || return 1 + virtualenvwrapper_verify_virtualenv_clone || return 1 + + typeset src_name="$1" + typeset trg_name="$2" + typeset src + typeset trg + + # without a source there is nothing to do + if [ "$src_name" = "" ]; then + echo "Please provide a valid virtualenv to copy." return 1 + else + # see if its already in workon + if [ ! -e "$WORKON_HOME/$src_name" ]; then + # so its a virtualenv we are importing + # make sure we have a full path + # and get the name + src=$(virtualenvwrapper_expandpath "$src_name") + # final verification + if [ ! -e "$src" ]; then + echo "Please provide a valid virtualenv to copy." + return 1 + fi + src_name=$(basename "$src") + else + src="$WORKON_HOME/$src_name" + fi fi - if echo "$WORKON_HOME" | (unset GREP_OPTIONS; \grep "/$" > /dev/null) - then - typeset env_home="$WORKON_HOME" + + if [ "$trg_name" = "" ]; then + # target not given, assume + # same as source + trg="$WORKON_HOME/$src_name" + trg_name="$src_name" else - typeset env_home="$WORKON_HOME/" + trg="$WORKON_HOME/$trg_name" fi - typeset source_env="$env_home$env_name" - typeset target_env="$env_home$new_env" + trg=$(virtualenvwrapper_expandpath "$trg") - if [ ! -e "$source_env" ] - then - echo "$env_name virtualenv doesn't exist" + # validate trg does not already exist + # catch copying virtualenv in workon home + # to workon home + if [ -e "$trg" ]; then + echo "$trg_name virtualenv already exists." return 1 fi - \cp -r "$source_env" "$target_env" - for script in $( \ls $target_env/$VIRTUALENVWRAPPER_ENV_BIN_DIR/* ) - do - newscript="$script-new" - \sed "s|$source_env|$target_env|g" < "$script" > "$newscript" - \mv "$newscript" "$script" - \chmod a+x "$script" - done + echo "Copying $src_name as $trg_name..." + ( + [ -n "$ZSH_VERSION" ] && setopt SH_WORD_SPLIT + \cd "$WORKON_HOME" && + "$VIRTUALENVWRAPPER_VIRTUALENV_CLONE" "$src" "$trg" + [ -d "$trg" ] && + virtualenvwrapper_run_hook "pre_cpvirtualenv" "$src" "$trg_name" && + virtualenvwrapper_run_hook "pre_mkvirtualenv" "$trg_name" + ) + typeset RC=$? + [ $RC -ne 0 ] && return $RC - "$VIRTUALENVWRAPPER_VIRTUALENV" "$target_env" --relocatable - \sed "s/VIRTUAL_ENV\(.*\)$env_name/VIRTUAL_ENV\1$new_env/g" < "$source_env/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate" > "$target_env/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate" + [ ! -d "$WORKON_HOME/$trg_name" ] && return 0 + + # Now activate the new environment + workon "$trg_name" - (\cd "$WORKON_HOME" && ( - virtualenvwrapper_run_hook "pre_cpvirtualenv" "$env_name" "$new_env"; - virtualenvwrapper_run_hook "pre_mkvirtualenv" "$new_env" - )) - workon "$new_env" virtualenvwrapper_run_hook "post_mkvirtualenv" virtualenvwrapper_run_hook "post_cpvirtualenv" } From d15ff945fb2dd7c6c9b783c3df2f3e8b5311ac00 Mon Sep 17 00:00:00 2001 From: Justin Barber Date: Sun, 20 May 2012 18:26:43 -0400 Subject: [PATCH 569/947] Did not mean to commit isitepackages --- tox.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/tox.ini b/tox.ini index 8aabed2..dd00002 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,6 @@ deps = virtualenv virtualenv-clone setenv = TOXIC = true -isitepackages=True # Not sure why this is needed, but on my system if it isn't included then # the python version picked up for 2.6 is actually 2.7. From 20f62c67161b59b340456ec2469d81cca3fd6914 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 21 May 2012 08:03:06 -0400 Subject: [PATCH 570/947] update README with supported python versions --- README.txt | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/README.txt b/README.txt index 1cbb3d1..9ab2680 100644 --- a/README.txt +++ b/README.txt @@ -56,34 +56,7 @@ from this page. Python Versions =============== -virtualenvwrapper is tested under Python 2.4 - 2.7. - -Upgrading to 2.9 -================ - -Version 2.9 includes the features previously delivered separately by -``virtualenvwrapper.project``. If you have an older verison of the -project extensions installed, remove them before upgrading. - -Upgrading from 1.x -================== - -The shell script containing the wrapper functions has been renamed in -the 2.x series to reflect the fact that shells other than bash are -supported. In your startup file, change ``source -/usr/local/bin/virtualenvwrapper_bashrc`` to ``source -/usr/local/bin/virtualenvwrapper.sh``. - -============ -Contributing -============ - -Before contributing new features to virtualenvwrapper core, consider -whether they should be implemented as an extension instead. - -Refer to the `developers docs -`__ -for tips on contributing patches. +virtualenvwrapper is tested under Python 2.6, 2.7 and 3.2. ======= Support From 8c6568a4be5a38e25c1cd82e0d5844d4191a23f7 Mon Sep 17 00:00:00 2001 From: Justin Barber Date: Mon, 21 May 2012 08:35:06 -0400 Subject: [PATCH 571/947] Forgot to uncommit the remove workon_home in teardown --- tests/test_cpvirtualenv.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_cpvirtualenv.sh b/tests/test_cpvirtualenv.sh index b6121d9..df1d695 100755 --- a/tests/test_cpvirtualenv.sh +++ b/tests/test_cpvirtualenv.sh @@ -16,7 +16,7 @@ tearDown () { then deactivate fi - #rm -rf "$WORKON_HOME" + rm -rf "$WORKON_HOME" } test_no_arguments () { From d4f2f8d938cd0a05d78ce14d7a41d5fcacc20f3c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 9 Jun 2012 12:28:09 -0400 Subject: [PATCH 572/947] document cpvirtualenv addition --- docs/en/history.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index 33cf9e8..c0d34fb 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -2,6 +2,14 @@ Release History =============== +dev + + - Rewrite :ref:`command-cpvirtualenv` to use `virtualenv-clone`_ + instead of making the new environment relocatable. Contributed by + Justin Barber (:bbuser:`barberj`). This also resolves a problem + with cpvirtualenv not honoring the ``--no-site-packages`` flag + (:bbissue:`102`). + 3.4 - Add :ref:`install-lazy-loader` option. From 0a775f0745831332e9b551846d8cc6e5f8e437c4 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 9 Jun 2012 12:28:28 -0400 Subject: [PATCH 573/947] if cpvirtualenv fails to create the target directory, return an error code --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index e9fe74b..6457cf5 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -829,7 +829,7 @@ function cpvirtualenv { typeset RC=$? [ $RC -ne 0 ] && return $RC - [ ! -d "$WORKON_HOME/$trg_name" ] && return 0 + [ ! -d "$WORKON_HOME/$trg_name" ] && return 1 # Now activate the new environment workon "$trg_name" From 186a96f9c96bbde7dc98b57c4393e9faa1a7ac5f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 9 Jun 2012 12:30:34 -0400 Subject: [PATCH 574/947] clean up cpvirtualenv documentation --- docs/en/command_ref.rst | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/en/command_ref.rst b/docs/en/command_ref.rst index c686a91..c4a7242 100644 --- a/docs/en/command_ref.rst +++ b/docs/en/command_ref.rst @@ -153,17 +153,20 @@ environment. cpvirtualenv ------------ -In the WORKON_HOME, duplicate an environment or clone an external environment. +Duplicate an existing virtualenv environment. The source can be an +environment managed by virtualenvwrapper or an external environment +created elsewhere. Syntax:: cpvirtualenv ENVNAME [TARGETENVNAME] - - .. note:: - Target environment name is required for WORKON_HOME duplications. However, target environment name can be ommited for external copies, causing the new environment to have the name of the original within the WORKON_HOME. + Target environment name is required for WORKON_HOME + duplications. However, target environment name can be ommited for + importing external environments. If omitted, the new environment is + given the same name as the original. :: From d56b8c4c931139f34316a2b7315b5c4490fc2f8b Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 9 Jun 2012 15:31:50 -0400 Subject: [PATCH 575/947] update docs with link to virtualenvwrapper-win port; fixes #140 --- docs/en/history.rst | 6 ++++++ docs/en/install.rst | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index c0d34fb..f2a8173 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -9,6 +9,12 @@ dev Justin Barber (:bbuser:`barberj`). This also resolves a problem with cpvirtualenv not honoring the ``--no-site-packages`` flag (:bbissue:`102`). + - Update docs with link to `virtualenvwrapper-win`_ port by David + Marble. + +.. _virtualenv-clone: http://pypi.python.org/pypi/virtualenv-clone +.. _virtualenvwrapper-win: http://pypi.python.org/pypi/virtualenvwrapper-win + 3.4 diff --git a/docs/en/install.rst b/docs/en/install.rst index bbe0e0d..f8c9253 100644 --- a/docs/en/install.rst +++ b/docs/en/install.rst @@ -24,6 +24,16 @@ from this page. .. _bitbucket project page: https://bitbucket.org/dhellmann/virtualenvwrapper/ +Windows Command Prompt +---------------------- + +David Marble has ported virtualenvwrapper to Windows batch scripts, +which can be run under Microsoft Windows Command Prompt. This is also +a separately distributed re-implementation. You can download +`virtualenvwrapper-win`_ from PyPI. + +.. _virtualenvwrapper-win: http://pypi.python.org/pypi/virtualenvwrapper-win + MSYS ---- From 62a8b8bc376daa67aa03df11bda3cad9c5b8799c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 9 Jun 2012 15:53:23 -0400 Subject: [PATCH 576/947] add test for lazy loading via workon; addresses #144 --- tests/test_lazy.sh | 17 ----------------- tests/test_lazy_run.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 17 deletions(-) create mode 100644 tests/test_lazy_run.sh diff --git a/tests/test_lazy.sh b/tests/test_lazy.sh index a87a1b0..fd55caf 100644 --- a/tests/test_lazy.sh +++ b/tests/test_lazy.sh @@ -88,21 +88,4 @@ test_mktmpenv_defined_lazy() { function_defined_lazy mktmpenv } - -# test_virtualenvwrapper_initialize() { -# assertTrue "Initialized" virtualenvwrapper_initialize -# for hook in premkvirtualenv postmkvirtualenv prermvirtualenv postrmvirtualenv preactivate postactivate predeactivate postdeactivate -# do -# assertTrue "Global $WORKON_HOME/$hook was not created" "[ -f $WORKON_HOME/$hook ]" -# assertTrue "Global $WORKON_HOME/$hook is not executable" "[ -x $WORKON_HOME/$hook ]" -# done -# assertTrue "Log file was not created" "[ -f $WORKON_HOME/hook.log ]" -# export pre_test_dir=$(cd "$test_dir"; pwd) -# echo "echo GLOBAL initialize >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/initialize" -# virtualenvwrapper_initialize -# output=$(cat "$test_dir/catch_output") -# expected="GLOBAL initialize" -# assertSame "$expected" "$output" -# } - . "$test_dir/shunit2" diff --git a/tests/test_lazy_run.sh b/tests/test_lazy_run.sh new file mode 100644 index 0000000..4cb322f --- /dev/null +++ b/tests/test_lazy_run.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +test_dir=$(cd $(dirname $0) && pwd) +source "$test_dir/setup.sh" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + (cd "$WORKON_HOME" && virtualenv lazy_load_test >/dev/null 2>&1) + source "$test_dir/../virtualenvwrapper_lazy.sh" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +test_workon_changes_defs() { + # See issue #144 + assertFalse "virtualenvwrapper_run_hook is already defined" "type virtualenvwrapper_run_hook" + workon lazy_load_test >/dev/null 2>&1 + assertTrue "virtualenvwrapper_run_hook is not defined" "type virtualenvwrapper_run_hook" + assertTrue "workon still set to run lazy loader" "typeset -f $name | grep 'virtualenvwrapper_load'" +} + +. "$test_dir/shunit2" From 89a2e390757847b7326a10f04e6659012984318c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 10 Jun 2012 14:44:16 -0400 Subject: [PATCH 577/947] allow the caller to control which shells are used for tests; unset variables that might be inherited and give the wrong idea about what the current shell is for a test; export SHELL to point to the current shell --- tests/run_tests | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/run_tests b/tests/run_tests index 1e7a66b..5a65cba 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -23,9 +23,10 @@ fi # Make sure the test shells exist before proceeding, otherwise tests are # going to fail later. +DESIRED_SHELLS=${DESIRED_SHELLS:-"bash zsh ksh"} missing_shells="" test_shells="" -for shell in bash ksh zsh +for shell in $DESIRED_SHELLS do if test_shell=$(which $shell); then test_shells="$test_shells $test_shell" @@ -69,11 +70,14 @@ do for test_shell in $test_shells do + unset BASH + unset ZSH_VERSION test_shell_opts= case /$test_shell in */zsh) test_shell_opts="-o shwordsplit" ;; esac export test_shell + export SHELL=$(which $test_shell) echo echo '********************************************************************************' From 04eb3398cdca2cd91f4faa19a900f921393e7927 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 10 Jun 2012 15:00:37 -0400 Subject: [PATCH 578/947] quiet some test operations and check for error codes before continuing --- tests/test.sh | 4 +++- tests/test_cp.sh | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test.sh b/tests/test.sh index c8fe6ba..ec11510 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -84,7 +84,9 @@ test_virtualenvwrapper_verify_workon_home_missing_dir_grep_options() { test_python_interpreter_set_incorrectly() { return_to="$(pwd)" cd "$WORKON_HOME" - mkvirtualenv no_wrappers + mkvirtualenv no_wrappers >/dev/null 2>&1 + RC=$? + assertEquals "0" "$RC" expected="ImportError: No module named virtualenvwrapper.hook_loader" # test_shell is set by tests/run_tests if [ "$test_shell" = "" ] diff --git a/tests/test_cp.sh b/tests/test_cp.sh index 0cec617..f7fcad9 100755 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -21,6 +21,8 @@ tearDown() { test_new_env_activated () { mkvirtualenv "source" >/dev/null 2>&1 + RC=$? + assertEquals "0" "$RC" (cd tests/testpackage && python setup.py install) >/dev/null 2>&1 cpvirtualenv "source" "destination" >/dev/null 2>&1 rmvirtualenv "source" >/dev/null 2>&1 From 94e3d32ea251a51fb191eaecab8c6d9b707764c6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 10 Jun 2012 15:02:57 -0400 Subject: [PATCH 579/947] Use "command" to avoid aliases or functions that mask common utilities. fixes #119 --- tests/test_tempfile.sh | 5 ++-- virtualenvwrapper.sh | 63 ++++++++++++++++++++++++++++++------------ 2 files changed, 48 insertions(+), 20 deletions(-) diff --git a/tests/test_tempfile.sh b/tests/test_tempfile.sh index 28effcd..8fd1378 100755 --- a/tests/test_tempfile.sh +++ b/tests/test_tempfile.sh @@ -43,12 +43,13 @@ test_bad_mktemp() { for mktemp_func in mktemp_nonzero mktemp_empty_string \ mktemp_missing_executable mktemp_missing_result do - mktemp() { $mktemp_func "$@"; } + __virtualenvwrapper_mktemp() { $mktemp_func "$@"; } filename=$(virtualenvwrapper_tempfile hook 2>/dev/null) assertSame "($mktemp_func) Unexpected exit code $?" "1" "$?" done - unset -f mktemp + # Restore the "real" definition of the replaceable function + __virtualenvwrapper_mktemp() { command mktemp "$@"; } } test_no_such_tmpdir () { diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 6457cf5..e64c8a9 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -47,7 +47,7 @@ # Locate the global Python where virtualenvwrapper is installed. if [ "$VIRTUALENVWRAPPER_PYTHON" = "" ] then - VIRTUALENVWRAPPER_PYTHON="$(\which python)" + VIRTUALENVWRAPPER_PYTHON="$(command \which python)" fi # Set the name of the virtualenv app to use. @@ -78,6 +78,29 @@ then export VIRTUALENVWRAPPER_PROJECT_FILENAME=".project" fi +# Portable shell scripting is hard, let's go shopping. +# +# People insist on aliasing commands like 'cd', either with a real +# alias or even a shell function. Under bash and zsh, "builtin" forces +# the use of a command that is part of the shell itself instead of an +# alias, function, or external command, while "command" does something +# similar but allows external commands. Under ksh "builtin" registers +# a new command from a shared library, but "command" will pick up +# existing builtin commands. We need to use a builtin for cd because +# we are trying to change the state of the current shell, so we use +# "builtin" for bash and zsh but "command" under ksh. +function __virtualenvwrapper_cd { + if [ -n "$BASH" ] + then + builtin \cd "$@" + elif [ -n "$ZSH_VERSION" ] + then + builtin \cd "$@" + else + command \cd "$@" + fi +} + function virtualenvwrapper_expandpath { if [ "$1" = "" ]; then return 1 @@ -99,7 +122,7 @@ function virtualenvwrapper_derive_workon_home { # If the path is relative, prefix it with $HOME # (note: for compatibility) - if echo "$workon_home_dir" | (unset GREP_OPTIONS; \grep '^[^/~]' > /dev/null) + if echo "$workon_home_dir" | (unset GREP_OPTIONS; command \grep '^[^/~]' > /dev/null) then workon_home_dir="$HOME/$WORKON_HOME" fi @@ -108,7 +131,7 @@ function virtualenvwrapper_derive_workon_home { # path might contain stuff to expand. # (it might be possible to do this in shell, but I don't know a # cross-shell-safe way of doing it -wolever) - if echo "$workon_home_dir" | (unset GREP_OPTIONS; \egrep '([\$~]|//)' >/dev/null) + if echo "$workon_home_dir" | (unset GREP_OPTIONS; command \egrep '([\$~]|//)' >/dev/null) then # This will normalize the path by: # - Removing extra slashes (e.g., when TMPDIR ends in a slash) @@ -141,13 +164,19 @@ function virtualenvwrapper_verify_workon_home { #HOOK_VERBOSE_OPTION="-q" +# Function to wrap mktemp so tests can replace it for error condition +# testing. +function __virtualenvwrapper_mktemp { + command \mktemp "$@" +} + # Expects 1 argument, the suffix for the new file. function virtualenvwrapper_tempfile { # Note: the 'X's must come last typeset suffix=${1:-hook} typeset file - file="`\mktemp -t virtualenvwrapper-$suffix-XXXXXXXXXX`" + file="$(__virtualenvwrapper_mktemp -t virtualenvwrapper-$suffix-XXXXXXXXXX)" if [ $? -ne 0 ] || [ -z "$file" ] || [ ! -f "$file" ] then echo "ERROR: virtualenvwrapper could not create a temporary file name." 1>&2 @@ -167,7 +196,7 @@ function virtualenvwrapper_run_hook { if [ -z "$VIRTUALENVWRAPPER_LOG_DIR" ] then echo "ERROR: VIRTUALENVWRAPPER_LOG_DIR is not set." 1>&2 - \rm -f "$hook_script" + command \rm -f "$hook_script" return 1 fi "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' $HOOK_VERBOSE_OPTION --script "$hook_script" "$@" @@ -178,7 +207,7 @@ function virtualenvwrapper_run_hook { if [ ! -f "$hook_script" ] then echo "ERROR: virtualenvwrapper_run_hook could not find temporary file $hook_script" 1>&2 - \rm -f "$hook_script" + command \rm -f "$hook_script" return 2 fi # cat "$hook_script" @@ -194,7 +223,7 @@ VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON and that PATH is set properly. EOF fi - \rm -f "$hook_script" + command \rm -f "$hook_script" return $result } @@ -263,7 +292,7 @@ function virtualenvwrapper_initialize { # Verify that the passed resource is in path and exists function virtualenvwrapper_verify_resource { - typeset exe_path=$(\which "$1" | (unset GREP_OPTIONS; \grep -v "not found")) + typeset exe_path=$(command \which "$1" | (unset GREP_OPTIONS; command \grep -v "not found")) if [ "$exe_path" = "" ] then echo "ERROR: virtualenvwrapper could not find $1 in your path" >&2 @@ -395,7 +424,7 @@ function mkvirtualenv { virtualenvwrapper_verify_virtualenv || return 1 ( [ -n "$ZSH_VERSION" ] && setopt SH_WORD_SPLIT - \cd "$WORKON_HOME" && + __virtualenvwrapper_cd "$WORKON_HOME" && "$VIRTUALENVWRAPPER_VIRTUALENV" $VIRTUALENVWRAPPER_VIRTUALENV_ARGS "$@" && [ -d "$WORKON_HOME/$envname" ] && \ virtualenvwrapper_run_hook "pre_mkvirtualenv" "$envname" @@ -456,16 +485,16 @@ function rmvirtualenv { # Move out of the current directory to one known to be # safe, in case we are inside the environment somewhere. typeset prior_dir="$(pwd)" - \cd "$WORKON_HOME" + __virtualenvwrapper_cd "$WORKON_HOME" virtualenvwrapper_run_hook "pre_rmvirtualenv" "$env_name" - \rm -rf "$env_dir" + command \rm -rf "$env_dir" virtualenvwrapper_run_hook "post_rmvirtualenv" "$env_name" # If the directory we used to be in still exists, move back to it. if [ -d "$prior_dir" ] then - \cd "$prior_dir" + __virtualenvwrapper_cd "$prior_dir" fi done } @@ -476,9 +505,7 @@ function virtualenvwrapper_show_workon_options { # NOTE: DO NOT use ls here because colorized versions spew control characters # into the output list. # echo seems a little faster than find, even with -depth 3. - (\cd "$WORKON_HOME"; for f in */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate; do echo $f; done) 2>/dev/null | \sed 's|^\./||' | \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate||" | \sort | (unset GREP_OPTIONS; \egrep -v '^\*$') - -# (\cd "$WORKON_HOME"; find -L . -depth 3 -path '*/bin/activate') | sed 's|^\./||' | sed 's|/bin/activate||' | sort + (__virtualenvwrapper_cd "$WORKON_HOME"; for f in */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate; do echo $f; done) 2>/dev/null | command \sed 's|^\./||' | command \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate||" | command \sort | (unset GREP_OPTIONS; command \egrep -v '^\*$') } function _lsvirtualenv_usage { @@ -725,14 +752,14 @@ function cdsitepackages { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 typeset site_packages="`virtualenvwrapper_get_site_packages_dir`" - \cd "$site_packages"/$1 + __virtualenvwrapper_cd "$site_packages"/$1 } # Does a ``cd`` to the root of the currently-active virtualenv. function cdvirtualenv { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 - \cd $VIRTUAL_ENV/$1 + __virtualenvwrapper_cd $VIRTUAL_ENV/$1 } # Shows the content of the site-packages directory of the currently-active @@ -820,7 +847,7 @@ function cpvirtualenv { echo "Copying $src_name as $trg_name..." ( [ -n "$ZSH_VERSION" ] && setopt SH_WORD_SPLIT - \cd "$WORKON_HOME" && + __virtualenvwrapper_cd "$WORKON_HOME" && "$VIRTUALENVWRAPPER_VIRTUALENV_CLONE" "$src" "$trg" [ -d "$trg" ] && virtualenvwrapper_run_hook "pre_cpvirtualenv" "$src" "$trg_name" && From b482f131b948f32758a9964b4a5e912507570987 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 10 Jun 2012 15:31:45 -0400 Subject: [PATCH 580/947] document previous changes --- docs/en/history.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/en/history.rst b/docs/en/history.rst index f2a8173..b7089a8 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -11,6 +11,8 @@ dev (:bbissue:`102`). - Update docs with link to `virtualenvwrapper-win`_ port by David Marble. + - Use ``command`` to avoid functions named the same as common + utilities. (:bbissue:`119`) .. _virtualenv-clone: http://pypi.python.org/pypi/virtualenv-clone .. _virtualenvwrapper-win: http://pypi.python.org/pypi/virtualenvwrapper-win From 0c282db00b3b71c02b555eb537153b022009713d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 10 Jun 2012 15:32:13 -0400 Subject: [PATCH 581/947] fix whitespace and rename a few worker functions to be consistent with the rest --- tests/test_tempfile.sh | 4 +-- virtualenvwrapper.sh | 56 +++++++++++++++++++++--------------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/tests/test_tempfile.sh b/tests/test_tempfile.sh index 8fd1378..895d0b1 100755 --- a/tests/test_tempfile.sh +++ b/tests/test_tempfile.sh @@ -43,13 +43,13 @@ test_bad_mktemp() { for mktemp_func in mktemp_nonzero mktemp_empty_string \ mktemp_missing_executable mktemp_missing_result do - __virtualenvwrapper_mktemp() { $mktemp_func "$@"; } + virtualenvwrapper_mktemp() { $mktemp_func "$@"; } filename=$(virtualenvwrapper_tempfile hook 2>/dev/null) assertSame "($mktemp_func) Unexpected exit code $?" "1" "$?" done # Restore the "real" definition of the replaceable function - __virtualenvwrapper_mktemp() { command mktemp "$@"; } + virtualenvwrapper_mktemp() { command mktemp "$@"; } } test_no_such_tmpdir () { diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index e64c8a9..002953d 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -89,25 +89,25 @@ fi # existing builtin commands. We need to use a builtin for cd because # we are trying to change the state of the current shell, so we use # "builtin" for bash and zsh but "command" under ksh. -function __virtualenvwrapper_cd { - if [ -n "$BASH" ] - then - builtin \cd "$@" - elif [ -n "$ZSH_VERSION" ] - then - builtin \cd "$@" - else - command \cd "$@" - fi +function virtualenvwrapper_cd { + if [ -n "$BASH" ] + then + builtin \cd "$@" + elif [ -n "$ZSH_VERSION" ] + then + builtin \cd "$@" + else + command \cd "$@" + fi } function virtualenvwrapper_expandpath { - if [ "$1" = "" ]; then - return 1 - else - "$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.normpath(os.path.expanduser(os.path.expandvars(\"$1\")))+'\n')" - return 0 - fi + if [ "$1" = "" ]; then + return 1 + else + "$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.normpath(os.path.expanduser(os.path.expandvars(\"$1\")))+'\n')" + return 0 + fi } function virtualenvwrapper_derive_workon_home { @@ -166,8 +166,8 @@ function virtualenvwrapper_verify_workon_home { # Function to wrap mktemp so tests can replace it for error condition # testing. -function __virtualenvwrapper_mktemp { - command \mktemp "$@" +function virtualenvwrapper_mktemp { + command \mktemp "$@" } # Expects 1 argument, the suffix for the new file. @@ -176,7 +176,7 @@ function virtualenvwrapper_tempfile { typeset suffix=${1:-hook} typeset file - file="$(__virtualenvwrapper_mktemp -t virtualenvwrapper-$suffix-XXXXXXXXXX)" + file="$(virtualenvwrapper_mktemp -t virtualenvwrapper-$suffix-XXXXXXXXXX)" if [ $? -ne 0 ] || [ -z "$file" ] || [ ! -f "$file" ] then echo "ERROR: virtualenvwrapper could not create a temporary file name." 1>&2 @@ -212,8 +212,8 @@ function virtualenvwrapper_run_hook { fi # cat "$hook_script" source "$hook_script" - elif [ "${1}" = "initialize" ] - then + elif [ "${1}" = "initialize" ] + then cat - 1>&2 </dev/null | command \sed 's|^\./||' | command \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate||" | command \sort | (unset GREP_OPTIONS; command \egrep -v '^\*$') + (virtualenvwrapper_cd "$WORKON_HOME"; for f in */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate; do echo $f; done) 2>/dev/null | command \sed 's|^\./||' | command \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate||" | command \sort | (unset GREP_OPTIONS; command \egrep -v '^\*$') } function _lsvirtualenv_usage { @@ -752,14 +752,14 @@ function cdsitepackages { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 typeset site_packages="`virtualenvwrapper_get_site_packages_dir`" - __virtualenvwrapper_cd "$site_packages"/$1 + virtualenvwrapper_cd "$site_packages"/$1 } # Does a ``cd`` to the root of the currently-active virtualenv. function cdvirtualenv { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 - __virtualenvwrapper_cd $VIRTUAL_ENV/$1 + virtualenvwrapper_cd $VIRTUAL_ENV/$1 } # Shows the content of the site-packages directory of the currently-active @@ -847,7 +847,7 @@ function cpvirtualenv { echo "Copying $src_name as $trg_name..." ( [ -n "$ZSH_VERSION" ] && setopt SH_WORD_SPLIT - __virtualenvwrapper_cd "$WORKON_HOME" && + virtualenvwrapper_cd "$WORKON_HOME" && "$VIRTUALENVWRAPPER_VIRTUALENV_CLONE" "$src" "$trg" [ -d "$trg" ] && virtualenvwrapper_run_hook "pre_cpvirtualenv" "$src" "$trg_name" && From fe1282d706838352c2bacf763bb653ce3cc40c66 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 10 Jun 2012 16:05:10 -0400 Subject: [PATCH 582/947] bump version number and update announcement text --- announce.rst | 28 ++++++++++++++++++---------- setup.py | 2 +- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/announce.rst b/announce.rst index 635bb0b..e0bc18e 100644 --- a/announce.rst +++ b/announce.rst @@ -1,11 +1,11 @@ ======================= - virtualenvwrapper 3.4 + virtualenvwrapper 3.5 ======================= .. tags:: virtualenvwrapper release python -What is virtualenvwrapper -========================= +What is virtualenvwrapper? +========================== virtualenvwrapper_ is a set of extensions to Ian Bicking's virtualenv_ tool. The extensions include wrappers for creating and deleting @@ -13,13 +13,21 @@ virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. -What's New -========== - -- Add a "lazy loading" option for startup scripts. Refer to the - `installation instructions - `_ - for more details. +What's New? +=========== + +- Rewrite ``command-cpvirtualenv`` to use `virtualenv-clone`_ + instead of making the new environment relocatable. Contributed by + Justin Barber (barberj). This also resolves a problem + with cpvirtualenv not honoring the ``--no-site-packages`` flag + (issue 102). +- Update docs with link to `virtualenvwrapper-win`_ port by David + Marble. +- Use ``command`` to avoid functions named the same as common + utilities. (issue 119) + +.. _virtualenv-clone: http://pypi.python.org/pypi/virtualenv-clone +.. _virtualenvwrapper-win: http://pypi.python.org/pypi/virtualenvwrapper-win Installing ========== diff --git a/setup.py b/setup.py index cb5fb55..6cf1dec 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ PROJECT = 'virtualenvwrapper' # Change docs/sphinx/conf.py too! -VERSION = '3.4' +VERSION = '3.5' # Bootstrap installation of Distribute import distribute_setup From 545a36e0f1ddaa274793ee96206d44d7d64aebea Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 10 Jun 2012 16:05:29 -0400 Subject: [PATCH 583/947] Added tag 3.5 for changeset c93b81815391 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 9985117..2d0e192 100644 --- a/.hgtags +++ b/.hgtags @@ -84,3 +84,4 @@ ebbb3ba8168703861c016ed66f443fb898f0b06b 3.1 dccf1a1abf4ea97589e9fa141167771049f031e0 3.2 45877370548ee7c2581a6c81df22b12fcc3f4891 3.3 07905d9135ac3ca8460143b40dc39aa8823d3691 3.4 +c93b81815391a939601ac455a07b6f006825838a 3.5 From 2a15b934831dcf48fbdfe1b1fdf5251a0fed936d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 10 Jun 2012 16:07:25 -0400 Subject: [PATCH 584/947] fix reference in announcement --- announce.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/announce.rst b/announce.rst index e0bc18e..5449df3 100644 --- a/announce.rst +++ b/announce.rst @@ -16,7 +16,7 @@ introducing conflicts in their dependencies. What's New? =========== -- Rewrite ``command-cpvirtualenv`` to use `virtualenv-clone`_ +- Rewrite ``cpvirtualenv`` to use `virtualenv-clone`_ instead of making the new environment relocatable. Contributed by Justin Barber (barberj). This also resolves a problem with cpvirtualenv not honoring the ``--no-site-packages`` flag From 34cb8e5e024eae25ddfb17845962f66f1d766174 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 19 Jun 2012 17:34:49 -0400 Subject: [PATCH 585/947] convert hook loader to use stevedore --- docs/en/history.rst | 6 +++++ setup.py | 1 + tests/test.sh | 2 +- tox.ini | 1 + virtualenvwrapper/hook_loader.py | 44 ++++++++++++++++++++++---------- 5 files changed, 39 insertions(+), 15 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index b7089a8..0a6a95a 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -4,6 +4,12 @@ Release History dev + - Switch to stevedore_ for plugin management + +.. _stevedore: http://pypi.python.org/pypi/stevedore + +3.5 + - Rewrite :ref:`command-cpvirtualenv` to use `virtualenv-clone`_ instead of making the new environment relocatable. Contributed by Justin Barber (:bbuser:`barberj`). This also resolves a problem diff --git a/setup.py b/setup.py index 6cf1dec..5d96df9 100644 --- a/setup.py +++ b/setup.py @@ -149,6 +149,7 @@ def find_package_data( ], install_requires=['virtualenv', 'virtualenv-clone', + 'stevedore', ], namespace_packages = [ 'virtualenvwrapper' ], diff --git a/tests/test.sh b/tests/test.sh index ec11510..02d68cb 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -86,7 +86,7 @@ test_python_interpreter_set_incorrectly() { cd "$WORKON_HOME" mkvirtualenv no_wrappers >/dev/null 2>&1 RC=$? - assertEquals "0" "$RC" + assertEquals "mkvirtualenv return code wrong" "0" "$RC" expected="ImportError: No module named virtualenvwrapper.hook_loader" # test_shell is set by tests/run_tests if [ "$test_shell" = "" ] diff --git a/tox.ini b/tox.ini index dd00002..8ee8c07 100644 --- a/tox.ini +++ b/tox.ini @@ -5,6 +5,7 @@ envlist = py27,py26,py32 commands = bash ./tests/run_tests {envdir} [] deps = virtualenv virtualenv-clone + stevedore setenv = TOXIC = true diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 419efec..856a95a 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -13,7 +13,8 @@ import os import sys -import pkg_resources +from stevedore import ExtensionManager +from stevedore import NamedExtensionManager class GroupWriteRotatingFileHandler(logging.handlers.RotatingFileHandler): @@ -138,24 +139,39 @@ def run_hooks(hook, options, args, output=None): if output is None: output = sys.stdout - for ep in pkg_resources.iter_entry_points('virtualenvwrapper.%s' % hook): - if options.names and ep.name not in options.names: - continue - plugin = ep.load() - if options.listing: - output.write(' %-10s -- %s\n' % (ep.name, inspect.getdoc(plugin) or '')) - continue - if options.sourcing: + namespace = 'virtualenvwrapper.%s' % hook + if options.names: + hook_mgr = NamedExtensionManager(namespace, options.names) + else: + hook_mgr = ExtensionManager(namespace) + + if options.listing: + def show(ext): + output.write(' %-10s -- %s\n' % (ext.name, inspect.getdoc(ext.plugin) or '')) + hook_mgr.map(show) + + elif options.sourcing: + def get_source(ext, args): # Show the shell commands so they can # be run in the calling shell. - contents = (plugin(args[1:]) or '').strip() + contents = (ext.plugin(args) or '').strip() if contents: - output.write('# %s\n' % ep.name) + output.write('# %s\n' % ext.name) output.write(contents) output.write("\n") - else: - # Just run the plugin ourselves - plugin(args[1:]) + try: + hook_mgr.map(get_source, args[1:]) + except RuntimeError: + pass + + else: + # Just run the plugin ourselves + def invoke(ext, args): + ext.plugin(args) + try: + hook_mgr.map(invoke, args[1:]) + except RuntimeError: + pass def list_hooks(output=None): From 58eae983fc74941d206a5256b8e671f22ab385f9 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 20 Jul 2012 10:19:49 -0400 Subject: [PATCH 586/947] use the right virtualenv binary to get help; fixes #148 --- docs/en/history.rst | 2 ++ virtualenvwrapper.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 0a6a95a..557dba3 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -5,6 +5,8 @@ Release History dev - Switch to stevedore_ for plugin management + - mkvirtualenv_help should use ``$VIRTUALENVWRAPPER_PYTHON`` instead + of calling ``virtualenv`` directly (:bbissue:`148`). .. _stevedore: http://pypi.python.org/pypi/stevedore diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 002953d..e877326 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -360,7 +360,7 @@ function mkvirtualenv_help { echo; echo 'virtualenv help:'; echo; - virtualenv $@; + "$VIRTUALENVWRAPPER_VIRTUALENV" $@; } # Create a new environment, in the WORKON_HOME. From 3eb6ba8d2991fda3146ec2a169695028506146cb Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 20 Jul 2012 11:09:50 -0400 Subject: [PATCH 587/947] fix lazy-loader function definitions under zsh; fixes #144 --- docs/en/history.rst | 1 + tests/test_lazy.sh | 10 +++++++++- virtualenvwrapper_lazy.sh | 4 ++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 557dba3..fd93278 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -7,6 +7,7 @@ dev - Switch to stevedore_ for plugin management - mkvirtualenv_help should use ``$VIRTUALENVWRAPPER_PYTHON`` instead of calling ``virtualenv`` directly (:bbissue:`148`). + - Fix issue with lazy-loader code under zsh (:bbissue:`144`). .. _stevedore: http://pypi.python.org/pypi/stevedore diff --git a/tests/test_lazy.sh b/tests/test_lazy.sh index fd55caf..34a9cf8 100644 --- a/tests/test_lazy.sh +++ b/tests/test_lazy.sh @@ -1,4 +1,3 @@ -#!/bin/sh test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" @@ -6,7 +5,9 @@ source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" + [ ! -z "$ZSH_VERSION" ] && unsetopt shwordsplit source "$test_dir/../virtualenvwrapper_lazy.sh" + [ ! -z "$ZSH_VERSION" ] && setopt shwordsplit } oneTimeTearDown() { @@ -22,6 +23,13 @@ function_defined_lazy() { name="$1" assertTrue "$name not defined" "type $name" assertTrue "$name does not load virtualenvwrapper" "typeset -f $name | grep 'virtualenvwrapper_load'" + if [ "$name" = "mkvirtualenv" ] + then + lookfor="rmvirtualenv" + else + lookfor="mkvirtualenv" + fi + assertFalse "$name includes reference to $lookfor: $(typeset -f $name)" "typeset -f $name | grep $lookfor" } test_mkvirtualenv_defined_lazy() { diff --git a/virtualenvwrapper_lazy.sh b/virtualenvwrapper_lazy.sh index e603d11..de4a396 100644 --- a/virtualenvwrapper_lazy.sh +++ b/virtualenvwrapper_lazy.sh @@ -20,12 +20,12 @@ function virtualenvwrapper_load { # Set up "alias" functions based on the API definition. function virtualenvwrapper_setup_lazy_loader { typeset venvw_name - for venvw_name in $_VIRTUALENVWRAPPER_API + for venvw_name in $(echo ${_VIRTUALENVWRAPPER_API}) do eval " function $venvw_name { virtualenvwrapper_load - $venvw_name \"\$@\" + ${venvw_name} \"\$@\" } " done From 62eb6b5f6c7ef85c451b46938d367e8108695fb9 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 20 Jul 2012 11:33:18 -0400 Subject: [PATCH 588/947] pep8 cleanup --- tox.ini | 7 ++- virtualenvwrapper/hook_loader.py | 97 +++++++++++++++++-------------- virtualenvwrapper/project.py | 7 ++- virtualenvwrapper/user_scripts.py | 45 ++++++++------ 4 files changed, 92 insertions(+), 64 deletions(-) diff --git a/tox.ini b/tox.ini index 8ee8c07..56f5fbe 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py26,py32 +envlist = py27,py26,py32,pep8 [testenv] commands = bash ./tests/run_tests {envdir} [] @@ -9,6 +9,11 @@ deps = virtualenv setenv = TOXIC = true +[testenv:pep8] +deps = pep8==1.1 +commands = pep8 --ignore=E501 --repeat --show-source virtualenvwrapper + + # Not sure why this is needed, but on my system if it isn't included then # the python version picked up for 2.6 is actually 2.7. # IF THIS CAUSES YOU A PROBLEM COMMENT IT OUT BEFORE RUNNING THE TESTS. diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 856a95a..ae07513 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -16,9 +16,11 @@ from stevedore import ExtensionManager from stevedore import NamedExtensionManager +LOG_FORMAT = '%(asctime)s %(levelname)s %(name)s %(message)s' + class GroupWriteRotatingFileHandler(logging.handlers.RotatingFileHandler): - """Taken from http://stackoverflow.com/questions/1407474/does-python-logging-handlers-rotatingfilehandler-allow-creation-of-a-group-writa + """Taken from http://stackoverflow.com/questions/1407474 """ def _open(self): prevumask = os.umask(0o002) @@ -34,44 +36,50 @@ def main(): description='Manage hooks for virtualenvwrapper', ) - parser.add_option('-S', '--script', - help='Runs "hook" then "_source", writing the ' + - 'result to ', - dest='script_filename', - default=None, - ) - parser.add_option('-s', '--source', - help='Print the shell commands to be run in the current shell', - action='store_true', - dest='sourcing', - default=False, - ) - parser.add_option('-l', '--list', - help='Print a list of the plugins available for the given hook', - action='store_true', - default=False, - dest='listing', - ) - parser.add_option('-v', '--verbose', - help='Show more information on the console', - action='store_const', - const=2, - default=1, - dest='verbose_level', - ) - parser.add_option('-q', '--quiet', - help='Show less information on the console', - action='store_const', - const=0, - dest='verbose_level', - ) - parser.add_option('-n', '--name', - help='Only run the hook from the named plugin', - action='append', - dest='names', - default=[], - ) - parser.disable_interspersed_args() # stop when we hit an option without an '-' + parser.add_option( + '-S', '--script', + help='Runs "hook" then "_source", writing the ' + + 'result to ', + dest='script_filename', + default=None, + ) + parser.add_option( + '-s', '--source', + help='Print the shell commands to be run in the current shell', + action='store_true', + dest='sourcing', + default=False, + ) + parser.add_option( + '-l', '--list', + help='Print a list of the plugins available for the given hook', + action='store_true', + default=False, + dest='listing', + ) + parser.add_option( + '-v', '--verbose', + help='Show more information on the console', + action='store_const', + const=2, + default=1, + dest='verbose_level', + ) + parser.add_option( + '-q', '--quiet', + help='Show less information on the console', + action='store_const', + const=0, + dest='verbose_level', + ) + parser.add_option( + '-n', '--name', + help='Only run the hook from the named plugin', + action='append', + dest='names', + default=[], + ) + parser.disable_interspersed_args() # stop when on option without an '-' options, args = parser.parse_args() root_logger = logging.getLogger('') @@ -79,11 +87,12 @@ def main(): # Set up logging to a file root_logger.setLevel(logging.DEBUG) file_handler = GroupWriteRotatingFileHandler( - os.path.expandvars(os.path.join('$VIRTUALENVWRAPPER_LOG_DIR', 'hook.log')), + os.path.expandvars(os.path.join('$VIRTUALENVWRAPPER_LOG_DIR', + 'hook.log')), maxBytes=10240, backupCount=1, ) - formatter = logging.Formatter('%(asctime)s %(levelname)s %(name)s %(message)s') + formatter = logging.Formatter(LOG_FORMAT) file_handler.setFormatter(formatter) root_logger.addHandler(file_handler) @@ -121,7 +130,8 @@ def main(): run_hooks(hook, options, args) if options.script_filename: - log.debug('Saving sourcable %s hooks to %s', hook, options.script_filename) + log.debug('Saving sourcable %s hooks to %s', + hook, options.script_filename) options.sourcing = True output = open(options.script_filename, "w") try: @@ -147,7 +157,8 @@ def run_hooks(hook, options, args, output=None): if options.listing: def show(ext): - output.write(' %-10s -- %s\n' % (ext.name, inspect.getdoc(ext.plugin) or '')) + output.write(' %-10s -- %s\n' % + (ext.name, inspect.getdoc(ext.plugin) or '')) hook_mgr.map(show) elif options.sourcing: diff --git a/virtualenvwrapper/project.py b/virtualenvwrapper/project.py index 65a9695..5119826 100644 --- a/virtualenvwrapper/project.py +++ b/virtualenvwrapper/project.py @@ -8,8 +8,6 @@ import logging import os -import pkg_resources - from virtualenvwrapper.user_scripts import make_hook, run_global log = logging.getLogger(__name__) @@ -28,6 +26,7 @@ "This hook is run after a project is deleted."), ] + def initialize(args): """Set up user hooks """ @@ -38,10 +37,11 @@ def initialize(args): def pre_mkproject(args): log.debug('pre_mkproject %s', str(args)) - envname=args[0] + envname = args[0] run_global('premkproject', *args) return + def post_mkproject_source(args): return """ # @@ -50,6 +50,7 @@ def post_mkproject_source(args): [ -f "$WORKON_HOME/postmkproject" ] && source "$WORKON_HOME/postmkproject" """ + def post_activate_source(args): return """ # diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index a2e881c..483ca26 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -12,13 +12,15 @@ import subprocess import sys -import pkg_resources log = logging.getLogger(__name__) - # Are we running under msys -if sys.platform == 'win32' and os.environ.get('OS') == 'Windows_NT' and os.environ.get('MSYSTEM') == 'MINGW32': +if (sys.platform == 'win32' + and + os.environ.get('OS') == 'Windows_NT' + and + os.environ.get('MSYSTEM') == 'MINGW32'): is_msys = True script_folder = 'Scripts' else: @@ -32,12 +34,12 @@ def run_script(script_path, *args): if os.path.exists(script_path): cmd = [script_path] + list(args) if is_msys: - cmd = [get_path(os.environ['MSYS_HOME'],'bin','sh.exe')] + cmd + cmd = [get_path(os.environ['MSYS_HOME'], 'bin', 'sh.exe')] + cmd log.debug('running %s', str(cmd)) try: - return_code = subprocess.call(cmd) + subprocess.call(cmd) except OSError: - _, msg, _ = sys.exc_info() + _, msg, _ = sys.exc_info() log.error('could not run "%s": %s', script_path, str(msg)) #log.debug('Returned %s', return_code) return @@ -85,7 +87,8 @@ def run_global(script_name, *args): # get_env_details ("get_env_details", - "This hook is run when the list of virtualenvs is printed so each name can include details."), + "This hook is run when the list of virtualenvs is printed " + "so each name can include details."), ] @@ -104,13 +107,14 @@ def run_global(script_name, *args): # get_env_details ("get_env_details", - "This hook is run when the list of virtualenvs is printed in 'long' mode so each name can include details."), + "This hook is run when the list of virtualenvs is printed " + "in 'long' mode so each name can include details."), ] def make_hook(filename, comment): """Create a hook script. - + :param filename: The name of the file to write. :param comment: The comment to insert into the file. """ @@ -122,14 +126,15 @@ def make_hook(filename, comment): f.write("""#!%(shell)s # %(comment)s -""" % {'comment':comment, 'shell':os.environ.get('SHELL', '/bin/sh')}) +""" % {'comment': comment, + 'shell': os.environ.get('SHELL', '/bin/sh'), + }) finally: f.close() os.chmod(filename, PERMISSIONS) return - # HOOKS @@ -147,9 +152,10 @@ def initialize_source(args): [ -f "$VIRTUALENVWRAPPER_HOOK_DIR/initialize" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/initialize" """ + def pre_mkvirtualenv(args): log.debug('pre_mkvirtualenv %s', str(args)) - envname=args[0] + envname = args[0] for filename, comment in LOCAL_HOOKS: make_hook(get_path('$WORKON_HOME', envname, script_folder, filename), comment) run_global('premkvirtualenv', *args) @@ -164,9 +170,10 @@ def post_mkvirtualenv_source(args): [ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postmkvirtualenv" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/postmkvirtualenv" """ + def pre_cpvirtualenv(args): log.debug('pre_cpvirtualenv %s', str(args)) - envname=args[0] + envname = args[0] for filename, comment in LOCAL_HOOKS: make_hook(get_path('$WORKON_HOME', envname, script_folder, filename), comment) run_global('precpvirtualenv', *args) @@ -234,7 +241,7 @@ def post_deactivate_source(args): [ -f "$WORKON_HOME/%(env_name)s/bin/postdeactivate" ] && source "$WORKON_HOME/%(env_name)s/bin/postdeactivate" [ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postdeactivate" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/postdeactivate" unset VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV -""" % { 'env_name':args[0] } +""" % {'env_name': args[0]} def get_env_details(args): @@ -244,10 +251,14 @@ def get_env_details(args): run_script(script_path, *args) return + def get_path(*args): ''' Get a full path from args. - Path separator is determined according to the os and the shell and allow to use is_msys. + + Path separator is determined according to the os and the shell and + allow to use is_msys. + Variables and user are expanded during the process. ''' path = os.path.expanduser(os.path.expandvars(os.path.join(*args))) @@ -255,7 +266,7 @@ def get_path(*args): # MSYS accept unix or Win32 and sometimes it drives to mixed style paths if re.match(r'^/[a-zA-Z](/|^)', path): # msys path could starts with '/c/'-form drive letter - path = ''.join((path[1],':',path[2:])) + path = ''.join((path[1], ':', path[2:])) path = path.replace('/', os.sep) - + return os.path.abspath(path) From d759930e939de260c28baa239c87f5463beceb2c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 20 Jul 2012 14:27:29 -0400 Subject: [PATCH 589/947] fix issue with add2virtualenv and noclobber setting in shell; fixes #137 --- docs/en/history.rst | 1 + tests/test_add2virtualenv.sh | 38 ++++++++++++++++++++++++++++++++++++ virtualenvwrapper.sh | 4 ++-- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index fd93278..0a11220 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -8,6 +8,7 @@ dev - mkvirtualenv_help should use ``$VIRTUALENVWRAPPER_PYTHON`` instead of calling ``virtualenv`` directly (:bbissue:`148`). - Fix issue with lazy-loader code under zsh (:bbissue:`144`). + - Fix issue with ``noclobber`` option under zsh (:bbissue:`137`). .. _stevedore: http://pypi.python.org/pypi/stevedore diff --git a/tests/test_add2virtualenv.sh b/tests/test_add2virtualenv.sh index 5b68cb8..531e9ba 100755 --- a/tests/test_add2virtualenv.sh +++ b/tests/test_add2virtualenv.sh @@ -37,6 +37,44 @@ test_add2virtualenv () { cd - >/dev/null 2>&1 } +test_add2virtualenv_zsh_noclobber () { + # See issue #137 + if [ ! -z $ZSH_VERSION ] + then + set -o noclobber + elif [[ "$SHELL" =~ "bash" ]] + then + shopt -o -s noclobber + else + return 0 + fi + mkvirtualenv "pathtest_noclobber" >/dev/null 2>&1 + full_path=$(pwd) + add2virtualenv "$full_path" + RC=$? + if [ ! -z $ZSH_VERSION ] + then + unsetopt noclobber + elif [[ "/$SHELL" =~ "/bash" ]] + then + shopt -o -u noclobber + fi + assertEquals "0" "$RC" + cdsitepackages + # Check contents of path file + path_file="./_virtualenv_path_extensions.pth" + assertTrue "No $full_path in $(cat $path_file)" "grep -q $full_path $path_file" + assertTrue "No path insert code in $(cat $path_file)" "grep -q sys.__egginsert $path_file" + # Check the path we inserted is actually at the top + expected="$full_path" + actual=$($WORKON_HOME/pathtest_noclobber/bin/python -c "import sys; sys.stdout.write(sys.path[1]+'\n')") + assertSame "$expected" "$actual" + # Make sure the temporary file created + # during the edit was removed + assertFalse "Temporary file ${path_file}.tmp still exists" "[ -f ${path_file}.tmp ]" + cd - >/dev/null 2>&1 +} + test_add2virtualenv_relative () { mkvirtualenv "pathtest_relative" >/dev/null 2>&1 parent_dir=$(dirname $(pwd)) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index e877326..3eca675 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -721,8 +721,8 @@ function add2virtualenv { if [ ! -f "$path_file" ] then - echo "import sys; sys.__plen = len(sys.path)" >> "$path_file" - echo "import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)" >> "$path_file" + echo "import sys; sys.__plen = len(sys.path)" > "$path_file" || return 1 + echo "import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)" >> "$path_file" || return 1 fi for pydir in "$@" From 7f0e0e5b78ea9e921400dbdcdc9a384e2cc00fcd Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 20 Jul 2012 14:28:13 -0400 Subject: [PATCH 590/947] add attribution to history file for previous patch --- docs/en/history.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/en/history.rst b/docs/en/history.rst index 0a11220..487060d 100644 --- a/docs/en/history.rst +++ b/docs/en/history.rst @@ -8,7 +8,8 @@ dev - mkvirtualenv_help should use ``$VIRTUALENVWRAPPER_PYTHON`` instead of calling ``virtualenv`` directly (:bbissue:`148`). - Fix issue with lazy-loader code under zsh (:bbissue:`144`). - - Fix issue with ``noclobber`` option under zsh (:bbissue:`137`). + - Fix issue with ``noclobber`` option under zsh + (:bbissue:`137`). Fix based on patch from :bbuser:`rob_b`. .. _stevedore: http://pypi.python.org/pypi/stevedore From 286df2cd26dd543c357ef50c6fd48c157a836f66 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 20 Jul 2012 15:13:04 -0400 Subject: [PATCH 591/947] move es and ja versions of docs to their own repositories --HG-- rename : docs/en/command_ref.rst => docs/source/command_ref.rst rename : docs/sphinx/conf.py => docs/source/conf.py rename : docs/en/developers.rst => docs/source/developers.rst rename : docs/en/extensions.rst => docs/source/extensions.rst rename : docs/en/history.rst => docs/source/history.rst rename : docs/en/hooks.rst => docs/source/hooks.rst rename : docs/en/index.rst => docs/source/index.rst rename : docs/en/install.rst => docs/source/install.rst rename : docs/en/plugins.rst => docs/source/plugins.rst rename : docs/en/projects.rst => docs/source/projects.rst rename : docs/en/scripts.rst => docs/source/scripts.rst rename : docs/en/tips.rst => docs/source/tips.rst --- Makefile | 20 +- docs/Makefile | 207 +++++--- docs/es/command_ref.rst | 327 ------------ docs/es/developers.rst | 69 --- docs/es/extensions.rst | 45 -- docs/es/history.rst | 184 ------- docs/es/hooks.rst | 13 - docs/es/index.rst | 231 --------- docs/es/install.rst | 85 ---- docs/es/plugins.rst | 406 --------------- docs/es/scripts.rst | 185 ------- docs/es/tips.rst | 156 ------ docs/ja/command_ref.rst | 739 ---------------------------- docs/ja/developers.rst | 198 -------- docs/ja/extensions.rst | 99 ---- docs/ja/history.rst | 529 -------------------- docs/ja/hooks.rst | 22 - docs/ja/index.rst | 355 ------------- docs/ja/install.rst | 458 ----------------- docs/ja/plugins.rst | 612 ----------------------- docs/ja/projects.rst | 56 --- docs/ja/scripts.rst | 361 -------------- docs/ja/tips.rst | 261 ---------- docs/{en => source}/command_ref.rst | 0 docs/{sphinx => source}/conf.py | 3 +- docs/{en => source}/developers.rst | 0 docs/{en => source}/extensions.rst | 0 docs/{en => source}/history.rst | 0 docs/{en => source}/hooks.rst | 0 docs/{en => source}/index.rst | 0 docs/{en => source}/install.rst | 0 docs/{en => source}/plugins.rst | 0 docs/{en => source}/projects.rst | 0 docs/{en => source}/scripts.rst | 0 docs/{en => source}/tips.rst | 0 35 files changed, 137 insertions(+), 5484 deletions(-) delete mode 100644 docs/es/command_ref.rst delete mode 100644 docs/es/developers.rst delete mode 100644 docs/es/extensions.rst delete mode 100644 docs/es/history.rst delete mode 100644 docs/es/hooks.rst delete mode 100644 docs/es/index.rst delete mode 100644 docs/es/install.rst delete mode 100644 docs/es/plugins.rst delete mode 100644 docs/es/scripts.rst delete mode 100644 docs/es/tips.rst delete mode 100644 docs/ja/command_ref.rst delete mode 100644 docs/ja/developers.rst delete mode 100644 docs/ja/extensions.rst delete mode 100644 docs/ja/history.rst delete mode 100644 docs/ja/hooks.rst delete mode 100644 docs/ja/index.rst delete mode 100644 docs/ja/install.rst delete mode 100644 docs/ja/plugins.rst delete mode 100644 docs/ja/projects.rst delete mode 100644 docs/ja/scripts.rst delete mode 100644 docs/ja/tips.rst rename docs/{en => source}/command_ref.rst (100%) rename docs/{sphinx => source}/conf.py (98%) rename docs/{en => source}/developers.rst (100%) rename docs/{en => source}/extensions.rst (100%) rename docs/{en => source}/history.rst (100%) rename docs/{en => source}/hooks.rst (100%) rename docs/{en => source}/index.rst (100%) rename docs/{en => source}/install.rst (100%) rename docs/{en => source}/plugins.rst (100%) rename docs/{en => source}/projects.rst (100%) rename docs/{en => source}/scripts.rst (100%) rename docs/{en => source}/tips.rst (100%) diff --git a/Makefile b/Makefile index 1ba267c..cf7ac67 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,6 @@ help: @echo "develop - install development version" @echo "test - run the test suite" @echo "test-quick - run the test suite for bash and one version of Python ($(PYTHON26))" - @echo "website - generate web version of the docs" - @echo "installwebsite - copy web version of HTML docs up to server" .PHONY: sdist sdist: html @@ -20,28 +18,12 @@ sdist: html # Documentation .PHONY: html html: - (cd docs && $(MAKE) html LANGUAGE="en") - (cd docs && $(MAKE) html LANGUAGE="es") - (cd docs && $(MAKE) html LANGUAGE="ja") + (cd docs && $(MAKE) html) .PHONY: docclean docclean: rm -rf docs/build docs/html -# Website copy of documentation -.PHONY: website -website: - [ ~/Devel/doughellmann/doughellmann/templates/base.html -nt docs/sphinx/web/templates/base.html ] && (echo "Updating base.html" ; cp ~/Devel/doughellmann/doughellmann/templates/base.html docs/sphinx/web/templates/base.html) || exit 0 - rm -rf docs/website - (cd docs && $(MAKE) html BUILDDIR="website/en" LANGUAGE="en") - (cd docs && $(MAKE) html BUILDDIR="website/es" LANGUAGE="es") - (cd docs && $(MAKE) html BUILDDIR="website/ja" LANGUAGE="ja") - -installwebsite: website - (cd docs/website/en && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper/) - (cd docs/website/es && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper/es/) - (cd docs/website/ja && rsync --rsh=ssh --archive --delete --verbose . www.doughellmann.com:/var/www/doughellmann/DocumentRoot/docs/virtualenvwrapper/ja/) - # Register the new version on pypi .PHONY: register register: diff --git a/docs/Makefile b/docs/Makefile index 50cb69f..cc33f87 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,92 +1,153 @@ # Makefile for Sphinx documentation # -# If doc language is English you don't need to set this variable -LANGUAGE = en - # You can set these variables from the command line. -SPHINXOPTS = -c sphinx +SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = -BUILDDIR = html/$(LANGUAGE) +BUILDDIR = build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d build/$(LANGUAGE)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(LANGUAGE) +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source -.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext help: @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " dirhtml to make HTML files named index.html in directories" - @echo " pickle to make pickle files" - @echo " json to make JSON files" - @echo " htmlhelp to make HTML files and a HTML help project" - @echo " qthelp to make HTML files and a qthelp project" - @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" - @echo " changes to make an overview of all changed/added/deprecated items" - @echo " linkcheck to check all external links for integrity" - @echo " doctest to run all doctests embedded in the documentation (if enabled)" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf $(BUILDDIR)/* html: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR) - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)." - -# dirhtml: -# $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml -# @echo -# @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." - -# pickle: -# $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle -# @echo -# @echo "Build finished; now you can process the pickle files." - -# json: -# $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json -# @echo -# @echo "Build finished; now you can process the JSON files." - -# htmlhelp: -# $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp -# @echo -# @echo "Build finished; now you can run HTML Help Workshop with the" \ -# ".hhp project file in $(BUILDDIR)/htmlhelp." - -# qthelp: -# $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp -# @echo -# @echo "Build finished; now you can run "qcollectiongenerator" with the" \ -# ".qhcp project file in $(BUILDDIR)/qthelp, like this:" -# @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/virtualenvwrapper.qhcp" -# @echo "To view the help file:" -# @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/virtualenvwrapper.qhc" - -# latex: -# $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex -# @echo -# @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." -# @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ -# "run these through (pdf)latex." - -# changes: -# $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes -# @echo -# @echo "The overview file is in $(BUILDDIR)/changes." - -# linkcheck: -# $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck -# @echo -# @echo "Link check complete; look for any errors in the above output " \ -# "or in $(BUILDDIR)/linkcheck/output.txt." - -# doctest: -# $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest -# @echo "Testing of doctests in the sources finished, look at the " \ -# "results in $(BUILDDIR)/doctest/output.txt." + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/virtualenvwrapper.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/virtualenvwrapper.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/virtualenvwrapper" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/virtualenvwrapper" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." diff --git a/docs/es/command_ref.rst b/docs/es/command_ref.rst deleted file mode 100644 index 0b8384d..0000000 --- a/docs/es/command_ref.rst +++ /dev/null @@ -1,327 +0,0 @@ -.. Quick reference documentation for virtualenvwrapper command line functions - Originally contributed Thursday, May 28, 2009 by Steve Steiner (ssteinerX@gmail.com) - -.. _command: - -###################### -Referencia de comandos -###################### - -Todos los comandos, mostrados a continuación, son para ser utilizados -en una Terminal de línea de comandos. - -==================== -Administrar entornos -==================== - -.. _command-mkvirtualenv: - -mkvirtualenv ------------- - -Crea un nuevo entorno, dentro de WORKON_HOME. - -Sintaxis:: - - mkvirtualenv [options] ENVNAME - -Todas las opciones de línea de comandos son pasados directamente a -``virtualenv``. El nuevo entorno es automáticamente activado luego de su -inicialización. - -:: - - $ workon - $ mkvirtualenv mynewenv - New python executable in mynewenv/bin/python - Installing distribute............................................. - .................................................................. - .................................................................. - done. - (mynewenv)$ workon - mynewenv - (mynewenv)$ - -.. seealso:: - - * :ref:`scripts-premkvirtualenv` - * :ref:`scripts-postmkvirtualenv` - -rmvirtualenv ------------- - -Elimina un entorno, dentro de WORKON_HOME. - -Sintaxis:: - - rmvirtualenv ENVNAME - -Debes usar :ref:`command-deactivate` antes de eliminar el entorno actual. - -:: - - (mynewenv)$ deactivate - $ rmvirtualenv mynewenv - $ workon - $ - -.. seealso:: - - * :ref:`scripts-prermvirtualenv` - * :ref:`scripts-postrmvirtualenv` - -.. _command-cpvirtualenv: - -cpvirtualenv ------------- - -Duplica un entorno, dentro de WORKON_HOME. - -Sintaxis:: - - cpvirtualenv ENVNAME TARGETENVNAME - -.. note:: - - El entorno creado por la operación de copia es hecho `reubicable - `__. - -:: - - $ workon - $ mkvirtualenv source - New python executable in source/bin/python - Installing distribute............................................. - .................................................................. - .................................................................. - done. - (source)$ cpvirtualenv source dest - Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/easy_install relative - Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/easy_install-2.6 relative - Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/pip relative - Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/postactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) - Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/postdeactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) - Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/preactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) - Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/predeactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) - (dest)$ workon - dest - source - (dest)$ - -.. seealso:: - - * :ref:`scripts-precpvirtualenv` - * :ref:`scripts-postcpvirtualenv` - * :ref:`scripts-premkvirtualenv` - * :ref:`scripts-postmkvirtualenv` - -============================== -Controlar los entornos activos -============================== - -workon ------- - -Lista o cambia el entorno de trabajo actual - -Sintaxis:: - - workon [environment_name] - -Si no se especifica el ``environment_name``, la lista de entornos disponibles es -impresa en la salida estándar. - -:: - - $ workon - $ mkvirtualenv env1 - New python executable in env1/bin/python - Installing distribute............................................. - .................................................................. - .................................................................. - done. - (env1)$ mkvirtualenv env2 - New python executable in env2/bin/python - Installing distribute............................................. - .................................................................. - .................................................................. - done. - (env2)$ workon - env1 - env2 - (env2)$ workon env1 - (env1)$ echo $VIRTUAL_ENV - /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 - (env1)$ workon env2 - (env2)$ echo $VIRTUAL_ENV - /Users/dhellmann/Devel/virtualenvwrapper/tmp/env2 - (env2)$ - - -.. seealso:: - - * :ref:`scripts-predeactivate` - * :ref:`scripts-postdeactivate` - * :ref:`scripts-preactivate` - * :ref:`scripts-postactivate` - -.. _command-deactivate: - -deactivate ----------- - -Cambia de un entorno virtual a la versión instalada de Python en el sistema. - -Sintaxis:: - - deactivate - -.. note:: - - Este comando es actualmente parte de virtualenv, pero es encapsulado para - proveer ganchos antes y después, al igual que workon hace para *activate*. - -:: - - $ workon - $ echo $VIRTUAL_ENV - - $ mkvirtualenv env1 - New python executable in env1/bin/python - Installing distribute............................................. - .................................................................. - .................................................................. - done. - (env1)$ echo $VIRTUAL_ENV - /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 - (env1)$ deactivate - $ echo $VIRTUAL_ENV - - $ - -.. seealso:: - - * :ref:`scripts-predeactivate` - * :ref:`scripts-postdeactivate` - -====================================== -Rápida navegación dentro de virtualenv -====================================== - -Existen dos funciones que proveen atajos para navegar dentro del virtualenv -actualmente activado. - -cdvirtualenv ------------- - -Cambia el directorio de trabajo actual hacia ``$VIRTUAL_ENV``. - -Sintaxis:: - - cdvirtualenv [subdir] - -Al llamar ``cdvirtualenv`` se cambia el directorio de trabajo actual hacia la -sima de virtualenv (``$VIRTUAL_ENV``). Un argumento adicional es agregado a la -ruta, permitiendo navegar directamente dentro de un subdirectorio. - -:: - - $ mkvirtualenv env1 - New python executable in env1/bin/python - Installing distribute............................................. - .................................................................. - .................................................................. - done. - (env1)$ echo $VIRTUAL_ENV - /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 - (env1)$ cdvirtualenv - (env1)$ pwd - /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 - (env1)$ cdvirtualenv bin - (env1)$ pwd - /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1/bin - -cdsitepackages --------------- - -Cambia el directorio de trabajo actual al ``site-packages`` del -``$VIRTUAL_ENV``. - -Sintaxis:: - - cdsitepackages [subdir] - -Debido a que la ruta exacta hacia el directorio site-packages dentro del -virtualenv depende de la versión de Python, ``cdsitepackages`` es provisto como -un atajo para ``cdvirtualenv lib/python${pyvers}/site-packages``. Un argumento -opcional también está permitido, para especificar un directorio heredado dentro -del directorio ``site-packages`` y así ingresar a este. - -:: - - $ mkvirtualenv env1 - New python executable in env1/bin/python - Installing distribute............................................. - .................................................................. - .................................................................. - done. - (env1)$ echo $VIRTUAL_ENV - /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 - (env1)$ cdsitepackages PyMOTW/bisect/ - (env1)$ pwd - /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1/lib/python2.6/site-packages/PyMOTW/bisect - -lssitepackages --------------- - -``lssitepackages`` muestra el contenido del directorio ``site-packages`` -del entorno actualmente activado. - -Sintaxis:: - - lssitepackages - -:: - - $ mkvirtualenv env1 - New python executable in env1/bin/python - Installing distribute............................................. - .................................................................. - .................................................................. - done. - (env1)$ $ workon env1 - (env1)$ lssitepackages - distribute-0.6.10-py2.6.egg pip-0.6.3-py2.6.egg - easy-install.pth setuptools.pth - -======================= -Administración de rutas -======================= - -add2virtualenv --------------- - -Agrega los directorios especificados al path de Python para el entorno virtual -actualmente activo. - -Sintaxis:: - - add2virtualenv directory1 directory2 ... - -A veces esto es útli para compartir paquetes instalados que no están en el -directorio ``site-pacakges`` del sistema y no deben ser instalados en cada -entorno virtual. Una posible solución es crear enlaces simbólicos (*symlinks*) -hacia el código dentro del directorio ``site-packages`` del entorno, pero -también es fácil agregar a la variable PYTHONPATH directorios extras que están -incluidos en los archivos ``.pth`` dentro de ``site-packages`` usando ``add2virtualenv``. - -1. Descarga (*check out*) el código de un proyecto grande, como Django. -2. Ejecuta: ``add2virtualenv path_to_source``. -3. Ejecuta: ``add2virtualenv``. -4. Un mensaje de uso y una lista de las rutas "extras" actuales es impreso. - -Los nombres de los directorios son agregados a un archivo llamado -``virtualenv_path_extensions.pth`` dentro del directorio site-packages de este -entorno. - -*Basado en una contribución de James Bennett y Jannis Leidel.* diff --git a/docs/es/developers.rst b/docs/es/developers.rst deleted file mode 100644 index 03cf739..0000000 --- a/docs/es/developers.rst +++ /dev/null @@ -1,69 +0,0 @@ -#################### -Para desarrolladores -#################### - -Si quieres contribuir con virtualenvwrapper directamente, estas instrucciones -deberían ayudarte a empezar. Parches, reporte de bugs, y propuestas de -características son todas bienvenidas a través del `sitio de BitBucket -`_. Contribuciones en la -forma de parches o solicitud de *pull* son fáciles de integrar y recibirán -prioridad en la atención. - -.. note:: - - Antes de contribuir con nuevas características al *core* de virtualenvwrapper, - por favor considera, en vez, si no debe ser implementada como una extensión. - -Construir la documentación -========================== - -La documentación para virtualenvwrapper está escrita en reStructuredText y -convertida a HTML usando Sphinx. La propia construcción es impulsada por make. -Necesitas los siguientes paquetes para construir la documentación: - -- Sphinx -- docutils - -Una vez que todas las herramientas están instaladas dentro de un virtualenv -usando pip, ejecuta ``make html`` para generar la versión de HTML de la -documentación:: - - $ make html - rm -rf virtualenvwrapper/docs - (cd docs && make html SPHINXOPTS="-c sphinx/pkg") - sphinx-build -b html -d build/doctrees -c sphinx/pkg source build/html - Running Sphinx v0.6.4 - loading pickled environment... done - building [html]: targets for 2 source files that are out of date - updating environment: 0 added, 2 changed, 0 removed - reading sources... [ 50%] command_ref - reading sources... [100%] developers - - looking for now-outdated files... none found - pickling environment... done - checking consistency... done - preparing documents... done - writing output... [ 33%] command_ref - writing output... [ 66%] developers - writing output... [100%] index - - writing additional files... search - copying static files... WARNING: static directory '/Users/dhellmann/Devel/virtualenvwrapper/plugins/docs/sphinx/pkg/static' does not exist - done - dumping search index... done - dumping object inventory... done - build succeeded, 1 warning. - - Build finished. The HTML pages are in build/html. - cp -r docs/build/html virtualenvwrapper/docs - -La versión de publicación de la documentación termina dentro de -``./virtualenvwrapper/docs`` - -Ejecutar tests -============== - -La suite de test para virtualenvwrapper usa `shunit2 -`_. Para ejecutar los tests en bash, sh, y zsh, -usa ``make test``. - diff --git a/docs/es/extensions.rst b/docs/es/extensions.rst deleted file mode 100644 index 56924f7..0000000 --- a/docs/es/extensions.rst +++ /dev/null @@ -1,45 +0,0 @@ -======================== - Extensiones existentes -======================== - -Debajo se listan algunas de las extensiones disponibles para usar con -virtualenvwrapper. - -.. _extensions-user_scripts: - -project -======= - -La extensión project_ agrega la gestión del desarrollo de directorios con -plantillas para virtualenvwrapper. - -bitbucket ---------- - -La plantilla de proyecto bitbucket_ crea un directorio de trabajo y -automáticamente clona el repositorio desde BitBucket. Requiere project_ - -.. _project: http://www.doughellmann.com/projects/virtualenvwrapper.project/ - -.. _bitbucket: http://www.doughellmann.com/projects/virtualenvwrapper.bitbucket/ - -emacs-desktop -============= - -Emacs desktop-mode_ te permite guardar el estado de emacs (buffers abiertos, -posiciones de buffers, etc.) entre sesiones. También puede ser usado como un -archivo de proyecto similar a otros IDEs. El plugin emacs-desktop_ agrega -un disparador para guardar el archivo de proyecto actual y cargar uno nuevo -cuando se active un nuevo entorno usando ``workon``. - -.. _desktop-mode: http://www.emacswiki.org/emacs/DeskTop - -.. _emacs-desktop: http://www.doughellmann.com/projects/virtualenvwrapper-emacs-desktop/ - -user_scripts -============ - -La extensión ``user_scripts`` es distribuida con virtualenvwrapper y está -habilitada por default. Implementa la característica de script de personalización -de usuarios descrita en :ref:`scripts`. - diff --git a/docs/es/history.rst b/docs/es/history.rst deleted file mode 100644 index 0636f95..0000000 --- a/docs/es/history.rst +++ /dev/null @@ -1,184 +0,0 @@ -=============== -Release History -=============== - -2.1 - - - Add support for ksh. Thanks to Doug Latornell for doing the - research on what needed to be changed. - - Test import of virtualenvwrapper.hook_loader on startup and report - the error in a way that should help the user figure out how to fix - it (issue #33). - - Update :ref:`command-mkvirtualenv` documentation to include the - fact that a new environment is activated immediately after it is - created (issue #30). - - Added hooks around :ref:`command-cpvirtualenv`. - - Made deactivation more robust, especially under ksh. - - Use Python's ``tempfile`` module for creating temporary filenames - safely and portably. - - Fix a problem with ``virtualenvwrapper_show_workon_options`` that - caused it to show ``*`` as the name of a virtualenv when no - environments had yet been created. - - Change the hook loader so it can be told to run only a set of - named hooks. - - Add support for listing the available hooks, to be used in help - output of commands like virtualenvwrapper.project's mkproject. - - Fix mkvirtualenv -h option behavior. - - Change logging so the $WORKON_HOME/hook.log file rotates after - 10KiB. - -2.0.2 - - - Fixed issue #32, making virtualenvwrapper.user_scripts compatible - with Python 2.5 again. - -2.0.1 - - - Fixed issue #29, to use a default value for ``TMPDIR`` if it is - not set in the user's shell environment. - -2.0 - - - Rewrote hook management using Distribute_ entry points to make it - easier to share extensions. - -.. _Distribute: http://packages.python.org/distribute/ - -1.27 - - - Added cpvirtualenv command [Thomas Desvenain] - -1.26 - - - Fix a problem with error messages showing up during init for users - with the wrappers installed site-wide but who are not actually - using them. See issue #26. - - Split up the tests into multiple files. - - Run all tests with all supported shells. - -1.25 - - - Merged in changes to cdsitepackages from William McVey. It now - takes an argument and supports tab-completion for directories - within site-packages. - -1.24.2 - - - Add user provided :ref:`tips-and-tricks` section. - - Add link to Rich Leland's screencast to :ref:`references` section. - -1.24.1 - - - Add license text to the header of the script. - -1.24 - - - Resolve a bug with the preactivate hook not being run properly. - Refer to issue #21 for complete details. - -1.23 - - - Resolve a bug with the postmkvirtualenv hook not being run - properly. Refer to issues #19 and #20 for complete details. - -1.22 - - - Automatically create any missing hook scripts as stubs with - comments to expose the feature in case users are not aware of it. - -1.21 - - - Better protection of ``$WORKON_HOME`` does not exist when the wrapper script is sourced. - -1.20 - - - Incorporate lssitepackages feature from Sander Smits. - - Refactor some of the functions that were using copy-and-paste code to build path names. - - Add a few tests. - -1.19 - - - Fix problem with add2virtualenv and relative paths. Thanks to Doug Latornell for the bug report James Bennett for the suggested fix. - -1.18.1 - - - Incorporate patch from Sascha Brossmann to fix a issue #15. Directory normalization was causing ``WORKON_HOME`` to appear to be a missing directory if there were control characters in the output of ``pwd``. - -1.18 - - - Remove warning during installation if sphinxcontrib.paverutils is not installed. (#10) - - Added some basic developer information to the documentation. - - Added documentation for deactivate command. - -1.17 - - - Added documentation updates provided by Steve Steiner. - -1.16 - - - Merged in changes to ``cdvirtualenv`` from wam and added tests and docs. - - Merged in changes to make error messages go to stderr, also provided by wam. - -1.15 - - Better error handling in mkvirtualenv. - - Remove bogus VIRTUALENV_WRAPPER_BIN variable. - -1.14 - - Wrap the virtualenv version of deactivate() with one that lets us invoke - the predeactivate hooks. - - Fix virtualenvwrapper_show_workon_options for colorized versions of ls and - write myself a note so I don't break it again later. - - Convert test.sh to use true tests with `shunit2 `_ - -1.13 - - Fix issue #5 by correctly handling symlinks and limiting the list of envs to things - that look like they can be activated. - -1.12 - - Check return value of virtualenvwrapper_verify_workon_home everywhere, thanks to - Jeff Forcier for pointing out the errors. - - Fix instructions at top of README, pointed out by Matthew Scott. - - Add cdvirtualenv and cdsitepackages, contributed by James Bennett. - - Enhance test.sh. - -1.11 - - Optimize virtualenvwrapper_show_workon_options. - - Add global postactivate hook. - -1.10 - - Pull in fix for colorized ls from Jeff Forcier (b42a25f7b74a). - -1.9 - - Add more hooks for operations to run before and after creating or deleting environments based on changes from Chris Hasenpflug. - -1.8.1 - - Corrected a problem with change to mkvirtualenv that lead to release 1.8 by using an alternate fix proposed by James in comments on release 1.4. - -1.8 - - Fix for processing the argument list in mkvirtualenv from jorgevargas (BitBucket issue #1) - -1.7 - - Move to bitbucket.org for hosting - - clean up TODO list and svn keywords - - add license section below - -1.6.1 - - - More zsh support (fixes to rmvirtualenv) from Byron Clark. - -1.6 - - - Add completion support for zsh, courtesy of Ted Leung. - -1.5 - - - Fix some issues with spaces in directory or env names. They still don't really work with virtualenv, though. - - Added documentation for the postactivate and predeactivate scripts. - -1.4 - - - Includes a new .pth management function based on work contributed by James Bennett and Jannis Leidel. - -1.3.x - - - Includes a fix for a nasty bug in rmvirtualenv identified by John Shimek. diff --git a/docs/es/hooks.rst b/docs/es/hooks.rst deleted file mode 100644 index 10193fa..0000000 --- a/docs/es/hooks.rst +++ /dev/null @@ -1,13 +0,0 @@ -================================ - Personalizar Virtualenvwrapper -================================ - -virtualenvwrapper agrega varios ganchos que puedes usar para cambiar tus -configuraciones, el entorno del shell, u otras configuraciones al crear, -eliminar o cambiar entre entornos. Estos ganchos son expuestos en dos formas: - -.. toctree:: - :maxdepth: 1 - - scripts - plugins diff --git a/docs/es/index.rst b/docs/es/index.rst deleted file mode 100644 index c78197d..0000000 --- a/docs/es/index.rst +++ /dev/null @@ -1,231 +0,0 @@ -.. virtualenvwrapper documentation master file, created by - sphinx-quickstart on Thu May 28 22:35:13 2009. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -########################### -virtualenvwrapper |release| -########################### - -virtualenvwrapper es un conjunto de extensiones de la herramienta de Ian -Bicking `virtualenv `_. Las extensiones -incluyen funciones para la creación y eliminación de entornos virtuales y por otro -lado administración de tu rutina de desarrollo, haciendo fácil trabajar en más -de un proyecto al mismo tiempo sin introducir conflictos entre sus dependencias. - -=============== -Características -=============== - -1. Organiza todos tus entornos virtuales en un sólo lugar. -2. Funciones para administrar tus entornos virtuales (crear, eliminar, copiar). -3. Usa un sólo comando para cambiar entre los entornos. -4. Completa con Tab los comandos que toman un entorno virtual como argumento. -5. Ganchos configurables para todas las operaciones (ver :ref:`scripts`). -6. Sistema de plugins para la creación de extensiones compartibles (ver - :ref:`plugins`). - -============ -Introducción -============ - -La mejor forma de explicar las características que virtualenvwrapper brinda es -mostrarlo en acción. - -Primero, algunos pasos de inicialización. La mayoría de esto sólo necesita ser -hecho una sola vez. Vas a querer agregar el comando ``source -/usr/local/bin/virtualenvwrapper.sh`` al archivo de inicio de shell, cambiando -el path hacia virtualenvwrapper.sh dependiendo en dónde haya sido instalado por -pip. - -:: - - $ pip install virtualenvwrapper - ... - $ export WORKON_HOME=~/Envs - $ mkdir -p $WORKON_HOME - $ source /usr/local/bin/virtualenvwrapper.sh - $ mkvirtualenv env1 - Installing - distribute.......................................... - .................................................... - .................................................... - ...............................done. - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/predeactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/postdeactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/preactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/postactivate New python executable in env1/bin/python - (env1)$ ls $WORKON_HOME - env1 hook.log - -Ahora podemos instalar algún software dentro del entorno. - -:: - - (env1)$ pip install django - Downloading/unpacking django - Downloading Django-1.1.1.tar.gz (5.6Mb): 5.6Mb downloaded - Running setup.py egg_info for package django - Installing collected packages: django - Running setup.py install for django - changing mode of build/scripts-2.6/django-admin.py from 644 to 755 - changing mode of /Users/dhellmann/Envs/env1/bin/django-admin.py to 755 - Successfully installed django - -Podemos ver el nuevo paquete instalado con ``lssitepackages``:: - - (env1)$ lssitepackages - Django-1.1.1-py2.6.egg-info easy-install.pth - distribute-0.6.10-py2.6.egg pip-0.6.3-py2.6.egg - django setuptools.pth - -Por supuesto que no estamos limitados a un sólo virtualenv:: - - (env1)$ ls $WORKON_HOME - env1 hook.log - (env1)$ mkvirtualenv env2 - Installing distribute............................... - .................................................... - .................................................... - ........... ...............................done. - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/predeactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/postdeactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/preactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/postactivate New python executable in env2/bin/python - (env2)$ ls $WORKON_HOME - env1 env2 hook.log - -Cambiar entre entornos con ``workon``:: - - (env2)$ workon env1 - (env1)$ echo $VIRTUAL_ENV - /Users/dhellmann/Envs/env1 - (env1)$ - -El comando ``workon`` también incluye la opción de completar con Tab los nombres -de los entornos, e invoca a los scripts personalizados cuando un entorno es -activado o desactivado (ver :ref:`scripts`). - -:: - - (env1)$ echo 'cd $VIRTUAL_ENV' >> $WORKON_HOME/postactivate - (env1)$ workon env2 - (env2)$ pwd - /Users/dhellmann/Envs/env2 - -:ref:`scripts-postmkvirtualenv` es ejecutado cuando un nuevo entorno es creado, -dejándote instalar automáticamente herramientas comúnmente utilizadas. - -:: - - (env2)$ echo 'pip install sphinx' >> $WORKON_HOME/postmkvirtualenv - (env3)$ mkvirtualenv env3 - New python executable in env3/bin/python - Installing distribute............................... - .................................................... - .................................................... - ........... ...............................done. - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/predeactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/postdeactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/preactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/postactivate - Downloading/unpacking sphinx - Downloading Sphinx-0.6.5.tar.gz (972Kb): 972Kb downloaded - Running setup.py egg_info for package sphinx - no previously-included directories found matching 'doc/_build' - Downloading/unpacking Pygments>=0.8 (from sphinx) - Downloading Pygments-1.3.1.tar.gz (1.1Mb): 1.1Mb downloaded - Running setup.py egg_info for package Pygments - Downloading/unpacking Jinja2>=2.1 (from sphinx) - Downloading Jinja2-2.4.tar.gz (688Kb): 688Kb downloaded - Running setup.py egg_info for package Jinja2 - warning: no previously-included files matching '*' found under directory 'docs/_build/doctrees' - Downloading/unpacking docutils>=0.4 (from sphinx) - Downloading docutils-0.6.tar.gz (1.4Mb): 1.4Mb downloaded - Running setup.py egg_info for package docutils - Installing collected packages: docutils, Jinja2, Pygments, sphinx - Running setup.py install for docutils - Running setup.py install for Jinja2 - Running setup.py install for Pygments - Running setup.py install for sphinx - no previously-included directories found matching 'doc/_build' - Installing sphinx-build script to /Users/dhellmann/Envs/env3/bin - Installing sphinx-quickstart script to /Users/dhellmann/Envs/env3/bin - Installing sphinx-autogen script to /Users/dhellmann/Envs/env3/bin - Successfully installed docutils Jinja2 Pygments sphinx (env3)$ - (venv3)$ which sphinx-build - /Users/dhellmann/Envs/env3/bin/sphinx-build - -A través de una combinación de funciones existentes definidas por el *core* -del paquete (ver :ref:`command`), plugins de terceros (ver -:ref:`plugins`), y scripts definidos por el usuario (ver :ref:`scripts`) -virtualenvwrapper brinda una amplia variedad de oportunidades para automatizar -tareas repetitivas. - -======== -Detalles -======== - -.. toctree:: - :maxdepth: 2 - - install - command_ref - hooks - tips - developers - extensions - history - -.. _references: - -=========== -Referencias -=========== - -`virtualenv `_, de Ian -Bicking, es un pre-requisito para usar estas extensiones. - -Para más detalles, referirse a la columna que escribí para la revista de -python (Python Magazine) en Mayo de 2008: `virtualenvwrapper | And Now For Something -Completely Different -`_. - -Rich Leland ha grabado un pequeño `screencast -`__ -mostrando las características de virtualenvwrapper. - -======== -Licencia -======== - -Copyright Doug Hellmann, All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Doug Hellmann not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - -.. note:: - - Esta traducción fue realizada por `Manuel Kaufmann - `__. - -.. seealso:: - - * `La traducción al español `__ - - * The original `English version - `__ of the - documentation. diff --git a/docs/es/install.rst b/docs/es/install.rst deleted file mode 100644 index 9c3fd2a..0000000 --- a/docs/es/install.rst +++ /dev/null @@ -1,85 +0,0 @@ -=========== -Instalación -=========== - -Instalación básica -================== - -virtualenvwrapper debe ser instalado usando pip_:: - - $ pip install virtualenvwrapper - -Querrás instalarlo dentro del site-packages global de Python, junto con -virtualenv. Quizás necesites privilegios de administrador para hacer esto. - -WORKON_HOME -=========== - -La variable ``WORKON_HOME`` le indica a virtualenvwrapper cuál es el lugar de -tus entornos virtuales. El default es ``$HOME/.virtualenvs``. -Este directorio debe ser creado antes de usar cualquier comando de -virtualenvwrapper. - -.. _install-shell-config: - -Archivo de inicio del shell -=========================== - -Agrega estas dos líneas a tu archivo de inicio del shell (``.bashrc``, ``.profile``, -etc.) para configurar la ubicación dónde se van a guardar los entornos virtuales -y los scripts instalados con este paquete:: - - export WORKON_HOME=$HOME/.virtualenvs - source /usr/local/bin/virtualenvwrapper.sh - -Después de editar este, recarga el archivo de inicio (por ejemplo, ejecuta: ``source -~/.bashrc``). - -Intérprete de Python y $PATH -============================ - -Durante el inicio, ``virtualenvwrapper.sh`` busca el primer ``python`` en la -variable ``$PATH`` y recuerda éste para su posterior uso. Esto elimina cualquier -conflicto con los cambios en ``$PATH``, permitiendo intérpretes dentro de -entornos en los cuales virtualenvwrapper no está instalado. Debido a este -comportamiento, es importante configurar la variable ``$PATH`` **antes** de -hacer la inclusión de ``virtualenvwrapper.sh`` (mediante ``source``). Por -ejemplo:: - - export PATH=/usr/local/bin:$PATH - source /usr/local/bin/virtualenvwrapper.sh - -Para reemplazar la búsqueda en ``$PATH``, se puede configurar la variable -``VIRTUALENVWRAPPER_PYTHON`` hacia la ruta absoluta del intérprete a usar -(también **antes** de incluir ``virtualenvwrapper.sh``). Por ejemplo:: - - export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python - source /usr/local/bin/virtualenvwrapper.sh - -Inicio rápido -============= - -1. Ejecuta: ``workon`` -2. Una lista de entornos, vacía, es impresa. -3. Ejecuta: ``mkvirtualenv temp`` -4. Un nuevo entorno, ``temp`` es creado y activado. -5. Ejecuta: ``workon`` -6. Esta vez, el entorno ``temp`` es incluido. - -Archivos temporales -=================== - -virtualenvwrapper crea archivos temporales en ``$TMPDIR``. Si la variable no -está configurada, este usa ``/tmp``. Para cambiar la ubicación de los archivos -temporales sólo para virtualenvwrapper, configura ``VIRTUALENVWRAPPER_TMPDIR``. - -Actualizar desde 1.x -==================== - -El script de shell que contiene las funciones ha sido renombrado en la serie -2.x para reflejar el hecho de que otros shells, además de bash, son soportados. En -tu archivo de inicio del shell, cambia ``source -/usr/local/bin/virtualenvwrapper_bashrc`` por ``source -/usr/local/bin/virtualenvwrapper.sh``. - -.. _pip: http://pypi.python.org/pypi/pip diff --git a/docs/es/plugins.rst b/docs/es/plugins.rst deleted file mode 100644 index fca3be6..0000000 --- a/docs/es/plugins.rst +++ /dev/null @@ -1,406 +0,0 @@ -.. _plugins: - -========================== -Extender Virtualenvwrapper -========================== - -Una gran experiencia con soluciones caseras para personalizar un entorno de -desarrollo ha demostrado cuán valioso puede ser tener la capacidad de -automatizar tareas comunes y eliminar molestias persistentes. Carpinteros -construyen plantillas de guía, desarrolladores de software escriben scripts de -shell. virtualenvwrapper continúa la tradición de animar a un artesano a -modificar sus herramientas para trabajar de la manera que ellos quieran, en vez -de al revés. - -Usa los ganchos provistos para eliminar operaciones manuales repetitivas y hacer -más simple tu flujo de desarrollo. Por ejemplo, configura los ganchos -:ref:`plugins-pre_activate` y :ref:`plugins-post_activate` para provocar que un -IDE cargue un proyecto o recargue los archivos desde la última sesión de -edición, administra el logueo de horas, o inicia y detiene versiones de -desarrollo de un servidor de aplicaciones. Usa el gancho -:ref:`plugins-initialize` para agregar nuevos comandos y ganchos a -virtualenvwrapper. Los ganchos :ref:`plugins-pre_mkvirtualenv` y -:ref:`plugins-post_mkvirtualenv` te brindan la oportunidad de instalar -requerimientos básicos dentro de cada nuevo entorno de desarrollo, inicializar -el repositorio de control de versiones para el código, o por otro lado -configurar un nuevo proyecto. - -Existen dos maneras para adjuntar tu código para que virtualenvwrapper lo -ejecute: los usuarios finales pueden usar scripts de shell o otros programas -para la personalización personal (ver :ref:`scripts`). Las extensiones también -pueden ser implementadas en Python usando *puntos de entrada* con Distribute_ , - -Definir una extensión -===================== - -.. note:: - - Virtualenvwrapper es distribuido con un plugin para la creación y ejecución de - los scripts de personalización de los usuarios (:ref:`extensions-user_scripts`). - Los ejemplos siguientes han sido tomados de la implementación de ese plugin. - -Organización del código ------------------------ - -El paquete Python para ``virtualenvwrapper`` es un *namespace package*. -Eso significa que múltiples librerías pueden instalar código dentro del paquete, -incluso si ellas no son distribuidas juntas o instaladas dentro del mismo -directorio. Las extensiones pueden (opcionalmente) usar el namespace de -``virtualenvwrapper`` configurando su estructura de directorios así: - -* virtualenvwrapper/ - - * __init__.py - * user_scripts.py - -Y agregando el siguiente código dentro de ``__init__.py``:: - - """virtualenvwrapper module - """ - - __import__('pkg_resources').declare_namespace(__name__) - -.. note:: - - Las extensiones pueden ser cargadas desde cualquier paquete, así que usar el - espacio de nombres de ``virtualenvwrapper`` no es requerido. - -Extensión API -------------- - -Después de que el paquete está establecido, el siguiente paso es crear un módulo -para alojar el código de la extensión. Por ejemplo, -``virtualenvwrapper/user_scripts.py``. El módulo debe contener la extensión -actual a los *entry points*. Soporte de código puede ser incluido, o importado -desde algún lugar usando la técnica de organización de código estándar de -Python. - -FIXME: I don't like the last paragraph - -La API es la misma para todos los puntos de extensión. Cada uno usa una función -de Python que toma un sólo argumento, una lista de strings pasada al script que -carga los ganchos en la línea de comandos. - -:: - - def function_name(args): - # args is a list of strings passed to the hook loader - -El contenido de la lista de argumentos está definida para cada punto de -extensión a continuación (ver :ref:`plugins-extension-points`). - -Invocación de la extensión --------------------------- - -Acción directa -~~~~~~~~~~~~~~ - -Los plugins pueden ser colgados a cada uno de los ganchos de dos formas -diferentes. La estándar es tener una función y hacer algún trabajo directamente. -Por ejemplo, la función ``initialize()`` para el plugin de los scripts de -usuarios crea scripts de usuarios por default cuando ``virtualenvwrapper.sh`` es -cargada. - -:: - - def initialize(args): - for filename, comment in GLOBAL_HOOKS: - make_hook(os.path.join('$WORKON_HOME', filename), comment) - return - -.. _plugins-user-env: - -Modificar el entorno de usuario -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Hay casos en dónde la extensión necesita actualizar el entorno del usuario (por -ejemplo, cambiar el directorio de trabajo actual o configurar variables de -entorno). Las modificaciones al entorno del usuario deben ser hechas dentro del -shell actual del usuario, y no pueden ser ejecutadas en un proceso separado. -Para tener código ejecutado en un proceso shell del usuario, las extensiones -pueden definir funciones gancho y retornar el texto de los comandos de shell -a ser ejecutados. Estos ganchos *fuente* son ejecutados después de los ganchos -comunes con el mismo nombre, y no deben hacer ningún trabajo por ellos mismos. - - -El gancho ``initialize_source()`` para el plugin de scripts de usuarios busca -un script ``initializa`` global y causa que este sea ejecutado en el proceso de -shell actual. - -:: - - def initialize_source(args): - return """ - # - # Run user-provided scripts - # - [ -f "$WORKON_HOME/initialize" ] && source "$WORKON_HOME/initialize" - """ - -.. warning:: - - Como las extensiones están modificando el shell de trabajo del usuario, se - debe tener mucho cuidado de corromper el entorno sobreescribiendo variables - con valores inesperados. Evita crear variables temporales cuando sea - posible. Poner prefijos a las variables con el nombre de la extensión es una - buena forma de manejar espacios de nombres. Por ejemplo, en vez de - ``temp_file`` usa ``user_scripts_temp_file``. Usa ``unset`` para liberar - nombres de variables temporales cuando no sean más necesarias. - -.. warning:: - - virtualenvwrapper funciona en varios shells con una sintaxis ligeramente - diferente (bash, sh, zsh, ksh). Ten en cuenta esta portabilidad cuando - definas ganchos incluidos (*sourced hooks*). Mantener la sintaxis lo más simple - posible evitará problemas comunes, pero quizás haya casos donde - examinar la variable de entorno ``SHELL`` y generar diferente sintaxis - para cada caso sea la única manera de alcanzar el resultado deseado. - -Registrar puntos de entrada ---------------------------- - -Las funciones definidas en el plugin necesitan ser registradas como *puntos de -entrada* para que el cargador de ganchos de virtualenvwrapper los encuentre. -Los puntos de entrada de Distribute_ se configuran en el ``setup.py`` de tu -paquete coincidiendo el nombre del punto de entrada con la función en el paquete -que lo implementa. - -Una copia parcial del ``setup.py`` de virtualenvwrapper ilustra cómo los puntos -de entrada ``initialize()`` y ``initialize_source()`` son configurados. - -:: - - # Bootstrap installation of Distribute - import distribute_setup - distribute_setup.use_setuptools() - - from setuptools import setup - - setup( - name = 'virtualenvwrapper', - version = '2.0', - - description = 'Enhancements to virtualenv', - - # ... details omitted ... - - namespace_packages = [ 'virtualenvwrapper' ], - - entry_points = { - 'virtualenvwrapper.initialize': [ - 'user_scripts = virtualenvwrapper.user_scripts:initialize', - ], - 'virtualenvwrapper.initialize_source': [ - 'user_scripts = virtualenvwrapper.user_scripts:initialize_source', - ], - - # ... details omitted ... - }, - ) - -El argumento ``entry_points`` de ``setup()`` es un diccionario que mapea los -*grupos de nombre* de puntos de entrada a listas de puntos de entrada -específicos. Un nombre de grupo diferente es definido por virtualenvwrapper por -cada punto de extensión (ver :ref:`plugins-extension-points`). - -Los identificadores de puntos de entrada son strings con la sintaxis ``name = -package.module:function``. Por convención, el *nombre* de cada punto de entrada -es el nombre del plugin, pero esto no es requerido (los nombres no son usados). - -.. seealso:: - - * `namespace packages `__ - * `Extensible Applications and Frameworks `__ - -El cargador de ganchos ----------------------- - -Las extensiones son ejecutadas mediante una aplicación de líneas de comando -implementada en ``virtualenvwrapper.hook_loader``. Como ``virtualenvwrapper.sh`` -es invocado primero y los usuarios generalmente no necesitan ejecutar la -aplicación directamente, ningún otro script es instalado por separado. En vez, -para ejecutar la aplicación, usa la opción ``-m`` del intérprete:: - - $ python -m virtualenvwrapper.hook_loader -h - Usage: virtualenvwrapper.hook_loader [options] [] - - Manage hooks for virtualenvwrapper - - Options: - -h, --help show this help message and exit - -s, --source Print the shell commands to be run in the current - shell - -l, --list Print a list of the plugins available for the given - hook - -v, --verbose Show more information on the console - -q, --quiet Show less information on the console - -n NAMES, --name=NAMES - Only run the hook from the named plugin - -Para ejecutar las extensiones para el gancho *initialize*:: - - $ python -m virtualenvwrapper.hook_loader -v initialize - -Para obtener los comandos de shell para el gancho *initialize*:: - - $ python -m virtualenvwrapper.hook_loader --source initialize - -En la práctica, en vez de invocar al cargador de ganchos directamente es -conveniente usar la función de shell, ``virtualenvwrapper_run_hook`` para -ejecutar los ganchos en ambos modos.:: - - $ virtualenvwrapper_run_hook initialize - -Todos los argumentos pasados a la función de shell son pasados directamente al -cargador de ganchos. - -Registro (*Logging*) --------------------- - -El cargador de ganchos configura el registro para que los mensajes sean escritos -en ``$WORKON_HOME/hook.log``. Los mensajes quizás sean escritos en stderr, -dependiendo de la flash verbose. Por default los mensajes con un nivel mayor o -igual a *info* se escriben en stderr, y los de nivel *debug* o mayor van al -archivo de registro. Usar el registro de esta forma provee un mecanismo -conveniente para que los usuarios controlen la verbosidad de las extensiones. - -Para usar el registro en tu extensión, simplemente instancia un registro y llama -a sus métodos ``info()``, ``debug()`` y otros métodos de mensajería. - -:: - - import logging - log = logging.getLogger(__name__) - - def pre_mkvirtualenv(args): - log.debug('pre_mkvirtualenv %s', str(args)) - # ... - -.. seealso:: - - * `Standard library documentation for logging `__ - * `PyMOTW for logging `__ - -.. _plugins-extension-points: - -Puntos de extensión -=================== - -Los nombres de los puntos de extensión para los plugins nativos siguen una -convención con varias partes: -``virtualenvwrapper.(pre|post)_[_source]``. ** es la acción tomada -por el usuario o virtualenvwrapper que provoca la extensión. ``(pre|post)`` -indica si llama a la extensión antes o después de un evento. El sufijo ``_source`` -es agregado para las extensiones que retornan código shell en vez de tomar una -acción directamente (ver :ref:`plugins-user-env`). - -.. _plugins-initialize: - -initialize ----------- - -Los ganchos ``virtualenvwrapper.initialize`` son ejecutados cada vez que -``virtualenvwrapper.sh`` es cargado en el entorno del usuario. El gancho -*initialize* puede ser usado para instalar plantillas para configurar archivos o -preparar el sistema para una operación correcta del plugin. - -.. _plugins-pre_mkvirtualenv: - -pre_mkvirtualenv ----------------- - -Los ganchos ``virtualenvwrapper.pre_mkvirtualenv`` son ejecutados después de que -el entorno es creado, pero antes de que el nuevo entorno sea activado. El -directorio de trabajo actual para cuando el gancho es ejecutado es ``$WORKON_HOME`` -y el nombre del nuevo entorno es pasado como un argumento. - -.. _plugins-post_mkvirtualenv: - -post_mkvirtualenv ------------------ - -Los ganchos ``virtualenvwrapper.post_mkvirtualenv`` son ejecutado después de que -un nuevo entorno sea creado y activado. ``$VIRTUAL_ENV`` es configurado para -apuntar al nuevo entorno. - -.. _plugins-pre_activate: - -pre_activate ------------- - -Los ganchos ``virtualenvwrapper.pre_activate`` son ejecutados justo antes -de que un entorno sea activado. El nombre del entorno es pasado como -primer argumento. - -.. _plugins-post_activate: - -post_activate -------------- - - -Los ganchos ``virtualenvwrapper.post_activate`` son ejecutados justo después -de que un entorno sea activado. ``$VIRTUAL_ENV`` apunta al entorno actual. - -.. _plugins-pre_deactivate: - -pre_deactivate --------------- - -Los ganchos ``virtualenvwrapper.pre_deactivate`` son ejecutados justo antes de -que un entorno sea desactivado. ``$VIRTUAL_ENV`` apunta al entorno actual. - -.. _plugins-post_deactivate: - -post_deactivate ---------------- - -Los ganchos ``virtualenvwrapper.post_deactivate`` son ejecutados justo después -de que un entorno sea desactivado. El nombre del entorno recién desactivado es -pasado como primer argumento. - -.. _plugins-pre_rmvirtualenv: - -pre_rmvirtualenv ----------------- - -Los ganchos ``virtualenvwrapper.pre_rmvirtualenv`` son ejecutados justo antes -de que un entorno sea eliminado. El nombre del entorno eliminado es pasado -como primer argumento. - -.. _plugins-post_rmvirtualenv: - -post_rmvirtualenv ------------------ - -Los ganchos ``virtualenvwrapper.post_rmvirtualenv`` son ejecutados justo después -de que un entorno haya sido eliminado. El nombre del entorno eliminado es pasado -como primer argumento. - - -Agregar nuevos puntos de extensión -================================== - -Los plugins que definen nuevas operaciones pueden también definir nuevos puntos -de extensión. No es necesario hacer ninguna configuración para permitir que el -cargador de ganchos encuentre las extensiones; documentar los nombres y agregar -llamadas a ``virtualenvwrapper_run_hook`` es suficiente para causar que ellos se -invoquen. - -El cargador de ganchos asume que todos los nombres de puntos de extensión -comienzan con ``virtualenvwrapper.`` y los nuevos plugins querrán usar su -propio espacio de nombres para agregar. Por ejemplo, la extensión project_ -define nuevos eventos para crear directorios del proyecto (pre y post). Esas son -llamadas a ``virtualenvwrapper.project.pre_mkproject`` y -``virtualenvwrapper.project.post_mkproject``. Estas son invocadas con:: - - virtualenvwrapper_run_hook project.pre_mkproject $project_name - -y:: - - virtualenvwrapper_run_hook project.post_mkproject - -respectivamente. - -.. _Distribute: http://packages.python.org/distribute/ - -.. _project: http://www.doughellmann.com/projects/virtualenvwrapper.project/ diff --git a/docs/es/scripts.rst b/docs/es/scripts.rst deleted file mode 100644 index ac3598f..0000000 --- a/docs/es/scripts.rst +++ /dev/null @@ -1,185 +0,0 @@ -.. _scripts: - -=============================== - Personalizaciones por usuario -=============================== - -Los scripts de personalización de usuarios finales son *incluidos* uno por uno -(permitiéndoles modificar su entorno de shell) o *ejecutados* como un programa externo -en el momento apropiado. - -.. _scripts-initialize: - -initialize -========== - - :Global/Local: global - :Argumento(s): ninguno - :Incluido/Ejecutado: incluido - -``$WORKON_HOME/initialize`` es incluido cuando ``virtualenvwrapper.sh`` -es cargado dentro de tu entorno. Usa este para ajustar configuraciones globales -cuando virtualenvwrapper es habilitado. - -.. _scripts-premkvirtualenv: - -premkvirtualenv -=============== - - :Global/Local: global - :Argumento(s): nombre de un nuevo virtualenv - :Incluido/Ejecutado: ejecutado - -``$WORKON_HOME/premkvirtualenv`` es ejecutado como un programa externo luego que -de un entorno virtual es creado pero antes de que el entorno actual sea cambiado -para apuntar al nuevo entorno. El directorio de trabajo actual para este script -es ``$WORKON_HOME`` y el nombre del nuevo entorno es pasado como argumento al -script. - -.. _scripts-postmkvirtualenv: - -postmkvirtualenv -================ - - :Global/Local: global - :Argumento(s): ninguno - :Incluido/Ejecutado: incluido - -``$WORKON_HOME/postmkvirtualenv`` es incluido después de que un nuevo entorno es -creado y activado. - -.. _scripts-precpvirtualenv: - -precpvirtualenv -=============== - - :Global/Local: global - :Argumento(s): nombre del entorno original, nombre del nuevo entorno - :Incluido/Ejecutado: ejecutado - -``$WORKON_HOME/precpvirtualenv`` es ejecutado como un programa externo luego de -que un entorno es duplicado y hecho reubicable, pero antes de que -``premkvirtualenv`` sea ejecutado o se haya cambiado al nuevo entorno creado. El -directorio de trabajo actual para este script es ``$WORKON_HOME`` y los nombres -del entorno original y el nuevo son pasados como argumento al script. - -.. _scripts-postcpvirtualenv: - -postcpvirtualenv -================ - - :Global/Local: global - :Argumento(s): ninguno - :Incluido/Ejecutado: incluido - -``$WORKON_HOME/postcpvirtualenv`` es incluido luego de que un nuevo entorno es -creado y activado. - -.. _scripts-preactivate: - -preactivate -=========== - - :Global/Local: global, local - :Argumento(s): nombre de entorno - :Incluido/Ejecutado: ejecutado - -El script global ``$WORKON_HOME/preactivate`` es ejecutado antes de que el nuevo -entorno sea habilitado. El nombre de entorno es pasado como primer argumento. - -El gancho ``$VIRTUAL_ENV/bin/preactivate`` es ejecutado antes de que el nuevo -entorno sea habilitado. El nombre del entorno es pasado como primer argumento. - -.. _scripts-postactivate: - -postactivate -============ - - :Global/Local: global, local - :Argumento(s): ninguno - :Incluido/Ejecutado: incluido - - -El script global ``$WORKON_HOME/postactivate`` es incluido luego de que el nuevo -entorno sea habilitado. ``$VIRTUAL_ENV`` hace referencia al nuevo entorno al -momento en el que se ejecuta el script. - -Este script de ejemplo añade un espacio entre el nombre del entorno virtual y la -tu variable PS1 haciendo uso de ``_OLD_VIRTUAL_PS1``. - -:: - - PS1="(`basename \"$VIRTUAL_ENV\"`) $_OLD_VIRTUAL_PS1" - -El script local ``$VIRTUAL_ENV/bin/postactivate`` es incluido luego de que el -nuevo entorno es habilitado. ``$VIRTUAL_ENV`` hace referencia al nuevo entorno -al momento en el que el script es ejecutado. - -Este script de ejemplo para el entorno PyMOTW cambia el directorio de trabajo -actual y la referencia de la variable PATH hacia el árbol que -contiene el código de PyMOTW. - -:: - - pymotw_root=/Users/dhellmann/Documents/PyMOTW - cd $pymotw_root - PATH=$pymotw_root/bin:$PATH - -.. _scripts-predeactivate: - -predeactivate -============= - - :Global/Local: local, global - :Argumento(s): ninguno - :Incluido/Ejecutado: incluido - -El script local ``$VIRTUAL_ENV/bin/predeactivate`` es incluido antes de que el entorno -actual sea desactivado, y puede ser usado para deshabilitar o limpiar -configuraciones en tu entorno. ``$VIRTUAL_ENV`` hace referencia al entorno viejo -al momento de ejecutar este script. - -El script global ``$WORKON_HOME/predeactivate`` es incluido antes de que el -entorno actual sea desactivado. ``$VIRTUAL_ENV`` hace referencia al entorno viejo -al momento de ejecutar este script. - -.. _scripts-postdeactivate: - -postdeactivate -============== - - :Global/Local: local, global - :Argumento(s): ninguno - :Incluido/Ejecutado: incluido - -El script ``$VIRTUAL_ENV/bin/postdeactivate`` es incluido luego de que el -entorno actual sea desactivado, y puede ser usado para deshabilitar o limpiar -configuraciones en tu entorno. El path hacia el entorno que recientemente se ha -desactivado está disponible en ``$VIRTUALENVWRAPPER_LAST_VIRTUALENV``. - -.. _scripts-prermvirtualenv: - -prermvirtualenv -=============== - - :Global/Local: global - :Argumento(s): nombre de entorno - :Incluido/Ejecutado: ejecutado - -EL script ``$WORKON_HOME/prermvirtualenv`` es ejecutado como un programa externo -antes de que el entorno sea eliminado. El path absoluto hacia el entorno es -pasado como argumento al script. - -.. _scripts-postrmvirtualenv: - -postrmvirtualenv -================ - - :Global/Local: global - :Argumento(s): nombre de entorno - :Incluido/Ejecutado: ejecutado - -El script ``$WORKON_HOME/postrmvirtualenv`` es ejecutado como un programa externo -luego de que el entorno sea eliminado. El path absoluto hacia el directorio del -entorno es pasado como argumento al script. - diff --git a/docs/es/tips.rst b/docs/es/tips.rst deleted file mode 100644 index 9a5d89f..0000000 --- a/docs/es/tips.rst +++ /dev/null @@ -1,156 +0,0 @@ -.. _tips-and-tricks: - -=================== - Consejos y Trucos -=================== - -Esta es una lista de contribuciones de usuarios para hacer virtualenv y -virtualenvwrapper incluso más útil. Si tienes tips para compartir, envíame un -email o deja un comentario en `esta entrada de mi blog -`__ -y lo agregaré aquí. - -Prompt zsh -========== - -De `Nat `_: - -Usando zsh, agregué algunas líneas a ``$WORKON_HOME/post(de)activate`` para -mostrar el virtualenv activo en el lado derecho de la pantalla en vez de a la -izquierda. - -En ``postactivate``:: - - PS1="$_OLD_VIRTUAL_PS1" - _OLD_RPROMPT="$RPROMPT" - RPROMPT="%{${fg_bold[white]}%}(env: %{${fg[green]}%}`basename \"$VIRTUAL_ENV\"`%{${fg_bold[white]}%})%{${reset_color}%} $RPROMPT" - -Agrega en ``postdeactivate``:: - - RPROMPT="$_OLD_RPROMPT" - -Ajusta los colores de acuerdo a tu gusto personal o a tu entorno. - -Actualizar las entradas de ``$PATH`` cacheadas -============================================== - -De `Nat `_: - -También agregué el comando 'rehas' a ``$WORKON_HOME/postactivate`` y -``$WORKON_HOME/postdeactivate`` porque estaba teniendo algunos problemas -con zsh ya que no actualizaba los paths inmediatamente. - -Atar el soporte para virtualenv de pip -====================================== - -Vía http://becomingguru.com/: - -Agrega esto al script de login de tu shell para indicarle a pip que use el mismo -directorio para virtualenv que para virtualenwrapper:: - - export PIP_VIRTUALENV_BASE=$WORKON_HOME - -y Vía Nat: - -además de lo que dijo becomingguru, esta línea es clave:: - - export PIP_RESPECT_VIRTUALENV=true - -Eso hace que pip detecte un virtualenv activo e instale dentro de este, sin -pasar el parámetro -E. - -Crear los directorio para trabajar en el proyecto -================================================= - -Vía `James `_: - -En el script ``postmkvirtualenv`` tengo lo siguiente para crear un directorio -basado en el nombre del proyecto, agregar ese directorio la path de python y -luego ingresar a este:: - - proj_name=$(echo $VIRTUAL_ENV|awk -F'/' '{print $NF}') - mkdir $HOME/projects/$proj_name - add2virtualenv $HOME/projects/$proj_name - cd $HOME/projects/$proj_name - - -En el script ``postactivate`` tengo configurado para que automáticamente ingrese -a este directorio cuando uso el comando workon:: - - proj_name=$(echo $VIRTUAL_ENV|awk -F'/' '{print $NF}') - cd ~/projects/$proj_name - -Ejecutar automáticamente workon cuando se ingresa a un directorio -================================================================= - -`Justin Lily escribió un post -`__ -sobre algún código que agrego a su entorno de shell para buscar en el directorio -cada vez que se ejecuta ``cd``. Si este encuentra un archivo llamado ``.venv``, -activa el entorno nombrado dentro. Una vez que se deja el directorio, el -virtualenv actual es automáticamente desactivado. - -`Harry Marr `__ -escribió una función similar que funciona con `repositorios git -`__. - -Instalar herramientas comunes automáticmante en nuevos entornos -=============================================================== - -Vía `rizumu `__: - -Tengo esto en postmkvirtualenv para instalar una configuración básica. - -:: - - $ cat postmkvirtualenv - #!/usr/bin/env bash - curl -O http://python-distribute.org/distribute_setup.p... />python distribute_setup.py - rm distribute_setup.py - easy_install pip==dev - pip install Mercurial - -Además, tengo un archivo de requerimiento de pip para instalar mis herramientas -de desarrollo. - -:: - - $ cat developer_requirements.txt - ipdb - ipython - pastescript - nose - http://douglatornell.ca/software/python/Nosy-1.0.tar.gz - coverage - sphinx - grin - pyflakes - pep8 - -Entonces, cada proyecto tiene su propio archivo de requerimientos para cosas -como PIL, psycopg2, django-apps, numpy, etc. - -Cambiar el comportamiento por default de ``cd`` -=============================================== - -Vía `mae `__: - -Esto se supone que es ejecutado después de workon, es como un gancho -``postactivate``. Basicamente sobreescribe ``cd`` para saber sobre VENV -entonces en vez de hacer ``cd`` para ir a ``~`` irá al root del venv, creo que -es muy práctico y no puedo vivir más sin esto. Si le pasas un path -apropiado entonces hará lo correcto. - -:: - - cd () { - if (( $# == 0 )) - then - builtin cd $VIRTUAL_ENV - else - builtin cd "$@" - fi - } - - cd - diff --git a/docs/ja/command_ref.rst b/docs/ja/command_ref.rst deleted file mode 100644 index 2ac9fcc..0000000 --- a/docs/ja/command_ref.rst +++ /dev/null @@ -1,739 +0,0 @@ -.. Quick reference documentation for virtualenvwrapper command line functions - Originally contributed Thursday, May 28, 2009 by Steve Steiner (ssteinerX@gmail.com) - -.. - ################# - Command Reference - ################# - -.. _command: - -#################### -コマンドリファレンス -#################### - -.. - All of the commands below are to be used on the Terminal command line. - -全てのコマンドは次のようにターミナル上で使用されます。 - -.. - ===================== - Managing Environments - ===================== - -================== -仮想環境を管理する -================== - -.. _command-mkvirtualenv: - -mkvirtualenv ------------- - -.. - Create a new environment, in the WORKON_HOME. - -WORKON_HOME に新たな仮想環境を作成します。 - -.. - Syntax:: - -構文:: - - mkvirtualenv [-a project_path] [-i package] [-r requirements_file] [virtualenv options] ENVNAME - -.. - All command line options except ``-a``, ``-i``, ``-r``, and ``-h`` are passed - directly to ``virtualenv``. The new environment is automatically - activated after being initialized. - -``-a``, ``-i``, ``-r``, ``-h`` を除いた全てのコマンドラインオプションは ``virtualenv`` へ直接的に渡されます。新しい仮想環境は初期化された後に自動的にアクティブ化されます。 - -:: - - $ workon - $ mkvirtualenv mynewenv - New python executable in mynewenv/bin/python - Installing distribute............................................. - .................................................................. - .................................................................. - done. - (mynewenv)$ workon - mynewenv - (mynewenv)$ - -.. - The ``-a`` option can be used to associate an existing project - directory with the new environment. - -``-a`` オプションは、既存のプロジェクトディレクトリに新しい環境を関連付けるのに使います。 - -.. - The ``-i`` option can be used to install one or more packages (by - repeating the option) after the environment is created. - -``-i`` オプションは、その環境を作成した後に指定したパッケージをインストールできます (このオプションを繰り返し使うことで複数のパッケージもインストールできます) 。 - -.. - The ``-r`` option can be used to specify a text file listing packages - to be installed. The argument value is passed to ``pip -r`` to be - installed. - -``-r`` オプションは、インストールしたいパッケージ一覧を保存したテキストファイルを指定するのに使います。この引数のファイル名は ``pip -r`` へ渡されてインストールが行われます。 - -.. seealso:: - - * :ref:`scripts-premkvirtualenv` - * :ref:`scripts-postmkvirtualenv` - * `requirements ファイルのフォーマット`_ - -.. _requirements file format: http://www.pip-installer.org/en/latest/requirement-format.html -.. _requirements ファイルのフォーマット: http://www.pip-installer.org/en/latest/requirements.html#the-requirements-file-format - -.. _command-mktmpenv: - -mktmpenv --------- - -.. - Create a new virtualenv in the ``WORKON_HOME`` directory. - -``WORKON_HOME`` ディレクトリに新しい環境を作成します。 - -.. - Syntax:: - -構文:: - - mktmpenv [VIRTUALENV_OPTIONS] - -.. - A unique virtualenv name is generated. - -一意な名前をもつ virtualenv 環境が生成されます。 - -:: - - $ mktmpenv - Using real prefix '/Library/Frameworks/Python.framework/Versions/2.7' - New python executable in 1e513ac6-616e-4d56-9aa5-9d0a3b305e20/bin/python - Overwriting 1e513ac6-616e-4d56-9aa5-9d0a3b305e20/lib/python2.7/distutils/__init__.py - with new content - Installing distribute............................................... - .................................................................... - .................................................................done. - This is a temporary environment. It will be deleted when deactivated. - (1e513ac6-616e-4d56-9aa5-9d0a3b305e20) $ - -.. _command-lsvirtualenv: - -lsvirtualenv ------------- - -.. - List all of the environments. - -全ての仮想環境を表示します。 - -.. - Syntax:: - -構文:: - - lsvirtualenv [-b] [-l] [-h] - --b - ブリーフモード、冗長な出力を無効にする - -.. Brief mode, disables verbose output. - --l - ロングモード、冗長な出力を有効にする(デフォルト) - -.. Long mode, enables verbose output. Default. - --h - lsvirtualenv のヘルプを表示する - -.. Print the help for lsvirtualenv. - -.. seealso:: - - * :ref:`scripts-get_env_details` - -.. _command-showvirtualenv: - -showvirtualenv --------------- - -.. - Show the details for a single virtualenv. - -1つの仮想環境の詳細を表示します。 - -.. - Syntax:: - -構文:: - - showvirtualenv [env] - -.. seealso:: - - * :ref:`scripts-get_env_details` - -.. _command-rmvirtualenv: - -rmvirtualenv ------------- - -.. - Remove an environment, in the WORKON_HOME. - -WORKON_HOME の仮想環境を削除します。 - -.. - Syntax:: - -構文:: - - rmvirtualenv ENVNAME - -.. - You must use :ref:`command-deactivate` before removing the current - environment. - -カレントの仮想環境を削除する前に :ref:`command-deactivate` を実行しなければなりません。 - -:: - - (mynewenv)$ deactivate - $ rmvirtualenv mynewenv - $ workon - $ - -.. seealso:: - - * :ref:`scripts-prermvirtualenv` - * :ref:`scripts-postrmvirtualenv` - -.. _command-cpvirtualenv: - -cpvirtualenv ------------- - -.. - Duplicate an environment, in the WORKON_HOME. - -WORKON_HOME の仮想環境を複製します。 - -.. - Syntax:: - -構文:: - - cpvirtualenv ENVNAME TARGETENVNAME - -.. note:: - - .. The environment created by the copy operation is made `relocatable - `__. - - コピー操作で作成された仮想環境は `再配置可能 `__ です。 - -:: - - $ workon - $ mkvirtualenv source - New python executable in source/bin/python - Installing distribute............................................. - .................................................................. - .................................................................. - done. - (source)$ cpvirtualenv source dest - Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/easy_install relative - Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/easy_install-2.6 relative - Making script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/pip relative - Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/postactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) - Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/postdeactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) - Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/preactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) - Script /Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/predeactivate cannot be made relative (it's not a normal script that starts with #!/Users/dhellmann/Devel/virtualenvwrapper/tmp/dest/bin/python) - (dest)$ workon - dest - source - (dest)$ - -.. seealso:: - - * :ref:`scripts-precpvirtualenv` - * :ref:`scripts-postcpvirtualenv` - * :ref:`scripts-premkvirtualenv` - * :ref:`scripts-postmkvirtualenv` - -.. - ================================== - Controlling the Active Environment - ================================== - -============================== -アクティブな仮想環境を制御する -============================== - -workon ------- - -.. - List or change working virtual environments - -作業する仮想環境を変更、または表示します。 - -.. - Syntax:: - -構文:: - - workon [environment_name] - -.. - If no ``environment_name`` is given the list of available environments - is printed to stdout. - -``environment_name`` が与えられない場合は標準出力に利用可能な仮想環境を表示します。 - -:: - - $ workon - $ mkvirtualenv env1 - New python executable in env1/bin/python - Installing distribute............................................. - .................................................................. - .................................................................. - done. - (env1)$ mkvirtualenv env2 - New python executable in env2/bin/python - Installing distribute............................................. - .................................................................. - .................................................................. - done. - (env2)$ workon - env1 - env2 - (env2)$ workon env1 - (env1)$ echo $VIRTUAL_ENV - /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 - (env1)$ workon env2 - (env2)$ echo $VIRTUAL_ENV - /Users/dhellmann/Devel/virtualenvwrapper/tmp/env2 - (env2)$ - - -.. seealso:: - - * :ref:`scripts-predeactivate` - * :ref:`scripts-postdeactivate` - * :ref:`scripts-preactivate` - * :ref:`scripts-postactivate` - -.. _command-deactivate: - -deactivate ----------- - -.. - Switch from a virtual environment to the system-installed version of - Python. - -仮想環境からシステムにインストールされた Python のバージョンに切り替えます。 - -.. - Syntax:: - -構文:: - - deactivate - -.. note:: - - .. This command is actually part of virtualenv, but is wrapped to - provide before and after hooks, just as workon does for activate. - - このコマンドは、実際は virtualenv の一部ですが、まさに workon が行うようにアクティブ化のために、処理の前後にフック機能を提供するためにラップされます。 - -:: - - $ workon - $ echo $VIRTUAL_ENV - - $ mkvirtualenv env1 - New python executable in env1/bin/python - Installing distribute............................................. - .................................................................. - .................................................................. - done. - (env1)$ echo $VIRTUAL_ENV - /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 - (env1)$ deactivate - $ echo $VIRTUAL_ENV - - $ - -.. seealso:: - - * :ref:`scripts-predeactivate` - * :ref:`scripts-postdeactivate` - -.. - ================================== - Quickly Navigating to a virtualenv - ================================== - -======================== -仮想環境へ簡単に移動する -======================== - -.. - There are two functions to provide shortcuts to navigate into the - currently-active virtualenv. - -カレントのアクティブ化された仮想環境内へ移動するためのショートカットを提供する2つの機能があります。 - -cdvirtualenv ------------- - -.. - Change the current working directory to ``$VIRTUAL_ENV``. - -``$VIRTUAL_ENV`` へカレントワークディレクトリを移動します。 - -.. - Syntax:: - -構文:: - - cdvirtualenv [subdir] - -.. - Calling ``cdvirtualenv`` changes the current working directory to the - top of the virtualenv (``$VIRTUAL_ENV``). An optional argument is - appended to the path, allowing navigation directly into a - subdirectory. - -``cdvirtualenv`` を呼び出すと、カレントワークディレクトリを仮想環境(``$VIRTUAL_ENV``)のトップへ移動します。オプションの引数はそのパスに追加されて、サブディレクトリへ直接的に移動することもできます。 - -:: - - $ mkvirtualenv env1 - New python executable in env1/bin/python - Installing distribute............................................. - .................................................................. - .................................................................. - done. - (env1)$ echo $VIRTUAL_ENV - /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 - (env1)$ cdvirtualenv - (env1)$ pwd - /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 - (env1)$ cdvirtualenv bin - (env1)$ pwd - /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1/bin - -cdsitepackages --------------- - -.. - Change the current working directory to the ``site-packages`` for - ``$VIRTUAL_ENV``. - -``$VIRTUAL_ENV`` の ``site-packages`` へカレントワークディレクトリを移動します。 - -.. - Syntax:: - -構文:: - - cdsitepackages [subdir] - -.. - Because the exact path to the site-packages directory in the - virtualenv depends on the version of Python, ``cdsitepackages`` is - provided as a shortcut for ``cdvirtualenv - lib/python${pyvers}/site-packages``. An optional argument is also - allowed, to specify a directory hierarchy within the ``site-packages`` - directory to change into. - -仮想環境の site-packages ディレクトリへの正確なパスは Python のバージョンに依存するので、 ``cdsitepackages`` は ``cdvirtualenv lib/python${pyvers}/site-packages`` のショートカットです。さらにオプションの引数は直接移動する ``site-packages`` 内の階層構造のディレクトリを指定することもできます。 - -:: - - $ mkvirtualenv env1 - New python executable in env1/bin/python - Installing distribute............................................. - .................................................................. - .................................................................. - done. - (env1)$ echo $VIRTUAL_ENV - /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1 - (env1)$ cdsitepackages PyMOTW/bisect/ - (env1)$ pwd - /Users/dhellmann/Devel/virtualenvwrapper/tmp/env1/lib/python2.6/site-packages/PyMOTW/bisect - -lssitepackages --------------- - -.. - Calling ``lssitepackages`` shows the content of the ``site-packages`` - directory of the currently-active virtualenv. - -``lssitepackages`` を呼び出すと、カレントのアクティブ化された仮想環境の ``site-packages`` ディレクトリのコンテンツを表示します。 - -.. - Syntax:: - -構文:: - - lssitepackages - -:: - - $ mkvirtualenv env1 - New python executable in env1/bin/python - Installing distribute............................................. - .................................................................. - .................................................................. - done. - (env1)$ $ workon env1 - (env1)$ lssitepackages - distribute-0.6.10-py2.6.egg pip-0.6.3-py2.6.egg - easy-install.pth setuptools.pth - -.. - =============== - Path Management - =============== - -======== -パス管理 -======== - -add2virtualenv --------------- - -.. - Adds the specified directories to the Python path for the - currently-active virtualenv. - -カレントのアクティブ化された仮想環境の Python パスへ指定したディレクトリを追加します。 - -.. - Syntax:: - -構文:: - - add2virtualenv directory1 directory2 ... - -.. - Sometimes it is desirable to share installed packages that are not in - the system ``site-pacakges`` directory and which should not be - installed in each virtualenv. One possible solution is to symlink the - source into the environment ``site-packages`` directory, but it is - also easy to add extra directories to the PYTHONPATH by including them - in a ``.pth`` file inside ``site-packages`` using ``add2virtualenv``. - -システムの ``site-pacakges`` ディレクトリに存在しないインストール済みのパッケージやそれぞれの仮想環境にインストールしたくないパッケージを共有したいときがあります。1つの解決方法はその仮想環境の ``site-packages`` ディレクトリへシンボリックリンクを張ることです。しかし、 ``add2virtualenv`` を使用して ``site-packages`` 内の ``.pth`` ファイルへそういったパッケージを含めることで、PYTHONPATH へ拡張ディレクトリを追加することも簡単です。 - -.. - 1. Check out the source for a big project, such as Django. - 2. Run: ``add2virtualenv path_to_source``. - 3. Run: ``add2virtualenv``. - 4. A usage message and list of current "extra" paths is printed. - -1. Django のような、大きなプロジェクトのソースをチェックアウトする -2. ``add2virtualenv path_to_source`` を実行する -3. ``add2virtualenv`` を実行する -4. 使用方法とカレントの "拡張された" パスリストが表示される - -.. - The directory names are added to a path file named - ``virtualenv_path_extensions.pth`` inside the site-packages directory - for the environment. - -site-packages ディレクトリ内の ``virtualenv_path_extensions.pth`` と名付けられたパスファイルへそのディレクトリ名が追加されます。 - -.. - *Based on a contribution from James Bennett and Jannis Leidel.* - -*James Bennett と Jannis Leidel から提供されたものに基づいています。* - -.. _command-toggleglobalsitepackages: - -toggleglobalsitepackages ------------------------- - -.. - Controls whether the active virtualenv will access the packages in the - global Python ``site-packages`` directory. - -アクティブな virtualenv が、グローバルの Python ``site-packages`` ディレクトリにあるパッケージにアクセスさせるかどうかを制御します。 - -.. - Syntax:: - -構文:: - - toggleglobalsitepackages [-q] - -.. - Outputs the new state of the virtualenv. Use the ``-q`` switch to turn off all - output. - -実行すると virtualenv の更新後の状態を表示します。非表示にするには ``-q`` を指定してください。 - -:: - - $ mkvirtualenv env1 - New python executable in env1/bin/python - Installing distribute............................................. - .................................................................. - .................................................................. - done. - (env1)$ toggleglobalsitepackages - Disabled global site-packages - (env1)$ toggleglobalsitepackages - Enabled global site-packages - (env1)$ toggleglobalsitepackages -q - (env1)$ - -.. - ============================ - Project Directory Management - ============================ - -============================== -プロジェクトディレクトリの管理 -============================== - -.. seealso:: - - :ref:`project-management` - -.. _command-mkproject: - -mkproject ---------- - -.. - Create a new virtualenv in the WORKON_HOME and project directory in - PROJECT_HOME. - -PROJECT_HOME にプロジェクトディレクトリと WORKON_HOME に新しい virtualenv を作成します。 - -.. - Syntax:: - -構文:: - - mkproject [-t template] [virtualenv_options] ENVNAME - -.. - The template option may be repeated to have several templates used to - create a new project. The templates are applied in the order named on - the command line. All other options are passed to ``mkvirtualenv`` to - create a virtual environment with the same name as the project. - -テンプレートオプションは、新しいプロジェクトを作成するのに使うテンプレートを複数指定できます。テンプレートはコマンドラインで指定した順番で適用されます。その他の全てのオプションは、プロジェクトと同じ名前をもつ仮想環境を作成するために ``mkvirtualenv`` に渡されます。 - -:: - - $ mkproject myproj - New python executable in myproj/bin/python - Installing distribute............................................. - .................................................................. - .................................................................. - done. - Creating /Users/dhellmann/Devel/myproj - (myproj)$ pwd - /Users/dhellmann/Devel/myproj - (myproj)$ echo $VIRTUAL_ENV - /Users/dhellmann/Envs/myproj - (myproj)$ - -.. seealso:: - - * :ref:`scripts-premkproject` - * :ref:`scripts-postmkproject` - -.. _command-setvirtualenvproject: - -setvirtualenvproject --------------------- - -.. - Bind an existing virtualenv to an existing project. - -既存の virtualenv を既存のプロジェクトに束縛します。 - -.. - Syntax:: - -構文:: - - setvirtualenvproject [virtualenv_path project_path] - -.. - The arguments to ``setvirtualenvproject`` are the full paths to the - virtualenv and project directory. An association is made so that when - ``workon`` activates the virtualenv the project is also activated. - -``setvirtualenvproject`` への引数は、virtualenv とプロジェクトディレクトリへのフルパスです。仮想環境のアクティブ化を ``workon`` で行うときに、そのプロジェクトもアクティブ化されるように連携します。 - -:: - - $ mkproject myproj - New python executable in myproj/bin/python - Installing distribute............................................. - .................................................................. - .................................................................. - done. - Creating /Users/dhellmann/Devel/myproj - (myproj)$ mkvirtualenv myproj_new_libs - New python executable in myproj/bin/python - Installing distribute............................................. - .................................................................. - .................................................................. - done. - Creating /Users/dhellmann/Devel/myproj - (myproj_new_libs)$ setvirtualenvproject $VIRTUAL_ENV $(pwd) - -.. - When no arguments are given, the current virtualenv and current - directory are assumed. - -引数を指定しない場合は、カレントの virtualenv とカレントディレクトリが指定されたと見なします。 - -.. - Any number of virtualenvs can refer to the same project directory, - making it easy to switch between versions of Python or other - dependencies for testing. - -任意の数の virtualenv が、Python またはその他のテスト向けの依存関係をもったバージョン間で切り替えやすいように、同じプロジェクトディレクトリを参照できます。 - -.. _command-cdproject: - -cdproject ---------- - -.. - Change the current working directory to the one specified as the - project directory for the active virtualenv. - -カレントのワークディレクトリから、アクティブな virtualenv のプロジェクトディレクトリとして指定したディレクトリに変更します。 - -.. - Syntax:: - -構文:: - - - cdproject - diff --git a/docs/ja/developers.rst b/docs/ja/developers.rst deleted file mode 100644 index ab099e4..0000000 --- a/docs/ja/developers.rst +++ /dev/null @@ -1,198 +0,0 @@ -.. - ############## - For Developers - ############## - -########## -開発者向け -########## - -.. - If you would like to contribute to virtualenvwrapper directly, these - instructions should help you get started. Patches, bug reports, and - feature requests are all welcome through the `BitBucket site - `_. Contributions - in the form of patches or pull requests are easier to integrate and - will receive priority attention. - -あなたが直接 virtualenvwrapper に貢献したいなら、次の説明が役に立つでしょう。パッチ、バグレポートや機能要求は `BitBucket サイト `_ で歓んで受け付けます。パッチや pull リクエストによる貢献はその修正を取り込んだり、優先度の配慮も行い易いでしょう。 - -.. note:: - - .. Before contributing new features to virtualenvwrapper core, please - consider whether they should be implemented as an extension instead. - - virtualenvwrapper のコアへ新しい機能を追加する前に、その代わりに機能拡張として実装すべきかどうかをよく考えてください。 - -.. - Building Documentation - ====================== - -ドキュメントを作成する -====================== - -.. - The documentation for virtualenvwrapper is written in reStructuredText - and converted to HTML using Sphinx. The build itself is driven by - make. You will need the following packages in order to build the - docs: - -virtualenvwrapper のドキュメントは reStructuredText で書かれていて Sphinx で HTML に変換されます。それは make コマンドでビルドされます。ドキュメントをビルドするために次のパッケージが必要になります。 - -- Sphinx -- docutils - -.. - Once all of the tools are installed into a virtualenv using - pip, run ``make html`` to generate the HTML version of the - documentation:: - -全てのツールが pip を使用して仮想環境内にインストールされたら、ドキュメントの HTML バージョンを生成するために ``make html`` を実行してください。 - -:: - - $ make html - rm -rf virtualenvwrapper/docs - (cd docs && make html SPHINXOPTS="-c sphinx/pkg") - sphinx-build -b html -d build/doctrees -c sphinx/pkg source build/html - Running Sphinx v0.6.4 - loading pickled environment... done - building [html]: targets for 2 source files that are out of date - updating environment: 0 added, 2 changed, 0 removed - reading sources... [ 50%] command_ref - reading sources... [100%] developers - - looking for now-outdated files... none found - pickling environment... done - checking consistency... done - preparing documents... done - writing output... [ 33%] command_ref - writing output... [ 66%] developers - writing output... [100%] index - - writing additional files... search - copying static files... WARNING: static directory '/Users/dhellmann/Devel/virtualenvwrapper/plugins/docs/sphinx/pkg/static' does not exist - done - dumping search index... done - dumping object inventory... done - build succeeded, 1 warning. - - Build finished. The HTML pages are in build/html. - cp -r docs/build/html virtualenvwrapper/docs - -.. - The output version of the documentation ends up in - ``./virtualenvwrapper/docs`` inside your sandbox. - -最終的なドキュメントの生成内容はサンドボックスの ``./virtualenvwrapper/docs`` にあります。 - -.. - Running Tests - ============= - -テストを実行する -================ - -.. - The test suite for virtualenvwrapper uses shunit2_ and tox_. The - shunit2 source is included in the ``tests`` directory, but tox must be - installed separately (``pip install tox``). - -virtualenvwrapper のテストスイートは shunit2_ と tox_ を使います。shunit2 のソースは ``tests`` ディレクトリに含まれていますが、tox は別途インストールする必要があります (``pip install tox``) 。 - -.. - To run the tests under bash, zsh, and ksh for Python 2.4 through 2.7, - run ``tox`` from the top level directory of the hg repository. - -bash, zsh, ksh 環境で Python 2.4 - 2.7 のテストを実行するには、hg リポジトリの最上位ディレクトリから ``tox`` を実行してください。 - -.. - To run individual test scripts, use a command like:: - -個別のテストスクリプトを実行するには、次のように実行します。 - -:: - - $ tox tests/test_cd.sh - -.. - To run tests under a single version of Python, specify the appropriate - environment when running tox:: - -Python のあるバージョンでテストを実行するには、tox を実行するときに適切な環境を指定します。 - -:: - - - $ tox -e py27 - -.. - Combine the two modes to run specific tests with a single version of - Python:: - -前述した特定テストと Python バージョンのテストを実行するには、2つの方法を組み合わせてください。 - -:: - - $ tox -e py27 tests/test_cd.sh - -.. - Add new tests by modifying an existing file or creating new script in - the ``tests`` directory. - -既存のファイルを変更して新しいテストを追加するか、 ``tests`` ディレクトリに新しいスクリプトを作成してください。 - -.. _shunit2: http://shunit2.googlecode.com/ - -.. _tox: http://codespeak.net/tox - -.. - Creating a New Template - ======================= - -.. _developer-templates: - -新しいテンプレートの作成 -======================== - -.. - virtualenvwrapper.project templates work like `virtualenvwrapper - plugins - `__. - The *entry point* group name is - ``virtualenvwrapper.project.template``. Configure your entry point to - refer to a function that will **run** (source hooks are not supported - for templates). - -virtualenvwrapper.project テンプレートは `virtualenvwrapper plugins `__ と同じように動作します。 -*entry point* グループの名前は ``virtualenvwrapper.project.template`` です。 -**run** を実行する関数を参照する独自のエントリーポイントを設定してください -(ソースフックはテンプレートをサポートしていません) 。 - -.. - The argument to the template function is the name of the project being - created. The current working directory is the directory created to - hold the project files (``$PROJECT_HOME/$envname``). - -テンプレート関数の引数は、作成するプロジェクトの名前です。 -カレントワークディレクトリは、プロジェクトのファイルを保持するために作成されたディレクトリです (``$PROJECT_HOME/$envname``) 。 - -.. - Help Text - --------- - -ヘルプテキスト --------------- - -.. - One difference between project templates and other virtualenvwrapper - extensions is that only the templates specified by the user are run. - The ``mkproject`` command has a help option to give the user a list of - the available templates. The names are taken from the registered - entry point names, and the descriptions are taken from the docstrings - for the template functions. - -プロジェクトテンプレートとその他の virtualenvwrapper 拡張との違いは、ユーザーが指定したテンプレートのみが実行されることです。 -``mkproject`` コマンドは、ユーザーへ利用できるテンプレート一覧表示するヘルプオプションがあります。 -テンプレート名は、登録されたエントリーポイントから取得される名前です。 -そして、テンプレートの説明は、テンプレート関数の docstrings を表示します。 diff --git a/docs/ja/extensions.rst b/docs/ja/extensions.rst deleted file mode 100644 index 19cbada..0000000 --- a/docs/ja/extensions.rst +++ /dev/null @@ -1,99 +0,0 @@ -.. - ===================== - Existing Extensions - ===================== - -================ - 既存の拡張機能 -================ - -.. - Below is a list of some of the extensions available for use with - virtualenvwrapper. - -次に virtualenvwrapper で利用できる拡張機能を紹介します。 - -emacs-desktop -============= - -.. - Emacs desktop-mode_ lets you save the state of emacs (open buffers, - kill rings, buffer positions, etc.) between sessions. It can also be - used as a project file similar to other IDEs. The emacs-desktop_ - plugin adds a trigger to save the current desktop file and load a new - one when activating a new virtualenv using ``workon``. - -emacs desktop-mode_ はセッション間で emacs の状態(バッファのオープン、リングの削除、バッファの位置等)を保存させます。それは他の IDE に対する1つのプロジェクトファイルとして使用することもできます。 emacs-desktop_ プラグインは、カレントのデスクトップファイルを保存するトリガーを追加して、 ``workon`` で新しい仮想環境をアクティブ化するときに新たなファイルを読み込みます。 - -.. _desktop-mode: http://www.emacswiki.org/emacs/DeskTop - -.. _emacs-desktop: http://www.doughellmann.com/projects/virtualenvwrapper-emacs-desktop/ - -.. _extensions-user_scripts: - -user_scripts -============ - -.. - The ``user_scripts`` extension is delivered with virtualenvwrapper and - enabled by default. It implements the user customization script - features described in :ref:`scripts`. - -``user_scripts`` 拡張は virtualenvwrapper で提供され、デフォルトで有効です。それは :ref:`scripts` で説明したユーザのカスタマイズスクリプト機能を実装します。 - -vim-virtualenv -============== - -.. - `vim-virtualenv`_ is Jeremey Cantrell's plugin for controlling - virtualenvs from within vim. When used together with - virtualenvwrapper, vim-virtualenv identifies the virtualenv to - activate based on the name of the file being edited. - -`vim-virtualenv`_ は、Jeremey Cantrell によるプラグインで vim から virtualenvs を制御します。virtualenvwrapper と一緒に使う場合は、vim-virtualenv が編集するファイル名に対応してアクティブ化する virtualenv を識別します。 - -.. _vim-virtualenv: https://github.com/jmcantrell/vim-virtualenv - -.. - Templates - ========= - -.. _extensions-templates: - -テンプレート -============ - -.. - Below is a list of some of the templates available for use with - :ref:`command-mkproject`. - -:ref:`command-mkproject` で利用できるテンプレートの一覧を紹介します。 - -.. _templates-bitbucket: - -bitbucket ---------- - -.. - The bitbucket_ extension automatically clones a mercurial repository - from the specified bitbucket project. - -bitbucket_ 拡張は、指定した bitbucket プロジェクトから自動的に mercurial のリポジトリをクローンします。 - -.. _bitbucket: http://www.doughellmann.com/projects/virtualenvwrapper.bitbucket/ - -.. _templates-django: - -django ------- - -.. - The django_ extension automatically creates a new Django project. - -django_ 拡張は、自動的に新しい Django プロジェクトを作成します。 - -.. _django: http://www.doughellmann.com/projects/virtualenvwrapper.django/ - -.. seealso:: - - * :ref:`developer-templates` diff --git a/docs/ja/history.rst b/docs/ja/history.rst deleted file mode 100644 index 1d13430..0000000 --- a/docs/ja/history.rst +++ /dev/null @@ -1,529 +0,0 @@ -.. - =============== - Release History - =============== - -============ -リリース履歴 -============ - -dev - - - Clean up file permissions and remove shebangs from scripts not - intended to be executed on the command line. (contributed by - :bbuser:`ralphbean`) - - Worked on some brittle tests. - -3.2 - - - Make ``project_dir`` a local variable so that - :ref:`command-cdproject` does not interfere with other variables - the user might have set. (contributed by :bbuser:`slackorama`) - - Fix typo in documentation reported by Nick Martin. - - Change trove classifier for license "MIT" to reflect the license - text presented in the documentation. *This does not indicate a - change in the license, just a correction to the expression of that - intent. See :ref:`license`* (contributed by :bbuser:`ralphbean` as - fix for :bbissue:`134`) - - Extend :ref:`command-rmvirtualenv` to allow removing more than one - environment at a time. (contributed by :bbuser:`ciberglo`) - - Change the definition of - ``virtualenvwrapper_get_site_packages_dir`` to ask ``distutils`` - for the ``site-packages`` directory instead of trying to build the - path ourselves in the shell script. This should resolve - :bbissue:`112` and improve support for Python interpreters other - than C Python. Thanks to Carl Meyer and Dario Bertini for their - contributions toward the fix. - -3.1 - - - Fix a problem with activation hooks when associating a new - virtualenv with an existing project directory. (:bbissue:`122`) - - Fix a problem with :ref:`command-add2virtualenv` and paths - containing "special" characters such as ``&``. (:bbissue:`132`) - -3.0.1 - - - Fix some packaging issues that made it more difficult to run the - tests directly from the sdist package. (:bbissue:`126`) - -3.0 - - - Add Python 3 support, thanks in large part to the efforts of - Daniel Kraus (:bbuser:`dakra`). Tested under Python 2.6, 2.7, and - 3.2. - -2.11.1 - - - Remove the initialization shortcut because it breaks tab - completion in sub-shell environments like screen and - tmux. (:bbissue:`121`) - -2.11 - - - Add ``-a`` option to :ref:`command-mkvirtualenv` to associate a - new virtualenv with an existing project directory. Contributed by - Mike Fogel (:bbuser:`mfogel`). - - Drops support for Python 2.4 and 2.5. The tools may still work, - but I no longer have a development environment set up for testing - them, so I do not officially support them. - - Shortcut initialization if it has run before. - - Set hook log file permissions to be group-writable. (:bbissue:`62` - reported by :bbuser:`hedgeddown`) - - Add ``VIRTUALENVWRAPPER_PROJECT_FILENAME`` variable so the - ``.project`` file used to link a virtualenv to a project can be - renamed to avoid conflicts with other tools. (:bbissue:`120` - reported by :bbuser:`arthuralvim`) - -2.10.1 - - - Changed arguments to :ref:`command-mktmpenv` so it always creates - an environment name for you. (:bbissue:`114` reported by - :bbuser:`alex_gaynor`) - -2.10 - - - Incorporated patch to add ``-d`` option to - :ref:`command-add2virtualenv`, contributed by :bbuser:`miracle2k`. - - Add ``-i`` option to :ref:`command-mkvirtualenv`. - - Add :ref:`command-mktmpenv` command for creating temporary - environments that are automatically removed when they are - deactivated. - - Fixed a problem with hook_loader that prevented it from working - under Python 2.5 and 2.4. - - Fix a problem with the way template names were processed under - zsh. (:bbissue:`111`) - -2.9 - - - Change the shell function shell definition syntax so that ksh will - treat typeset-declared variables as local. No kidding. - - Merge the "project directory" features of the - ``virtualenvwrapper.project`` plugin into the main project, adding - :ref:`command-mkproject`, :ref:`command-cdproject`, and - :ref:`command-setvirtualenvproject` commands. - - Add ``-r`` option to :ref:`command-mkvirtualenv` to install - dependencies using a pip requirements file. - -2.8 - - - Use VIRTUALENVWRAPPER_VIRTUALENV in `cpvirtualenv` (:bbissue:`104`). - - Add support for `MSYS `_ - environment under Windows. Contributed by Axel - H. (:bbuser:`noirbizarre`). - -2.7.2 - - - Move setup code for tab completion later in the startup code so - all of the needed variables are configured. (:bbissue:`97`) - - Expand tab completion for zsh to work for all commands. - -2.7.1 - - - When testing for WORKON_HOME during startup, dereference any - symlink to make sure it is a directory. - - Set VIRTUALENVWRAPPER_HOOK_DIR and VIRTUALENV_WRAPPER_LOG DIR in - virtualenvwrapper_initialize after WORKON_HOME is set - (:bbissue:`94`). - - Update the :ref:`install-basic` instructions to be more explicit - about needing to install virtualenvwrapper globally (or at least - outside of a virtualenv). - -2.7 - - - Fix problem with space in WORKON_HOME path (:bbissue:`79`). - - Fix problem with argument processing in lsvirtualenv under zsh - (:bbissue:`86`). Thanks to Nat Williams (:bbuser:`natw`) for the - bug report and patch. - - If WORKON_HOME does not exist, create it. Patch from Carl Karsten - (:bbuser:`CarlFK`). Test updates based on patches from Matt Austin - (:bbuser:`maafy6`) and Hugo Lopes Tavares (:bbuser:`hltbra`). - - Merge in contributions from Paul McLanahan (:bbuser:`pmclanahan`) - to fix the test harness to ensure that the test scripts are - actually running under the expected shell. - - Merge in new shell command :ref:`command-toggleglobalsitepackages` - from Paul McLanahan (:bbuser:`pmclanahan`). The new command - changes the configuration of the active virtualenv to enable or - disable the global ``site-packages`` directory. - - Fixed some tests that were failing under ksh on Ubuntu 10.10. - - Document the :ref:`VIRTUALENVWRAPPER_VIRTUALENV - ` variable. - - Implement suggestion by Van Lindberg to have - :ref:`VIRTUALENVWRAPPER_HOOK_DIR - ` and - :ref:`VIRTUALENVWRAPPER_LOG_DIR - ` variables to control the - locations of hooks and logs. - - Enabled tab completion for :ref:`command-showvirtualenv` - (:bbissue:`78`). - - Fixed a problem with running :ref:`command-rmvirtualenv` from - within the environment being removed (:bbissue:`83`). - - Removed use of -e option in calls to grep for better portability - (:bbissue:`85`). - -2.6.3 - - .. - Hard-code the version information in the setup.py and conf.py - scripts so it works for http://readthedocs.org. - - - http://readthedocs.org でドキュメントを生成するために setup.py や conf.py スクリプトのバージョン情報をハードコードしました。 - -2.6.2 - - .. - Attempted to make the doc build work with http://readthedocs.org. - - Merged in `Japanese translation of the documentation - `__ from - Tetsuya Morimoto. - - Incorporate a suggestion from Ales Zoulek to let the user specify - the virtualenv binary through an environment variable - (:ref:`VIRTUALENVWRAPPER_VIRTUALENV `). - - - http://readthedocs.org でドキュメントを生成してみました。 - - Tetsuya Morimoto からの `日本語の翻訳ドキュメント `__ を取り込みました。 - - 環境変数 (:ref:`VIRTUALENVWRAPPER_VIRTUALENV `) で virtualenv バイナリをユーザが指定できるように Ales Zoulek からの提案を取り入れました。 - -2.6.1 - - .. - Fixed virtualenvwrapper_get_python_version (:bbissue:`73`). - - - virtualenvwrapper_get_python_version を修正しました(:bbissue:`73`)。 - -2.6 - - .. - Fixed a problem with hook script line endings under Cygwin - (:bbissue:`68`). - - Updated documentation to include a list of the compatible shells - (:ref:`supported-shells`) and Python versions - (:ref:`supported-versions`) (:bbissue:`70`). - - Fixed installation dependency on virtualenv (:bbissue:`60`). - - Fixed the method for determining the Python version so it works - under Python 2.4 (:bbissue:`61`). - - Converted the test infrastructure to use `tox - `_ instead of home-grown - scripts in the Makefile. - - - Cygwin 環境でフックスクリプトの改行の問題を修正しました(:bbissue:`68`)。 - - 互換シェルのリスト(:ref:`supported-shells`) と Python バージョン(:ref:`supported-versions`)を含むようにドキュメントを更新しました(:bbissue:`70`)。 - - virtualenv のインストールの依存関係を修正しました(:bbissue:`60`)。 - - Python 2.4 で動作するように Python バージョンを決定するメソッドを修正しました(:bbissue:`61`)。 - - Makefile の自作スクリプトの代わりに `tox `_ を使用するためにテストインフラを変換しました。 - -2.5.3 - - .. - Point release uploaded to PyPI during outage on doughellmann.com. - - - doughellmann.com の休止期間中に PyPI へアップロードしたポイントリリースです。 - -2.5.2 - - .. - Apply patch from Zach Voase to fix :ref:`command-lsvirtualenv` - under zsh. Resolves :bbissue:`64`. - - - zsh 環境の :ref:`command-lsvirtualenv` を修正する Zach Voase からのパッチを適用しました。 :bbissue:`64` を解決しました。 - -2.5.1 - - .. - Make :ref:`command-workon` list brief environment details when run - without argument, instead of full details. - - - 数無しで実行したときに :ref:`command-workon` に完全な環境詳細ではなく簡潔な詳細を表示するようにしました。 - -2.5 - - .. - Add :ref:`command-showvirtualenv` command. Modify - :ref:`command-lsvirtualenv` to make verbose output the default. - - - :ref:`command-showvirtualenv` コマンドを追加しました。デフォルトで冗長な出力を行うように :ref:`command-lsvirtualenv` を変更しました。 - -2.4 - - .. - Add :ref:`command-lsvirtualenv` command with ``-l`` option to run - :ref:`scripts-get_env_details` hook instead of always running it - when :ref:`command-workon` has no arguments. - - - :ref:`command-workon` が引数無しで実行されるときに :ref:`scripts-get_env_details` フックを実行するために ``-l`` オプションを持つ :ref:`command-lsvirtualenv` コマンドを追加しました。 - -2.3 - - .. - Added ``get_env_details`` hook. - - - ``get_env_details`` フックを追加しました。 - -2.2.2 - - .. - Integrate Fred Palmer's patch to escape more shell commands to - avoid aliases. Resolves :bbissue:`57`. - - Fix a problem with egrep argument escaping (:bbissue:`55`). - - Fix a problem with running mkvirtualenv without arguments (:bbissue:`56`). - - - エイリアスを避けてシェルコマンドをさらにエスケープ処理する Fred Palmer のパッチを取り込みました。 :bbissue:`57` を解決しました。 - - egrep 引数のエスケープ処理の問題を修正しました(:bbissue:`55`)。 - - 引数無しで mkvirtualenv を実行するときの問題を修正しました(:bbissue:`56`)。 - -2.2.1 - - .. - Escape ``which`` calls to avoid aliases. Resolves :bbissue:`46`. - - Integrate Manuel Kaufmann's patch to unset GREP_OPTIONS before - calling grep. Resolves :bbissue:`51`. - - Escape ``$`` in regex to resolve :bbissue:`53`. - - Escape ``rm`` to avoid issues with aliases and resolve - :bbissue:`50`. - - - ``which`` 呼び出しがエイリアスを避けるようにエスケープしました。 :bbissue:`46` を解決しました。 - - grep を呼び出す前に GREP_OPTIONS をアンセットする Manuel Kaufmann のパッチを取り込みました。 :bbissue:`51` を解決しました。 - - :bbissue:`53` を解決する正規表現の ``$`` をエスケープしました。 - - ``rm`` のエイリアスに関する問題をエスケープして :bbissue:`50` を解決しました。 - -2.2 - - .. - Switched hook loader execution to a form that works with Python - 2.4 to resolve :bbissue:`43`. - - Tested under Python 2.7b1. See :bbissue:`44`. - - Incorporated performance improvements from David Wolever. See - :bbissue:`38`. - - Added some debug instrumentation for :bbissue:`35`. - - - :bbissue:`43` を解決するために Python 2.4 で動作する形でフックローダの実行を切り替えました。 - - Python 2.7b1 でテストしました。 :bbissue:`44` を参照してください。 - - David Wolever からのパフォーマンス改善を取り込みました。 :bbissue:`38` を参照してください。 - - :bbissue:`35` のためにデバッグ命令を追加しました。 - -2.1.1 - - .. - Added `Spanish translation for the documentation - `__ via - Manuel Kaufmann's fork at - http://bitbucket.org/humitos/virtualenvwrapper-es-translation/ - - Fixed improper use of python from ``$PATH`` instead of the - location where the wrappers are installed. See :bbissue:`41`. - - Quiet spurrious error/warning messages when deactivating a - virtualenv under zsh. See :bbissue:`42`. - - - Manuel Kaufmann の http://bitbucket.org/humitos/virtualenvwrapper-es-translation/ から `スペイン語の翻訳ドキュメント `__ を追加しました。 - - ラッパーがインストールされる場所ではなく ``$PATH`` から Python の不適切な利用を修正しました。 :bbissue:`41` を参照してください。 - - zsh で仮想環境を非アクティブ化したときの誤ったエラー/ワーニングメッセージをなだめました。 :bbissue:`42` を参照してください。 - -2.1 - - .. - Add support for ksh. Thanks to Doug Latornell for doing the - research on what needed to be changed. - - Test import of virtualenvwrapper.hook_loader on startup and report - the error in a way that should help the user figure out how to fix - it (:bbissue:`33`). - - Update :ref:`command-mkvirtualenv` documentation to include the - fact that a new environment is activated immediately after it is - created (:bbissue:`30`). - - Added hooks around :ref:`command-cpvirtualenv`. - - Made deactivation more robust, especially under ksh. - - Use Python's ``tempfile`` module for creating temporary filenames - safely and portably. - - Fix a problem with ``virtualenvwrapper_show_workon_options`` that - caused it to show ``*`` as the name of a virtualenv when no - environments had yet been created. - - Change the hook loader so it can be told to run only a set of - named hooks. - - Add support for listing the available hooks, to be used in help - output of commands like virtualenvwrapper.project's mkproject. - - Fix mkvirtualenv -h option behavior. - - Change logging so the $WORKON_HOME/hook.log file rotates after - 10KiB. - - - ksh サポートを追加しました。変更する箇所を調査してくれた Doug Latornell に感謝します。 - - 起動時に virtualenvwrapper.hook_loader のインポートテストをして、ユーザへ修正方法を理解するのに役立つようにエラーを報告します(:bbissue:`33`)。 - - 新しい仮想環境が作成された後ですぐにアクティブ化することについて :ref:`command-mkvirtualenv` ドキュメントを更新しました(:bbissue:`30`)。 - - :ref:`command-cpvirtualenv` に関連するフックを追加しました。 - - 特に ksh 環境で、非アクティブ化をより堅牢にしました。 - - 安全で移植性の高い一時ファイル名を作成するために Python の ``tempfile`` モジュールを使用しました。 - - 仮想環境がまだ1つも作成されていないときに仮想環境の名前として ``*`` を表示することで発生する ``virtualenvwrapper_show_workon_options`` の問題を修正しました。 - - 名前付きフックのみを実行できるようにフックローダを変更しました。 - - virtualenvwrapper.project の mkproject のようにコマンドのヘルプ出力を使用して利用可能なフックの取得サポートを追加しました。 - - mkvirtualenv の -h オプションの振る舞いを修正しました。 - - $WORKON_HOME/hook.log ファイルを 10KiB でローテートするように logging を変更しました。 - -2.0.2 - - .. - Fixed :bbissue:`32`, making virtualenvwrapper.user_scripts compatible - with Python 2.5 again. - - - virtualenvwrapper.user_scripts が Python 2.5 互換になるように :bbissue:`32` を修正しました。 - -2.0.1 - - .. - Fixed :bbissue:`29`, to use a default value for ``TMPDIR`` if it - is not set in the user's shell environment. - - - ``TMPDIR`` がユーザのシェル環境でセットされていないときにデフォルト値を使用するように :bbissue:`29` を修正しました。 - -2.0 - - .. - Rewrote hook management using Distribute_ entry points to make it - easier to share extensions. - - - 拡張機能を共有し易くするために Distribute_ エントリポイントを使用してフック管理を書き直しました。 - -.. _Distribute: http://packages.python.org/distribute/ - -1.27 - - - Added cpvirtualenv command [Thomas Desvenain] - -1.26 - - - Fix a problem with error messages showing up during init for users - with the wrappers installed site-wide but who are not actually - using them. See :bbissue:`26`. - - Split up the tests into multiple files. - - Run all tests with all supported shells. - -1.25 - - - Merged in changes to cdsitepackages from William McVey. It now - takes an argument and supports tab-completion for directories - within site-packages. - -1.24.2 - - - Add user provided :ref:`tips-and-tricks` section. - - Add link to Rich Leland's screencast to :ref:`references` section. - -1.24.1 - - - Add license text to the header of the script. - -1.24 - - - Resolve a bug with the preactivate hook not being run properly. - Refer to :bbissue:`21` for complete details. - -1.23 - - - Resolve a bug with the postmkvirtualenv hook not being run - properly. Refer to :bbissue:`19` and :bbissue:`20` for complete - details. - -1.22 - - - Automatically create any missing hook scripts as stubs with - comments to expose the feature in case users are not aware of it. - -1.21 - - - Better protection of ``$WORKON_HOME`` does not exist when the - wrapper script is sourced. - -1.20 - - - Incorporate lssitepackages feature from Sander Smits. - - Refactor some of the functions that were using copy-and-paste code - to build path names. - - Add a few tests. - -1.19 - - - Fix problem with add2virtualenv and relative paths. Thanks to Doug - Latornell for the bug report James Bennett for the suggested fix. - -1.18.1 - - - Incorporate patch from Sascha Brossmann to fix a - :bbissue:`15`. Directory normalization was causing ``WORKON_HOME`` - to appear to be a missing directory if there were control - characters in the output of ``pwd``. - -1.18 - - - Remove warning during installation if sphinxcontrib.paverutils is - not installed. (:bbissue:`10`) - - Added some basic developer information to the documentation. - - Added documentation for deactivate command. - -1.17 - - - Added documentation updates provided by Steve Steiner. - -1.16 - - - Merged in changes to ``cdvirtualenv`` from wam and added tests and - docs. - - Merged in changes to make error messages go to stderr, also - provided by wam. - -1.15 - - Better error handling in mkvirtualenv. - - Remove bogus VIRTUALENV_WRAPPER_BIN variable. - -1.14 - - Wrap the virtualenv version of deactivate() with one that lets us - invoke the predeactivate hooks. - - Fix virtualenvwrapper_show_workon_options for colorized versions - of ls and write myself a note so I don't break it again later. - - Convert test.sh to use true tests with `shunit2 - `_ - -1.13 - - - Fix :bbissue:`5` by correctly handling symlinks and limiting the - list of envs to things that look like they can be activated. - -1.12 - - - Check return value of virtualenvwrapper_verify_workon_home - everywhere, thanks to Jeff Forcier for pointing out the errors. - - Fix instructions at top of README, pointed out by Matthew Scott. - - Add cdvirtualenv and cdsitepackages, contributed by James Bennett. - - Enhance test.sh. - -1.11 - - - Optimize virtualenvwrapper_show_workon_options. - - Add global postactivate hook. - -1.10 - - - Pull in fix for colorized ls from Jeff Forcier - (:bbchangeset:`b42a25f7b74a`). - -1.9 - - - Add more hooks for operations to run before and after creating or - deleting environments based on changes from Chris Hasenpflug. - -1.8.1 - - - Corrected a problem with change to mkvirtualenv that lead to - release 1.8 by using an alternate fix proposed by James in - comments on release 1.4. - -1.8 - - - Fix for processing the argument list in mkvirtualenv from - jorgevargas (:bbissue:`1`) - -1.7 - - - Move to bitbucket.org for hosting - - clean up TODO list and svn keywords - - add license section below - -1.6.1 - - - More zsh support (fixes to rmvirtualenv) from Byron Clark. - -1.6 - - - Add completion support for zsh, courtesy of Ted Leung. - -1.5 - - - Fix some issues with spaces in directory or env names. They still - don't really work with virtualenv, though. - - Added documentation for the postactivate and predeactivate scripts. - -1.4 - - - Includes a new .pth management function based on work contributed - by James Bennett and Jannis Leidel. - -1.3.x - - - Includes a fix for a nasty bug in rmvirtualenv identified by John Shimek. diff --git a/docs/ja/hooks.rst b/docs/ja/hooks.rst deleted file mode 100644 index 5c4923a..0000000 --- a/docs/ja/hooks.rst +++ /dev/null @@ -1,22 +0,0 @@ -.. - =============================== - Customizing Virtualenvwrapper - =============================== - -====================================== - virtualenvwrapper をカスタマイズする -====================================== - -.. - virtualenvwrapper adds several hook points you can use to change your - settings, shell environment, or other configuration values when - creating, deleting, or moving between environments. These hooks are - exposed in two ways: - -virtualenvwrapper は仮想環境を作成・削除したり、環境間を移動したりするときに、設定内容、シェル環境またはその他の設定値を変更できる複数のフックポイントを追加します。そういったフック機能は2つの方法で提供されています。 - -.. toctree:: - :maxdepth: 1 - - scripts - plugins diff --git a/docs/ja/index.rst b/docs/ja/index.rst deleted file mode 100644 index c2b2159..0000000 --- a/docs/ja/index.rst +++ /dev/null @@ -1,355 +0,0 @@ -.. virtualenvwrapper documentation master file, created by - sphinx-quickstart on Thu May 28 22:35:13 2009. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -########################### -virtualenvwrapper |release| -########################### - -.. - virtualenvwrapper is a set of extensions to Ian Bicking's `virtualenv - `_ tool. The extensions - include wrappers for creating and deleting virtual environments and - otherwise managing your development workflow, making it easier to work - on more than one project at a time without introducing conflicts in - their dependencies. - -virtualenvwrapper は Ian Bicking の `virtualenv `_ ツールの拡張機能です。この拡張機能は仮想環境の作成・削除を行ったり、開発ワークフローを管理するラッパーを提供します。このラッパーを使うことで、開発環境の依存関係による競合を起こさず、同時に複数のプロジェクトで作業しやすくなります。 - -.. - ======== - Features - ======== - -==== -機能 -==== - -.. - 1. Organizes all of your virtual environments in one place. - 2. Wrappers for managing your virtual environments (create, delete, - copy). - 3. Use a single command to switch between environments. - 4. Tab completion for commands that take a virtual environment as - argument. - 5. User-configurable hooks for all operations (see :ref:`scripts`). - 6. Plugin system for more creating sharable extensions (see - :ref:`plugins`). - -1. 1つの場所に全ての仮想環境を構成する -2. 仮想環境を管理(作成、削除、コピー)するラッパー -3. 1つのコマンドで仮想環境を切り替える -4. コマンドの引数から仮想環境をタブ補完できる -5. 全ての操作をユーザ設定でフックできる(:ref:`scripts` を参照) -6. 共有できる拡張機能を作成できるプラグインシステム(:ref:`plugins` を参照) - -.. - ============ - Introduction - ============ - -==== -入門 -==== - -.. - The best way to explain the features virtualenvwrapper gives you is to - show it in use. - -virtualenvwrapper が提供する機能を説明するには、実際に使ってみるのが最も良い方法です。 - -.. - First, some initialization steps. Most of this only needs to be done - one time. You will want to add the command to ``source - /usr/local/bin/virtualenvwrapper.sh`` to your shell startup file, - changing the path to virtualenvwrapper.sh depending on where it was - installed by pip. - -まず初期化の作業があります。この作業の大半は一度だけ行う必要があります。pip でインストールした場所に依存する virtualenvwrapper.sh のパスを変更したり、 ``source /usr/local/bin/virtualenvwrapper.sh`` のコマンドをシェル起動時に読み込まれるファイルへ追加したりするでしょう。 - -:: - - $ pip install virtualenvwrapper - ... - $ export WORKON_HOME=~/Envs - $ mkdir -p $WORKON_HOME - $ source /usr/local/bin/virtualenvwrapper.sh - $ mkvirtualenv env1 - Installing - distribute.......................................... - .................................................... - .................................................... - ...............................done. - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/predeactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/postdeactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/preactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/postactivate New python executable in env1/bin/python - (env1)$ ls $WORKON_HOME - env1 hook.log - -.. - Now we can install some software into the environment. - -これで作成した仮想環境へソフトウェアをインストールできます。 - -:: - - (env1)$ pip install django - Downloading/unpacking django - Downloading Django-1.1.1.tar.gz (5.6Mb): 5.6Mb downloaded - Running setup.py egg_info for package django - Installing collected packages: django - Running setup.py install for django - changing mode of build/scripts-2.6/django-admin.py from 644 to 755 - changing mode of /Users/dhellmann/Envs/env1/bin/django-admin.py to 755 - Successfully installed django - -.. - We can see the new package with ``lssitepackages`` - -``lssitepackages`` で新たにインストールしたパッケージを調べられます。 - -:: - - (env1)$ lssitepackages - Django-1.1.1-py2.6.egg-info easy-install.pth - distribute-0.6.10-py2.6.egg pip-0.6.3-py2.6.egg - django setuptools.pth - -.. - Of course we are not limited to a single virtualenv - -当然、1つだけの仮想環境に制限されるわけではりません。 - -:: - - (env1)$ ls $WORKON_HOME - env1 hook.log - (env1)$ mkvirtualenv env2 - Installing distribute............................... - .................................................... - .................................................... - ........... ...............................done. - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/predeactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/postdeactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/preactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/postactivate New python executable in env2/bin/python - (env2)$ ls $WORKON_HOME - env1 env2 hook.log - -.. - Switch between environments with ``workon`` - -``workon`` で仮想環境を切り替えます。 - -:: - - (env2)$ workon env1 - (env1)$ echo $VIRTUAL_ENV - /Users/dhellmann/Envs/env1 - (env1)$ - -.. - The ``workon`` command also includes tab completion for the - environment names, and invokes customization scripts as an environment - is activated or deactivated (see :ref:`scripts`). - -さらに ``workon`` コマンドは仮想環境名をタブ補完できます。そして、ある仮想環境がアクティブ化または非アクティブ化されるようにカスタムスクリプトを実行します(:ref:`scripts` を参照)。 - -:: - - (env1)$ echo 'cd $VIRTUAL_ENV' >> $WORKON_HOME/postactivate - (env1)$ workon env2 - (env2)$ pwd - /Users/dhellmann/Envs/env2 - -.. - :ref:`scripts-postmkvirtualenv` is run when a new environment is - created, letting you automatically install commonly-used tools. - -新たな環境が作成されるときに :ref:`scripts-postmkvirtualenv` が実行されて、一般的に使用するツールを自動的にインストールします。 - -:: - - (env2)$ echo 'pip install sphinx' >> $WORKON_HOME/postmkvirtualenv - (env3)$ mkvirtualenv env3 - New python executable in env3/bin/python - Installing distribute............................... - .................................................... - .................................................... - ........... ...............................done. - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/predeactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/postdeactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/preactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/postactivate - Downloading/unpacking sphinx - Downloading Sphinx-0.6.5.tar.gz (972Kb): 972Kb downloaded - Running setup.py egg_info for package sphinx - no previously-included directories found matching 'doc/_build' - Downloading/unpacking Pygments>=0.8 (from sphinx) - Downloading Pygments-1.3.1.tar.gz (1.1Mb): 1.1Mb downloaded - Running setup.py egg_info for package Pygments - Downloading/unpacking Jinja2>=2.1 (from sphinx) - Downloading Jinja2-2.4.tar.gz (688Kb): 688Kb downloaded - Running setup.py egg_info for package Jinja2 - warning: no previously-included files matching '*' found under directory 'docs/_build/doctrees' - Downloading/unpacking docutils>=0.4 (from sphinx) - Downloading docutils-0.6.tar.gz (1.4Mb): 1.4Mb downloaded - Running setup.py egg_info for package docutils - Installing collected packages: docutils, Jinja2, Pygments, sphinx - Running setup.py install for docutils - Running setup.py install for Jinja2 - Running setup.py install for Pygments - Running setup.py install for sphinx - no previously-included directories found matching 'doc/_build' - Installing sphinx-build script to /Users/dhellmann/Envs/env3/bin - Installing sphinx-quickstart script to /Users/dhellmann/Envs/env3/bin - Installing sphinx-autogen script to /Users/dhellmann/Envs/env3/bin - Successfully installed docutils Jinja2 Pygments sphinx (env3)$ - (venv3)$ which sphinx-build - /Users/dhellmann/Envs/env3/bin/sphinx-build - -.. - Through a combination of the existing functions defined by the core - package (see :ref:`command`), third-party plugins (see - :ref:`plugins`), and user-defined scripts (see :ref:`scripts`) - virtualenvwrapper gives you a wide variety of opportunities to - automate repetitive operations. - -コアパッケージで定義された既存機能(:ref:`command` を参照)、サードパーティのプラグイン(:ref:`plugins` を参照)やユーザ定義スクリプト(:ref:`scripts` を参照)を組み合わせて、virtualenvwrapper は雑多な繰り返し行う操作を自動化する機会を提供します。 - -.. - ======= - Details - ======= - -======== -詳細内容 -======== - -.. toctree:: - :maxdepth: 2 - - install - command_ref - hooks - projects - tips - developers - extensions - history - -.. _references: - -.. - ========== - References - ========== - -======== -参考文献 -======== - -.. - `virtualenv `_, from Ian - Bicking, is a pre-requisite to using these extensions. - -Ian Bicking の `virtualenv `_ が virtualenvwrapper の拡張機能を使用するために必須です。 - -.. - For more details, refer to the column I wrote for the May 2008 issue - of Python Magazine: `virtualenvwrapper | And Now For Something - Completely Different - `_. - -さらに詳細は私が書いた2008年5月の Python マガジンのコラムを参照してください。 -`virtualenvwrapper | ところで話は変わりますが -`_ - -.. - Rich Leland has created a short `screencast - `__ - showing off the features of virtualenvwrapper. - -Rich Leland は virtualenvwrapper の機能を誇示するために短い `スクリーンキャスト `__ を作成しました。 - -.. - Manuel Kaufmann has `translated this documentation into Spanish - `__. - -Manuel Kaufmann は `このドキュメントをスペイン語に翻訳しました `__ 。 - -.. - Tetsuya Morimoto has `translated this documentation into Japanese - `__. - -Tetsuya Morimoto は `このドキュメントを日本語に翻訳しました `__ 。 - -.. - ======= - Support - ======= - -======== -サポート -======== - -.. - Join the `virtualenvwrapper Google Group - `__ to discuss - issues and features. - -問題や機能を議論するには `virtualenvwrapper Google Group `__ に参加してください。 - -.. - Report bugs via the `bug tracker on BitBucket - `__. - -`BitBucket のバグトラッカー `__ でバグを報告してください。 - -.. - Shell Aliases - ============= - -シェルエイリアス -================ - -.. - Since virtualenvwrapper is largely a shell script, it uses shell - commands for a lot of its actions. If your environment makes heavy - use of shell aliases or other customizations, you may encounter - issues. Before reporting bugs in the bug tracker, please test - *without* your aliases enabled. If you can identify the alias causing - the problem, that will help make virtualenvwrapper more robust. - -virtualenvwrapper は大きなシェルスクリプトなので、多くのアクションはシェルコマンドを使用します。あなたの環境が多くのシェルエイリアスやその他のカスタマイズを行っているなら、何かしら問題に遭遇する可能性があります。バグトラッカーにバグを報告する前に、そういったエイリアスを無効な *状態* でテストしてください。あなたがその問題を引き起こすエイリアスを判別できるなら virtualenvwrapper をもっと堅牢なものにすることに役立つでしょう。 - -.. - ======= - License - ======= - -.. _license: - -========== -ライセンス -========== - -Copyright Doug Hellmann, All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Doug Hellmann not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO -EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. diff --git a/docs/ja/install.rst b/docs/ja/install.rst deleted file mode 100644 index 16a9663..0000000 --- a/docs/ja/install.rst +++ /dev/null @@ -1,458 +0,0 @@ -.. - ============ - Installation - ============ - -============ -インストール -============ - -.. - Supported Shells - ================ - -.. _supported-shells: - -サポートシェル -============== - -.. - virtualenvwrapper is a set of shell *functions* defined in Bourne - shell compatible syntax. Its automated tests run under these - shells on OS X and Linux: - -virtualenvwrapper は Bourne シェル互換の構文をもつ一連のシェル *関数* です。Mac OS X と Linux 環境の、次のシェルで自動テストを行っています。 - -* ``bash`` -* ``ksh`` -* ``zsh`` - -.. - It may work with other shells, so if you find that it does work with a - shell not listed here please let me know. If you can modify it to - work with another shell without completely rewriting it, then send a pull - request through the `bitbucket project page`_. If you write a clone to - work with an incompatible shell, let me know and I will link to it - from this page. - -その他のシェルでも動作するかもしれません。ここに記載されていないシェルで動作するのを発見したら私に教えてください。また、その他のシェルでも動作するように virtualenvwrapper を全く違うものに書き換えずに修正できるなら、 `bitbucket のプロジェクトページ`_ から pull リクエストを送ってください。あなたが非互換なシェル上で動作させるクローンを作成するなら、このページでリンクを張るので私に連絡してください。 - -.. _bitbucket project page: https://bitbucket.org/dhellmann/virtualenvwrapper/ -.. _bitbucket のプロジェクトページ: https://bitbucket.org/dhellmann/virtualenvwrapper/ - -MSYS ----- - -.. - It is possible to use virtualenv wrapper under `MSYS - `_ with a native Windows Python - installation. In order to make it work, you need to define an extra - environment variable named ``MSYS_HOME`` containing the root path to - the MSYS installation. - -Python を Windows ネイティブにインストールした `MSYS `_ 環境でも virtualenvwrapper が使えます。そのためには、インストールした MSYS 環境へのルートパスを ``MSYS_HOME`` という環境変数で定義する必要があります。 - -:: - - export WORKON_HOME=$HOME/.virtualenvs - export MSYS_HOME=/c/msys/1.0 - source /usr/local/bin/virtualenvwrapper.sh - -.. - or:: - -または:: - - export WORKON_HOME=$HOME/.virtualenvs - export MSYS_HOME=C:\msys\1.0 - source /usr/local/bin/virtualenvwrapper.sh - -.. - Depending on your MSYS setup, you may need to install the `MSYS mktemp - binary`_ in the ``MSYS_HOME/bin`` folder. - -MSYS の設定によります。 ``MSYS_HOME/bin`` フォルダーに `MSYS mktemp binary`_ をインストールする必要があるかもしれません。 - -.. _MSYS mktemp binary: http://sourceforge.net/projects/mingw/files/MSYS/mktemp/ - -PowerShell ----------- - -.. - Guillermo López-Anglada has ported virtualenvwrapper to run under - Microsoft's PowerShell. We have agreed that since it is not compatible - with the rest of the extensions, and is largely a re-implementation - (rather than an adaptation), it should be distributed separately. You - can download virtualenvwrapper-powershell_ from PyPI. - -Guillermo López-Anglada は、Microsoft の PowerShell 環境で実行できるように virtualenvwrapper を移植しました。それは他の拡張機能と互換性がなく、(機能拡張というよりは) 大幅な再実装であることから、別に配布するようにしました。 virtualenvwrapper-powershell_ は、PyPI からダウンロードできます。 - -.. _virtualenvwrapper-powershell: http://pypi.python.org/pypi/virtualenvwrapper-powershell/2.7.1 - -.. - Python Versions - =============== - -.. _supported-versions: - -Python バージョン -================= - -.. - virtualenvwrapper is tested under Python 2.4 - 2.7. - -virtualenvwrapper は Python 2.4 - 2.7 でテストされています。 - -.. - Basic Installation - ================== - -.. _install-basic: - -基本的なインストール -==================== - -.. - virtualenvwrapper should be installed into the same global - site-packages area where virtualenv is installed. You may need - administrative privileges to do that. The easiest way to install it - is using pip_:: - -virtualenvwrapper は、virtualenv がインストールされているグローバルな site-packages ディレクトリと同じところにインストールする必要があります。それを行うには、管理者特権が必要になるかもしれません。最も簡単なインストール方法は pip_ を使うことです。 - -:: - - $ pip install virtualenvwrapper - -または:: - - $ sudo pip install virtualenvwrapper - -.. warning:: - - .. - virtualenv lets you create many different Python environments. You - should only ever install virtualenv and virtualenvwrapper on your - base Python installation (i.e. NOT while a virtualenv is active) - so that the same release is shared by all Python environments that - depend on it. - - virtualenv を使うと、たくさんの独立した Python 環境を作成できます。システム環境に依存する全ての Python 環境から同じパッケージを共有できるように、システムにインストールされている Python (virtualenv がアクティブではない) に virtualenv と virtualenvwrapper の2つだけはインストールする必要があります。 - -.. - An alternative to installing it into the global site-packages is to - add it to `your user local directory - `__ - (usually `~/.local`). - -グローバルの site-packages ディレクトリにインストールする代わりに `ユーザーのローカルディレクトリ `__ (普通は `~/.local`) にインストールできます。 - -:: - - $ pip install --install-option="--user" virtualenvwrapper - -.. - Shell Startup File - ================== - -.. _install-shell-config: - -シェルの起動ファイル -==================== - -.. - Add three lines to your shell startup file (``.bashrc``, ``.profile``, - etc.) to set the location where the virtual environments should live, - the location of your development project directories, and the location - of the script installed with this package:: - -シェルの起動ファイル (``.bashrc``, ``.profile`` など) に、仮想環境を構築する場所、開発中のプロジェクトディレクトリの場所、virtualenvwrapper がインストールしたシェルスクリプトの場所の3行を追加してください。 - -:: - - export WORKON_HOME=$HOME/.virtualenvs - export PROJECT_HOME=$HOME/Devel - source /usr/local/bin/virtualenvwrapper.sh - -.. - After editing it, reload the startup file (e.g., run ``source - ~/.bashrc``). - -編集後に起動ファイルを再読み込みしてください (例えば ``source ~/.bashrc`` を実行する) 。 - -.. - Quick-Start - =========== - -クイックスタート -================ - -.. - 1. Run: ``workon`` - 2. A list of environments, empty, is printed. - 3. Run: ``mkvirtualenv temp`` - 4. A new environment, ``temp`` is created and activated. - 5. Run: ``workon`` - 6. This time, the ``temp`` environment is included. - -1. ``workon`` を実行する -2. 仮想環境のリストが表示されるか、何も表示されない -3. ``mkvirtualenv temp`` を実行する -4. 新たな仮想環境 ``temp`` が作成されてアクティブ化される -5. ``workon`` を実行する -6. このときに ``temp`` の仮想環境が提供される - -.. - Configuration - ============= - -設定 -==== - -.. - virtualenvwrapper can be customized by changing environment - variables. Set the variables in your shell startup file *before* - loading ``virtualenvwrapper.sh``. - -virtualenvwrapper は、環境変数を変更することでカスタマイズできます。 ``virtualenvwrapper.sh`` が読み込まれる *前の* シェルの起動ファイルで環境変数を設定してください。 - -.. - Location of Environments - ------------------------ - -.. _variable-WORKON_HOME: - -仮想環境の場所 --------------- - -.. - The variable ``WORKON_HOME`` tells virtualenvwrapper where to place - your virtual environments. The default is ``$HOME/.virtualenvs``. If - the directory does not exist when virtualenvwrapper is loaded, it will - be created automatically. - -環境変数 ``WORKON_HOME`` は、virtualenvwrapper が使う仮想環境の場所を指定します。デフォルト設定は ``$HOME/.virtualenvs`` です。virtualenvwrapper が読み込まれたときにそのディレクトリが存在しない場合は、自動的に作成されます。 - -.. - Location of Project Directories - ------------------------------- - -.. _variable-PROJECT_HOME: - -プロジェクトディレクトリの場所 ------------------------------- - -.. - The variable ``PROJECT_HOME`` tells virtualenvwrapper where to place - your project working directories. The variable must be set and the - directory created before :ref:`command-mkproject` is used. - -環境変数 ``PROJECT_HOME`` は、virtualenvwrapper が使うプロジェクトのワークディレクトリの場所を指定します。この環境変数は :ref:`command-mkproject` を利用する前に設定して、そのディレクトリを作成しておく必要があります。 - -.. seealso:: - - * :ref:`project-management` - -.. - Project Linkage Filename - ------------------------ - -.. _variable-VIRTUALENVWRAPPER_PROJECT_FILENAME: - -プロジェクトのリンクファイル名 ------------------------------- - -.. - The variable ``VIRTUALENVWRAPPER_PROJECT_FILENAME`` tells - virtualenvwrapper how to name the file linking a virtualenv to a - project working directory. The default is ``.project``. - -環境変数 ``VIRTUALENVWRAPPER_PROJECT_FILENAME`` は、virtualenvwrapper が使う、プロジェクトのワークディレクトリに対して virtualenv をリンクするファイル名を指定します。 - -.. seealso:: - - * :ref:`project-management` - -.. - Location of Hook Scripts - ------------------------ - -.. _variable-VIRTUALENVWRAPPER_HOOK_DIR: - -フックスクリプトの場所 ----------------------- - -.. - The variable ``VIRTUALENVWRAPPER_HOOK_DIR`` tells virtualenvwrapper - where the :ref:`user-defined hooks ` should be placed. The - default is ``$WORKON_HOME``. - -環境変数 ``VIRTUALENVWRAPPER_HOOK_DIR`` は、virtualenvwrapper が使う :ref:`ユーザー定義のフック ` が保存される場所を指定します。デフォルト設定 ``$WORKON_HOME`` です。 - -.. seealso:: - - * :ref:`scripts` - -.. - Location of Hook Logs - --------------------- - -.. _variable-VIRTUALENVWRAPPER_LOG_DIR: - -フックログの場所 ----------------- - -.. - The variable ``VIRTUALENVWRAPPER_LOG_DIR`` tells virtualenvwrapper - where the logs for the hook loader should be written. The default is - ``$WORKON_HOME``. - -環境変数 ``VIRTUALENVWRAPPER_LOG_DIR`` は、virtualenvwrapper のフックローダーが書き込むログの場所を指定します。デフォルト設定 ``$WORKON_HOME`` です。 - -.. _variable-VIRTUALENVWRAPPER_VIRTUALENV: - -.. _variable-VIRTUALENVWRAPPER_VIRTUALENV_ARGS: - -.. _variable-VIRTUALENVWRAPPER_PYTHON: - -Python インタープリターと virtualenv と $PATH ---------------------------------------------- - -.. - Python Interpreter, virtualenv, and $PATH - ----------------------------------------- - -.. - During startup, ``virtualenvwrapper.sh`` finds the first ``python`` - and ``virtualenv`` programs on the ``$PATH`` and remembers them to use - later. This eliminates any conflict as the ``$PATH`` changes, - enabling interpreters inside virtual environments where - virtualenvwrapper is not installed or where different versions of - virtualenv are installed. Because of this behavior, it is important - for the ``$PATH`` to be set **before** sourcing - ``virtualenvwrapper.sh``. For example:: - -起動ファイルの読み込み時に ``virtualenvwrapper.sh`` は、最初に ``$PATH`` 上の ``python`` と ``virtualenv`` を見つけて、後で使うためにその情報を覚えておきます。これは virtualenvwrapper がインストールされていない、または別のバージョンの virtualenv がインストールされた仮想環境内部でインタープリタを有効にしていながら ``$PATH`` 変更による競合が起こらないようにします。この動作の理由は ``virtualenvwrapper.sh`` を source する **前に** 設定された ``$PATH`` が重要だからです。 - -例えば:: - - export PATH=/usr/local/bin:$PATH - source /usr/local/bin/virtualenvwrapper.sh - -.. - To override the ``$PATH`` search, set the variable - ``VIRTUALENVWRAPPER_PYTHON`` to the full path of the interpreter to - use and ``VIRTUALENVWRAPPER_VIRTUALENV`` to the full path of the - ``virtualenv`` binary to use. Both variables *must* be set before - sourcing ``virtualenvwrapper.sh``. For example:: - -``$PATH`` の探索を上書きするには、 -利用するインタープリターのフルパスを指定した ``VIRTUALENVWRAPPER_PYTHON`` と、 -利用する ``virtualenv`` バイナリ指定した ``VIRTUALENVWRAPPER_VIRTUALENV`` のフルパスを設定してください。 -両方の環境変数は ``virtualenvwrapper.sh`` が source される前に *設定する必要があります* 。 - -例えば:: - - export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python - export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv - source /usr/local/bin/virtualenvwrapper.sh - -.. - Default Arguments for virtualenv - -------------------------------- - -virtualenv のデフォルト引数 ---------------------------- - -.. - If the application identified by ``VIRTUALENVWRAPPER_VIRTUALENV`` - needs arguments, they can be set in - ``VIRTUALENVWRAPPER_VIRTUALENV_ARGS``. The same variable can be used - to set default arguments to be passed to ``virtualenv``. For example, - set the value to ``--no-site-packages`` to ensure that all new - environments are isolated from the system ``site-packages`` directory. - -``VIRTUALENVWRAPPER_VIRTUALENV`` で指定されたアプリケーションが引数を取るなら、その引数を ``VIRTUALENVWRAPPER_VIRTUALENV_ARGS`` に設定できます。この環境変数は ``virtualenv`` に渡すデフォルト引数を設定するのにも使えます。例えば、システムの ``site-packages`` ディレクトリと独立した仮想環境を毎回新たに作成するには、 ``--no-site-packages`` をその値として設定します。 - -:: - - export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages' - -.. - Temporary Files - --------------- - -一時ファイル ------------- - -.. - virtualenvwrapper creates temporary files in ``$TMPDIR``. If the - variable is not set, it uses ``/tmp``. To change the location of - temporary files just for virtualenvwrapper, set - ``VIRTUALENVWRAPPER_TMPDIR``. - -virtualenvwrapper は ``$TMPDIR`` に一時ファイルを作成します。その環境変数がセットされていない場合は ``/tmp`` を使用します。virtualenvwrapper 向けだけの一時ファイルの作成場所を変更するには ``VIRTUALENVWRAPPER_TMPDIR`` をセットしてください。 - -.. - Site-wide Configuration - ----------------------- - -サイト全体の設定 ----------------- - -.. - Most UNIX systems include the ability to change the configuration for - all users. This typically takes one of two forms: editing the - *skeleton* files for new accounts or editing the global startup file - for a shell. - -ほとんどの UNIX システムは、全てのユーザーに設定を適用する機能を提供します。これは典型的に2つの方法のいずれかを取ります。新しいアカウントの作成時の *skeleton* ファイルを編集するか、シェルのグローバルな起動ファイルを編集するかです。 - -.. - Editing the skeleton files for new accounts means that each new user - will have their private startup files preconfigured to load - virtualenvwrapper. They can disable it by commenting out or removing - those lines. Refer to the documentation for the shell and operating - system to identify the appropriate file to edit. - -新しいアカウントの作成時にスケルトンファイルを編集する方法は、各ユーザーが virtualenvwrapper を読み込むようにあらかじめ設定された自分たちの起動ファイルをもちます。各ユーザーは、起動ファイルの該当行をコメントアウトしたり、削除することで設定を無効にできます。編集する必要のある適切なファイルを把握するには、オペレーティングシステム、またはシェルのドキュメントを参照してください。 - -.. - Modifying the global startup file for a given shell means that all - users of that shell will have virtualenvwrapper enabled, and they - cannot disable it. Refer to the documentation for the shell to - identify the appropriate file to edit. - -特定シェルのグローバルの起動ファイルを変更する方法は、そのシェルの全ユーザーに対して virtualenvwrapper が有効となり、各ユーザーが無効にすることはできません。編集する必要のある適切なファイルを把握するには、オペレーティングシステム、またはシェルのドキュメントを参照してください。 - -.. - Upgrading to 2.9 - ================ - -2.9 へのアップグレード -====================== - -.. - Version 2.9 includes the features previously delivered separately by - ``virtualenvwrapper.project``. If you have an older verison of the - project extensions installed, remove them before upgrading. - -バージョン 2.9 は、それまで別で配布していた ``virtualenvwrapper.project`` の機能を提供します。そのプロジェクト拡張の古いバージョンをインストールしているなら、アップグレード前にそれらを削除してください。 - -.. - Upgrading from 1.x - ================== - -1.x からのアップグレード -======================== - -.. - The shell script containing the wrapper functions has been renamed in - the 2.x series to reflect the fact that shells other than bash are - supported. In your startup file, change ``source - /usr/local/bin/virtualenvwrapper_bashrc`` to ``source - /usr/local/bin/virtualenvwrapper.sh``. - -ラッパー関数を含むシェルスクリプトは 2.x バージョンで bash 以外のシェルをサポートするためにその名前が変更されました。あなたの起動ファイルの ``source /usr/local/bin/virtualenvwrapper_bashrc`` を ``source /usr/local/bin/virtualenvwrapper.sh`` へ変更してください。 - -.. _pip: http://pypi.python.org/pypi/pip diff --git a/docs/ja/plugins.rst b/docs/ja/plugins.rst deleted file mode 100644 index 7662942..0000000 --- a/docs/ja/plugins.rst +++ /dev/null @@ -1,612 +0,0 @@ -.. - =========================== - Extending Virtualenvwrapper - =========================== - -.. _plugins: - -============================ -virtualenvwrapper を拡張する -============================ - -.. - Long experience with home-grown solutions for customizing a - development environment has proven how valuable it can be to have the - ability to automate common tasks and eliminate persistent annoyances. - Carpenters build jigs, software developers write shell scripts. - virtualenvwrapper continues the tradition of encouraging a craftsman - to modify their tools to work the way they want, rather than the other - way around. - -開発環境をカスタマイズするために自作で解決してきた長い経験から、共通タスクを自動化して、何度も繰り返す苛々するような作業を取り除く機能がどれほどの価値をもつか分かりました。大工は治具を組み立て、ソフトウェア開発者はシェルスクリプトを書きます。virtualenvwrapper は逆になりますが、求める方法で動作するようにツールを修正する職人を励ます伝統を受け継いでいます。 - -.. - Use the hooks provided to eliminate repetitive manual operations and - streamline your development workflow. For example, set up the - :ref:`plugins-pre_activate` and :ref:`plugins-post_activate` hooks to - trigger an IDE to load a project file to reload files from the last - editing session, manage time-tracking records, or start and stop - development versions of an application server. Use the - :ref:`plugins-initialize` hook to add entirely new commands and hooks - to virtualenvwrapper. And the :ref:`plugins-pre_mkvirtualenv` and - :ref:`plugins-post_mkvirtualenv` hooks give you an opportunity to - install basic requirements into each new development environment, - initialize a source code control repository, or otherwise set up a new - project. - -繰り返し行う手動の操作を取り除いたり開発ワークフローを効率化するために提供されるフックを使用してください。例えば、最後に編集されたセッションからファイルを再読み込みするために IDE にプロジェクトファイルを読む込ませる、時間追跡記録を管理する、もしくはアプリケーションサーバの開発バージョンを起動・停止するために :ref:`plugins-pre_activate` や :ref:`plugins-post_activate` フックを設定してください。 :ref:`plugins-initialize` は virtualenvwrapper に対するフックや完全に新しいコマンドを追加するためのフックです。そして :ref:`plugins-pre_mkvirtualenv` や :ref:`plugins-post_mkvirtualenv` といったフックはそれぞれの新しい開発環境へ基本的な必需品をインストールする、ソースコードリポジトリの初期化、その他の新たなプロジェクトの設定を行うといった機会を与えます。 - -.. - There are two ways to attach your code so that virtualenvwrapper will - run it: End-users can use shell scripts or other programs for personal - customization (see :ref:`scripts`). Extensions can also be - implemented in Python by using Distribute_ *entry points*, making it - possible to share common behaviors between systems and developers. - -virtualenvwrapper がそういったことを実行できるようにあなたのコードをアタッチする方法が2つあります。エンドユーザはシェルスクリプトか、個人的なカスタマイズを施したプログラムを使用できます(:ref:`scripts` を参照)。さらに拡張機能は、システムと開発者間で共通の振る舞いを共有できるようにする Distribute_ *エントリポイント* を使用して Python で実装することもできます。 - -.. - Defining an Extension - ===================== - -拡張機能を定義する -================== - -.. note:: - - .. Virtualenvwrapper is delivered with a plugin for creating and - running the user customization scripts - (:ref:`extensions-user_scripts`). The examples below are taken from - the implementation of that plugin. - - virtualenvwrapper はユーザのカスタムスクリプトを作成して実行することをプラグインで実現します(:ref:`extensions-user_scripts`)。次のサンプルはそういったプラグインの実装を紹介します。 - -.. - Code Organization - ----------------- - -コードの構成 ------------- - -.. - The Python package for ``virtualenvwrapper`` is a *namespace package*. - That means multiple libraries can install code into the package, even - if they are not distributed together or installed into the same - directory. Extensions can (optionally) use the ``virtualenvwrapper`` - namespace by setting up their source tree like: - -``virtualenvwrapper`` の Python パッケージは *名前空間パッケージ* です。複数のライブラリが一緒に配布されていなかったり同じディレクトリ内にインストールされていなかったとしても、そのパッケージ内へインストールできます。拡張機能は次のようにソースツリーを設定することで ``virtualenvwrapper`` の名前空間を(オプションで)使用することが出来ます。 - -* virtualenvwrapper/ - - * __init__.py - * user_scripts.py - -.. - And placing the following code in ``__init__.py``:: - -そして ``__init__.py`` に次のコードを含めます。 - -:: - - """virtualenvwrapper module - """ - - __import__('pkg_resources').declare_namespace(__name__) - -.. note:: - - .. Extensions can be loaded from any package, so using the - ``virtualenvwrapper`` namespace is not required. - - 拡張機能はどんなパッケージからも読み込まれるので ``virtualenvwrapper`` の名前空間を使用する必要はありません。 - -.. - Extension API - ------------- - -拡張 API --------- - -.. - After the package is established, the next step is to create a module - to hold the extension code. For example, - ``virtualenvwrapper/user_scripts.py``. The module should contain the - actual extension entry points. Supporting code can be included, or - imported from elsewhere using standard Python code organization - techniques. - -パッケージを作成した後の次のステップとして、拡張コードを保持するモジュールを作成します。例えば ``virtualenvwrapper/user_scripts.py`` です。そのモジュールは実際の拡張機能のエントリポイントを含みます。サポートするコードが含められるか、標準の Python コードの構成テクニックを利用してインポートされます。 - -.. - The API is the same for every extension point. Each uses a Python - function that takes a single argument, a list of strings passed to the - hook loader on the command line. - -API は全ての拡張ポイントで同じです。それぞれは1つの引数、つまりコマンドライン上でフックローダへ渡される文字列のリストを受け取る Python 関数を使用します。 - -:: - - def function_name(args): - # args is a list of strings passed to the hook loader - -.. - The contents of the argument list are defined for each extension point - below (see :ref:`plugins-extension-points`). - -引数リストのコンテンツは次の拡張ポイント毎に定義されます(:ref:`plugins-extension-points` を参照)。 - -.. - Extension Invocation - -------------------- - -拡張機能の起動 --------------- - -.. - Direct Action - ~~~~~~~~~~~~~ - -ダイレクトアクション -~~~~~~~~~~~~~~~~~~~~ - -.. - Plugins can attach to each hook in two different ways. The default is - to have a function run and do some work directly. For example, the - ``initialize()`` function for the user scripts plugin creates default - user scripts when ``virtualenvwrapper.sh`` is loaded. - -プラグインは2つの方法でそれぞれのフックをアタッチできます。デフォルトは直接的に何らかの処理を実行する関数を持ちます。例えば、ユーザスクリプトプラグインの ``initialize()`` 関数は ``virtualenvwrapper.sh`` が読み込まれるときにデフォルトユーザスクリプトを作成します。 - -:: - - def initialize(args): - for filename, comment in GLOBAL_HOOKS: - make_hook(os.path.join('$WORKON_HOME', filename), comment) - return - -.. - Modifying the User Environment - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. _plugins-user-env: - -ユーザ環境を変更する -~~~~~~~~~~~~~~~~~~~~ - -.. - There are cases where the extension needs to update the user's - environment (e.g., changing the current working directory or setting - environment variables). Modifications to the user environment must be - made within the user's current shell, and cannot be run in a separate - process. To have code run in the user's shell process, extensions can - define hook functions to return the text of the shell statements to be - executed. These *source* hooks are run after the regular hooks with - the same name, and should not do any work of their own. - -拡張機能がユーザ環境のアップデートを必要とするケースがあります(例えば、カレントワークディレクトリを変更したり、環境変数を設定する等)。ユーザ環境に対する変更はユーザのカレントシェル内で行われなければならず、独立したプロセスで実行できません。ユーザのシェルプロセスで実行するコードを持つために、拡張機能は実行されるシェル構文のテキストを返すフック関数を定義できます。これらの *source* フックは同じ名前を持つ通常のフックの後で実行されます。そして、そのフック内部で処理を行ってはいけません。 - -.. - The ``initialize_source()`` hook for the user scripts plugin looks for - a global initialize script and causes it to be run in the current - shell process. - -ユーザスクリプトプラグインの ``initialize_source()`` フックは、グローバルな初期化スクリプトを調べてカレントのシェルプロセスでそのスクリプトを実行させます。 - -:: - - def initialize_source(args): - return """ - # - # Run user-provided scripts - # - [ -f "$WORKON_HOME/initialize" ] && source "$WORKON_HOME/initialize" - """ - -.. warning:: - - .. Because the extension is modifying the user's working shell, care - must be taken not to corrupt the environment by overwriting - existing variable values unexpectedly. Avoid creating temporary - variables where possible, and use unique names where variables - cannot be avoided. Prefixing variables with the extension name is - a good way to manage the namespace. For example, instead of - ``temp_file`` use ``user_scripts_temp_file``. Use ``unset`` to - release temporary variable names when they are no longer needed. - - 拡張機能はユーザのワークシェルを変更しているので、予期しない既存変数の上書きにより環境が汚染されないように注意しなければなりません。できるだけ一時的な変数を作成せずに、必要なところで一意な名前を使用してください。接頭辞として拡張名が付く変数は名前空間を管理するのに良い方法です。例えば、 ``temp_file`` ではなく ``user_scripts_temp_file`` を使用してください。一時的な変数は必要なくなったときに ``unset`` で解放してください。 - -.. warning:: - - .. virtualenvwrapper works under several shells with slightly - different syntax (bash, sh, zsh, ksh). Take this portability into - account when defining source hooks. Sticking to the simplest - possible syntax usually avoids problems, but there may be cases - where examining the ``SHELL`` environment variable to generate - different syntax for each case is the only way to achieve the - desired result. - - virtualenvwrapper は構文が少し違う複数のシェル(bash, sh, zsh, ksh)で動作します。ソースフックを定義するときにアカウント内にこの移植性を考慮してください。最も簡単な構文のみを使用することで普通は問題ありませんが、求める結果を得るためには唯一の方法しかないケースにおいて、違う構文を生成する ``SHELL`` 環境変数を調べる可能性があります。 - -.. - Registering Entry Points - ------------------------ - -エントリポイントを登録する --------------------------- - -.. - The functions defined in the plugin need to be registered as *entry - points* in order for virtualenvwrapper's hook loader to find them. - Distribute_ entry points are configured in the ``setup.py`` for your - package by mapping the entry point name to the function in the package - that implements it. - -プラグインで定義された関数は virtualenvwrapper のフックローダが見つけられるために *エントリポイント* として登録する必要があります。 Distribute_ エントリポイントは関数を実装するパッケージでその関数に対するエントリポイントの名前をマッピングすることにより、そのパッケージの ``setup.py`` で設定されます。 - -.. - This partial copy of virtualenvwrapper's ``setup.py`` illustrates how - the ``initialize()`` and ``initialize_source()`` entry points are - configured. - -この virtualenvwrapper の ``setup.py`` の一部は ``initialize()`` や ``initialize_source()`` エントリポイントの設定方法を説明します。 - -:: - - # Bootstrap installation of Distribute - import distribute_setup - distribute_setup.use_setuptools() - - from setuptools import setup - - setup( - name = 'virtualenvwrapper', - version = '2.0', - - description = 'Enhancements to virtualenv', - - # ... details omitted ... - - namespace_packages = [ 'virtualenvwrapper' ], - - entry_points = { - 'virtualenvwrapper.initialize': [ - 'user_scripts = virtualenvwrapper.user_scripts:initialize', - ], - 'virtualenvwrapper.initialize_source': [ - 'user_scripts = virtualenvwrapper.user_scripts:initialize_source', - ], - - # ... details omitted ... - }, - ) - -.. - The ``entry_points`` argument to ``setup()`` is a dictionary mapping - the entry point *group names* to lists of entry point specifiers. A - different group name is defined by virtualenvwrapper for each - extension point (see :ref:`plugins-extension-points`). - -``setup()`` への ``entry_points`` 引数はエントリポイントの指定子を表示するエントリポイント *グループ名* をマッピングするディクショナリです。違うグループ名はそれぞれの拡張ポイントのために virtualenvwrapper により定義されます(:ref:`plugins-extension-points` を参照)。 - -.. - The entry point specifiers are strings with the syntax ``name = - package.module:function``. By convention, the *name* of each entry - point is the plugin name, but that is not required (the names are not - used). - -エントリポイント指定子は ``name = package.module:function`` という構文の文字列です。慣例からエントリポイントの *名前* はプラグインの名前を付けますが、必須だというわけではありません (その名前を使わなくても構いません) 。 - -.. seealso:: - - .. * `namespace packages `__ - * `Extensible Applications and Frameworks `__ - - * `名前空間パッケージ `__ - * `拡張可能なアプリケーションとフレームワーク `__ - -.. - The Hook Loader - --------------- - -フックローダ ------------- - -.. - Extensions are run through a command line application implemented in - ``virtualenvwrapper.hook_loader``. Because ``virtualenvwrapper.sh`` - is the primary caller and users do not typically need to run the app - directly, no separate script is installed. Instead, to run the - application, use the ``-m`` option to the interpreter:: - -拡張機能は ``virtualenvwrapper.hook_loader`` で実装されたコマンドラインアプリケーションを通して実行されます。 ``virtualenvwrapper.sh`` がプライマリの呼び出しであり、ユーザはそのアプリケーションを直接的に実行する必要はないので、分割されたスクリプトはインストールされません。その代わり、そのアプリケーションを実行するにはインタープリタに ``-m`` オプションを指定してください。 - -:: - - $ python -m virtualenvwrapper.hook_loader -h - Usage: virtualenvwrapper.hook_loader [options] [] - - Manage hooks for virtualenvwrapper - - Options: - -h, --help show this help message and exit - -s, --source Print the shell commands to be run in the current - shell - -l, --list Print a list of the plugins available for the given - hook - -v, --verbose Show more information on the console - -q, --quiet Show less information on the console - -n NAMES, --name=NAMES - Only run the hook from the named plugin - -.. - To run the extensions for the initialize hook - -initialize フックのためにその拡張機能を実行するには次のようにします。 - -:: - - $ python -m virtualenvwrapper.hook_loader -v initialize - -.. - To get the shell commands for the initialize hook - -initialize フックのためにシェルコマンドを読み込むには次のようにします。 - -:: - - $ python -m virtualenvwrapper.hook_loader --source initialize - -.. - In practice, rather than invoking the hook loader directly it is more - convenient to use the shell function, ``virtualenvwrapper_run_hook`` - to run the hooks in both modes. - -実際は、フックローダが直接フックを実行するよりも両方のモードでフックを実行するシェル関数 ``virtualenvwrapper_run_hook`` を使用する方がもっと便利です。 - -:: - - $ virtualenvwrapper_run_hook initialize - -.. - All of the arguments given to shell function are passed directly to - the hook loader. - -シェル関数に与えられた全ての引数はフックローダへ直接渡されます。 - -.. - Logging - ------- - -ロギング --------- - -.. - The hook loader configures logging so that messages are written to - ``$WORKON_HOME/hook.log``. Messages also may be written to stderr, - depending on the verbosity flag. The default is for messages at *info* - or higher levels to be written to stderr, and *debug* or higher to go to - the log file. Using logging in this way provides a convenient - mechanism for users to control the verbosity of extensions. - -フックローダはログメッセージを ``$WORKON_HOME/hook.log`` に書き込むように設定します。またログメッセージは冗長フラグにより標準エラーにも出力されます。デフォルトでは、ログメッセージは *info* かそれ以上のレベルが標準エラーへ出力され、 *debug* かそれ以上がログファイルへ書き込まれます。この方法でロギングを使用することでユーザに拡張機能の冗長性を制御する便利な仕組みを提供します。 - -.. - To use logging from within your extension, simply instantiate a logger - and call its ``info()``, ``debug()`` and other methods with the - messages. - -拡張機能からロギングを使用するには、単純にロガーをインスタンス化して、ログメッセージと共にその ``info()``, ``debug()`` やその他のメソッドを呼び出してください。 - -:: - - import logging - log = logging.getLogger(__name__) - - def pre_mkvirtualenv(args): - log.debug('pre_mkvirtualenv %s', str(args)) - # ... - -.. seealso:: - - .. * `Standard library documentation for logging `__ - * `PyMOTW for logging `__ - - * `logging の標準ライブラリドキュメント `__ - * `logging の PyMOTW `__ - -.. - Extension Points - ================ - -.. _plugins-extension-points: - -拡張ポイント -============ - -.. - The extension point names for native plugins follow a naming - convention with several parts: - ``virtualenvwrapper.(pre|post)_[_source]``. The ** is - the action taken by the user or virtualenvwrapper that triggers the - extension. ``(pre|post)`` indicates whether to call the extension - before or after the event. The suffix ``_source`` is added for - extensions that return shell code instead of taking action directly - (see :ref:`plugins-user-env`). - -ネイティブプラグインの拡張ポイントの名前は複数のパートを持つ命名規則 ``virtualenvwrapper.(pre|post)_[_source]`` に従います。 ** は拡張機能が引き起こす virtualenvwrapper またはユーザによるアクションです。 ``(pre|post)`` はその拡張機能の呼び出しがイベントの前か後かのどちらかを指します。接尾辞 ``_source`` は直接アクションを受け取らずにシェルスクリプトのコードを返す拡張機能に追加されます(:ref:`plugins-user-env` を参照)。 - -.. _plugins-get_env_details: - -get_env_details -=============== - -.. - The ``virtualenvwrapper.get_env_details`` hooks are run when - ``workon`` is run with no arguments and a list of the virtual - environments is printed. The hook is run once for each environment, - after the name is printed, and can be used to show additional - information about that environment. - -``virtualenvwrapper.get_env_details`` フックは ``workon`` が引数無しで実行されるときに実行されます。そして、仮想環境のリストを表示します。仮想環境の名前が表示された後で、そのフックは環境毎に一度実行されて、その環境に関する追加情報を表示します。 - -.. _plugins-initialize: - -initialize ----------- - -.. - The ``virtualenvwrapper.initialize`` hooks are run each time - ``virtualenvwrapper.sh`` is loaded into the user's environment. The - initialize hook can be used to install templates for configuration - files or otherwise prepare the system for proper plugin operation. - -``virtualenvwrapper.initialize`` フックは ``virtualenvwrapper.sh`` が環境に読み込まれる毎に実行されます。initialize フックは設定ファイルのテンプレートをインストールしたり、適切なプラグイン操作のためにシステムを整備するために使用されます。 - -.. _plugins-pre_mkvirtualenv: - -pre_mkvirtualenv ----------------- - -.. - The ``virtualenvwrapper.pre_mkvirtualenv`` hooks are run after the - virtual environment is created, but before the new environment is - activated. The current working directory for when the hook is run is - ``$WORKON_HOME`` and the name of the new environment is passed as an - argument. - -``virtualenvwrapper.pre_mkvirtualenv`` フックは仮想環境が作成された後で実行されますが、新しい環境がアクティブ化される前に実行されます。そのフックが実行されるときのためにカレントワークディレクトリは ``$WORKON_HOME`` で、1つの引数として新しい環境の名前が渡されます。 - -.. _plugins-post_mkvirtualenv: - -post_mkvirtualenv ------------------ - -.. - The ``virtualenvwrapper.post_mkvirtualenv`` hooks are run after a new - virtual environment is created and activated. ``$VIRTUAL_ENV`` is set - to point to the new environment. - -``virtualenvwrapper.post_mkvirtualenv`` フックは新しい仮想仮想が作成されて、アクティブ化された後で実行されます。 ``$VIRTUAL_ENV`` は新しい環境を指すようにセットされます。 - -.. _plugins-pre_activate: - -pre_activate ------------- - -.. - The ``virtualenvwrapper.pre_activate`` hooks are run just before an - environment is enabled. The environment name is passed as the first - argument. - -``virtualenvwrapper.pre_activate`` フックは仮想環境が有効になる前に実行されます。環境の名前は1番目の引数として渡されます。 - -.. _plugins-post_activate: - -post_activate -------------- - -.. - The ``virtualenvwrapper.post_activate`` hooks are run just after an - environment is enabled. ``$VIRTUAL_ENV`` is set to point to the - current environment. - -``virtualenvwrapper.post_activate`` フックは仮想環境が有効になった後で実行されます。 ``$VIRTUAL_ENV`` はカレント環境を指すようにセットされます。 - -.. _plugins-pre_deactivate: - -pre_deactivate --------------- - -.. - The ``virtualenvwrapper.pre_deactivate`` hooks are run just before an - environment is disabled. ``$VIRTUAL_ENV`` is set to point to the - current environment. - -``virtualenvwrapper.pre_deactivate`` フックは仮想環境が無効になる前に実行されます。 ``$VIRTUAL_ENV`` はカレント環境を指すようにセットされます。 - -.. _plugins-post_deactivate: - -post_deactivate ---------------- - -.. - The ``virtualenvwrapper.post_deactivate`` hooks are run just after an - environment is disabled. The name of the environment just deactivated - is passed as the first argument. - -``virtualenvwrapper.post_deactivate`` フックは仮想環境が無効になった後で実行されます。非アクティブ化される環境の名前は1番目の引数として渡されます。 - -.. _plugins-pre_rmvirtualenv: - -pre_rmvirtualenv ----------------- - -.. - The ``virtualenvwrapper.pre_rmvirtualenv`` hooks are run just before - an environment is deleted. The name of the environment being deleted - is passed as the first argument. - -``virtualenvwrapper.pre_rmvirtualenv`` フックは仮想環境が削除される前に実行されます。削除される環境の名前は1番目の引数として渡されます。 - -.. _plugins-post_rmvirtualenv: - -post_rmvirtualenv ------------------ - -.. - The ``virtualenvwrapper.post_rmvirtualenv`` hooks are run just after - an environment is deleted. The name of the environment being deleted - is passed as the first argument. - -``virtualenvwrapper.post_rmvirtualenv`` フックは仮想環境が削除された後で実行されます。削除される環境の名前は1番目の引数として渡されます。 - -.. - Adding New Extension Points - =========================== - -新しい拡張ポイントを追加する -============================ - -.. - Plugins that define new operations can also define new extension - points. No setup needs to be done to allow the hook loader to find - the extensions; documenting the names and adding calls to - ``virtualenvwrapper_run_hook`` is sufficient to cause them to be - invoked. - -さらに新しい操作を定義するプラグインは新しい拡張ポイントも定義できます。フックローダが拡張機能を見つけるために行う設定は必要ありません。名前を記述して ``virtualenvwrapper_run_hook`` の呼び出しを追加することで、追加した拡張機能が実行されるようになります。 - -.. - The hook loader assumes all extension point names start with - ``virtualenvwrapper.`` and new plugins will want to use their own - namespace qualifier to append to that. For example, the project_ - extension defines new events around creating project directories (pre - and post). These are called - ``virtualenvwrapper.project.pre_mkproject`` and - ``virtualenvwrapper.project.post_mkproject``. These are invoked - with:: - -フックローダは全ての拡張ポイントの名前が ``virtualenvwrapper.`` で始まることを前提としています。そして、新しいプラグインは独自の名前空間の修飾語句をその接頭辞に追加したくなるでしょう。例えば project_ 拡張はプロジェクトのディレクトリ作成(前後)に関連して新たなイベントを定義します。そこで ``virtualenvwrapper.project.pre_mkproject`` と ``virtualenvwrapper.project.post_mkproject`` が呼び出されます。それは次のように1つずつ実行されます。 - -:: - - virtualenvwrapper_run_hook project.pre_mkproject $project_name - -.. - and - -と - -:: - - virtualenvwrapper_run_hook project.post_mkproject - -.. - respectively. - -です。 - -.. _Distribute: http://packages.python.org/distribute/ - -.. _project: http://www.doughellmann.com/projects/virtualenvwrapper.project/ diff --git a/docs/ja/projects.rst b/docs/ja/projects.rst deleted file mode 100644 index 90c65a8..0000000 --- a/docs/ja/projects.rst +++ /dev/null @@ -1,56 +0,0 @@ -.. _project-management: - -================== - プロジェクト管理 -================== - -.. - ==================== - Project Management - ==================== - -.. - A :term:`project directory` is associated with a virtualenv, but - usually contains the source code under active development rather than - the installed components needed to support the development. For - example, the project directory may contain the source code checked out - from a version control system, temporary artifacts created by testing, - experimental files not committed to version control, etc. - -:term:`project directory` は virtualenv に関連付けられますが、開発を支援するために必要とされるコンポーネントをインストールするというより、普通は活発に開発中のソースコードを含みます。例えば、プロジェクトディレクトリは、バージョン管理システムからチェックアウトされたソースコード、まだバージョン管理システムにコミットされていないテストや実験的なファイルから作成された一時的なファイルを含むかもしれません。 - -.. - A project directory is created and bound to a virtualenv when - :ref:`command-mkproject` is run instead of - :ref:`command-mkvirtualenv`. To bind an existing project directory to - a virtualenv, use :ref:`command-setvirtualenvproject`. - -プロジェクトディレクトリが作成して、 :ref:`command-mkvirtualenv` の代わりに :ref:`command-mkproject` を実行するときに virtualenv を束縛します。既存のプロジェクトディレクトリを virtualenv に束縛するには :ref:`command-setvirtualenvproject` を使ってください。 - -.. - Using Templates - =============== - -テンプレートの利用 -================== - -.. - A new project directory can be created empty, or populated using one - or more :term:`template` plugins. Templates should be specified as - arguments to :ref:`command-mkproject`. Multiple values can be provided - to apply more than one template. For example, to check out a Mercurial - repository from on a project on bitbucket and create a new Django - site, combine the :ref:`templates-bitbucket` and - :ref:`templates-django` templates. - -新しいプロジェクトディレクトリは、空のディレクトリ、または :term:`template` プラグインを使って作成されます。テンプレートは :ref:`command-mkproject` の引数として指定します。複数のテンプレートも適用できます。例えば、bitbucket のプロジェクトから Mercurial リポジトリをチェックアウトして新たに Django サイトを作成するには、 :ref:`templates-bitbucket` と :ref:`templates-django` のテンプレートを組み合わせて使います。 - -:: - - $ mkproject -t bitbucket -t django my_site - -.. seealso:: - - * :ref:`extensions-templates` - * :ref:`variable-PROJECT_HOME` - * :ref:`variable-VIRTUALENVWRAPPER_PROJECT_FILENAME` diff --git a/docs/ja/scripts.rst b/docs/ja/scripts.rst deleted file mode 100644 index d50dbac..0000000 --- a/docs/ja/scripts.rst +++ /dev/null @@ -1,361 +0,0 @@ -.. - ======================== - Per-User Customization - ======================== - -.. _scripts: - -==================== - ユーザカスタマイズ -==================== - -.. - The end-user customization scripts are either *sourced* (allowing them - to modify your shell environment) or *run* as an external program at - the appropriate trigger time. - -エンドユーザのカスタマイズスクリプトは *読み込み* (シェル環境を変更できる) されるか、適切な条件で外部プログラムのように *実行* されるかのどちらかです。 - -.. - The global scripts applied to all environments should be placed in the - directory named by :ref:`VIRTUALENVWRAPPER_HOOK_DIR - `. The local scripts should be - placed in the ``bin`` directory of the virtualenv. - -全ての環境に適用されるグローバルスクリプトは、 :ref:`VIRTUALENVWRAPPER_HOOK_DIR ` で指定したディレクトリに置きます。ローカルスクリプトは virtualenv の ``bin`` ディレクトリに置きます。 - -.. _scripts-get_env_details: - -get_env_details -=============== - - .. :Global/Local: both - :Argument(s): env name - :Sourced/Run: run - - :グローバル/ローカル: 両方 - :引数: 環境名 - :読み込み/実行: 実行 - -.. - ``$VIRTUALENVWRAPPER_HOOK_DIR/get_env_details`` is run when ``workon`` is run with no - arguments and a list of the virtual environments is printed. The hook - is run once for each environment, after the name is printed, and can - print additional information about that environment. - -``$VIRTUALENVWRAPPER_HOOK_DIR/get_env_details`` は ``workon`` が引数無しで実行されるときに実行されます。そして、仮想環境のリストを表示します。仮想環境の名前が表示された後で、そのフックは環境毎に一度実行されて、その環境に関する追加情報を表示します。 - -.. _scripts-initialize: - -initialize -========== - - .. :Global/Local: global - :Argument(s): None - :Sourced/Run: sourced - - :グローバル/ローカル: グローバル - :引数: 無し - :読み込み/実行: 読み込み - -.. - ``$VIRTUALENVWRAPPER_HOOK_DIR/initialize`` is sourced when ``virtualenvwrapper.sh`` - is loaded into your environment. Use it to adjust global settings - when virtualenvwrapper is enabled. - -あなたの環境に ``virtualenvwrapper.sh`` を読み込むときに ``$VIRTUALENVWRAPPER_HOOK_DIR/initialize`` が読み込まれます。virtualenvwrapper が有効になるときにグローバルな設定を調整するために使用してください。 - -.. _scripts-premkvirtualenv: - -premkvirtualenv -=============== - - .. :Global/Local: global - :Argument(s): name of new environment - :Sourced/Run: run - - :グローバル/ローカル: グローバル - :引数: 新しい環境名 - :読み込み/実行: 実行 - -.. - ``$VIRTUALENVWRAPPER_HOOK_DIR/premkvirtualenv`` is run as an external program after - the virtual environment is created but before the current environment - is switched to point to the new env. The current working directory for - the script is ``$WORKON_HOME`` and the name of the new environment is - passed as an argument to the script. - -``$VIRTUALENVWRAPPER_HOOK_DIR/premkvirtualenv`` は仮想環境が作成された後で外部プログラムのように実行されますが、カレントの環境が新しい環境へ切り替わる前に実行されます。そのスクリプトのカレントワークディレクトリは ``$WORKON_HOME`` で、そのスクリプトへの引数として新しい環境の名前が渡されます。 - -.. _scripts-postmkvirtualenv: - -postmkvirtualenv -================ - - .. :Global/Local: global - :Argument(s): none - :Sourced/Run: sourced - - :グローバル/ローカル: グローバル - :引数: 無し - :読み込み/実行: 読み込み - -.. - ``$VIRTUALENVWRAPPER_HOOK_DIR/postmkvirtualenv`` is sourced after the new environment - is created and activated. If the ``-a`` flag was used, - the link to the project directory is set up before this script is sourced. - -``$VIRTUALENVWRAPPER_HOOK_DIR/postmkvirtualenv`` は、新しい環境が作成されてアクティブ化された後で読み込まれます。 ``-a`` フラグを指定された場合、このスクリプトを読み込む前にプロジェクトディレクトリへのリンクを設定します。 - -.. _scripts-precpvirtualenv: - -precpvirtualenv -=============== - - .. :Global/Local: global - :Argument(s): name of original environment, name of new environment - :Sourced/Run: run - - :グローバル/ローカル: グローバル - :引数: オリジナルの環境名、新しい環境名 - :読み込み/実行: 実行 - -.. - ``$VIRTUALENVWRAPPER_HOOK_DIR/precpvirtualenv`` is run as an external program after - the source environment is duplicated and made relocatable, but before - the ``premkvirtualenv`` hook is run or the current environment is - switched to point to the new env. The current working directory for - the script is ``$WORKON_HOME`` and the names of the source and new - environments are passed as arguments to the script. - -``$VIRTUALENVWRAPPER_HOOK_DIR/precpvirtualenv`` は元の環境が複製されて再配置可能になるときに外部プログラムのように実行されますが、 ``premkvirtualenv`` フックが実行される前、もしくはカレントの環境が新しい環境へ切り替わる前に実行されます。そのスクリプトのカレントワークディレクトリは ``$WORKON_HOME`` で、そのスクリプトへの引数として元の環境名と新しい環境名が渡されます。 - -.. _scripts-postcpvirtualenv: - -postcpvirtualenv -================ - - .. :Global/Local: global - :Argument(s): none - :Sourced/Run: sourced - - :グローバル/ローカル: グローバル - :引数: 無し - :読み込み/実行: 読み込み - -.. - ``$VIRTUALENVWRAPPER_HOOK_DIR/postcpvirtualenv`` is sourced after the new environment - is created and activated. - -``$VIRTUALENVWRAPPER_HOOK_DIR/postcpvirtualenv`` は新しい環境が作成されてアクティブ化された後で読み込まれます。 - -.. _scripts-preactivate: - -preactivate -=========== - - .. :Global/Local: global, local - :Argument(s): environment name - :Sourced/Run: run - - :グローバル/ローカル: グローバル、ローカル - :引数: 環境名 - :読み込み/実行: 実行 - -.. - The global ``$VIRTUALENVWRAPPER_HOOK_DIR/preactivate`` script is run before the new - environment is enabled. The environment name is passed as the first - argument. - -グローバルの ``$VIRTUALENVWRAPPER_HOOK_DIR/preactivate`` スクリプトは新しい仮想環境が有効になる前に実行されます。その環境名は1番目の引数として渡されます。 - -.. - The local ``$VIRTUAL_ENV/bin/preactivate`` hook is run before the new - environment is enabled. The environment name is passed as the first - argument. - -ローカルの ``$VIRTUAL_ENV/bin/preactivate`` フックは新しい仮想環境が有効になる前に実行されます。その環境名は1番目の引数として渡されます。 - -.. _scripts-postactivate: - -postactivate -============ - - .. :Global/Local: global, local - :Argument(s): none - :Sourced/Run: sourced - - :グローバル/ローカル: グローバル、ローカル - :引数: 無し - :読み込み/実行: 読み込み - -.. - The global ``$VIRTUALENVWRAPPER_HOOK_DIR/postactivate`` script is sourced after the - new environment is enabled. ``$VIRTUAL_ENV`` refers to the new - environment at the time the script runs. - -グローバルの ``$VIRTUALENVWRAPPER_HOOK_DIR/postactivate`` スクリプトは新しい仮想環境が有効になった後で読み込まれます。 ``$VIRTUAL_ENV`` はそのスクリプトが実行されるときに新しい環境を参照します。 - -.. - This example script adds a space between the virtual environment name - and your old PS1 by making use of ``_OLD_VIRTUAL_PS1``. - -このサンプルスクリプトは ``_OLD_VIRTUAL_PS1`` を使用して仮想環境の名前と古い PS1 名前の間にスペースを追加します。 - -:: - - PS1="(`basename \"$VIRTUAL_ENV\"`) $_OLD_VIRTUAL_PS1" - -.. - The local ``$VIRTUAL_ENV/bin/postactivate`` script is sourced after - the new environment is enabled. ``$VIRTUAL_ENV`` refers to the new - environment at the time the script runs. - -ローカルの ``$VIRTUAL_ENV/bin/postactivate`` スクリプトは新しい仮想環境が有効になった後で読み込まれます。 ``$VIRTUAL_ENV`` はそのスクリプトが実行されるときに新しい環境を参照します。 - -.. - This example script for the PyMOTW environment changes the current - working directory and the PATH variable to refer to the source tree - containing the PyMOTW source. - -この PyMOTW 環境のサンプルは PyMOTW に含まれるソースツリーを参照して PATH 変数とカレントワークディレクトリを変更します。 - -:: - - pymotw_root=/Users/dhellmann/Documents/PyMOTW - cd $pymotw_root - PATH=$pymotw_root/bin:$PATH - -.. _scripts-predeactivate: - -predeactivate -============= - - .. :Global/Local: local, global - :Argument(s): none - :Sourced/Run: sourced - - :グローバル/ローカル: グローバル、ローカル - :引数: 無し - :読み込み/実行: 読み込み - -.. - The local ``$VIRTUAL_ENV/bin/predeactivate`` script is sourced before the - current environment is deactivated, and can be used to disable or - clear settings in your environment. ``$VIRTUAL_ENV`` refers to the old - environment at the time the script runs. - -ローカルの ``$VIRTUAL_ENV/bin/predeactivate`` スクリプトはカレントの仮想環境が非アクティブ化される前に読み込まれます。そして、あなたの環境の設定をクリアしたり、無効にするために使用されます。 ``$VIRTUAL_ENV`` はそのスクリプトが実行されるときに古い環境を参照します。 - -.. - The global ``$VIRTUALENVWRAPPER_HOOK_DIR/predeactivate`` script is sourced before the - current environment is deactivated. ``$VIRTUAL_ENV`` refers to the - old environment at the time the script runs. - -グローバルの ``$VIRTUALENVWRAPPER_HOOK_DIR/predeactivate`` スクリプトはカレントの仮想環境が非アクティブ化される前に読み込まれます。 ``$VIRTUAL_ENV`` はそのスクリプトが実行されるときに古い環境を参照します。 - -.. _scripts-postdeactivate: - -postdeactivate -============== - - .. :Global/Local: local, global - :Argument(s): none - :Sourced/Run: sourced - - :グローバル/ローカル: グローバル、ローカル - :引数: 無し - :読み込み/実行: 読み込み - -.. - The ``$VIRTUAL_ENV/bin/postdeactivate`` script is sourced after the - current environment is deactivated, and can be used to disable or - clear settings in your environment. The path to the environment just - deactivated is available in ``$VIRTUALENVWRAPPER_LAST_VIRTUALENV``. - -``$VIRTUAL_ENV/bin/postdeactivate`` スクリプトはカレントの仮想環境が非アクティブ化される前に読み込まれます。そして、あなたの環境の設定をクリアしたり、無効にするために使用されます。非アクティブ化される環境へのパスは ``$VIRTUALENVWRAPPER_LAST_VIRTUALENV`` でのみ有効です。 - -.. _scripts-prermvirtualenv: - -prermvirtualenv -=============== - - .. :Global/Local: global - :Argument(s): environment name - :Sourced/Run: run - - :グローバル/ローカル: グローバル - :引数: 環境名 - :読み込み/実行: 実行 - -.. - The ``$VIRTUALENVWRAPPER_HOOK_DIR/prermvirtualenv`` script is run as an external - program before the environment is removed. The full path to the - environment directory is passed as an argument to the script. - -``$VIRTUALENVWRAPPER_HOOK_DIR/prermvirtualenv`` スクリプトは仮想環境が削除される前に外部コマンドのように実行されます。そのスクリプトへの引数としてその環境のディレクトリに対するフルパスが渡されます。 - -.. _scripts-postrmvirtualenv: - -postrmvirtualenv -================ - - .. :Global/Local: global - :Argument(s): environment name - :Sourced/Run: run - - :グローバル/ローカル: グローバル - :引数: 環境名 - :読み込み/実行: 実行 - -.. - The ``$VIRTUALENVWRAPPER_HOOK_DIR/postrmvirtualenv`` script is run as an external - program after the environment is removed. The full path to the - environment directory is passed as an argument to the script. - -``$VIRTUALENVWRAPPER_HOOK_DIR/postrmvirtualenv`` スクリプトは仮想環境が削除された後で外部コマンドのように実行されます。そのスクリプトへの引数としてその環境のディレクトリに対するフルパスが渡されます。 - -.. _scripts-premkproject: - -premkproject -=============== - - .. :Global/Local: global - :Argument(s): name of new project - :Sourced/Run: run - - :グローバル/ローカル: グローバル - :引数: 新しいプロジェクト名 - :読み込み/実行: 実行 - -.. - ``$WORKON_HOME/premkproject`` is run as an external program after the - virtual environment is created and after the current environment is - switched to point to the new env, but before the new project directory - is created. The current working directory for the script is - ``$PROJECT_HOME`` and the name of the new project is passed as an - argument to the script. - -``$WORKON_HOME/premkproject`` は、仮想環境が作成されてカレントの環境が新しい環境を指すように切り替わった後で、外部プログラムとして実行されます。 -但し、そのタイミングは新しいプロジェクトディレクトリが作成される前です。 -このスクリプトのカレントのワークディレクトリは ``$PROJECT_HOME`` となり、新しいプロジェクト名がこのスクリプトの引数として渡されます。 - -.. _scripts-postmkproject: - -postmkproject -================ - - .. :Global/Local: global - :Argument(s): none - :Sourced/Run: sourced - - :グローバル/ローカル: グローバル - :引数: 無し - :読み込み/実行: 読み込み - -.. - ``$WORKON_HOME/postmkproject`` is sourced after the new environment - and project directories are created and the virtualenv is activated. - The current working directory is the project directory. - -``$WORKON_HOME/postmkproject`` は、新しい環境とプロジェクトディレクトリが作成されて virtualenv がアクティブ化された後で読み込まれます。カレントのワークディレクトリはプロジェクトディレクトリです。 diff --git a/docs/ja/tips.rst b/docs/ja/tips.rst deleted file mode 100644 index 4ee6b34..0000000 --- a/docs/ja/tips.rst +++ /dev/null @@ -1,261 +0,0 @@ -.. - ================= - Tips and Tricks - ================= - -.. _tips-and-tricks: - -================= - Tips とトリック -================= - -.. - This is a list of user-contributed tips for making virtualenv and - virtualenvwrapper even more useful. If you have tip to share, drop me - an email or post a comment on `this blog post - `__ - and I'll add it here. - -これは virtualenv と virtualenvwrapper をさらに使い易くするためにユーザが教えてくれた tips です。あなたが共有したい tip を持っているなら、私にメールを送ってもらうか、 `このブログ `__ にコメントをください。私はこのページにその tip を追加します。 - -.. - zsh Prompt - ========== - -zsh プロンプト -============== - -.. - From `Nat `_: - -`Nat `_ からです。 - -.. - Using zsh, I added some bits to ``$WORKON_HOME/post(de)activate`` to show - the active virtualenv on the right side of my screen instead. - -zsh を使用して、アクティブな仮想環境をスクリーンの右側に表示するために ``$WORKON_HOME/post(de)activate`` に少し追加しました。 - -``postactivate`` は次になります。 - -:: - - PS1="$_OLD_VIRTUAL_PS1" - _OLD_RPROMPT="$RPROMPT" - RPROMPT="%{${fg_bold[white]}%}(env: %{${fg[green]}%}`basename \"$VIRTUAL_ENV\"`%{${fg_bold[white]}%})%{${reset_color}%} $RPROMPT" - -そして ``postdeactivate`` は次になります。 - -:: - - RPROMPT="$_OLD_RPROMPT" - -.. - Adjust colors according to your own personal tastes or environment. - -個人的な趣向や環境に応じて色を調整してください。 - -.. - Updating cached ``$PATH`` entries - ================================= - -キャッシュされた ``$PATH`` エントリを更新する -============================================= - -.. - From `Nat `_: - -`Nat `_ からです。 - -.. - I also added the command 'rehash' to ``$WORKON_HOME/postactivate`` and - ``$WORKON_HOME/postdeactivate`` as I was having some problems with zsh - not picking up the new paths immediately. - -さらに zsh は新たなパスをすぐに取得しない問題があったので ``$WORKON_HOME/postactivate`` と ``$WORKON_HOME/postdeactivate`` へコマンド 'rehash' も追加しました。 - -.. - Tying to pip's virtualenv support - ================================= - -pip の virtualenv サポート -========================== - -.. - Via http://becomingguru.com/: - -http://becomingguru.com/ からです。 - -.. - Add this to your shell login script to make pip use the same directory - for virtualenvs as virtualenvwrapper - -virtualenvwrapper として virtualenvs のために pip が同じディレクトリを使用するようにログインシェルに次の内容を追加してください。 - -:: - - export PIP_VIRTUALENV_BASE=$WORKON_HOME - -.. - and Via Nat: - -さらに Nat からです。 - -.. - in addition to what becomingguru said, this line is key - -becomingguru が指摘したことに加えて次の行がキーになります。 - -:: - - export PIP_RESPECT_VIRTUALENV=true - -.. - That makes pip detect an active virtualenv and install to it, without - having to pass it the -E parameter. - -それは -E パラメータを pip へ渡さずに pip がアクティブな仮想環境を検出してインストールします。 - -.. - Creating Project Work Directories - ================================= - -プロジェクトのワークディレクトリを作成する -========================================== - -`James `_ からです。 - -.. - In the ``postmkvirtualenv`` script I have the following to create a - directory based on the project name, add that directory to the python - path and then cd into it:: - -私は ``postmkvirtualenv`` スクリプトでプロジェクト名に基づいてディレクトリを作成して、 -Python パスへそのディレクトリを追加してからそこへ移動します。 - -:: - - proj_name=$(echo $VIRTUAL_ENV|awk -F'/' '{print $NF}') - mkdir $HOME/projects/$proj_name - add2virtualenv $HOME/projects/$proj_name - cd $HOME/projects/$proj_name - -.. - In the ``postactivate`` script I have it set to automatically change - to the project directory when I use the workon command:: - -私は ``postactivate`` スクリプトで workon コマンドを使用するときに自動的にプロジェクトディレクトリへ移動するようにセットします。 - -:: - - proj_name=$(echo $VIRTUAL_ENV|awk -F'/' '{print $NF}') - cd ~/projects/$proj_name - -.. - Automatically Run workon When Entering a Directory - ================================================== - -ディレクトリへ移動したときに自動的に workon を実行する -====================================================== - -.. - `Justin Lily posted - `__ - about some code he added to his shell environment to look at the - directory each time he runs ``cd``. If it finds a ``.venv`` file, it - activates the environment named within. On leaving that directory, - the current virtualenv is automatically deactivated. - -``cd`` を実行する毎にそのディレクトリでシェル環境を調べるように追加したコードを `Justin Lily が投稿しました `__ 。 ``.venv`` ファイルを見つけたら、そのファイルに含まれる環境の名前でアクティブ化します。そのディレクトリから移動すると、カレントの仮想環境は自動的に非アクティブ化します。 - -.. - `Harry Marr `__ - wrote a similar function that works with `git repositories - `__. - -`Harry Marr `__ は `git リポジトリ `__ で動作するよく似た機能を書きました。 - -.. - Installing Common Tools Automatically in New Environments - ========================================================= - -新しい環境に共通ツールを自動的にインストールする -================================================ - -.. - Via `rizumu `__: - -`rizumu `__ からです。 - -.. - I have this ``postmkvirtualenv`` to install the get a basic setup. - -私はこの ``postmkvirtualenv`` を基本的なセットアップを行うインストールに使用します。 - -:: - - $ cat postmkvirtualenv - #!/usr/bin/env bash - curl -O http://python-distribute.org/distribute_setup.p... />python distribute_setup.py - rm distribute_setup.py - easy_install pip==dev - pip install Mercurial - -.. - Then I have a pip requirement file with my dev tools. - -それから、私の開発ツールと共に pip の要求ファイルを持ちます。 - -:: - - $ cat developer_requirements.txt - ipdb - ipython - pastescript - nose - http://douglatornell.ca/software/python/Nosy-1.0.tar.gz - coverage - sphinx - grin - pyflakes - pep8 - -.. - Then each project has it's own pip requirement file for things like - PIL, psycopg2, django-apps, numpy, etc. - -それぞれのプロジェクトは PIL, psycopg2, django-apps, numpy といったその独自の pip 要求ファイルを持ちます。 - -.. - Changing the Default Behavior of ``cd`` - ======================================= - -``cd`` のデフォルトの振る舞いを変更する -======================================= - -.. - Via `mae `__: - -`mae `__ からです。 - -.. - This is supposed to be executed after workon, that is as a - ``postactivate`` hook. It basically overrides ``cd`` to know about the - VENV so instead of doing ``cd`` to go to ``~`` you will go to the venv - root, IMO very handy and I can't live without it anymore. if you pass - it a proper path then it will do the right thing. - -これは workon の後で実行することになる ``postactivate`` フックです。venv ルートへ移動する ``~`` へ ``cd`` で移動する代わりに VENV を知っているように ``cd`` を基本的に上書きします。IMO はとても扱い易くて、もうそれなしでは生きていけません。適切なパスが渡されると正常に移動します。 - -:: - - cd () { - if (( $# == 0 )) - then - builtin cd $VIRTUAL_ENV - else - builtin cd "$@" - fi - } - - cd diff --git a/docs/en/command_ref.rst b/docs/source/command_ref.rst similarity index 100% rename from docs/en/command_ref.rst rename to docs/source/command_ref.rst diff --git a/docs/sphinx/conf.py b/docs/source/conf.py similarity index 98% rename from docs/sphinx/conf.py rename to docs/source/conf.py index 63f2fbb..5311890 100644 --- a/docs/sphinx/conf.py +++ b/docs/source/conf.py @@ -11,6 +11,7 @@ # All configuration values have a default; values that are commented out # serve to show the default. +import datetime import sys, os import subprocess @@ -41,7 +42,7 @@ # General information about the project. project = u'virtualenvwrapper' -copyright = u'2009-2011, Doug Hellmann' +copyright = u'2009-%s, Doug Hellmann' % datetime.datetime.today().year # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the diff --git a/docs/en/developers.rst b/docs/source/developers.rst similarity index 100% rename from docs/en/developers.rst rename to docs/source/developers.rst diff --git a/docs/en/extensions.rst b/docs/source/extensions.rst similarity index 100% rename from docs/en/extensions.rst rename to docs/source/extensions.rst diff --git a/docs/en/history.rst b/docs/source/history.rst similarity index 100% rename from docs/en/history.rst rename to docs/source/history.rst diff --git a/docs/en/hooks.rst b/docs/source/hooks.rst similarity index 100% rename from docs/en/hooks.rst rename to docs/source/hooks.rst diff --git a/docs/en/index.rst b/docs/source/index.rst similarity index 100% rename from docs/en/index.rst rename to docs/source/index.rst diff --git a/docs/en/install.rst b/docs/source/install.rst similarity index 100% rename from docs/en/install.rst rename to docs/source/install.rst diff --git a/docs/en/plugins.rst b/docs/source/plugins.rst similarity index 100% rename from docs/en/plugins.rst rename to docs/source/plugins.rst diff --git a/docs/en/projects.rst b/docs/source/projects.rst similarity index 100% rename from docs/en/projects.rst rename to docs/source/projects.rst diff --git a/docs/en/scripts.rst b/docs/source/scripts.rst similarity index 100% rename from docs/en/scripts.rst rename to docs/source/scripts.rst diff --git a/docs/en/tips.rst b/docs/source/tips.rst similarity index 100% rename from docs/en/tips.rst rename to docs/source/tips.rst From 567bba54e459d54c6ccf809ad8487aeda2878676 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 20 Jul 2012 15:18:02 -0400 Subject: [PATCH 592/947] change to the default theme for readthedocs.org --- docs/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 5311890..3009acd 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -96,7 +96,7 @@ # The theme to use for HTML and HTML Help pages. Major themes that come with # Sphinx are currently 'default' and 'sphinxdoc'. -html_theme = 'nature' +html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the From 46e4ddc7e09e30277701922f7b02414ac29cd15c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 20 Jul 2012 15:51:21 -0400 Subject: [PATCH 593/947] update the links to the translated versions of the documentation --- docs/source/index.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 14b4cfe..9710da7 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -200,10 +200,10 @@ Rich Leland has created a short `screencast showing off the features of virtualenvwrapper. Manuel Kaufmann has `translated this documentation into Spanish -`__. +`__. Tetsuya Morimoto has `translated this documentation into Japanese -`__. +`__. ======= Support From 1e8aaf3523b851ddd11345de73aecc89e6c387a3 Mon Sep 17 00:00:00 2001 From: Radu Voicilas Date: Fri, 3 Aug 2012 12:33:13 -0700 Subject: [PATCH 594/947] Update documentation to point to the real file where add2virtualenv command adds directories to PYTHONPATH --- docs/source/command_ref.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index c4a7242..7b5d74b 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -408,7 +408,7 @@ in a ``.pth`` file inside ``site-packages`` using ``add2virtualenv``. 4. A usage message and list of current "extra" paths is printed. The directory names are added to a path file named -``virtualenv_path_extensions.pth`` inside the site-packages directory +``_virtualenv_path_extensions.pth`` inside the site-packages directory for the environment. *Based on a contribution from James Bennett and Jannis Leidel.* From 5fb444223312287f662387cc5ca7e518a71396ca Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 3 Aug 2012 15:57:23 -0400 Subject: [PATCH 595/947] update history for previous change --- docs/source/history.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/source/history.rst b/docs/source/history.rst index 487060d..8976b4f 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -10,6 +10,9 @@ dev - Fix issue with lazy-loader code under zsh (:bbissue:`144`). - Fix issue with ``noclobber`` option under zsh (:bbissue:`137`). Fix based on patch from :bbuser:`rob_b`. + - Fix documentation for ``add2virtualenv`` to show the correct name + for the file containing the new path entry. (contributed by + :bbuser:`rvoicilas`) .. _stevedore: http://pypi.python.org/pypi/stevedore From 85634f3a31df4b036e6868063c0f32e112ef01a9 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 18 Aug 2012 11:47:08 -0400 Subject: [PATCH 596/947] Fix virtualenvwrapper_show_workon_options under zsh with chpwd Fixes issue #153 Re-implement virtualenvwrapper_show_workon_options to work for zsh users with chpwd hook functions that emit output. --- docs/source/history.rst | 2 ++ tests/test_workon.sh | 16 ++++++++++++++++ virtualenvwrapper.sh | 19 ++++++++++++++++--- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index 8976b4f..e69ff0f 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -13,6 +13,8 @@ dev - Fix documentation for ``add2virtualenv`` to show the correct name for the file containing the new path entry. (contributed by :bbuser:`rvoicilas`) + - Fix problem with ``virtualenvwrapper_show_workon_options`` under + zsh with ``chpwd`` functions that produce output. (:bbissue:`153`) .. _stevedore: http://pypi.python.org/pypi/stevedore diff --git a/tests/test_workon.sh b/tests/test_workon.sh index 15b6de7..f034c4b 100755 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -83,6 +83,22 @@ test_virtualenvwrapper_show_workon_options_grep_options () { rm -f "$WORKON_HOME/link_env" } +test_virtualenvwrapper_show_workon_options_chpwd () { + # https://bitbucket.org/dhellmann/virtualenvwrapper/issue/153 + function chpwd { + local SEARCH=' ' + local REPLACE='%20' + local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}" + printf '\e]7;%s\a' "$PWD_URL" + echo -n "\033]0;${HOST//.*}:$USER\007" + } + mkdir "$WORKON_HOME/not_env" + envs=$(virtualenvwrapper_show_workon_options | tr '\n' ' ') + assertSame "env1 env2 " "$envs" + rmdir "$WORKON_HOME/not_env" + rm -f "$WORKON_HOME/link_env" +} + test_virtualenvwrapper_show_workon_options_no_envs () { old_home="$WORKON_HOME" export WORKON_HOME=${TMPDIR:-/tmp}/$$ diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 3eca675..533a6b0 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -502,10 +502,23 @@ function rmvirtualenv { # List the available environments. function virtualenvwrapper_show_workon_options { virtualenvwrapper_verify_workon_home || return 1 - # NOTE: DO NOT use ls here because colorized versions spew control characters - # into the output list. + # NOTE: DO NOT use ls or cd here because colorized versions spew control + # characters into the output list. # echo seems a little faster than find, even with -depth 3. - (virtualenvwrapper_cd "$WORKON_HOME"; for f in */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate; do echo $f; done) 2>/dev/null | command \sed 's|^\./||' | command \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate||" | command \sort | (unset GREP_OPTIONS; command \egrep -v '^\*$') + # + # 1. Look for environments by finding the activate scripts. + # Use a subshell so we can suppress the message printed + # by zsh if the glob pattern fails to match any files. + # 2. Strip the WORKON_HOME prefix from each name. + # 3. Strip the bindir/activate script suffix. + # 4. Format the output to show one name on a line. + # 5. Eliminate any lines with * on them because that means there + # were no envs. + (echo $WORKON_HOME/*/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate) 2>/dev/null \ + | command \sed "s|$WORKON_HOME/||g" \ + | command \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate||g" \ + | command \fmt -w 1 \ + | (unset GREP_OPTIONS; command \egrep -v '^\*$') 2>/dev/null } function _lsvirtualenv_usage { From 88e5023df316b4da365d8301dcebb6e6f7c701a3 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 18 Aug 2012 16:58:36 -0400 Subject: [PATCH 597/947] fix pep8 issues with sphinx conf file --- docs/source/conf.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 3009acd..2516d4d 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -12,7 +12,6 @@ # serve to show the default. import datetime -import sys, os import subprocess # If extensions (or modules to document with autodoc) are in another directory, @@ -24,7 +23,7 @@ # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = [ 'sphinxcontrib.bitbucket' ] +extensions = ['sphinxcontrib.bitbucket'] bitbucket_project_url = 'http://bitbucket.org/dhellmann/virtualenvwrapper/' From dd97b952012c77ede24b2d71838476af78312440 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 18 Aug 2012 17:00:43 -0400 Subject: [PATCH 598/947] fix pep8 issues with setup.py --- setup.py | 85 +++++++++++++++++++++++++++----------------------------- 1 file changed, 41 insertions(+), 44 deletions(-) diff --git a/setup.py b/setup.py index 5d96df9..e9cf700 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,6 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' - -# Change docs/sphinx/conf.py too! VERSION = '3.5' # Bootstrap installation of Distribute @@ -30,6 +28,7 @@ standard_exclude_directories = ('.*', 'CVS', '_darcs', './build', './dist', 'EGG-INFO', '*.egg-info') + def find_package_data( where='.', package='', exclude=standard_exclude, @@ -61,7 +60,7 @@ def find_package_data( Note patterns use wildcards, or can be exact paths (including leading ``./``), and all searching is case-insensitive. - + This function is by Ian Bicking. """ @@ -106,42 +105,40 @@ def find_package_data( break if bad_name: continue - out.setdefault(package, []).append(prefix+name) + out.setdefault(package, []).append(prefix + name) return out ################################################################################ - + setup( - name = PROJECT, - version = VERSION, - - description = 'Enhancements to virtualenv', - long_description = long_description, - - author = 'Doug Hellmann', - author_email = 'doug.hellmann@gmail.com', - - url = 'http://www.doughellmann.com/projects/%s/' % PROJECT, - #download_url = 'http://www.doughellmann.com/downloads/%s-%s.tar.gz' % \ - # (PROJECT, VERSION), - - classifiers = [ 'Development Status :: 5 - Production/Stable', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.6', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.2', - 'Intended Audience :: Developers', - 'Environment :: Console', - ], - - platforms = ['Any'], - - scripts = ['virtualenvwrapper.sh', - 'virtualenvwrapper_lazy.sh', - ], + name=PROJECT, + version=VERSION, + + description='Enhancements to virtualenv', + long_description=long_description, + + author='Doug Hellmann', + author_email='doug.hellmann@gmail.com', + + url='http://www.doughellmann.com/projects/%s/' % PROJECT, + + classifiers=['Development Status :: 5 - Production/Stable', + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.2', + 'Intended Audience :: Developers', + 'Environment :: Console', + ], + + platforms=['Any'], + + scripts=['virtualenvwrapper.sh', + 'virtualenvwrapper_lazy.sh', + ], provides=['virtualenvwrapper', 'virtualenvwrapper.user_scripts', @@ -152,18 +149,18 @@ def find_package_data( 'stevedore', ], - namespace_packages = [ 'virtualenvwrapper' ], - packages = find_packages(), - include_package_data = True, + namespace_packages=['virtualenvwrapper'], + packages=find_packages(), + include_package_data=True, # Scan the input for package information - # to grab any data files (text, images, etc.) + # to grab any data files (text, images, etc.) # associated with sub-packages. - package_data = find_package_data(PROJECT, - package=PROJECT, - only_in_packages=False, - ), + package_data=find_package_data(PROJECT, + package=PROJECT, + only_in_packages=False, + ), - entry_points = { + entry_points={ #'console_scripts': [ 'venvw_hook = virtualenvwrapper.hook_loader:main' ], 'virtualenvwrapper.initialize': [ 'user_scripts = virtualenvwrapper.user_scripts:initialize', From f5da0cd5716296681a1376f29a071fc47432eba6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 18 Aug 2012 17:02:56 -0400 Subject: [PATCH 599/947] update version number before release --- announce.rst | 33 +++++++++++++++++---------------- docs/source/history.rst | 2 +- setup.py | 2 +- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/announce.rst b/announce.rst index 5449df3..b97acf8 100644 --- a/announce.rst +++ b/announce.rst @@ -7,27 +7,28 @@ What is virtualenvwrapper? ========================== -virtualenvwrapper_ is a set of extensions to Ian Bicking's virtualenv_ -tool. The extensions include wrappers for creating and deleting -virtual environments and otherwise managing your development workflow, -making it easier to work on more than one project at a time without +virtualenvwrapper_ is a set of extensions to virtualenv_. The +extensions include wrappers for creating and deleting virtual +environments and otherwise managing your development workflow, making +it easier to work on more than one project at a time without introducing conflicts in their dependencies. What's New? =========== -- Rewrite ``cpvirtualenv`` to use `virtualenv-clone`_ - instead of making the new environment relocatable. Contributed by - Justin Barber (barberj). This also resolves a problem - with cpvirtualenv not honoring the ``--no-site-packages`` flag - (issue 102). -- Update docs with link to `virtualenvwrapper-win`_ port by David - Marble. -- Use ``command`` to avoid functions named the same as common - utilities. (issue 119) - -.. _virtualenv-clone: http://pypi.python.org/pypi/virtualenv-clone -.. _virtualenvwrapper-win: http://pypi.python.org/pypi/virtualenvwrapper-win +- Switch to stevedore_ for plugin management +- mkvirtualenv_help should use ``$VIRTUALENVWRAPPER_PYTHON`` instead + of calling ``virtualenv`` directly (issue 148). +- Fix issue with lazy-loader code under zsh (issue 144). +- Fix issue with ``noclobber`` option under zsh + (issue 137`). Fix based on patch from rob_b. +- Fix documentation for ``add2virtualenv`` to show the correct name + for the file containing the new path entry. (contributed by + rvoicilas) +- Fix problem with ``virtualenvwrapper_show_workon_options`` under + zsh with ``chpwd`` functions that produce output. (issue 153) + +.. _stevedore: http://pypi.python.org/pypi/stevedore Installing ========== diff --git a/docs/source/history.rst b/docs/source/history.rst index e69ff0f..4ac73b1 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -2,7 +2,7 @@ Release History =============== -dev +3.6 - Switch to stevedore_ for plugin management - mkvirtualenv_help should use ``$VIRTUALENVWRAPPER_PYTHON`` instead diff --git a/setup.py b/setup.py index e9cf700..563355d 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' -VERSION = '3.5' +VERSION = '3.6' # Bootstrap installation of Distribute import distribute_setup From 6c88b2f74fd9174d95d5a1c0340319494bfa7144 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 18 Aug 2012 17:03:14 -0400 Subject: [PATCH 600/947] update version number before release, 2 --- announce.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/announce.rst b/announce.rst index b97acf8..750dac4 100644 --- a/announce.rst +++ b/announce.rst @@ -1,5 +1,5 @@ ======================= - virtualenvwrapper 3.5 + virtualenvwrapper 3.6 ======================= .. tags:: virtualenvwrapper release python From ae236e238683cec17d91a0e26d5dd67f8794993e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 18 Aug 2012 17:03:18 -0400 Subject: [PATCH 601/947] Added tag 3.6 for changeset 002a0ccdcc7a --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 2d0e192..8a2b288 100644 --- a/.hgtags +++ b/.hgtags @@ -85,3 +85,4 @@ dccf1a1abf4ea97589e9fa141167771049f031e0 3.2 45877370548ee7c2581a6c81df22b12fcc3f4891 3.3 07905d9135ac3ca8460143b40dc39aa8823d3691 3.4 c93b81815391a939601ac455a07b6f006825838a 3.5 +002a0ccdcc7aea6ecee76685425bccbbe1b45bfa 3.6 From c70de162f08d7ae13442de4bbc5ab8840bf7b4a1 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 18 Aug 2012 17:04:47 -0400 Subject: [PATCH 602/947] fix markup typo in announcement --- announce.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/announce.rst b/announce.rst index 750dac4..83ef696 100644 --- a/announce.rst +++ b/announce.rst @@ -21,7 +21,7 @@ What's New? of calling ``virtualenv`` directly (issue 148). - Fix issue with lazy-loader code under zsh (issue 144). - Fix issue with ``noclobber`` option under zsh - (issue 137`). Fix based on patch from rob_b. + (issue 137). Fix based on patch from rob_b. - Fix documentation for ``add2virtualenv`` to show the correct name for the file containing the new path entry. (contributed by rvoicilas) From e41f4f17b148ef15fee48260ec7e48b917696be9 Mon Sep 17 00:00:00 2001 From: Radu Voicilas Date: Mon, 12 Nov 2012 00:12:05 +0200 Subject: [PATCH 603/947] Fix --python switch for virtualenv. When using mkvirtualenv and pass in the --python (or the shorter -p version), virtualenv will fail to find the correct interpreter path if that path is relative to the working dir, because virtualenvwrapper switches the current directory right before calling virtualenv. --- virtualenvwrapper.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 533a6b0..ed71987 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -402,6 +402,10 @@ function mkvirtualenv { -i) i=$(( $i + 1 )); packages="$packages ${in_args[$i]}";; + -p|--python) + i=$(( $i + 1 )); + interpreter="${in_args[$i]}"; + interpreter=$(realpath "$interpreter");; -r) i=$(( $i + 1 )); requirements="${in_args[$i]}"; @@ -417,6 +421,11 @@ function mkvirtualenv { i=$(( $i + 1 )) done + if [ ! -z $interpreter ] + then + out_args=( "--python=$interpreter" ${out_args[@]} ) + fi; + set -- "${out_args[@]}" eval "envname=\$$#" From eb51a3284e676dbc4348251fb6722ae5fe3a7d7c Mon Sep 17 00:00:00 2001 From: Radu Voicilas Date: Mon, 12 Nov 2012 00:12:35 +0200 Subject: [PATCH 604/947] Fix typo in documentation. --- docs/source/command_ref.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 7b5d74b..e4d84ac 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -396,7 +396,7 @@ Syntax:: add2virtualenv directory1 directory2 ... Sometimes it is desirable to share installed packages that are not in -the system ``site-pacakges`` directory and which should not be +the system ``site-packages`` directory and which should not be installed in each virtualenv. One possible solution is to symlink the source into the environment ``site-packages`` directory, but it is also easy to add extra directories to the PYTHONPATH by including them From 132b2b0bd9758745f3fafa7821fec484e331cf75 Mon Sep 17 00:00:00 2001 From: Radu Voicilas Date: Mon, 26 Nov 2012 15:13:44 +0200 Subject: [PATCH 605/947] Replace realpath with a more portable way of converting a relative path to an absolute path --- virtualenvwrapper.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index ed71987..0cba00f 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -110,6 +110,15 @@ function virtualenvwrapper_expandpath { fi } +function virtualenvwrapper_absolutepath { + if [ "$1" = "" ]; then + return 1 + else + "$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.abspath(\"$1\")+'\n')" + return 0 + fi +} + function virtualenvwrapper_derive_workon_home { typeset workon_home_dir="$WORKON_HOME" @@ -405,7 +414,7 @@ function mkvirtualenv { -p|--python) i=$(( $i + 1 )); interpreter="${in_args[$i]}"; - interpreter=$(realpath "$interpreter");; + interpreter=$(virtualenvwrapper_absolutepath "$interpreter");; -r) i=$(( $i + 1 )); requirements="${in_args[$i]}"; @@ -749,7 +758,7 @@ function add2virtualenv { for pydir in "$@" do - absolute_path=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.abspath(\"$pydir\")+'\n')") + absolute_path=$(virtualenvwrapper_absolutepath "$pydir") if [ "$absolute_path" != "$pydir" ] then echo "Warning: Converting \"$pydir\" to \"$absolute_path\"" 1>&2 From 05549fe423ae00bc331c5bb8248a52ccb825c6b8 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 19 Dec 2012 17:50:48 -0500 Subject: [PATCH 606/947] Fix link to setvirtualenvproject command Fixes bug #166 --- docs/source/command_ref.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index e4d84ac..a693cd7 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -488,6 +488,8 @@ create a virtual environment with the same name as the project. * :ref:`scripts-premkproject` * :ref:`scripts-postmkproject` +.. _command-setvirtualenvproject: + setvirtualenvproject -------------------- From 61749bce79fd6e5fe7bf6fa8b20b43f492556906 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Tue, 22 Jan 2013 15:07:50 +0800 Subject: [PATCH 607/947] Add complete-time load to lazy loader. --- virtualenvwrapper_lazy.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/virtualenvwrapper_lazy.sh b/virtualenvwrapper_lazy.sh index de4a396..ce310ab 100644 --- a/virtualenvwrapper_lazy.sh +++ b/virtualenvwrapper_lazy.sh @@ -31,4 +31,14 @@ function $venvw_name { done } +# Set up completion functions to virtualenvwrapper_load +function virtualenvwrapper_setup_lazy_completion { + if [ -n "$BASH" ] ; then + complete -o nospace -F virtualenvwrapper_load cdvirtualenv cdsitepackages workon rmvirtualenv cpvirtualenv showvirtualenv + elif [ -n "$ZSH_VERSION" ] ; then + compctl -K virtualenvwrapper_load cdvirtualenv cdsitepackages workon rmvirtualenv cpvirtualenv showvirtualenv + fi +} + virtualenvwrapper_setup_lazy_loader +virtualenvwrapper_setup_lazy_completion From 573da16a3c1936d2ca368ba23ed2b41d005630d9 Mon Sep 17 00:00:00 2001 From: Steve Steiner Date: Sat, 26 Jan 2013 21:22:55 -0500 Subject: [PATCH 608/947] Added exclusion for docs/en, docs/es, and docs/ja to .hgignore. --- .hgignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.hgignore b/.hgignore index ab738ed..7f154f2 100644 --- a/.hgignore +++ b/.hgignore @@ -9,6 +9,9 @@ distribute*.tar.gz docs/build docs/html docs/website +docs/en +docs/es +docs/ja tests/catch_output tests/testpackage/build tests/testpackage/dist From 089cb76d53f34c69f2a2a37ca93ffc2133836898 Mon Sep 17 00:00:00 2001 From: Jeff Byrnes Date: Wed, 6 Mar 2013 11:49:08 -0500 Subject: [PATCH 609/947] Rename READMEs to be RST --HG-- rename : README.es.txt => README.es.rst rename : README.ja.txt => README.ja.rst rename : README.txt => README.rst --- README.es.txt => README.es.rst | 0 README.ja.txt => README.ja.rst | 0 README.txt => README.rst | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename README.es.txt => README.es.rst (100%) rename README.ja.txt => README.ja.rst (100%) rename README.txt => README.rst (100%) diff --git a/README.es.txt b/README.es.rst similarity index 100% rename from README.es.txt rename to README.es.rst diff --git a/README.ja.txt b/README.ja.rst similarity index 100% rename from README.ja.txt rename to README.ja.rst diff --git a/README.txt b/README.rst similarity index 100% rename from README.txt rename to README.rst From 84b091631700c3e183eff7efc0348ca6360f57ba Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 8 Mar 2013 07:13:30 -0500 Subject: [PATCH 610/947] prepare 3.6.1 release --- announce.rst | 23 +++++++---------------- docs/source/history.rst | 8 ++++++++ setup.py | 2 +- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/announce.rst b/announce.rst index 83ef696..ad881d7 100644 --- a/announce.rst +++ b/announce.rst @@ -1,6 +1,6 @@ -======================= - virtualenvwrapper 3.6 -======================= +========================= + virtualenvwrapper 3.6.1 +========================= .. tags:: virtualenvwrapper release python @@ -16,19 +16,10 @@ introducing conflicts in their dependencies. What's New? =========== -- Switch to stevedore_ for plugin management -- mkvirtualenv_help should use ``$VIRTUALENVWRAPPER_PYTHON`` instead - of calling ``virtualenv`` directly (issue 148). -- Fix issue with lazy-loader code under zsh (issue 144). -- Fix issue with ``noclobber`` option under zsh - (issue 137). Fix based on patch from rob_b. -- Fix documentation for ``add2virtualenv`` to show the correct name - for the file containing the new path entry. (contributed by - rvoicilas) -- Fix problem with ``virtualenvwrapper_show_workon_options`` under - zsh with ``chpwd`` functions that produce output. (issue 153) - -.. _stevedore: http://pypi.python.org/pypi/stevedore +- Replace realpath with a more portable way of converting a relative + path to an absolute path, used with the ``--python`` option to + mkvirtualenv (contributed by Radu Voicilas). +- Posted release to PyPI, resolving download redirect issue. Installing ========== diff --git a/docs/source/history.rst b/docs/source/history.rst index 4ac73b1..32a3293 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -2,6 +2,14 @@ Release History =============== +3.6.1 + + - Replace realpath with a more portable way of converting a relative + path to an absolute path, used with the ``--python`` option to + mkvirtualenv (contributed by Radu Voicilas, :bbuser:`rvoicilas`). + - Posted release to PyPI, resolving download redirect + issue. (:bbissue:`171` and :bbissue:`172`) + 3.6 - Switch to stevedore_ for plugin management diff --git a/setup.py b/setup.py index 563355d..3f752b1 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' -VERSION = '3.6' +VERSION = '3.6.1' # Bootstrap installation of Distribute import distribute_setup From db8f6622832c9107d47548f98c26e70ec917ecc5 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 8 Mar 2013 07:13:35 -0500 Subject: [PATCH 611/947] Added tag 3.6.1 for changeset c180ccae77b4 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 8a2b288..975d562 100644 --- a/.hgtags +++ b/.hgtags @@ -86,3 +86,4 @@ dccf1a1abf4ea97589e9fa141167771049f031e0 3.2 07905d9135ac3ca8460143b40dc39aa8823d3691 3.4 c93b81815391a939601ac455a07b6f006825838a 3.5 002a0ccdcc7aea6ecee76685425bccbbe1b45bfa 3.6 +c180ccae77b40c2728e53612648dab7e0356584f 3.6.1 From 75d24b74813d5ae57090c56ba754482b48ead7da Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Thu, 14 Mar 2013 08:00:19 +0800 Subject: [PATCH 612/947] Use $_VIRTUALENVWRAPPER_API instead of listing functions. --- virtualenvwrapper_lazy.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virtualenvwrapper_lazy.sh b/virtualenvwrapper_lazy.sh index ce310ab..c0a78f8 100644 --- a/virtualenvwrapper_lazy.sh +++ b/virtualenvwrapper_lazy.sh @@ -34,9 +34,9 @@ function $venvw_name { # Set up completion functions to virtualenvwrapper_load function virtualenvwrapper_setup_lazy_completion { if [ -n "$BASH" ] ; then - complete -o nospace -F virtualenvwrapper_load cdvirtualenv cdsitepackages workon rmvirtualenv cpvirtualenv showvirtualenv + complete -o nospace -F virtualenvwrapper_load $(echo ${_VIRTUALENVWRAPPER_API}) elif [ -n "$ZSH_VERSION" ] ; then - compctl -K virtualenvwrapper_load cdvirtualenv cdsitepackages workon rmvirtualenv cpvirtualenv showvirtualenv + compctl -K virtualenvwrapper_load $(echo ${_VIRTUALENVWRAPPER_API}) fi } From 71022622ba913d2ef9a797a346d0d2ec29b7c887 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 14 Mar 2013 15:16:05 -0700 Subject: [PATCH 613/947] do not check in test output --- trace.log | 118 ------------------------------------------------------ 1 file changed, 118 deletions(-) delete mode 100644 trace.log diff --git a/trace.log b/trace.log deleted file mode 100644 index 8795e79..0000000 --- a/trace.log +++ /dev/null @@ -1,118 +0,0 @@ -_________________________________ [tox sdist] __________________________________ -[TOX] ***creating sdist package -[TOX] /Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup$ /Users/dhellmann/Envs/virtualenvwrapper/bin/python setup.py sdist --formats=zip --dist-dir .tox/dist >.tox/log/0.log -[TOX] ***copying new sdistfile to '/Users/dhellmann/.tox/distshare/virtualenvwrapper-3.3.zip' -______________________________ [tox testenv:py27] ______________________________ -[TOX] ***reusing existing matching virtualenv py27 -[TOX] ***upgrade-installing sdist -[TOX] /Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/py27/log$ ../bin/pip install --download-cache=/Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/_download /Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/dist/virtualenvwrapper-3.3.zip -U --no-deps >21.log -[TOX] WARNING:test command found but not installed in testenv - cmd: /bin/bash - env: /Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/py27 -Maybe forgot to specify a dependency? -[TOX] /Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup$ /bin/bash ./tests/run_tests /Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/py27 tests/test.sh - -******************************************************************************** -Running tests/test.sh - VIRTUAL_ENV=/Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/py27 - VIRTUALENVWRAPPER_PYTHON=/Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/py27/bin/python - Python 2.7.2 - PYTHONPATH= - SHELL=/bin/bash - - -test_virtualenvwrapper_initialize - -test_virtualenvwrapper_run_init_hooks - -test_virtualenvwrapper_space_in_workon_home - -test_virtualenvwrapper_verify_workon_home - -test_virtualenvwrapper_verify_workon_home_missing_dir - -test_virtualenvwrapper_verify_workon_home_missing_dir_quiet - -test_virtualenvwrapper_verify_workon_home_missing_dir_grep_options - -test_python_interpreter_set_incorrectly -Using real prefix '/Library/Frameworks/Python.framework/Versions/2.7' -New python executable in no_wrappers/bin/python -Installing distribute.............................................................................................................................................................................................done. -Installing pip...............done. - -Ran 8 tests. - -OK - - -******************************************************************************** -Running tests/test.sh - VIRTUAL_ENV=/Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/py27 - VIRTUALENVWRAPPER_PYTHON=/Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/py27/bin/python - Python 2.7.2 - PYTHONPATH= - SHELL=/bin/ksh - - -test_virtualenvwrapper_initialize - -test_virtualenvwrapper_run_init_hooks - -test_virtualenvwrapper_space_in_workon_home - -test_virtualenvwrapper_verify_workon_home - -test_virtualenvwrapper_verify_workon_home_missing_dir - -test_virtualenvwrapper_verify_workon_home_missing_dir_quiet - -test_virtualenvwrapper_verify_workon_home_missing_dir_grep_options - -test_python_interpreter_set_incorrectly -Using real prefix '/Library/Frameworks/Python.framework/Versions/2.7' -New python executable in no_wrappers/bin/python -Installing distribute.............................................................................................................................................................................................done. -Installing pip...............done. - -Ran 8 tests. - -OK - - -******************************************************************************** -Running tests/test.sh - VIRTUAL_ENV=/Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/py27 - VIRTUALENVWRAPPER_PYTHON=/Users/dhellmann/Devel/virtualenvwrapper/virtualenvwrapper-startup/.tox/py27/bin/python - Python 2.7.2 - PYTHONPATH= - SHELL=/bin/zsh - - -test_virtualenvwrapper_initialize - -test_virtualenvwrapper_run_init_hooks - -test_virtualenvwrapper_space_in_workon_home - -test_virtualenvwrapper_verify_workon_home - -test_virtualenvwrapper_verify_workon_home_missing_dir - -test_virtualenvwrapper_verify_workon_home_missing_dir_quiet - -test_virtualenvwrapper_verify_workon_home_missing_dir_grep_options - -test_python_interpreter_set_incorrectly -Using real prefix '/Library/Frameworks/Python.framework/Versions/2.7' -New python executable in no_wrappers/bin/python -Installing distribute.............................................................................................................................................................................................done. -Installing pip...............done. - -Ran 8 tests. - -OK - -________________________________ [tox summary] _________________________________ -[TOX] py27: commands succeeded -[TOX] congratulations :) From 3f8ddacc7bd462d0eb52e9245edd67b9981fa00e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 14 Mar 2013 15:16:21 -0700 Subject: [PATCH 614/947] show which virtualenv is used in tests --- tests/run_tests | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/run_tests b/tests/run_tests index 5a65cba..d884251 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -40,7 +40,7 @@ then exit 1 fi -# Force the tox virtualenv to be active. +# Force the tox virtualenv to be active. # # Since this script runs from within a separate shell created by tox, # the name of the virtualenv (in $VIRTUAL_ENV) is inherited, but the @@ -87,6 +87,7 @@ do echo " $($VIRTUALENVWRAPPER_PYTHON -V 2>&1)" echo " PYTHONPATH=$PYTHONPATH" echo " SHELL=$test_shell" + echo " virtualenv=$(which virtualenv)" echo export SHUNIT_PARENT="$test_script" $test_shell $test_shell_opts $test_script || exit 1 From f1db8cd146d73809a57469b5a8c19917b9a780f0 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 14 Mar 2013 15:17:16 -0700 Subject: [PATCH 615/947] fix issue with toggleglobalsitepackages tests that was hidden by old test virtualenv --- tests/test_toggleglobalsitepackages.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_toggleglobalsitepackages.sh b/tests/test_toggleglobalsitepackages.sh index ef73a22..e86dd1c 100755 --- a/tests/test_toggleglobalsitepackages.sh +++ b/tests/test_toggleglobalsitepackages.sh @@ -16,24 +16,24 @@ oneTimeTearDown() { setUp () { echo rm -f "$test_dir/catch_output" - mkvirtualenv --system-site-packages "globaltest" >/dev/null 2>&1 } tearDown () { deactivate >/dev/null 2>&1 - rmvirtualenv "globaltest" >/dev/null 2>&1 } test_toggleglobalsitepackages () { - ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" - assertTrue "$ngsp_file does not exist" "[ -f \"$ngsp_file\" ]" + mkvirtualenv --no-site-packages "test1" + ngsp_file=$(dirname "`virtualenvwrapper_get_site_packages_dir`")/no-global-site-packages.txt + assertTrue "$ngsp_file does not exist 1" "[ -f \"$ngsp_file\" ]" toggleglobalsitepackages -q assertFalse "$ngsp_file exists" "[ -f \"$ngsp_file\" ]" toggleglobalsitepackages -q - assertTrue "$ngsp_file does not exist" "[ -f \"$ngsp_file\" ]" + assertTrue "$ngsp_file does not exist 2" "[ -f \"$ngsp_file\" ]" } test_toggleglobalsitepackages_quiet () { + mkvirtualenv --no-site-packages "test2" assertEquals "Command output is not correct" "Enabled global site-packages" "`toggleglobalsitepackages`" assertEquals "Command output is not correct" "Disabled global site-packages" "`toggleglobalsitepackages`" From e3b7ba5a88984009dc8fb44ba61808e281ac5ccc Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 14 Mar 2013 16:05:27 -0700 Subject: [PATCH 616/947] Add --help option to mkproject Fixes issue #156 --- virtualenvwrapper.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 0cba00f..d8cf413 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -972,9 +972,8 @@ function mkproject { while [ $i $tst $# ] do a="${in_args[$i]}" - # echo "arg $i : $a" case "$a" in - -h) + -h|--help) mkproject_help; return;; -t) From 2187fa66842ccbe198e4942dd50d81905877fff4 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 14 Mar 2013 16:15:39 -0700 Subject: [PATCH 617/947] Add help option to workon Fixes issue #169 --- docs/source/history.rst | 2 ++ virtualenvwrapper.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/docs/source/history.rst b/docs/source/history.rst index 2965794..d57a750 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -6,6 +6,8 @@ dev - Improve tab-completion support for users of the lazy-loading mode. (:bbuser:`upsuper`) + - Add ``--help`` option to ``mkproject``. + - Add ``--help`` option to ``workon``. 3.6.1 diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index d8cf413..101b609 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -619,11 +619,51 @@ function showvirtualenv { echo } +# Show help for workon +function workon_help { + echo "Usage: workon env_name" + echo "" + echo " Deactivate any currently activated virtualenv" + echo " and activate the named environment, triggering" + echo " any hooks in the process." + echo "" + echo " workon" + echo "" + echo " Print a list of available environments." + echo " (See also lsvirtualenv -b)" + echo "" + echo " workon (-h|--help)" + echo "" + echo " Show this help message." + echo "" +} + # List or change working virtual environments # # Usage: workon [environment_name] # function workon { + in_args=( "$@" ) + + if [ -n "$ZSH_VERSION" ] + then + i=1 + tst="-le" + else + i=0 + tst="-lt" + fi + while [ $i $tst $# ] + do + a="${in_args[$i]}" + case "$a" in + -h|--help) + workon_help; + return 0;; + esac + i=$(( $i + 1 )) + done + typeset env_name="$1" if [ "$env_name" = "" ] then From 71aa555af1dd4dc9e276ffebbf3d7e511e5b29ad Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 14 Mar 2013 17:50:05 -0700 Subject: [PATCH 618/947] Turn off logging by default Fix race condition in hook loader by disabling logging by default. Fixes bug #152 --HG-- rename : tests/test_log_dir.sh => tests/test_log_file.sh --- docs/source/history.rst | 7 +++++++ docs/source/install.rst | 6 +++--- tests/test.sh | 1 - tests/{test_log_dir.sh => test_log_file.sh} | 14 ++++++-------- tests/test_run_hook.sh | 7 ------- virtualenvwrapper.sh | 12 ------------ virtualenvwrapper/hook_loader.py | 21 +++++++++++---------- 7 files changed, 27 insertions(+), 41 deletions(-) rename tests/{test_log_dir.sh => test_log_file.sh} (53%) diff --git a/docs/source/history.rst b/docs/source/history.rst index d57a750..14bb460 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -8,6 +8,13 @@ dev mode. (:bbuser:`upsuper`) - Add ``--help`` option to ``mkproject``. - Add ``--help`` option to ``workon``. + - Turn off logging from the hook loader by default, and replace + ``VIRTUALENVWRAPPER_LOG_DIR`` environment variable with + ``VIRTUALENVWRAPPER_LOG_FILE``. The rotating log behavior remains + the same. The motivation for this change is the race condition + caused by that rotating behavior, especially when the wrappers are + being used by users with different permissions and + umasks. (:bbissue:`152`) 3.6.1 diff --git a/docs/source/install.rst b/docs/source/install.rst index f8c9253..ebd1129 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -220,14 +220,14 @@ default is ``$WORKON_HOME``. * :ref:`scripts` -.. _variable-VIRTUALENVWRAPPER_LOG_DIR: +.. _variable-VIRTUALENVWRAPPER_LOG_FILE: Location of Hook Logs --------------------- -The variable ``VIRTUALENVWRAPPER_LOG_DIR`` tells virtualenvwrapper +The variable ``VIRTUALENVWRAPPER_LOG_FILE`` tells virtualenvwrapper where the logs for the hook loader should be written. The default is -``$WORKON_HOME``. +to not log from the hooks. .. _variable-VIRTUALENVWRAPPER_VIRTUALENV: diff --git a/tests/test.sh b/tests/test.sh index 02d68cb..b8a8ac8 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -26,7 +26,6 @@ test_virtualenvwrapper_initialize() { assertTrue "Global $WORKON_HOME/$hook was not created" "[ -f $WORKON_HOME/$hook ]" assertTrue "Global $WORKON_HOME/$hook is not executable" "[ -x $WORKON_HOME/$hook ]" done - assertTrue "Log file was not created" "[ -f $WORKON_HOME/hook.log ]" export pre_test_dir=$(cd "$test_dir"; pwd) echo "echo GLOBAL initialize >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/initialize" virtualenvwrapper_initialize diff --git a/tests/test_log_dir.sh b/tests/test_log_file.sh similarity index 53% rename from tests/test_log_dir.sh rename to tests/test_log_file.sh index 60ec4dc..f6909df 100644 --- a/tests/test_log_dir.sh +++ b/tests/test_log_file.sh @@ -8,27 +8,25 @@ setUp () { } test_set_by_user() { - export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME/logs" - mkdir -p "$VIRTUALENVWRAPPER_LOG_DIR" + export VIRTUALENVWRAPPER_LOG_FILE="$WORKON_HOME/hooks.log" source "$test_dir/../virtualenvwrapper.sh" - assertTrue "Log file was not created" "[ -f $WORKON_HOME/logs/hook.log ]" + assertTrue "Log file was not created" "[ -f $VIRTUALENVWRAPPER_LOG_FILE ]" } test_file_permissions() { - export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME/logs" - mkdir -p "$VIRTUALENVWRAPPER_LOG_DIR" + export VIRTUALENVWRAPPER_LOG_FILE="$WORKON_HOME/hooks.log" source "$test_dir/../virtualenvwrapper.sh" - perms=$(ls -l "$WORKON_HOME/logs/hook.log" | cut -f1 -d' ') + perms=$(ls -l "$VIRTUALENVWRAPPER_LOG_FILE" | cut -f1 -d' ') #echo $perms assertTrue "Log file permissions are wrong: $perms" "echo $perms | grep '^-rw-rw'" } test_not_set_by_user() { unset WORKON_HOME - unset VIRTUALENVWRAPPER_LOG_DIR + unset VIRTUALENVWRAPPER_LOG_FILE unset VIRTUALENVWRAPPER_HOOK_DIR source "$test_dir/../virtualenvwrapper.sh" - assertSame "$WORKON_HOME" "$VIRTUALENVWRAPPER_LOG_DIR" + assertSame "" "$VIRTUALENVWRAPPER_LOG_FILE" } . "$test_dir/shunit2" diff --git a/tests/test_run_hook.sh b/tests/test_run_hook.sh index bcee1be..2a2ddda 100755 --- a/tests/test_run_hook.sh +++ b/tests/test_run_hook.sh @@ -64,11 +64,4 @@ test_virtualenvwrapper_run_hook_permissions() { assertSame "Errno 13] Permission denied" "$error" } -test_virtualenvwrapper_run_hook_without_log_dir() { - old_log_dir="$VIRTUALENVWRAPPER_LOG_DIR" - unset VIRTUALENVWRAPPER_LOG_DIR - assertFalse "virtualenvwrapper_run_hook initialize" - export VIRTUALENVWRAPPER_LOG_DIR="$old_log_dir" -} - . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 101b609..b56ca97 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -202,12 +202,6 @@ function virtualenvwrapper_run_hook { hook_script="$(virtualenvwrapper_tempfile ${1}-hook)" || return 1 - if [ -z "$VIRTUALENVWRAPPER_LOG_DIR" ] - then - echo "ERROR: VIRTUALENVWRAPPER_LOG_DIR is not set." 1>&2 - command \rm -f "$hook_script" - return 1 - fi "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' $HOOK_VERBOSE_OPTION --script "$hook_script" "$@" result=$? @@ -286,12 +280,6 @@ function virtualenvwrapper_initialize { export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME" fi - # Set the location of the hook script logs - if [ "$VIRTUALENVWRAPPER_LOG_DIR" = "" ] - then - export VIRTUALENVWRAPPER_LOG_DIR="$WORKON_HOME" - fi - virtualenvwrapper_run_hook "initialize" virtualenvwrapper_setup_tab_completion diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index ae07513..8e51ddb 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -85,16 +85,17 @@ def main(): root_logger = logging.getLogger('') # Set up logging to a file - root_logger.setLevel(logging.DEBUG) - file_handler = GroupWriteRotatingFileHandler( - os.path.expandvars(os.path.join('$VIRTUALENVWRAPPER_LOG_DIR', - 'hook.log')), - maxBytes=10240, - backupCount=1, - ) - formatter = logging.Formatter(LOG_FORMAT) - file_handler.setFormatter(formatter) - root_logger.addHandler(file_handler) + logfile = os.environ.get('VIRTUALENVWRAPPER_LOG_FILE') + if logfile: + root_logger.setLevel(logging.DEBUG) + file_handler = GroupWriteRotatingFileHandler( + logfile, + maxBytes=10240, + backupCount=1, + ) + formatter = logging.Formatter(LOG_FORMAT) + file_handler.setFormatter(formatter) + root_logger.addHandler(file_handler) # Send higher-level messages to the console, too console = logging.StreamHandler() From 4a72dc942f29d028066cb828ef7cfc0e9af0a732 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 15 Mar 2013 15:35:30 -0700 Subject: [PATCH 619/947] use flake8 instead of pep8 for style checking --- docs/source/history.rst | 1 + tox.ini | 8 ++--- virtualenvwrapper/hook_loader.py | 51 +++++++++++++------------- virtualenvwrapper/project.py | 12 ++++--- virtualenvwrapper/user_scripts.py | 60 +++++++++++++++++++------------ 5 files changed, 75 insertions(+), 57 deletions(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index 14bb460..5de3613 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -15,6 +15,7 @@ dev caused by that rotating behavior, especially when the wrappers are being used by users with different permissions and umasks. (:bbissue:`152`) + - Use flake8 for style checking. 3.6.1 diff --git a/tox.ini b/tox.ini index 56f5fbe..a8fb1d8 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py26,py32,pep8 +envlist = py27,py26,py32,style [testenv] commands = bash ./tests/run_tests {envdir} [] @@ -9,9 +9,9 @@ deps = virtualenv setenv = TOXIC = true -[testenv:pep8] -deps = pep8==1.1 -commands = pep8 --ignore=E501 --repeat --show-source virtualenvwrapper +[testenv:style] +deps = flake8 +commands = flake8 virtualenvwrapper # Not sure why this is needed, but on my system if it isn't included then diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 8e51ddb..f8ba13a 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -34,7 +34,7 @@ def main(): usage='usage: %prog [options] []', prog='virtualenvwrapper.hook_loader', description='Manage hooks for virtualenvwrapper', - ) + ) parser.add_option( '-S', '--script', @@ -42,21 +42,21 @@ def main(): 'result to ', dest='script_filename', default=None, - ) + ) parser.add_option( '-s', '--source', help='Print the shell commands to be run in the current shell', action='store_true', dest='sourcing', default=False, - ) + ) parser.add_option( '-l', '--list', help='Print a list of the plugins available for the given hook', action='store_true', default=False, dest='listing', - ) + ) parser.add_option( '-v', '--verbose', help='Show more information on the console', @@ -64,21 +64,21 @@ def main(): const=2, default=1, dest='verbose_level', - ) + ) parser.add_option( '-q', '--quiet', help='Show less information on the console', action='store_const', const=0, dest='verbose_level', - ) + ) parser.add_option( '-n', '--name', help='Only run the hook from the named plugin', action='append', dest='names', default=[], - ) + ) parser.disable_interspersed_args() # stop when on option without an '-' options, args = parser.parse_args() @@ -92,7 +92,7 @@ def main(): logfile, maxBytes=10240, backupCount=1, - ) + ) formatter = logging.Formatter(LOG_FORMAT) file_handler.setFormatter(formatter) root_logger.addHandler(file_handler) @@ -189,23 +189,24 @@ def invoke(ext, args): def list_hooks(output=None): if output is None: output = sys.stdout - for hook in itertools.chain( - ('_'.join(h) - for h in itertools.product(['pre', 'post'], - ['mkvirtualenv', - 'rmvirtualenv', - 'activate', - 'deactivate', - 'cpvirtualenv', - ]) - ), - ['initialize', - 'get_env_details', - 'project.pre_mkproject', - 'project.post_mkproject', - 'project.template', - ] - ): + static_names = [ + 'initialize', + 'get_env_details', + 'project.pre_mkproject', + 'project.post_mkproject', + 'project.template', + ] + pre_post_hooks = ( + '_'.join(h) + for h in itertools.product(['pre', 'post'], + ['mkvirtualenv', + 'rmvirtualenv', + 'activate', + 'deactivate', + 'cpvirtualenv', + ]) + ) + for hook in itertools.chain(static_names, pre_post_hooks): output.write(hook + '\n') diff --git a/virtualenvwrapper/project.py b/virtualenvwrapper/project.py index 5119826..61c9749 100644 --- a/virtualenvwrapper/project.py +++ b/virtualenvwrapper/project.py @@ -15,7 +15,8 @@ GLOBAL_HOOKS = [ # mkproject ("premkproject", - "This hook is run after a new project is created and before it is activated."), + "This hook is run after a new project is created " + "and before it is activated."), ("postmkproject", "This hook is run after a new project is activated."), @@ -24,20 +25,20 @@ "This hook is run before a project is deleted."), ("postrmproject", "This hook is run after a project is deleted."), - ] +] def initialize(args): """Set up user hooks """ for filename, comment in GLOBAL_HOOKS: - make_hook(os.path.join('$VIRTUALENVWRAPPER_HOOK_DIR', filename), comment) + make_hook(os.path.join('$VIRTUALENVWRAPPER_HOOK_DIR', filename), + comment) return def pre_mkproject(args): log.debug('pre_mkproject %s', str(args)) - envname = args[0] run_global('premkproject', *args) return @@ -56,5 +57,6 @@ def post_activate_source(args): # # Change to the project directory # -[ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" ] && cd "$(cat \"$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME\")" +[ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" ] && \ + cd "$(cat \"$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME\")" """ diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 483ca26..bd66634 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -16,11 +16,9 @@ log = logging.getLogger(__name__) # Are we running under msys -if (sys.platform == 'win32' - and - os.environ.get('OS') == 'Windows_NT' - and - os.environ.get('MSYSTEM') == 'MINGW32'): +if sys.platform == 'win32' and \ + os.environ.get('OS') == 'Windows_NT' and \ + os.environ.get('MSYSTEM') == 'MINGW32': is_msys = True script_folder = 'Scripts' else: @@ -59,11 +57,13 @@ def run_global(script_name, *args): GLOBAL_HOOKS = [ # initialize ("initialize", - "This hook is run during the startup phase when loading virtualenvwrapper.sh."), + "This hook is run during the startup phase " + "when loading virtualenvwrapper.sh."), # mkvirtualenv ("premkvirtualenv", - "This hook is run after a new virtualenv is created and before it is activated."), + "This hook is run after a new virtualenv is created " + "and before it is activated."), ("postmkvirtualenv", "This hook is run after a new virtualenv is activated."), @@ -89,7 +89,7 @@ def run_global(script_name, *args): ("get_env_details", "This hook is run when the list of virtualenvs is printed " "so each name can include details."), - ] +] LOCAL_HOOKS = [ @@ -109,7 +109,7 @@ def run_global(script_name, *args): ("get_env_details", "This hook is run when the list of virtualenvs is printed " "in 'long' mode so each name can include details."), - ] +] def make_hook(filename, comment): @@ -149,7 +149,8 @@ def initialize_source(args): # # Run user-provided scripts # -[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/initialize" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/initialize" +[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/initialize" ] && \ + source "$VIRTUALENVWRAPPER_HOOK_DIR/initialize" """ @@ -157,7 +158,8 @@ def pre_mkvirtualenv(args): log.debug('pre_mkvirtualenv %s', str(args)) envname = args[0] for filename, comment in LOCAL_HOOKS: - make_hook(get_path('$WORKON_HOME', envname, script_folder, filename), comment) + make_hook(get_path('$WORKON_HOME', envname, script_folder, filename), + comment) run_global('premkvirtualenv', *args) return @@ -167,7 +169,8 @@ def post_mkvirtualenv_source(args): # # Run user-provided scripts # -[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postmkvirtualenv" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/postmkvirtualenv" +[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postmkvirtualenv" ] && \ + source "$VIRTUALENVWRAPPER_HOOK_DIR/postmkvirtualenv" """ @@ -175,7 +178,8 @@ def pre_cpvirtualenv(args): log.debug('pre_cpvirtualenv %s', str(args)) envname = args[0] for filename, comment in LOCAL_HOOKS: - make_hook(get_path('$WORKON_HOME', envname, script_folder, filename), comment) + make_hook(get_path('$WORKON_HOME', envname, script_folder, filename), + comment) run_global('precpvirtualenv', *args) return @@ -185,7 +189,8 @@ def post_cpvirtualenv_source(args): # # Run user-provided scripts # -[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postcpvirtualenv" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/postcpvirtualenv" +[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postcpvirtualenv" ] && \ + source "$VIRTUALENVWRAPPER_HOOK_DIR/postcpvirtualenv" """ @@ -204,7 +209,8 @@ def post_rmvirtualenv(args): def pre_activate(args): log.debug('pre_activate') run_global('preactivate', *args) - script_path = get_path('$WORKON_HOME', args[0], script_folder, 'preactivate') + script_path = get_path('$WORKON_HOME', args[0], + script_folder, 'preactivate') run_script(script_path, *args) return @@ -215,8 +221,10 @@ def post_activate_source(args): # # Run user-provided scripts # -[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postactivate" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/postactivate" -[ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/postactivate" ] && source "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/postactivate" +[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postactivate" ] && \ + source "$VIRTUALENVWRAPPER_HOOK_DIR/postactivate" +[ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/postactivate" ] && \ + source "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/postactivate" """ @@ -226,8 +234,10 @@ def pre_deactivate_source(args): # # Run user-provided scripts # -[ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/predeactivate" ] && source "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/predeactivate" -[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/predeactivate" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/predeactivate" +[ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/predeactivate" ] && \ + source "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/predeactivate" +[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/predeactivate" ] && \ + source "$VIRTUALENVWRAPPER_HOOK_DIR/predeactivate" """ @@ -238,8 +248,10 @@ def post_deactivate_source(args): # Run user-provided scripts # VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV="$WORKON_HOME/%(env_name)s" -[ -f "$WORKON_HOME/%(env_name)s/bin/postdeactivate" ] && source "$WORKON_HOME/%(env_name)s/bin/postdeactivate" -[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postdeactivate" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/postdeactivate" +[ -f "$WORKON_HOME/%(env_name)s/bin/postdeactivate" ] && \ + source "$WORKON_HOME/%(env_name)s/bin/postdeactivate" +[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postdeactivate" ] && \ + source "$VIRTUALENVWRAPPER_HOOK_DIR/postdeactivate" unset VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV """ % {'env_name': args[0]} @@ -247,7 +259,8 @@ def post_deactivate_source(args): def get_env_details(args): log.debug('get_env_details') run_global('get_env_details', *args) - script_path = get_path('$WORKON_HOME', args[0], script_folder, 'get_env_details') + script_path = get_path('$WORKON_HOME', args[0], + script_folder, 'get_env_details') run_script(script_path, *args) return @@ -263,7 +276,8 @@ def get_path(*args): ''' path = os.path.expanduser(os.path.expandvars(os.path.join(*args))) if is_msys: - # MSYS accept unix or Win32 and sometimes it drives to mixed style paths + # MSYS accept unix or Win32 and sometimes + # it drives to mixed style paths if re.match(r'^/[a-zA-Z](/|^)', path): # msys path could starts with '/c/'-form drive letter path = ''.join((path[1], ':', path[2:])) From e1d31c8b3c8cb0c35aeac58167092aec599b4eae Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 16 Mar 2013 07:22:13 -0700 Subject: [PATCH 620/947] add link to flake8 in history --- docs/source/history.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index 5de3613..1db4126 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -15,7 +15,9 @@ dev caused by that rotating behavior, especially when the wrappers are being used by users with different permissions and umasks. (:bbissue:`152`) - - Use flake8 for style checking. + - Use flake8_ for style checking. + +.. _flake8: https://pypi.python.org/pypi/flake8 3.6.1 From bad8275ee6b79a023c3df77cd40c5a074fe575a4 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 16 Mar 2013 07:34:46 -0700 Subject: [PATCH 621/947] Apply style to sphinx config file --- docs/source/conf.py | 29 ++++++++++++++++++----------- tox.ini | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 2516d4d..71a912a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -3,7 +3,8 @@ # virtualenvwrapper documentation build configuration file, created by # sphinx-quickstart on Thu May 28 22:35:13 2009. # -# This file is execfile()d with the current directory set to its containing dir. +# This file is execfile()d with the current directory set to its +# containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. @@ -19,10 +20,11 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.append(os.path.abspath('.')) -# -- General configuration ----------------------------------------------------- +# -- General configuration --------------------------------------------------- -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. extensions = ['sphinxcontrib.bitbucket'] bitbucket_project_url = 'http://bitbucket.org/dhellmann/virtualenvwrapper/' @@ -48,7 +50,10 @@ # built documents. # # The short X.Y version. -version = subprocess.check_output(['sh', '-c', 'cd ../..; python setup.py --version']) +version = subprocess.check_output([ + 'sh', '-c', + 'cd ../..; python setup.py --version', +]) version = version.strip() # The full version, including alpha/beta/rc tags. release = version @@ -70,7 +75,8 @@ # for source files. exclude_trees = ['_build'] -# The reST default role (used for this markup: `text`) to use for all documents. +# The reST default role (used for this markup: `text`) to use for all +# documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. @@ -91,7 +97,7 @@ #modindex_common_prefix = [] -# -- Options for HTML output --------------------------------------------------- +# -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. Major themes that come with # Sphinx are currently 'default' and 'sphinxdoc'. @@ -165,7 +171,7 @@ htmlhelp_basename = 'virtualenvwrapperdoc' -# -- Options for LaTeX output -------------------------------------------------- +# -- Options for LaTeX output ------------------------------------------------ # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' @@ -174,10 +180,11 @@ #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). +# (source start file, target name, title, author, documentclass +# [howto/manual]). latex_documents = [ - ('index', 'virtualenvwrapper.tex', u'virtualenvwrapper Documentation', - u'Doug Hellmann', 'manual'), + ('index', 'virtualenvwrapper.tex', u'virtualenvwrapper Documentation', + u'Doug Hellmann', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of diff --git a/tox.ini b/tox.ini index a8fb1d8..16d8390 100644 --- a/tox.ini +++ b/tox.ini @@ -11,7 +11,7 @@ setenv = [testenv:style] deps = flake8 -commands = flake8 virtualenvwrapper +commands = flake8 virtualenvwrapper docs/source/conf.py # Not sure why this is needed, but on my system if it isn't included then From 1c4b584b1c54c8961c58abb059135d20abc6f01c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 16 Mar 2013 07:35:52 -0700 Subject: [PATCH 622/947] update version number --- announce.rst | 24 +++++++++++++++++------- docs/source/history.rst | 2 +- setup.py | 2 +- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/announce.rst b/announce.rst index ad881d7..0c23d41 100644 --- a/announce.rst +++ b/announce.rst @@ -1,6 +1,6 @@ -========================= - virtualenvwrapper 3.6.1 -========================= +======================= + virtualenvwrapper 3.7 +======================= .. tags:: virtualenvwrapper release python @@ -16,10 +16,20 @@ introducing conflicts in their dependencies. What's New? =========== -- Replace realpath with a more portable way of converting a relative - path to an absolute path, used with the ``--python`` option to - mkvirtualenv (contributed by Radu Voicilas). -- Posted release to PyPI, resolving download redirect issue. +- Improve tab-completion support for users of the lazy-loading + mode. +- Add ``--help`` option to ``mkproject``. +- Add ``--help`` option to ``workon``. +- Turn off logging from the hook loader by default, and replace + ``VIRTUALENVWRAPPER_LOG_DIR`` environment variable with + ``VIRTUALENVWRAPPER_LOG_FILE``. The rotating log behavior remains + the same. The motivation for this change is the race condition + caused by that rotating behavior, especially when the wrappers are + being used by users with different permissions and + umasks. +- Use flake8_ for style checking. + +.. _flake8: https://pypi.python.org/pypi/flake8 Installing ========== diff --git a/docs/source/history.rst b/docs/source/history.rst index 1db4126..f9c6553 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -2,7 +2,7 @@ Release History =============== -dev +3.7 - Improve tab-completion support for users of the lazy-loading mode. (:bbuser:`upsuper`) diff --git a/setup.py b/setup.py index a357910..2632a39 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' -VERSION = '3.6.1' +VERSION = '3.7' # Bootstrap installation of Distribute import distribute_setup From 3405b8bc87065bb123154d216dae3c71c8cd78ea Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 16 Mar 2013 07:35:55 -0700 Subject: [PATCH 623/947] Added tag 3.7 for changeset 303ff1485acb --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 975d562..6cead79 100644 --- a/.hgtags +++ b/.hgtags @@ -87,3 +87,4 @@ dccf1a1abf4ea97589e9fa141167771049f031e0 3.2 c93b81815391a939601ac455a07b6f006825838a 3.5 002a0ccdcc7aea6ecee76685425bccbbe1b45bfa 3.6 c180ccae77b40c2728e53612648dab7e0356584f 3.6.1 +303ff1485acb605720408d092cd375ef0d2b17d3 3.7 From e9d895d863c2178851c32d8d353fb524fc6e8aaa Mon Sep 17 00:00:00 2001 From: Devin Sevilla Date: Wed, 27 Mar 2013 11:42:34 -0700 Subject: [PATCH 624/947] Update link to requirements docs --HG-- branch : link-fix --- docs/source/command_ref.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index a693cd7..19ef533 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -57,7 +57,7 @@ installed. * :ref:`scripts-postmkvirtualenv` * `requirements file format`_ -.. _requirements file format: http://www.pip-installer.org/en/latest/requirement-format.html +.. _requirements file format: http://www.pip-installer.org/en/latest/requirements.html .. _command-mktmpenv: From 2ff96ebc1e1ab20723bcec369b5a0e88f8a1824a Mon Sep 17 00:00:00 2001 From: John Brewer Date: Tue, 2 Apr 2013 11:41:06 -0400 Subject: [PATCH 625/947] Fixed broken screencast link. --- README.es.rst | 2 +- README.ja.rst | 2 +- README.rst | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.es.rst b/README.es.rst index b9d9b24..6147175 100644 --- a/README.es.rst +++ b/README.es.rst @@ -27,7 +27,7 @@ Características 6. Sistema de plugins para la creación de extensiones compartibles. Rich Leland ha grabado un pequeño `screencast -`__ +`__ mostrando las características de virtualenvwrapper. diff --git a/README.ja.rst b/README.ja.rst index 607814e..805f0ce 100644 --- a/README.ja.rst +++ b/README.ja.rst @@ -28,7 +28,7 @@ virtualenvwrapper は Ian Bicking の 6. さらに共有可能な拡張機能を作成できるプラグインシステム(:ref:`plugins` を参照) Rich Leland は virtualenvwrapper の機能を誇示するために短い -`スクリーンキャスト `__ +`スクリーンキャスト `__ を作成しました。 ============ diff --git a/README.rst b/README.rst index 9ab2680..4849dcb 100644 --- a/README.rst +++ b/README.rst @@ -30,7 +30,7 @@ Features 6. Plugin system for more creating sharable extensions. Rich Leland has created a short `screencast -`__ +`__ showing off the features of virtualenvwrapper. ============ From 71b4ebbce947bca83bbbfd40f9212f16cfefc981 Mon Sep 17 00:00:00 2001 From: David Szotten Date: Sat, 6 Apr 2013 21:48:42 +0100 Subject: [PATCH 626/947] prevent workon_help from polluting the global namespace --- virtualenvwrapper.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index b56ca97..efd8221 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -608,7 +608,7 @@ function showvirtualenv { } # Show help for workon -function workon_help { +function _workon_help { echo "Usage: workon env_name" echo "" echo " Deactivate any currently activated virtualenv" @@ -646,7 +646,7 @@ function workon { a="${in_args[$i]}" case "$a" in -h|--help) - workon_help; + _workon_help; return 0;; esac i=$(( $i + 1 )) From 6cbc438dc026d4b01b092d7469d2b8388da2536d Mon Sep 17 00:00:00 2001 From: David Szotten Date: Sat, 6 Apr 2013 22:07:45 +0100 Subject: [PATCH 627/947] better prefix and fix for other help functions --- virtualenvwrapper.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index efd8221..7af330e 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -337,7 +337,7 @@ function virtualenvwrapper_verify_active_environment { } # Help text for mkvirtualenv -function mkvirtualenv_help { +function virtualenvwrapper_mkvirtualenv_help { echo "Usage: mkvirtualenv [-a project_path] [-i package] [-r requirements_file] [virtualenv options] env_name" echo echo " -a project_path" @@ -394,7 +394,7 @@ function mkvirtualenv { i=$(( $i + 1 )); project="${in_args[$i]}";; -h|--help) - mkvirtualenv_help $a; + virtualenvwrapper_mkvirtualenv_help $a; return;; -i) i=$(( $i + 1 )); @@ -608,7 +608,7 @@ function showvirtualenv { } # Show help for workon -function _workon_help { +function virtualenvwrapper_workon_help { echo "Usage: workon env_name" echo "" echo " Deactivate any currently activated virtualenv" @@ -646,7 +646,7 @@ function workon { a="${in_args[$i]}" case "$a" in -h|--help) - _workon_help; + virtualenvwrapper_workon_help; return 0;; esac i=$(( $i + 1 )) @@ -962,7 +962,7 @@ function setvirtualenvproject { } # Show help for mkproject -function mkproject_help { +function virtualenvwrapper_mkproject_help { echo "Usage: mkproject [-t template] [virtualenv options] project_name" echo "" echo "Multiple templates may be selected. They are applied in the order" @@ -1002,7 +1002,7 @@ function mkproject { a="${in_args[$i]}" case "$a" in -h|--help) - mkproject_help; + virtualenvwrapper_mkproject_help; return;; -t) i=$(( $i + 1 )); From 2e16143e50c81254152680b50dcac7777fadc30a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 7 Apr 2013 10:52:07 -0400 Subject: [PATCH 628/947] note change in the history file --- docs/source/history.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/source/history.rst b/docs/source/history.rst index f9c6553..13f2fe7 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -2,6 +2,12 @@ Release History =============== +dev + + - Rename functions for generating help so they do not pollute the + global namespace, and especially so they do not interfere with tab + completion. Contributed by :bbuser:`davidszotten`. + 3.7 - Improve tab-completion support for users of the lazy-loading From ea8257f41bca02cd4cdd0b093f70f002c31a9a67 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 7 Apr 2013 11:09:10 -0400 Subject: [PATCH 629/947] Fix project template listing when none installed If there are no project templates installed, show a nice message instead of a traceback from stevedore. Fixes issue #179 --- docs/source/history.rst | 2 ++ virtualenvwrapper/hook_loader.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index 13f2fe7..a875f5a 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -7,6 +7,8 @@ dev - Rename functions for generating help so they do not pollute the global namespace, and especially so they do not interfere with tab completion. Contributed by :bbuser:`davidszotten`. + - Fix an issue with listing project templates if none are + installed. (:bbissue:`179`) 3.7 diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index f8ba13a..42f92ca 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -160,7 +160,10 @@ def run_hooks(hook, options, args, output=None): def show(ext): output.write(' %-10s -- %s\n' % (ext.name, inspect.getdoc(ext.plugin) or '')) - hook_mgr.map(show) + try: + hook_mgr.map(show) + except RuntimeError: # no templates + output.write(' No templates installed.\n') elif options.sourcing: def get_source(ext, args): From 5cef966f2b1f50d5907b9a026cbc246be58729af Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 7 Apr 2013 13:43:22 -0400 Subject: [PATCH 630/947] Make --python option to mkvirtualenv not sticky Fixes a problem with mkvirtualenv in which the value provided to --python is retained for subsequent calls. Fixes issue #178 --- docs/source/history.rst | 3 +++ tests/test_mkvirtualenv.sh | 8 ++++++++ virtualenvwrapper.sh | 1 + 3 files changed, 12 insertions(+) diff --git a/docs/source/history.rst b/docs/source/history.rst index a875f5a..b3e1828 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -9,6 +9,9 @@ dev completion. Contributed by :bbuser:`davidszotten`. - Fix an issue with listing project templates if none are installed. (:bbissue:`179`) + - Fix an issue with the ``--python`` option to ``mkvirtualenv`` + becoming *sticky* for future calls that do not explicitly specify + the option. (:bbissue:`178`) 3.7 diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index e1ae9c0..b00e9c2 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -166,5 +166,13 @@ test_virtualenv_fails () { VIRTUALENVWRAPPER_VIRTUALENV=virtualenv } +test_mkvirtualenv_python_not_sticky () { + typeset _save=$VIRTUALENVWRAPPER_VIRTUALENV + VIRTUALENVWRAPPER_VIRTUALENV=true + mkvirtualenv --python blah foo + assertSame "" "$interpreter" + VIRTUALENVWRAPPER_VIRTUALENV=$_save +} + . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 7af330e..b26c0f5 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -374,6 +374,7 @@ function mkvirtualenv { typeset envname typeset requirements typeset packages + typeset interpreter in_args=( "$@" ) From 7a5ba98eeca2673ae283aa6694c2a8d3a391dde4 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 7 Apr 2013 13:54:41 -0400 Subject: [PATCH 631/947] Prep 3.7.1 release --- announce.rst | 29 +++++++++++------------------ docs/source/history.rst | 2 +- setup.py | 2 +- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/announce.rst b/announce.rst index 0c23d41..1abf832 100644 --- a/announce.rst +++ b/announce.rst @@ -1,6 +1,6 @@ -======================= - virtualenvwrapper 3.7 -======================= +========================= + virtualenvwrapper 3.7.1 +========================= .. tags:: virtualenvwrapper release python @@ -16,20 +16,13 @@ introducing conflicts in their dependencies. What's New? =========== -- Improve tab-completion support for users of the lazy-loading - mode. -- Add ``--help`` option to ``mkproject``. -- Add ``--help`` option to ``workon``. -- Turn off logging from the hook loader by default, and replace - ``VIRTUALENVWRAPPER_LOG_DIR`` environment variable with - ``VIRTUALENVWRAPPER_LOG_FILE``. The rotating log behavior remains - the same. The motivation for this change is the race condition - caused by that rotating behavior, especially when the wrappers are - being used by users with different permissions and - umasks. -- Use flake8_ for style checking. - -.. _flake8: https://pypi.python.org/pypi/flake8 +- Rename functions for generating help so they do not pollute the + global namespace, and especially so they do not interfere with tab + completion. Contributed by ``davidszotten``. +- Fix an issue with listing project templates if none are installed. +- Fix an issue with the ``--python`` option to ``mkvirtualenv`` + becoming *sticky* for future calls that do not explicitly specify + the option. Installing ========== @@ -39,4 +32,4 @@ installation instructions. .. _virtualenv: http://pypi.python.org/pypi/virtualenv -.. _virtualenvwrapper: http://www.doughellmann.com/projects/virtualenvwrapper/ +.. _virtualenvwrapper: http://virtualenvwrapper.readthedocs.org/en/latest/ diff --git a/docs/source/history.rst b/docs/source/history.rst index b3e1828..30cd0b2 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -2,7 +2,7 @@ Release History =============== -dev +3.7.1 - Rename functions for generating help so they do not pollute the global namespace, and especially so they do not interfere with tab diff --git a/setup.py b/setup.py index 2632a39..22361be 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' -VERSION = '3.7' +VERSION = '3.7.1' # Bootstrap installation of Distribute import distribute_setup From c3ba559e8e9c377c9401d437ee072012122cc8c9 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 7 Apr 2013 20:04:00 -0400 Subject: [PATCH 632/947] flake8 fixes for setup.py --- setup.py | 148 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 77 insertions(+), 71 deletions(-) diff --git a/setup.py b/setup.py index 22361be..7f18454 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ except IOError: long_description = '' -################################################################################ +############################################################################# # find_package_data is an Ian Bicking creation. # Provided as an attribute, so you can append to these instead @@ -29,12 +29,13 @@ './dist', 'EGG-INFO', '*.egg-info') -def find_package_data( - where='.', package='', - exclude=standard_exclude, - exclude_directories=standard_exclude_directories, - only_in_packages=True, - show_ignored=False): +def find_package_data(where='.', + package='', + exclude=standard_exclude, + exclude_directories=standard_exclude_directories, + only_in_packages=True, + show_ignored=False, + ): """ Return a dictionary suitable for use in ``package_data`` in a distutils ``setup.py`` file. @@ -74,7 +75,7 @@ def find_package_data( bad_name = False for pattern in exclude_directories: if (fnmatchcase(name, pattern) - or fn.lower() == pattern.lower()): + or fn.lower() == pattern.lower()): bad_name = True if show_ignored: print >> sys.stderr, ( @@ -90,13 +91,16 @@ def find_package_data( new_package = package + '.' + name stack.append((fn, '', new_package, False)) else: - stack.append((fn, prefix + name + '/', package, only_in_packages)) + stack.append((fn, + prefix + name + '/', + package, + only_in_packages)) elif package or not only_in_packages: # is a file bad_name = False for pattern in exclude: if (fnmatchcase(name, pattern) - or fn.lower() == pattern.lower()): + or fn.lower() == pattern.lower()): bad_name = True if show_ignored: print >> sys.stderr, ( @@ -107,8 +111,66 @@ def find_package_data( continue out.setdefault(package, []).append(prefix + name) return out -################################################################################ - +############################################################################ + +us_pkg = 'virtualenvwrapper.user_scripts' + +entry_points = { + 'virtualenvwrapper.initialize': [ + 'user_scripts = %s:initialize' % us_pkg, + 'project = virtualenvwrapper.project:initialize', + ], + 'virtualenvwrapper.initialize_source': [ + 'user_scripts = %s:initialize_source' % us_pkg, + ], + + 'virtualenvwrapper.pre_mkvirtualenv': [ + 'user_scripts = %s:pre_mkvirtualenv' % us_pkg, + ], + 'virtualenvwrapper.post_mkvirtualenv_source': [ + 'user_scripts = %s:post_mkvirtualenv_source' % us_pkg, + ], + + 'virtualenvwrapper.pre_cpvirtualenv': [ + 'user_scripts = %s:pre_cpvirtualenv' % us_pkg, + ], + 'virtualenvwrapper.post_cpvirtualenv_source': [ + 'user_scripts = %s:post_cpvirtualenv_source' % us_pkg, + ], + + 'virtualenvwrapper.pre_rmvirtualenv': [ + 'user_scripts = %s:pre_rmvirtualenv' % us_pkg, + ], + 'virtualenvwrapper.post_rmvirtualenv': [ + 'user_scripts = %s:post_rmvirtualenv' % us_pkg, + ], + + 'virtualenvwrapper.project.pre_mkproject': [ + 'project = virtualenvwrapper.project:pre_mkproject', + ], + 'virtualenvwrapper.project.post_mkproject_source': [ + 'project = virtualenvwrapper.project:post_mkproject_source', + ], + + 'virtualenvwrapper.pre_activate': [ + 'user_scripts = %s:pre_activate' % us_pkg, + ], + 'virtualenvwrapper.post_activate_source': [ + 'user_scripts = %s:post_activate_source' % us_pkg, + 'project = virtualenvwrapper.project:post_activate_source', + ], + + 'virtualenvwrapper.pre_deactivate_source': [ + 'user_scripts = %s:pre_deactivate_source' % us_pkg, + ], + 'virtualenvwrapper.post_deactivate_source': [ + 'user_scripts = %s:post_deactivate_source' % us_pkg, + ], + + 'virtualenvwrapper.get_env_details': [ + 'user_scripts = %s:get_env_details' % us_pkg, + ], +} setup( name=PROJECT, @@ -155,68 +217,12 @@ def find_package_data( # Scan the input for package information # to grab any data files (text, images, etc.) # associated with sub-packages. - package_data=find_package_data(PROJECT, + package_data=find_package_data(PROJECT, package=PROJECT, only_in_packages=False, ), - entry_points={ - #'console_scripts': [ 'venvw_hook = virtualenvwrapper.hook_loader:main' ], - 'virtualenvwrapper.initialize': [ - 'user_scripts = virtualenvwrapper.user_scripts:initialize', - 'project = virtualenvwrapper.project:initialize', - ], - 'virtualenvwrapper.initialize_source': [ - 'user_scripts = virtualenvwrapper.user_scripts:initialize_source', - ], - - 'virtualenvwrapper.pre_mkvirtualenv': [ - 'user_scripts = virtualenvwrapper.user_scripts:pre_mkvirtualenv', - ], - 'virtualenvwrapper.post_mkvirtualenv_source': [ - 'user_scripts = virtualenvwrapper.user_scripts:post_mkvirtualenv_source', - ], - - 'virtualenvwrapper.pre_cpvirtualenv': [ - 'user_scripts = virtualenvwrapper.user_scripts:pre_cpvirtualenv', - ], - 'virtualenvwrapper.post_cpvirtualenv_source': [ - 'user_scripts = virtualenvwrapper.user_scripts:post_cpvirtualenv_source', - ], - - 'virtualenvwrapper.pre_rmvirtualenv': [ - 'user_scripts = virtualenvwrapper.user_scripts:pre_rmvirtualenv', - ], - 'virtualenvwrapper.post_rmvirtualenv': [ - 'user_scripts = virtualenvwrapper.user_scripts:post_rmvirtualenv', - ], - - 'virtualenvwrapper.project.pre_mkproject': [ - 'project = virtualenvwrapper.project:pre_mkproject', - ], - 'virtualenvwrapper.project.post_mkproject_source': [ - 'project = virtualenvwrapper.project:post_mkproject_source', - ], - - 'virtualenvwrapper.pre_activate': [ - 'user_scripts = virtualenvwrapper.user_scripts:pre_activate', - ], - 'virtualenvwrapper.post_activate_source': [ - 'user_scripts = virtualenvwrapper.user_scripts:post_activate_source', - 'project = virtualenvwrapper.project:post_activate_source', - ], - - 'virtualenvwrapper.pre_deactivate_source': [ - 'user_scripts = virtualenvwrapper.user_scripts:pre_deactivate_source', - ], - 'virtualenvwrapper.post_deactivate_source': [ - 'user_scripts = virtualenvwrapper.user_scripts:post_deactivate_source', - ], - - 'virtualenvwrapper.get_env_details': [ - 'user_scripts = virtualenvwrapper.user_scripts:get_env_details', - ], - }, + entry_points=entry_points, zip_safe=False, - ) +) From 4e3d522017ff7220d291e3449d9386ed0da007c8 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 8 Apr 2013 09:12:30 -0400 Subject: [PATCH 633/947] reorg test runner to remove redundant test runs --- tests/run_tests | 75 ++++++++----------------- tests/setup.sh | 0 tests/test.sh | 2 +- tests/test_add2virtualenv.sh | 2 +- tests/test_cd.sh | 2 +- tests/test_cp.sh | 2 +- tests/test_cpvirtualenv.sh | 2 +- tests/test_deactivate.sh | 2 +- tests/test_derive_workon_home.sh | 2 +- tests/test_dir_stack.sh | 2 +- tests/test_expandpath.sh | 2 +- tests/test_hook_dir.sh | 2 +- tests/test_lazy.sh | 1 + tests/test_lazy_loaded.sh | 2 +- tests/test_lazy_run.sh | 2 +- tests/test_log_file.sh | 2 +- tests/test_ls.sh | 2 +- tests/test_mktmpenv.sh | 2 +- tests/test_mkvirtualenv.sh | 2 +- tests/test_mkvirtualenv_associate.sh | 2 +- tests/test_mkvirtualenv_install.sh | 2 +- tests/test_mkvirtualenv_requirements.sh | 2 +- tests/test_project.sh | 2 +- tests/test_project_activate.sh | 2 +- tests/test_project_cd.sh | 2 +- tests/test_project_mk.sh | 2 +- tests/test_project_templates.sh | 2 +- tests/test_rmvirtualenv.sh | 2 +- tests/test_run_hook.sh | 2 +- tests/test_support.sh | 2 +- tests/test_tempfile.sh | 2 +- tests/test_toggleglobalsitepackages.sh | 2 +- tests/test_workon.sh | 2 +- tox.ini | 39 +++++++++++-- 34 files changed, 90 insertions(+), 85 deletions(-) mode change 100644 => 100755 tests/setup.sh mode change 100644 => 100755 tests/test_dir_stack.sh mode change 100644 => 100755 tests/test_hook_dir.sh mode change 100644 => 100755 tests/test_lazy.sh mode change 100644 => 100755 tests/test_lazy_loaded.sh mode change 100644 => 100755 tests/test_lazy_run.sh mode change 100644 => 100755 tests/test_log_file.sh mode change 100644 => 100755 tests/test_mktmpenv.sh mode change 100644 => 100755 tests/test_mkvirtualenv_associate.sh mode change 100644 => 100755 tests/test_mkvirtualenv_install.sh mode change 100644 => 100755 tests/test_mkvirtualenv_requirements.sh diff --git a/tests/run_tests b/tests/run_tests index d884251..3f2b2f3 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -2,12 +2,6 @@ #set -x -if [ -z "$TOXIC" ] -then - echo "Only run this via tox" 1>&2 - exit 1 -fi - envdir="$1" shift scripts="$*" @@ -21,25 +15,6 @@ then fi fi -# Make sure the test shells exist before proceeding, otherwise tests are -# going to fail later. -DESIRED_SHELLS=${DESIRED_SHELLS:-"bash zsh ksh"} -missing_shells="" -test_shells="" -for shell in $DESIRED_SHELLS -do - if test_shell=$(which $shell); then - test_shells="$test_shells $test_shell" - else - missing_shells="$missing_shells $shell" - fi -done -if [ -n "$missing_shells" ] -then - echo "Couldn't find the following shells: $missing_shells" 1>&2 - exit 1 -fi - # Force the tox virtualenv to be active. # # Since this script runs from within a separate shell created by tox, @@ -48,14 +23,19 @@ fi # are *not* inherited. # source "$envdir/bin/activate" +TMPDIR="$envdir/tmp" +export TMPDIR +mkdir -p "$TMPDIR" # Set up virtualenvwrapper.hook_loader to print more details than usual for debugging. #export HOOK_VERBOSE_OPTION=-vvv -export HOOK_VERBOSE_OPTION="-q" +HOOK_VERBOSE_OPTION="-q" +export HOOK_VERBOSE_OPTION # Force virtualenvwrapper to use the python interpreter in the # tox-created virtualenv. -export VIRTUALENVWRAPPER_PYTHON="$envdir/bin/python" +VIRTUALENVWRAPPER_PYTHON="$envdir/bin/python" +export VIRTUALENVWRAPPER_PYTHON # Clear any user settings for the hook directory or log directory unset VIRTUALENVWRAPPER_HOOK_DIR @@ -68,31 +48,24 @@ unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS for test_script in $scripts do - for test_shell in $test_shells - do - unset BASH - unset ZSH_VERSION - test_shell_opts= - case /$test_shell in - */zsh) test_shell_opts="-o shwordsplit" ;; - esac - export test_shell - export SHELL=$(which $test_shell) + echo + echo '********************************************************************************' + echo "Running $test_script" + echo " VIRTUAL_ENV=$VIRTUAL_ENV" + echo " VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON" + echo " $($VIRTUALENVWRAPPER_PYTHON -V 2>&1)" + echo " PYTHONPATH=$PYTHONPATH" + echo " SHELL=$SHELL" + echo " BASH_VERSION=$BASH_VERSION" + echo " ZSH_VERSION=$ZSH_VERSION" + echo " KSH_VERSION=$KSH_VERSION" + echo " virtualenv=$(which virtualenv)" + echo + SHUNIT_PARENT="$test_script" + export SHUNIT_PARENT + $test_shell_opts $test_script || exit 1 + echo - echo - echo '********************************************************************************' - echo "Running $test_script" - echo " VIRTUAL_ENV=$VIRTUAL_ENV" - echo " VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON" - echo " $($VIRTUALENVWRAPPER_PYTHON -V 2>&1)" - echo " PYTHONPATH=$PYTHONPATH" - echo " SHELL=$test_shell" - echo " virtualenv=$(which virtualenv)" - echo - export SHUNIT_PARENT="$test_script" - $test_shell $test_shell_opts $test_script || exit 1 - echo - done done exit 0 diff --git a/tests/setup.sh b/tests/setup.sh old mode 100644 new mode 100755 diff --git a/tests/test.sh b/tests/test.sh index b8a8ac8..5266a0c 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_add2virtualenv.sh b/tests/test_add2virtualenv.sh index 531e9ba..28115e1 100755 --- a/tests/test_add2virtualenv.sh +++ b/tests/test_add2virtualenv.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_cd.sh b/tests/test_cd.sh index 56dc05c..15dc4d7 100755 --- a/tests/test_cd.sh +++ b/tests/test_cd.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_cp.sh b/tests/test_cp.sh index f7fcad9..0015853 100755 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_cpvirtualenv.sh b/tests/test_cpvirtualenv.sh index df1d695..2a21b57 100755 --- a/tests/test_cpvirtualenv.sh +++ b/tests/test_cpvirtualenv.sh @@ -1,4 +1,4 @@ -#venv!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_deactivate.sh b/tests/test_deactivate.sh index 7a7fd9c..10f05bd 100755 --- a/tests/test_deactivate.sh +++ b/tests/test_deactivate.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_derive_workon_home.sh b/tests/test_derive_workon_home.sh index b2b38fb..7bed753 100755 --- a/tests/test_derive_workon_home.sh +++ b/tests/test_derive_workon_home.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_dir_stack.sh b/tests/test_dir_stack.sh old mode 100644 new mode 100755 index c807e7f..e391754 --- a/tests/test_dir_stack.sh +++ b/tests/test_dir_stack.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_expandpath.sh b/tests/test_expandpath.sh index fbdfefd..541df56 100755 --- a/tests/test_expandpath.sh +++ b/tests/test_expandpath.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_hook_dir.sh b/tests/test_hook_dir.sh old mode 100644 new mode 100755 index 70d23f0..2669348 --- a/tests/test_hook_dir.sh +++ b/tests/test_hook_dir.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_lazy.sh b/tests/test_lazy.sh old mode 100644 new mode 100755 index 34a9cf8..e81961c --- a/tests/test_lazy.sh +++ b/tests/test_lazy.sh @@ -1,3 +1,4 @@ +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_lazy_loaded.sh b/tests/test_lazy_loaded.sh old mode 100644 new mode 100755 index b71e68e..d4bc20f --- a/tests/test_lazy_loaded.sh +++ b/tests/test_lazy_loaded.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_lazy_run.sh b/tests/test_lazy_run.sh old mode 100644 new mode 100755 index 4cb322f..da3f169 --- a/tests/test_lazy_run.sh +++ b/tests/test_lazy_run.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_log_file.sh b/tests/test_log_file.sh old mode 100644 new mode 100755 index f6909df..73f57a6 --- a/tests/test_log_file.sh +++ b/tests/test_log_file.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_ls.sh b/tests/test_ls.sh index 4b71e4a..8c95392 100755 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_mktmpenv.sh b/tests/test_mktmpenv.sh old mode 100644 new mode 100755 index a781798..98b81d5 --- a/tests/test_mktmpenv.sh +++ b/tests/test_mktmpenv.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index b00e9c2..c9f0087 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_mkvirtualenv_associate.sh b/tests/test_mkvirtualenv_associate.sh old mode 100644 new mode 100755 index d825e5c..2fe28c0 --- a/tests/test_mkvirtualenv_associate.sh +++ b/tests/test_mkvirtualenv_associate.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_mkvirtualenv_install.sh b/tests/test_mkvirtualenv_install.sh old mode 100644 new mode 100755 index 2f99dab..9915a1d --- a/tests/test_mkvirtualenv_install.sh +++ b/tests/test_mkvirtualenv_install.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_mkvirtualenv_requirements.sh b/tests/test_mkvirtualenv_requirements.sh old mode 100644 new mode 100755 index c08fe2c..bf5bcf9 --- a/tests/test_mkvirtualenv_requirements.sh +++ b/tests/test_mkvirtualenv_requirements.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_project.sh b/tests/test_project.sh index 883a607..9f7ce5f 100755 --- a/tests/test_project.sh +++ b/tests/test_project.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(dirname $0) source "$test_dir/setup.sh" diff --git a/tests/test_project_activate.sh b/tests/test_project_activate.sh index 055cb15..93bb9e9 100755 --- a/tests/test_project_activate.sh +++ b/tests/test_project_activate.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(dirname $0) source "$test_dir/setup.sh" diff --git a/tests/test_project_cd.sh b/tests/test_project_cd.sh index dd8d53b..71823cc 100755 --- a/tests/test_project_cd.sh +++ b/tests/test_project_cd.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(dirname $0) source "$test_dir/setup.sh" diff --git a/tests/test_project_mk.sh b/tests/test_project_mk.sh index 5ee3491..10c5908 100755 --- a/tests/test_project_mk.sh +++ b/tests/test_project_mk.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(dirname $0) source "$test_dir/setup.sh" diff --git a/tests/test_project_templates.sh b/tests/test_project_templates.sh index c6250cc..18194ac 100755 --- a/tests/test_project_templates.sh +++ b/tests/test_project_templates.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(dirname $0) source "$test_dir/setup.sh" diff --git a/tests/test_rmvirtualenv.sh b/tests/test_rmvirtualenv.sh index 717d1e2..9aa903a 100755 --- a/tests/test_rmvirtualenv.sh +++ b/tests/test_rmvirtualenv.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_run_hook.sh b/tests/test_run_hook.sh index 2a2ddda..5790fa3 100755 --- a/tests/test_run_hook.sh +++ b/tests/test_run_hook.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_support.sh b/tests/test_support.sh index 2c5f226..65aaf8c 100755 --- a/tests/test_support.sh +++ b/tests/test_support.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_tempfile.sh b/tests/test_tempfile.sh index 895d0b1..e7a26c8 100755 --- a/tests/test_tempfile.sh +++ b/tests/test_tempfile.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_toggleglobalsitepackages.sh b/tests/test_toggleglobalsitepackages.sh index e86dd1c..00434d5 100755 --- a/tests/test_toggleglobalsitepackages.sh +++ b/tests/test_toggleglobalsitepackages.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tests/test_workon.sh b/tests/test_workon.sh index f034c4b..943d5e8 100755 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -1,4 +1,4 @@ -#!/bin/sh +# -*- mode: shell-script -*- test_dir=$(cd $(dirname $0) && pwd) source "$test_dir/setup.sh" diff --git a/tox.ini b/tox.ini index 16d8390..b71804c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py26,py32,style +envlist = py27,py26,py32,py33,zsh,ksh,style [testenv] commands = bash ./tests/run_tests {envdir} [] @@ -13,10 +13,41 @@ setenv = deps = flake8 commands = flake8 virtualenvwrapper docs/source/conf.py +[testenv:py27] +setenv = + SHELL = /bin/bash +commands = bash ./tests/run_tests {envdir} [] -# Not sure why this is needed, but on my system if it isn't included then -# the python version picked up for 2.6 is actually 2.7. +# Not sure why the basepython setting is needed, but on my system if +# it isn't included then the python version picked up for 2.6 is +# actually 2.7. +# # IF THIS CAUSES YOU A PROBLEM COMMENT IT OUT BEFORE RUNNING THE TESTS. +# [testenv:py26] -#basepython=/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 basepython=python2.6 +setenv = + SHELL = /bin/bash +commands = bash ./tests/run_tests {envdir} [] + +[testenv:py32] +setenv = + SHELL = /bin/bash +commands = bash ./tests/run_tests {envdir} [] + +[testenv:py33] +setenv = + SHELL = /bin/bash +commands = bash ./tests/run_tests {envdir} [] + +[testenv:zsh] +basepython=python2.7 +setenv = + SHELL = /bin/zsh +commands = zsh -o shwordsplit ./tests/run_tests {envdir} [] + +[testenv:ksh] +basepython=python2.7 +setenv = + SHELL = /bin/ksh +commands = ksh ./tests/run_tests {envdir} [] From 51ed4792d8ce8753565ad16be0a847f89313ccb1 Mon Sep 17 00:00:00 2001 From: Scott Stevenson Date: Thu, 11 Apr 2013 17:13:27 +0200 Subject: [PATCH 634/947] Correct script name in error message. --- virtualenvwrapper_lazy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper_lazy.sh b/virtualenvwrapper_lazy.sh index c0a78f8..68ff67c 100644 --- a/virtualenvwrapper_lazy.sh +++ b/virtualenvwrapper_lazy.sh @@ -9,7 +9,7 @@ then fi if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ] then - echo "ERROR: virtualenvwrapper_quick.sh: Could not find virtualenvwrapper.sh" 1>&2 + echo "ERROR: virtualenvwrapper_lazy.sh: Could not find virtualenvwrapper.sh" 1>&2 fi # Load the real implementation of the API from virtualenvwrapper.sh From 470480875543a8628f94851bf9da67b9c6c0dd0c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 13 Apr 2013 09:55:51 -0400 Subject: [PATCH 635/947] add attribution for previous fix to the history file --- docs/source/history.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/source/history.rst b/docs/source/history.rst index 30cd0b2..295ceb5 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -2,6 +2,12 @@ Release History =============== +dev + + - Fix the name of the script in an error message produced + by ``virtualenvwrapper_lazy.sh``. (Contributed by + :bbuser:`scottstvnsn`.) + 3.7.1 - Rename functions for generating help so they do not pollute the From 77157651da4893c201d89a94eadf2b0270d4721f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 22 Apr 2013 18:19:15 -0400 Subject: [PATCH 636/947] update tested-under version lists --- README.rst | 4 ++-- docs/source/install.rst | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 4849dcb..7329c9f 100644 --- a/README.rst +++ b/README.rst @@ -45,7 +45,7 @@ Supported Shells ================ virtualenvwrapper is a set of shell *functions* defined in Bourne -shell compatible syntax. It is tested under `bash`, `ksh`, and `zsh`. +shell compatible syntax. It is tested under ``bash``, ``ksh``, and ``zsh``. It may work with other shells, so if you find that it does work with a shell not listed here please let me know. If you can modify it to work with another shell, without completely rewriting it, send a pull @@ -56,7 +56,7 @@ from this page. Python Versions =============== -virtualenvwrapper is tested under Python 2.6, 2.7 and 3.2. +virtualenvwrapper is tested under Python 2.6 - 3.3. ======= Support diff --git a/docs/source/install.rst b/docs/source/install.rst index ebd1129..0693376 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -76,7 +76,7 @@ can download virtualenvwrapper-powershell_ from PyPI. Python Versions =============== -virtualenvwrapper is tested under Python 2.4 - 2.7. +virtualenvwrapper is tested under Python 2.6-3.3. .. _install-basic: From 5c5895010875d9a3ca8dc7549212a7dab0803bf1 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 22 Apr 2013 18:19:59 -0400 Subject: [PATCH 637/947] assume setuptools is available during the installation --- distribute_setup.py | 477 -------------------------------------------- setup.py | 4 - tox.ini | 3 +- 3 files changed, 2 insertions(+), 482 deletions(-) delete mode 100644 distribute_setup.py diff --git a/distribute_setup.py b/distribute_setup.py deleted file mode 100644 index 0021336..0000000 --- a/distribute_setup.py +++ /dev/null @@ -1,477 +0,0 @@ -#!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 sys -import time -import fnmatch -import tempfile -import tarfile -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.10" -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): - # 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'): - log.warn('Something went wrong during the installation.') - log.warn('See the error message above.') - finally: - os.chdir(old_wd) - - -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) - # 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 _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 - - -def _same_content(path, content): - return open(path).read() == content - -def _no_sandbox(function): - def __no_sandbox(*args, **kw): - try: - from setuptools.sandbox import DirectorySandbox - def violation(*args): - pass - DirectorySandbox._old = DirectorySandbox._violation - DirectorySandbox._violation = violation - patched = True - except ImportError: - patched = False - - try: - return function(*args, **kw) - finally: - if patched: - DirectorySandbox._violation = DirectorySandbox._old - del DirectorySandbox._old - - return __no_sandbox - -@_no_sandbox -def _rename_path(path): - new_name = path + '.OLD.%s' % time.time() - log.warn('Renaming %s into %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('Removing 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 - - -def _after_install(dist): - log.warn('After install bootstrap.') - placeholder = dist.get_command_obj('install').install_purelib - _create_fake_setuptools_pkg_info(placeholder) - -@_no_sandbox -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) - f = open(pkg_info, 'w') - 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() - -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 - - -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) - elif option == '--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('Patched done.') - _relaunch() - - -def _relaunch(): - log.warn('Relaunching...') - # we have to relaunch the process - 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 main(argv, version=DEFAULT_VERSION): - """Install or upgrade setuptools and EasyInstall""" - tarball = download_setuptools() - _install(tarball) - - -if __name__ == '__main__': - main(sys.argv[1:]) diff --git a/setup.py b/setup.py index 7f18454..9d16713 100644 --- a/setup.py +++ b/setup.py @@ -3,10 +3,6 @@ PROJECT = 'virtualenvwrapper' VERSION = '3.7.1' -# Bootstrap installation of Distribute -import distribute_setup -distribute_setup.use_setuptools() - from setuptools import setup, find_packages from distutils.util import convert_path diff --git a/tox.ini b/tox.ini index b71804c..b2f9710 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,8 @@ envlist = py27,py26,py32,py33,zsh,ksh,style [testenv] commands = bash ./tests/run_tests {envdir} [] -deps = virtualenv +deps = distribute + virtualenv virtualenv-clone stevedore setenv = From 84c0a0f090680fe7382b2c9be3c796e970582261 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 28 Apr 2013 06:12:20 -0400 Subject: [PATCH 638/947] Update Python 3 compatibility. Run the hook loader (and all Python-based hooks) within the WORKON_HOME directory, instead of wherever the shell happened to be before. In particular, this effects projects templates, which used to be run in the project directory. That path is now passed as an argument to the template, instead. Update tests to account for differences in output when exceptions are reported between different Python versions. Use typeset to properly scope variables used in deactivate(). Fix syntax for declaration of mktmpenv. --- docs/source/history.rst | 85 +++++++++++++++++++++++++- tests/test.sh | 9 +-- tests/test_project_mk.sh | 2 +- tests/testtemplate/mytemplates/main.py | 9 +-- virtualenvwrapper.sh | 16 ++++- 5 files changed, 106 insertions(+), 15 deletions(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index 295ceb5..dac538f 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -3,12 +3,22 @@ Release History =============== dev +=== - - Fix the name of the script in an error message produced - by ``virtualenvwrapper_lazy.sh``. (Contributed by - :bbuser:`scottstvnsn`.) +**Warning:** This release includes some potentially incompatible +changes for extensions. The python modules for extensions are now +*always* run with ``PWD=$WORKON_HOME`` (previously the value of PWD +varied depending on the hook). The *shell* portion of any hook +(anything sourced by the user's shell when the hook is run) is still +run in the same place as before. + +- All tests pass under Python 3.2 and 3.3. +- Fix the name of the script in an error message produced + by ``virtualenvwrapper_lazy.sh``. (Contributed by + :bbuser:`scottstvnsn`.) 3.7.1 +===== - Rename functions for generating help so they do not pollute the global namespace, and especially so they do not interfere with tab @@ -20,6 +30,7 @@ dev the option. (:bbissue:`178`) 3.7 +=== - Improve tab-completion support for users of the lazy-loading mode. (:bbuser:`upsuper`) @@ -37,6 +48,7 @@ dev .. _flake8: https://pypi.python.org/pypi/flake8 3.6.1 +===== - Replace realpath with a more portable way of converting a relative path to an absolute path, used with the ``--python`` option to @@ -45,6 +57,7 @@ dev issue. (:bbissue:`171` and :bbissue:`172`) 3.6 +=== - Switch to stevedore_ for plugin management - mkvirtualenv_help should use ``$VIRTUALENVWRAPPER_PYTHON`` instead @@ -61,6 +74,7 @@ dev .. _stevedore: http://pypi.python.org/pypi/stevedore 3.5 +=== - Rewrite :ref:`command-cpvirtualenv` to use `virtualenv-clone`_ instead of making the new environment relocatable. Contributed by @@ -77,10 +91,12 @@ dev 3.4 +=== - Add :ref:`install-lazy-loader` option. 3.3 +=== - Clean up file permissions and remove shebangs from scripts not intended to be executed on the command line. (contributed by @@ -104,6 +120,7 @@ dev - Make whitespace consistent. (:bbuser:`agriffis`) 3.2 +=== - Make ``project_dir`` a local variable so that :ref:`command-cdproject` does not interfere with other variables @@ -125,6 +142,7 @@ dev contributions toward the fix. 3.1 +=== - Fix a problem with activation hooks when associating a new virtualenv with an existing project directory. (:bbissue:`122`) @@ -132,23 +150,27 @@ dev containing "special" characters such as ``&``. (:bbissue:`132`) 3.0.1 +===== - Fix some packaging issues that made it more difficult to run the tests directly from the sdist package. (:bbissue:`126`) 3.0 +=== - Add Python 3 support, thanks in large part to the efforts of Daniel Kraus (:bbuser:`dakra`). Tested under Python 2.6, 2.7, and 3.2. 2.11.1 +====== - Remove the initialization shortcut because it breaks tab completion in sub-shell environments like screen and tmux. (:bbissue:`121`) 2.11 +==== - Add ``-a`` option to :ref:`command-mkvirtualenv` to associate a new virtualenv with an existing project directory. Contributed by @@ -165,12 +187,14 @@ dev reported by :bbuser:`arthuralvim`) 2.10.1 +====== - Changed arguments to :ref:`command-mktmpenv` so it always creates an environment name for you. (:bbissue:`114` reported by :bbuser:`alex_gaynor`) 2.10 +==== - Incorporated patch to add ``-d`` option to :ref:`command-add2virtualenv`, contributed by :bbuser:`miracle2k`. @@ -184,6 +208,7 @@ dev zsh. (:bbissue:`111`) 2.9 +=== - Change the shell function shell definition syntax so that ksh will treat typeset-declared variables as local. No kidding. @@ -195,6 +220,7 @@ dev dependencies using a pip requirements file. 2.8 +=== - Use VIRTUALENVWRAPPER_VIRTUALENV in `cpvirtualenv` (:bbissue:`104`). - Add support for `MSYS `_ @@ -202,12 +228,14 @@ dev H. (:bbuser:`noirbizarre`). 2.7.2 +===== - Move setup code for tab completion later in the startup code so all of the needed variables are configured. (:bbissue:`97`) - Expand tab completion for zsh to work for all commands. 2.7.1 +===== - When testing for WORKON_HOME during startup, dereference any symlink to make sure it is a directory. @@ -219,6 +247,7 @@ dev outside of a virtualenv). 2.7 +=== - Fix problem with space in WORKON_HOME path (:bbissue:`79`). - Fix problem with argument processing in lsvirtualenv under zsh @@ -251,6 +280,7 @@ dev (:bbissue:`85`). 2.6.3 +===== - Hard-code the version information in the setup.py and conf.py scripts. This still doesn't work for http://readthedocs.org, since @@ -258,6 +288,7 @@ dev will make it easier to transition the docs to another site later. 2.6.2 +===== - Attempted to make the doc build work with http://readthedocs.org. - Merged in `Japanese translation of the documentation @@ -268,10 +299,12 @@ dev (:ref:`VIRTUALENVWRAPPER_VIRTUALENV `). 2.6.1 +===== - Fixed virtualenvwrapper_get_python_version (:bbissue:`73`). 2.6 +=== - Fixed a problem with hook script line endings under Cygwin (:bbissue:`68`). @@ -286,35 +319,42 @@ dev scripts in the Makefile. 2.5.3 +===== - Point release uploaded to PyPI during outage on doughellmann.com. 2.5.2 +===== - Apply patch from Zach Voase to fix :ref:`command-lsvirtualenv` under zsh. Resolves :bbissue:`64`. 2.5.1 +===== - Make :ref:`command-workon` list brief environment details when run without argument, instead of full details. 2.5 +=== - Add :ref:`command-showvirtualenv` command. Modify :ref:`command-lsvirtualenv` to make verbose output the default. 2.4 +=== - Add :ref:`command-lsvirtualenv` command with ``-l`` option to run :ref:`scripts-get_env_details` hook instead of always running it when :ref:`command-workon` has no arguments. 2.3 +=== - Added ``get_env_details`` hook. 2.2.2 +===== - Integrate Fred Palmer's patch to escape more shell commands to avoid aliases. Resolves :bbissue:`57`. @@ -322,6 +362,7 @@ dev - Fix a problem with running mkvirtualenv without arguments (:bbissue:`56`). 2.2.1 +===== - Escape ``which`` calls to avoid aliases. Resolves :bbissue:`46`. - Integrate Manuel Kaufmann's patch to unset GREP_OPTIONS before @@ -331,6 +372,7 @@ dev :bbissue:`50`. 2.2 +=== - Switched hook loader execution to a form that works with Python 2.4 to resolve :bbissue:`43`. @@ -340,6 +382,7 @@ dev - Added some debug instrumentation for :bbissue:`35`. 2.1.1 +===== - Added `Spanish translation for the documentation `__ via @@ -351,6 +394,7 @@ dev virtualenv under zsh. See :bbissue:`42`. 2.1 +=== - Add support for ksh. Thanks to Doug Latornell for doing the research on what needed to be changed. @@ -376,16 +420,19 @@ dev 10KiB. 2.0.2 +===== - Fixed :bbissue:`32`, making virtualenvwrapper.user_scripts compatible with Python 2.5 again. 2.0.1 +===== - Fixed :bbissue:`29`, to use a default value for ``TMPDIR`` if it is not set in the user's shell environment. 2.0 +=== - Rewrote hook management using Distribute_ entry points to make it easier to share extensions. @@ -393,10 +440,12 @@ dev .. _Distribute: http://packages.python.org/distribute/ 1.27 +==== - Added cpvirtualenv command [Thomas Desvenain] 1.26 +==== - Fix a problem with error messages showing up during init for users with the wrappers installed site-wide but who are not actually @@ -405,42 +454,50 @@ dev - Run all tests with all supported shells. 1.25 +==== - Merged in changes to cdsitepackages from William McVey. It now takes an argument and supports tab-completion for directories within site-packages. 1.24.2 +====== - Add user provided :ref:`tips-and-tricks` section. - Add link to Rich Leland's screencast to :ref:`references` section. 1.24.1 +====== - Add license text to the header of the script. 1.24 +==== - Resolve a bug with the preactivate hook not being run properly. Refer to :bbissue:`21` for complete details. 1.23 +==== - Resolve a bug with the postmkvirtualenv hook not being run properly. Refer to :bbissue:`19` and :bbissue:`20` for complete details. 1.22 +==== - Automatically create any missing hook scripts as stubs with comments to expose the feature in case users are not aware of it. 1.21 +==== - Better protection of ``$WORKON_HOME`` does not exist when the wrapper script is sourced. 1.20 +==== - Incorporate lssitepackages feature from Sander Smits. - Refactor some of the functions that were using copy-and-paste code @@ -448,11 +505,13 @@ dev - Add a few tests. 1.19 +==== - Fix problem with add2virtualenv and relative paths. Thanks to Doug Latornell for the bug report James Bennett for the suggested fix. 1.18.1 +====== - Incorporate patch from Sascha Brossmann to fix a :bbissue:`15`. Directory normalization was causing ``WORKON_HOME`` @@ -460,6 +519,7 @@ dev characters in the output of ``pwd``. 1.18 +==== - Remove warning during installation if sphinxcontrib.paverutils is not installed. (:bbissue:`10`) @@ -467,10 +527,12 @@ dev - Added documentation for deactivate command. 1.17 +==== - Added documentation updates provided by Steve Steiner. 1.16 +==== - Merged in changes to ``cdvirtualenv`` from wam and added tests and docs. @@ -478,10 +540,14 @@ dev provided by wam. 1.15 +==== + - Better error handling in mkvirtualenv. - Remove bogus VIRTUALENV_WRAPPER_BIN variable. 1.14 +==== + - Wrap the virtualenv version of deactivate() with one that lets us invoke the predeactivate hooks. - Fix virtualenvwrapper_show_workon_options for colorized versions @@ -490,11 +556,13 @@ dev `_ 1.13 +==== - Fix :bbissue:`5` by correctly handling symlinks and limiting the list of envs to things that look like they can be activated. 1.12 +==== - Check return value of virtualenvwrapper_verify_workon_home everywhere, thanks to Jeff Forcier for pointing out the errors. @@ -503,56 +571,67 @@ dev - Enhance test.sh. 1.11 +==== - Optimize virtualenvwrapper_show_workon_options. - Add global postactivate hook. 1.10 +==== - Pull in fix for colorized ls from Jeff Forcier (:bbchangeset:`b42a25f7b74a`). 1.9 +=== - Add more hooks for operations to run before and after creating or deleting environments based on changes from Chris Hasenpflug. 1.8.1 +===== - Corrected a problem with change to mkvirtualenv that lead to release 1.8 by using an alternate fix proposed by James in comments on release 1.4. 1.8 +=== - Fix for processing the argument list in mkvirtualenv from jorgevargas (:bbissue:`1`) 1.7 +=== - Move to bitbucket.org for hosting - clean up TODO list and svn keywords - add license section below 1.6.1 +===== - More zsh support (fixes to rmvirtualenv) from Byron Clark. 1.6 +=== - Add completion support for zsh, courtesy of Ted Leung. 1.5 +=== - Fix some issues with spaces in directory or env names. They still don't really work with virtualenv, though. - Added documentation for the postactivate and predeactivate scripts. 1.4 +=== - Includes a new .pth management function based on work contributed by James Bennett and Jannis Leidel. 1.3.x +===== - Includes a fix for a nasty bug in rmvirtualenv identified by John Shimek. diff --git a/tests/test.sh b/tests/test.sh index 5266a0c..16426e7 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -86,18 +86,19 @@ test_python_interpreter_set_incorrectly() { mkvirtualenv no_wrappers >/dev/null 2>&1 RC=$? assertEquals "mkvirtualenv return code wrong" "0" "$RC" - expected="ImportError: No module named virtualenvwrapper.hook_loader" + expected="No module named virtualenvwrapper" # test_shell is set by tests/run_tests if [ "$test_shell" = "" ] then export test_shell=$SHELL fi - subshell_output=$(VIRTUALENVWRAPPER_PYTHON="$WORKON_HOME/no_wrappers/bin/python" $test_shell $return_to/virtualenvwrapper.sh 2>&1) + outfilename="$WORKON_HOME/test_out.$$" + subshell_output=$(VIRTUALENVWRAPPER_PYTHON="$WORKON_HOME/no_wrappers/bin/python" $test_shell $return_to/virtualenvwrapper.sh >"$outfilename" 2>&1) #echo "$subshell_output" - echo "$subshell_output" | grep -q "$expected" 2>&1 + cat "$outfilename" | sed "s/'//g" | grep -q "$expected" 2>&1 found_it=$? #echo "$found_it" - assertTrue "Expected \'$expected\', got: \'$subshell_output\'" "[ $found_it -eq 0 ]" + assertTrue "Expected \'$expected\', got: \'$(cat "$outfilename")\'" "[ $found_it -eq 0 ]" assertFalse "Failed to detect invalid Python location" "VIRTUALENVWRAPPER_PYTHON=$VIRTUAL_ENV/bin/python virtualenvwrapper_run_hook initialize >/dev/null 2>&1" cd "$return_to" deactivate diff --git a/tests/test_project_mk.sh b/tests/test_project_mk.sh index 10c5908..bd3d178 100755 --- a/tests/test_project_mk.sh +++ b/tests/test_project_mk.sh @@ -46,7 +46,7 @@ test_hooks () { output=$(cat "$WORKON_HOME/catch_output") - expected="GLOBAL premkproject $PROJECT_HOME myproject3 + expected="GLOBAL premkproject $WORKON_HOME myproject3 GLOBAL postmkproject $PROJECT_HOME/myproject3" assertSame "$expected" "$output" diff --git a/tests/testtemplate/mytemplates/main.py b/tests/testtemplate/mytemplates/main.py index 9d07f72..581fb5b 100644 --- a/tests/testtemplate/mytemplates/main.py +++ b/tests/testtemplate/mytemplates/main.py @@ -11,13 +11,14 @@ log = logging.getLogger(__name__) + def template(args): """Creates a test file containing the args passed to us """ - log.info('Running test template with args %r', args) - project = args[0] - filename = 'TEST_FILE' - log.info('Writing to %s', filename) + print('Running test template with args %r' % args) + project, project_dir = args + filename = os.path.join(project_dir, 'TEST_FILE') + print('Writing to %s' % filename) output = open(filename, 'w') try: output.write('\n'.join(args)) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index b26c0f5..1efe18a 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -202,7 +202,15 @@ function virtualenvwrapper_run_hook { hook_script="$(virtualenvwrapper_tempfile ${1}-hook)" || return 1 - "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' $HOOK_VERBOSE_OPTION --script "$hook_script" "$@" + # Use a subshell to run the python interpreter with hook_loader so + # we can change the working directory. This avoids having the + # Python 3 interpreter decide that its "prefix" is the virtualenv + # if we happen to be inside the virtualenv when we start. + ( \ + cd "$WORKON_HOME" && + "$VIRTUALENVWRAPPER_PYTHON" -m 'virtualenvwrapper.hook_loader' \ + $HOOK_VERBOSE_OPTION --script "$hook_script" "$@" \ + ) result=$? if [ $result -eq 0 ] @@ -691,6 +699,8 @@ function workon { # Replace the deactivate() function with a wrapper. eval 'deactivate () { + typeset env_postdeactivate_hook + typeset old_env # Call the local hook before the global so we can undo # any settings made by the local postactivate first. @@ -1053,7 +1063,7 @@ function mkproject { # For some reason zsh insists on prefixing the template # names with a space, so strip them out before passing # the value to the hook loader. - virtualenvwrapper_run_hook --name $(echo $t | sed 's/^ //') "project.template" $envname + virtualenvwrapper_run_hook --name $(echo $t | sed 's/^ //') "project.template" "$envname" "$PROJECT_HOME/$envname" done virtualenvwrapper_run_hook "project.post_mkproject" @@ -1085,7 +1095,7 @@ function cdproject { # # Originally part of virtualenvwrapper.tmpenv plugin # -mktmpenv() { +function mktmpenv { typeset tmpenvname typeset RC From 5b08ed0308c93025e9b8a081e6d8518fef2f8250 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 28 Apr 2013 06:17:16 -0400 Subject: [PATCH 639/947] Prepare for 4.0 release. --- README.rst | 7 +++++++ announce.rst | 24 ++++++++++++++---------- docs/source/history.rst | 4 ++-- setup.py | 2 +- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/README.rst b/README.rst index 7329c9f..ec8a686 100644 --- a/README.rst +++ b/README.rst @@ -11,6 +11,13 @@ managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. +**Warning:** The 4.x release includes some potentially incompatible +changes for extensions from 3.x. The python modules for extensions are +now *always* run with ``PWD=$WORKON_HOME`` (previously the value of +PWD varied depending on the hook). The *shell* portion of any hook +(anything sourced by the user's shell when the hook is run) is still +run in the same place as before. + ======== Features ======== diff --git a/announce.rst b/announce.rst index 1abf832..58ad81d 100644 --- a/announce.rst +++ b/announce.rst @@ -1,6 +1,6 @@ -========================= - virtualenvwrapper 3.7.1 -========================= +======================= + virtualenvwrapper 4.0 +======================= .. tags:: virtualenvwrapper release python @@ -16,13 +16,17 @@ introducing conflicts in their dependencies. What's New? =========== -- Rename functions for generating help so they do not pollute the - global namespace, and especially so they do not interfere with tab - completion. Contributed by ``davidszotten``. -- Fix an issue with listing project templates if none are installed. -- Fix an issue with the ``--python`` option to ``mkvirtualenv`` - becoming *sticky* for future calls that do not explicitly specify - the option. +**Warning:** This release includes some potentially incompatible +changes for extensions. The python modules for extensions are now +*always* run with ``PWD=$WORKON_HOME`` (previously the value of PWD +varied depending on the hook). The *shell* portion of any hook +(anything sourced by the user's shell when the hook is run) is still +run in the same place as before. + +- All tests pass under Python 2.6, 2.7, 3.2 and 3.3. +- Fix the name of the script in an error message produced + by ``virtualenvwrapper_lazy.sh``. (Contributed by + :bbuser:`scottstvnsn`.) Installing ========== diff --git a/docs/source/history.rst b/docs/source/history.rst index dac538f..ce3edbe 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -2,7 +2,7 @@ Release History =============== -dev +4.0 === **Warning:** This release includes some potentially incompatible @@ -12,7 +12,7 @@ varied depending on the hook). The *shell* portion of any hook (anything sourced by the user's shell when the hook is run) is still run in the same place as before. -- All tests pass under Python 3.2 and 3.3. +- All tests pass under Python 2.6, 2.7, 3.2 and 3.3. - Fix the name of the script in an error message produced by ``virtualenvwrapper_lazy.sh``. (Contributed by :bbuser:`scottstvnsn`.) diff --git a/setup.py b/setup.py index 9d16713..2b97207 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python PROJECT = 'virtualenvwrapper' -VERSION = '3.7.1' +VERSION = '4.0' from setuptools import setup, find_packages From 59b9cd3f3e768960ed24ee3a6119684bb99ce50a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 28 Apr 2013 06:29:15 -0400 Subject: [PATCH 640/947] Added tag 4.0 for changeset 2ba65a13f804 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 6cead79..c709255 100644 --- a/.hgtags +++ b/.hgtags @@ -88,3 +88,4 @@ c93b81815391a939601ac455a07b6f006825838a 3.5 002a0ccdcc7aea6ecee76685425bccbbe1b45bfa 3.6 c180ccae77b40c2728e53612648dab7e0356584f 3.6.1 303ff1485acb605720408d092cd375ef0d2b17d3 3.7 +2ba65a13f804584d49df12ccedcbd20422fa85f9 4.0 From b4313558872ec64ee7fa50df72230c4eead6206d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 28 Apr 2013 06:51:09 -0400 Subject: [PATCH 641/947] add python 3.3 classifier --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 2b97207..905271f 100644 --- a/setup.py +++ b/setup.py @@ -188,6 +188,7 @@ def find_package_data(where='.', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.2', + 'Programming Language :: Python :: 3.3', 'Intended Audience :: Developers', 'Environment :: Console', ], From 83fc18a71c54ae698c61ee5281452c56e82a6f05 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 28 Apr 2013 07:01:17 -0400 Subject: [PATCH 642/947] fix home page url --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 905271f..3c7bd41 100644 --- a/setup.py +++ b/setup.py @@ -178,7 +178,7 @@ def find_package_data(where='.', author='Doug Hellmann', author_email='doug.hellmann@gmail.com', - url='http://www.doughellmann.com/projects/%s/' % PROJECT, + url='http://%s.readthedocs.org' % PROJECT, classifiers=['Development Status :: 5 - Production/Stable', 'License :: OSI Approved :: MIT License', From 1b1d7a16f2879009500ec85937f22cd7bdff420e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 28 Apr 2013 07:11:02 -0400 Subject: [PATCH 643/947] fix rst in announcement file --- announce.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/announce.rst b/announce.rst index 58ad81d..33a83b8 100644 --- a/announce.rst +++ b/announce.rst @@ -26,7 +26,7 @@ run in the same place as before. - All tests pass under Python 2.6, 2.7, 3.2 and 3.3. - Fix the name of the script in an error message produced by ``virtualenvwrapper_lazy.sh``. (Contributed by - :bbuser:`scottstvnsn`.) + scottstvnsn.) Installing ========== From 0e85c6f65b3962b20ed7bb72661cd689cab26146 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 28 Apr 2013 07:24:04 -0400 Subject: [PATCH 644/947] add a warning to cpvirtualenv command docs --- docs/source/command_ref.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 19ef533..9e34737 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -157,6 +157,13 @@ Duplicate an existing virtualenv environment. The source can be an environment managed by virtualenvwrapper or an external environment created elsewhere. +.. warning:: + + Copying virtual environments is not well supported. Each virtualenv + has path information hard-coded into it, and there may be cases + where the copy code does not know to update a particular + file. **Use with caution.** + Syntax:: cpvirtualenv ENVNAME [TARGETENVNAME] From 00763100d2202b59eea8a19eb01509a41e938ddf Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 28 Apr 2013 18:38:19 -0400 Subject: [PATCH 645/947] add doc explaining implementation choices --- docs/source/design.rst | 178 +++++++++++++++++++++++++++++++++++++++++ docs/source/index.rst | 1 + 2 files changed, 179 insertions(+) create mode 100644 docs/source/design.rst diff --git a/docs/source/design.rst b/docs/source/design.rst new file mode 100644 index 0000000..40562a8 --- /dev/null +++ b/docs/source/design.rst @@ -0,0 +1,178 @@ +========================================================= + Why virtualenvwrapper is (Mostly) Not Written In Python +========================================================= + +If you look at the source code for virtualenvwrapper you will see that +most of the interesting parts are implemented as shell functions in +``virtualenvwrapper.sh``. The hook loader is a Python app, but doesn't +do much to manage the virtualenvs. Some of the most frequently asked +questions about virtualenvwrapper are "Why didn't you write this as a +set of Python programs?" or "Have you thought about rewriting it in +Python?" For a long time these questions baffled me, because it was +always obvious to me that it had to be implemented as it is. But they +come up frequently enough that I feel the need to explain. + +tl;dr: POSIX Made Me Do It +========================== + +The choice of implementation language for virtualenvwrapper was made +for pragmatic, rather than philosophical, reasons. The wrapper +commands need to modify the state and environment of the user's +*current shell process*, and the only way to do that is to have the +commands run *inside that shell.* That resulted in me writing +virtualenvwrapper as a set of shell functions, rather than separate +shell scripts or even Python programs. + +Where Do POSIX Processes Come From? +=================================== + +New POSIX processes are created when an existing process invokes the +``fork()`` system call. The invoking process becomes the "parent" of +the new "child" process, and the child is a full clone of the +parent. The *semantic* result of ``fork()`` is that an entire new copy +of the parent process is created. In practice, optimizations are +normally made to avoid copying more memory than is absolutely +necessary (frequently via a copy-on-write system). But for the +purposes of this explanation it is sufficient to think of the child as +a full replica of the parent. + +The important parts of the parent process that are copied include +dynamic memory (the stack and heap), static stuff (the program code), +resources like open file descriptors, and the *environment variables* +exported from the parent process. Inheriting environment variables is +a fundamental aspect of the way POSIX programs pass state and +configuration information to one another. A parent can establish a +series of ``name=value`` pairs, which are then given to the child +process. The child can access them through functions like +``getenv()``, ``setenv()`` (and in Python through ``os.environ``). + +The choice of the term *inherit* to describe the way the variables and +their contents are passed from parent to child is +significant. Although a child can change its own environment, it +cannot directly change the environment settings of its parent +because there is no system call to modify the parental environment +settings. + +How the Shell Runs a Program +============================ + +When a shell receives a command to be executed, either interactively +or by parsing a script file, and determines that the command is +implemented in a separate program file, is uses ``fork()`` to create a +new process and then inside that process it uses one of the ``exec`` +functions to start the specified program. The language that program is +written in doesn't make any difference in the decision about whether +or not to ``fork()``, so even if the "program" is a shell script +written in the language understood by the current shell, a new process +is created. + +On the other hand, if the shell decides that the command is a +*function*, then it looks at the definition and invokes it +directly. Shell functions are made up of other commands, some of which +may result in child processes being created, but the function itself +runs in the original shell process and can therefore modify its state, +for example by changing the working directory or the values of +variables. + +It is possible to force the shell to run a script directly, and not in +a child process, by *sourcing* it. The ``source`` command causes the +shell to read the file and interpret it in the current process. Again, +as with functions, the contents of the file may cause child processes +to be spawned, but there is not a second shell process interpreting +the series of commands. + +What Does This Mean for virtualenvwrapper? +========================================== + +The original and most important features of virtualenvwrapper are +automatically activating a virtualenv when it is created by +``mkvirtualenv`` and using ``workon`` to deactivate one environment +and activate another. Making these features work drove the +implementation decisions for the other parts of virtualenvwrapper, +too. + +Environments are activated interactively by sourcing ``bin/activate`` +inside the virtualenv. The ``activate`` script does a few things, but +the important parts are setting the ``VIRTUAL_ENV`` variable and +modifying the shell's search path through the ``PATH`` variable to put +the ``bin`` directory for the environment on the front of the +path. Changing the path means that the programs installed in the +environment, especially the python interpreter there, are found before +other programs with the same name. + +Simply running ``bin/activate``, without using ``source`` doesn't work +because it sets up the environment of the *child* process, without +affecting the parent. In order to source the activate script in the +interactive shell, both ``mkvirtualenv`` and ``workon`` also need to +be run in that shell process. + +Why Choose One When You Can Have Both? +====================================== + +The hook loader is one part of virtualenvwrapper that *is* written in +Python. Why? Again, because it was easier. Hooks are discovered using +setuptools entry points, because after an entry point is installed the +user doesn't have to take any other action to allow the loader to +discover and use it. It's easy to imagine writing a hook to create new +files on the filesystem (by installing a package, instantiating a +template, etc.). + +How, then, do hooks running in a separate process (the Python +interpreter) modify the shell environment to set variables or change +the working directory? They cheat, of course. + +Each hook point defined by virtualenvwrapper actually represents two +hooks. First, the hooks meant to be run in Python are executed. Then +the "source" hooks are run, and they *print out* a series of shell +commands. All of those commands are collected, saved to a temporary +file, and then the shell is told to source the file. + +Starting up the hook loader turns out to be way more expensive than +most of the other actions virtualenvwrapper takes, though, so I am +considering making its use optional. Most users customize the hooks by +using shell scripts (either globally or in the virtualenv). Finding +and running those can be handled by the shell quite easily. + +Implications for Cross-Shell Compatibility +========================================== + +Other than requests for a full-Python implementation, the other most +common request is to support additional shells. fish_ comes up a lot, +as do various Windows-only shells. The officially +:ref:`supported-shells` all have a common enough syntax that the same +implementation works for each. Supporting other shells would require +rewriting much, if not all, of the logic using an alternate syntax -- +those other shells are basically different programming languages. So +far I have dealt with the ports by encouraging other developers to +handle them, and then trying to link to and otherwise promote the +results. + +.. _fish: http://ridiculousfish.com/shell/ + +Not As Bad As It Seems +====================== + +Although there are some special challenges created by the the +requirement that the commands run in a user's interactive shell (see +the many bugs reported by users who alias common commands like ``rm`` +and ``cd``), using the shell as a programming language holds up quite +well. The shells are designed to make finding and executing other +programs easy, and especially to make it easy to combine a series of +smaller programs to perform more complicated operations. As that's +what virtualenvwrapper is doing, it's a natural fit. + +.. seealso:: + + * `Advanced Programming in the UNIX Environment`_ by W. Richard + Stevens & Stephen A. Rago + * `Fork (operating system)`_ on Wikipedia + * `Environment variable`_ on Wikipedia + * `Linux implementation of fork()`_ + +.. _Advanced Programming in the UNIX Environment: http://www.amazon.com/gp/product/0321637739/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=0321637739&linkCode=as2&tag=hellflynet-20 + +.. _Fork (operating system): http://en.wikipedia.org/wiki/Fork_(operating_system) + +.. _Environment variable: http://en.wikipedia.org/wiki/Environment_variable + +.. _Linux implementation of fork(): https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/fork.c?id=refs/tags/v3.9-rc8#n1558 diff --git a/docs/source/index.rst b/docs/source/index.rst index 9710da7..44f3afa 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -179,6 +179,7 @@ Details tips developers extensions + design history .. _references: From e0ed6000183ce62555e85fb4a786735d7e71dcbc Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 5 May 2013 12:17:59 -0400 Subject: [PATCH 646/947] Show more details when running under zsh. --- tests/run_tests | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/run_tests b/tests/run_tests index 3f2b2f3..4b6f7fa 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -1,5 +1,3 @@ -#!/bin/sh - #set -x envdir="$1" @@ -60,6 +58,7 @@ do echo " ZSH_VERSION=$ZSH_VERSION" echo " KSH_VERSION=$KSH_VERSION" echo " virtualenv=$(which virtualenv)" + echo " ZSH=$ZSH_NAME $ZSH_EVAL_CONTEXT" echo SHUNIT_PARENT="$test_script" export SHUNIT_PARENT From 388d33cf39b7e2cad94f7d62f88837f884b9e64a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 5 May 2013 12:23:41 -0400 Subject: [PATCH 647/947] Run the cdproject test in a subshell Watch for any command to fail for any reason and treat that as a failure. addresses issue #164 --- tests/test_project_cd.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/test_project_cd.sh b/tests/test_project_cd.sh index 71823cc..f4cc879 100755 --- a/tests/test_project_cd.sh +++ b/tests/test_project_cd.sh @@ -40,15 +40,17 @@ test_without_project () { } test_space_in_path () { - old_project_home="$PROJECT_HOME" + ( + set -x + set -e PROJECT_HOME="$PROJECT_HOME/with spaces" mkdir -p "$PROJECT_HOME" mkproject "myproject" >/dev/null 2>&1 - cd $TMPDIR + cd "$WORKON_HOME" cdproject - assertSame "$PROJECT_HOME/myproject" "$(pwd)" - deactivate - PROJECT_HOME="$old_project_home" + [ "$PROJECT_HOME/myproject" == "$(pwd)" ] + ) + assertTrue "Did not cd to project directory" $? } From ea5344f1a9d153aeb7609105b8372f75c4412092 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 5 May 2013 12:54:20 -0400 Subject: [PATCH 648/947] Skip pushd/popd test under ksh Since ksh does not have pushd or popd, there is no point in running the test there. Fixes issue #182 --- tests/test_dir_stack.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_dir_stack.sh b/tests/test_dir_stack.sh index e391754..f86c9fc 100755 --- a/tests/test_dir_stack.sh +++ b/tests/test_dir_stack.sh @@ -29,6 +29,7 @@ tearDown() { } test_ticket_101 () { + [ ! -z "$KSH_VERSION" ] && echo "Skipping test under ksh" && return 0 mkvirtualenv some_env deactivate cd "$WORKON_HOME/start_here" From 04fdc9e0e39d80ddcdaa2a0f07a66d15c4fe060e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 5 May 2013 13:03:38 -0400 Subject: [PATCH 649/947] Quote paths. Ensure that variables building paths from subcommands are quoted in case the paths include spaces. addresses issue #164 --- docs/source/history.rst | 6 ++++++ virtualenvwrapper.sh | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index ce3edbe..6aa2c4e 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -2,6 +2,12 @@ Release History =============== +dev +=== + +- Ensure that all $() style commands that produce paths are + quoted. Addresses :bbissue:`164`. + 4.0 === diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 1efe18a..6e6710b 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -146,7 +146,7 @@ function virtualenvwrapper_derive_workon_home { # - Removing extra slashes (e.g., when TMPDIR ends in a slash) # - Expanding variables (e.g., $foo) # - Converting ~s to complete paths (e.g., ~/ to /home/brian/ and ~arthur to /home/arthur) - workon_home_dir=$(virtualenvwrapper_expandpath "$workon_home_dir") + workon_home_dir="$(virtualenvwrapper_expandpath "$workon_home_dir")" fi echo "$workon_home_dir" @@ -297,7 +297,7 @@ function virtualenvwrapper_initialize { # Verify that the passed resource is in path and exists function virtualenvwrapper_verify_resource { - typeset exe_path=$(command \which "$1" | (unset GREP_OPTIONS; command \grep -v "not found")) + typeset exe_path="$(command \which "$1" | (unset GREP_OPTIONS; command \grep -v "not found"))" if [ "$exe_path" = "" ] then echo "ERROR: virtualenvwrapper could not find $1 in your path" >&2 @@ -411,11 +411,11 @@ function mkvirtualenv { -p|--python) i=$(( $i + 1 )); interpreter="${in_args[$i]}"; - interpreter=$(virtualenvwrapper_absolutepath "$interpreter");; + interpreter="$(virtualenvwrapper_absolutepath "$interpreter")";; -r) i=$(( $i + 1 )); requirements="${in_args[$i]}"; - requirements=$(virtualenvwrapper_expandpath "$requirements");; + requirements="$(virtualenvwrapper_expandpath "$requirements")";; *) if [ ${#out_args} -gt 0 ] then @@ -608,7 +608,7 @@ function showvirtualenv { echo "showvirtualenv [env]" return 1 fi - env_name=$(basename $VIRTUAL_ENV) + env_name=$(basename "$VIRTUAL_ENV") fi echo -n "$env_name" @@ -797,7 +797,7 @@ function add2virtualenv { for pydir in "$@" do - absolute_path=$(virtualenvwrapper_absolutepath "$pydir") + absolute_path="$(virtualenvwrapper_absolutepath "$pydir")" if [ "$absolute_path" != "$pydir" ] then echo "Warning: Converting \"$pydir\" to \"$absolute_path\"" 1>&2 @@ -884,13 +884,13 @@ function cpvirtualenv { # so its a virtualenv we are importing # make sure we have a full path # and get the name - src=$(virtualenvwrapper_expandpath "$src_name") + src="$(virtualenvwrapper_expandpath "$src_name")" # final verification if [ ! -e "$src" ]; then echo "Please provide a valid virtualenv to copy." return 1 fi - src_name=$(basename "$src") + src_name="$(basename "$src")" else src="$WORKON_HOME/$src_name" fi @@ -904,7 +904,7 @@ function cpvirtualenv { else trg="$WORKON_HOME/$trg_name" fi - trg=$(virtualenvwrapper_expandpath "$trg") + trg="$(virtualenvwrapper_expandpath "$trg")" # validate trg does not already exist # catch copying virtualenv in workon home @@ -1075,7 +1075,7 @@ function cdproject { virtualenvwrapper_verify_active_environment || return 1 if [ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" ] then - typeset project_dir=$(cat "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME") + typeset project_dir="$(cat "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME")" if [ ! -z "$project_dir" ] then cd "$project_dir" From 5e2f3ae084ed7bf31e8e822f69374467d971ce39 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 5 May 2013 14:55:00 -0400 Subject: [PATCH 650/947] remove trailing whitespace in tox.ini --- tox.ini | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tox.ini b/tox.ini index b2f9710..2972049 100644 --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,7 @@ deps = flake8 commands = flake8 virtualenvwrapper docs/source/conf.py [testenv:py27] -setenv = +setenv = SHELL = /bin/bash commands = bash ./tests/run_tests {envdir} [] @@ -27,28 +27,28 @@ commands = bash ./tests/run_tests {envdir} [] # [testenv:py26] basepython=python2.6 -setenv = +setenv = SHELL = /bin/bash commands = bash ./tests/run_tests {envdir} [] [testenv:py32] -setenv = +setenv = SHELL = /bin/bash commands = bash ./tests/run_tests {envdir} [] [testenv:py33] -setenv = +setenv = SHELL = /bin/bash commands = bash ./tests/run_tests {envdir} [] [testenv:zsh] basepython=python2.7 -setenv = +setenv = SHELL = /bin/zsh commands = zsh -o shwordsplit ./tests/run_tests {envdir} [] [testenv:ksh] basepython=python2.7 -setenv = +setenv = SHELL = /bin/ksh commands = ksh ./tests/run_tests {envdir} [] From 4af182fb30d2a7ae854efcb28f51754eeefc1fa4 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 May 2013 08:47:32 -0400 Subject: [PATCH 651/947] Update ignore file Move the old .hgignore to .gitignore after repository migration. Signed-off-by: Doug Hellmann --- .hgignore => .gitignore | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .hgignore => .gitignore (100%) diff --git a/.hgignore b/.gitignore similarity index 100% rename from .hgignore rename to .gitignore From bb513515101b99d6ee49b24939fce9a92918737a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 May 2013 08:50:39 -0400 Subject: [PATCH 652/947] Add wipeenv command Add the wipeenv command. Signed-off-by: Doug Hellmann --- docs/source/command_ref.rst | 15 ++++++++++++ docs/source/history.rst | 2 ++ tests/test_wipeenv.sh | 48 +++++++++++++++++++++++++++++++++++++ virtualenvwrapper.sh | 20 ++++++++++++++++ 4 files changed, 85 insertions(+) create mode 100755 tests/test_wipeenv.sh diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 9e34737..85e3c48 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -547,3 +547,18 @@ Syntax:: cdproject +=========================== +Managing Installed Packages +=========================== + +.. _command-wipeenv: + +wipeenv +------- + +Remove all of the installed third-party packages in the current +virtualenv. + +Syntax:: + + wipeenv diff --git a/docs/source/history.rst b/docs/source/history.rst index 6aa2c4e..9548857 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -7,6 +7,8 @@ dev - Ensure that all $() style commands that produce paths are quoted. Addresses :bbissue:`164`. +- Add :ref:`command-wipeenv` command for removing all packages + installed in the virtualenv. 4.0 === diff --git a/tests/test_wipeenv.sh b/tests/test_wipeenv.sh new file mode 100755 index 0000000..3ebc723 --- /dev/null +++ b/tests/test_wipeenv.sh @@ -0,0 +1,48 @@ +# -*- mode: shell-script -*- + +test_dir=$(cd $(dirname $0) && pwd) +source "$test_dir/setup.sh" + +setUp () { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" + rm -f "$test_dir/catch_output" + echo +} + +tearDown() { + if type deactivate >/dev/null 2>&1 + then + deactivate + fi + rm -rf "$WORKON_HOME" +} + +test_wipeenv () { + mkvirtualenv "wipetest" >/dev/null 2>&1 + (cd tests/testpackage && python setup.py install) >/dev/null 2>&1 + before="$(pip freeze)" + assertTrue "testpackage not installed" "pip freeze | grep testpackage" + wipeenv >/dev/null 2>&1 + after="$(pip freeze)" + assertFalse "testpackage still installed" "pip freeze | grep testpackage" +} + +test_empty_env () { + mkvirtualenv "wipetest" >/dev/null 2>&1 + before="$(pip freeze)" + assertFalse "testpackage still installed" "pip freeze | grep testpackage" + wipeenv >/dev/null 2>&1 + after="$(pip freeze)" + assertFalse "testpackage still installed" "pip freeze | grep testpackage" +} + +test_not_active_env () { + mkvirtualenv "wipetest" >/dev/null 2>&1 + deactivate + assertFalse "wipenv did not report an error" "wipeenv >/dev/null 2>&1" +} + +. "$test_dir/shunit2" + diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 6e6710b..3da73ee 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -1131,6 +1131,26 @@ fi EOF } +# +# Remove all installed packages from the env +# +function wipeenv { + virtualenvwrapper_verify_workon_home || return 1 + virtualenvwrapper_verify_active_environment || return 1 + + typeset req_file="$(virtualenvwrapper_tempfile "requirements.txt")" + pip freeze | egrep -v '(distribute|wsgiref)' > "$req_file" + if [ -n "$(cat "$req_file")" ] + then + echo "Uninstalling packages:" + cat "$req_file" + echo + pip uninstall -y $(cat "$req_file" | sed 's/>/=/g' | cut -f1 -d=) + else + echo "Nothing to remove." + fi + rm -f "$req_file" +} # # Invoke the initialization functions From 533f415f06d67b74a847925a8a77761889449fd6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 18 May 2013 13:38:49 -0400 Subject: [PATCH 653/947] Provide a way to extend the lazy-loader Allow _VIRTUALENVWRAPPER_API to be extended before the lazy-loader defines the API functions that trigger the full loader. Patch contributed by John Purnell. Resolves issue #188. Signed-off-by: Doug Hellmann --- docs/source/history.rst | 4 ++++ tests/test_lazy_extending.sh | 40 ++++++++++++++++++++++++++++++++++++ virtualenvwrapper_lazy.sh | 2 +- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100755 tests/test_lazy_extending.sh diff --git a/docs/source/history.rst b/docs/source/history.rst index 9548857..0254a6e 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -9,6 +9,10 @@ dev quoted. Addresses :bbissue:`164`. - Add :ref:`command-wipeenv` command for removing all packages installed in the virtualenv. +- Allow users of ``virtualenvwrapper_lazy.sh`` to extend the list of + API commands that trigger the lazy-loader by extending + ``_VIRTUALENVWRAPPER_API``. Patch contributed by John Purnell, see + :bbissue:`188`. 4.0 === diff --git a/tests/test_lazy_extending.sh b/tests/test_lazy_extending.sh new file mode 100755 index 0000000..9320bf4 --- /dev/null +++ b/tests/test_lazy_extending.sh @@ -0,0 +1,40 @@ +# -*- mode: shell-script -*- + +test_dir=$(cd $(dirname $0) && pwd) +source "$test_dir/setup.sh" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + [ ! -z "$ZSH_VERSION" ] && unsetopt shwordsplit +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +function_defined_lazy() { + name="$1" + assertTrue "$name not defined" "type $name" + assertTrue "$name does not load virtualenvwrapper" "typeset -f $name | grep 'virtualenvwrapper_load'" + if [ "$name" = "mkvirtualenv" ] + then + lookfor="rmvirtualenv" + else + lookfor="mkvirtualenv" + fi + assertFalse "$name includes reference to $lookfor: $(typeset -f $name)" "typeset -f $name | grep $lookfor" +} + +test_custom_defined_lazy() { + _VIRTUALENVWRAPPER_API="my_custom_command" + source "$test_dir/../virtualenvwrapper_lazy.sh" + function_defined_lazy my_custom_command +} + +. "$test_dir/shunit2" diff --git a/virtualenvwrapper_lazy.sh b/virtualenvwrapper_lazy.sh index 68ff67c..4f859ca 100644 --- a/virtualenvwrapper_lazy.sh +++ b/virtualenvwrapper_lazy.sh @@ -1,7 +1,7 @@ #!/bin/sh # Alternative startup script for faster login times. -export _VIRTUALENVWRAPPER_API="mkvirtualenv rmvirtualenv lsvirtualenv showvirtualenv workon add2virtualenv cdsitepackages cdvirtualenv lssitepackages toggleglobalsitepackages cpvirtualenv setvirtualenvproject mkproject cdproject mktmpenv" +export _VIRTUALENVWRAPPER_API="$_VIRTUALENVWRAPPER_API mkvirtualenv rmvirtualenv lsvirtualenv showvirtualenv workon add2virtualenv cdsitepackages cdvirtualenv lssitepackages toggleglobalsitepackages cpvirtualenv setvirtualenvproject mkproject cdproject mktmpenv" if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ] then From e79f55650da3d5308b8a1bed17177adaf7db670c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 18 May 2013 15:06:28 -0400 Subject: [PATCH 654/947] ignore emacs TAGS file Signed-off-by: Doug Hellmann --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7f154f2..747ea91 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ virtualenvwrapper.egg-info virtualenvwrapper/docs .tox *.orig +TAGS syntax: re .DS_Store From ba2c4ea6375972f052de1554b59b091a1168bd32 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 18 May 2013 15:07:43 -0400 Subject: [PATCH 655/947] add test for mkvirtualenv w/ site-packages Ensure that if the --system-site-packages option is passed properly, the new virtualenv is activated. Fixes issue #189 Signed-off-by: Doug Hellmann --- tests/test_mkvirtualenv.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index c9f0087..f64c496 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -51,7 +51,7 @@ GLOBAL postmkvirtualenv" rm -f "$WORKON_HOME/premkvirtualenv" rm -f "$WORKON_HOME/postmkvirtualenv" deactivate - rmvirtualenv "env3" + rmvirtualenv "env3" >/dev/null 2>&1 } test_no_virtualenv () { @@ -108,6 +108,28 @@ test_mkvirtualenv_sitepackages () { rmvirtualenv "env4" } +test_mkvirtualenv_hooks_system_site_packages () { + # See issue #189 + + export pre_test_dir=$(cd "$test_dir"; pwd) + + echo "#!/bin/sh" > "$WORKON_HOME/premkvirtualenv" + echo "echo GLOBAL premkvirtualenv \`pwd\` \"\$@\" >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" + chmod +x "$WORKON_HOME/premkvirtualenv" + + echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" + mkvirtualenv --system-site-packages "env189" >/dev/null 2>&1 + output=$(cat "$test_dir/catch_output") + workon_home_as_pwd=$(cd $WORKON_HOME; pwd) + expected="GLOBAL premkvirtualenv $workon_home_as_pwd env189 +GLOBAL postmkvirtualenv" + assertSame "$expected" "$output" + rm -f "$WORKON_HOME/premkvirtualenv" + rm -f "$WORKON_HOME/postmkvirtualenv" + deactivate + rmvirtualenv "env189" >/dev/null 2>&1 +} + test_mkvirtualenv_args () { # See issue #102 VIRTUALENVWRAPPER_VIRTUALENV_ARGS="--no-site-packages" From f9bc8f59f4c294bb98ee5250f4e8db19b66817aa Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 18 May 2013 19:32:43 -0400 Subject: [PATCH 656/947] quiet tests Signed-off-by: Doug Hellmann --- tests/test_mkvirtualenv.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index f64c496..2354e63 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -105,7 +105,7 @@ test_mkvirtualenv_sitepackages () { mkvirtualenv --no-site-packages "without_sp" >/dev/null 2>&1 ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" assertTrue "$ngsp_file does not exist" "[ -f \"$ngsp_file\" ]" - rmvirtualenv "env4" + rmvirtualenv "env4" >/dev/null 2>&1 } test_mkvirtualenv_hooks_system_site_packages () { @@ -137,7 +137,7 @@ test_mkvirtualenv_args () { mkvirtualenv "without_sp2" >/dev/null 2>&1 ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" assertTrue "$ngsp_file does not exist" "[ -f \"$ngsp_file\" ]" - rmvirtualenv "env4" + rmvirtualenv "env4" >/dev/null 2>&1 unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS } From c91167dceebcf051e9630331e790cef5683f612d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 19 May 2013 14:14:31 -0400 Subject: [PATCH 657/947] Ensure that -p and --python options are consistent The option parsing in mkvirtualenv was not handling the long-form of --python with the value attached to the same argument using = (it only worked if the option and value were separate command line arguments). Addresses issue #190. Signed-off-by: Doug Hellmann --- docs/source/history.rst | 2 ++ tests/test_mkvirtualenv.sh | 24 ++++++++++++++++++++++++ virtualenvwrapper.sh | 11 ++++++++--- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index 0254a6e..2d532b7 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -13,6 +13,8 @@ dev API commands that trigger the lazy-loader by extending ``_VIRTUALENVWRAPPER_API``. Patch contributed by John Purnell, see :bbissue:`188`. +- Fix detection of ``--python`` option to + :ref:`command-mkvirtualenv`. Resolves :bbissue:`190`. 4.0 === diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index 2354e63..e471e9e 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -196,5 +196,29 @@ test_mkvirtualenv_python_not_sticky () { VIRTUALENVWRAPPER_VIRTUALENV=$_save } +test_mkvirtualenv_python_short_option () { + typeset _save=$VIRTUALENVWRAPPER_VIRTUALENV + VIRTUALENVWRAPPER_VIRTUALENV=echo + output="$(mkvirtualenv -p python foo)" + assertSame "--python=$(pwd)/python foo" "$output" + VIRTUALENVWRAPPER_VIRTUALENV=$_save +} + +test_mkvirtualenv_python_long_option () { + typeset _save=$VIRTUALENVWRAPPER_VIRTUALENV + VIRTUALENVWRAPPER_VIRTUALENV=echo + output="$(mkvirtualenv --python python foo)" + assertSame "--python=$(pwd)/python foo" "$output" + VIRTUALENVWRAPPER_VIRTUALENV=$_save +} + +test_mkvirtualenv_python_long_option_equal () { + typeset _save=$VIRTUALENVWRAPPER_VIRTUALENV + VIRTUALENVWRAPPER_VIRTUALENV=echo + output="$(mkvirtualenv --python=python foo)" + assertSame "--python=$(pwd)/python foo" "$output" + VIRTUALENVWRAPPER_VIRTUALENV=$_save +} + . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 3da73ee..fa2c91c 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -408,9 +408,14 @@ function mkvirtualenv { -i) i=$(( $i + 1 )); packages="$packages ${in_args[$i]}";; - -p|--python) - i=$(( $i + 1 )); - interpreter="${in_args[$i]}"; + -p|--python*) + if echo "$a" | grep -q "=" + then + interpreter="$(echo "$a" | cut -f2 -d=)" + else + i=$(( $i + 1 )) + interpreter="${in_args[$i]}" + fi; interpreter="$(virtualenvwrapper_absolutepath "$interpreter")";; -r) i=$(( $i + 1 )); From e96ed1a4fddc4da9c744605ca104cbec1c63d409 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 19 May 2013 14:43:22 -0400 Subject: [PATCH 658/947] Add allvirtualenv command Add a new command to run a command across all of the managed virtualenvs. Resolves issue #186. Signed-off-by: Doug Hellmann --- docs/source/command_ref.rst | 21 +++++++++++++++++++++ docs/source/history.rst | 2 ++ tests/test_allvirtualenv.sh | 34 ++++++++++++++++++++++++++++++++++ virtualenvwrapper.sh | 31 ++++++++++++++++++++++++++----- 4 files changed, 83 insertions(+), 5 deletions(-) create mode 100755 tests/test_allvirtualenv.sh diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 85e3c48..f175aab 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -204,6 +204,27 @@ Syntax:: * :ref:`scripts-premkvirtualenv` * :ref:`scripts-postmkvirtualenv` +.. _command-allvirtualenv: + +allvirtualenv +------------- + +Run a command in all virtualenvs under WORKON_HOME. + +Syntax:: + + allenvs command with arguments + +Each virtualenv is activated, bypassing activation hooks, the current +working directory is changed to the current virtualenv, and then the +command is run. Commands cannot modify the current shell state, but +can modify the virtualenv. + +:: + + $ allenvs pip install -U pip + + ================================== Controlling the Active Environment ================================== diff --git a/docs/source/history.rst b/docs/source/history.rst index 2d532b7..7fc394d 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -15,6 +15,8 @@ dev :bbissue:`188`. - Fix detection of ``--python`` option to :ref:`command-mkvirtualenv`. Resolves :bbissue:`190`. +- Add :ref:`command-allvirtualenv` command to run a command across all + virtualenvs. Suggested by Dave Coutts in :bbissue:`186`. 4.0 === diff --git a/tests/test_allvirtualenv.sh b/tests/test_allvirtualenv.sh new file mode 100755 index 0000000..06666f1 --- /dev/null +++ b/tests/test_allvirtualenv.sh @@ -0,0 +1,34 @@ +# -*- mode: shell-script -*- + +test_dir=$(cd $(dirname $0) && pwd) +source "$test_dir/setup.sh" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + unset VIRTUAL_ENV + source "$test_dir/../virtualenvwrapper.sh" + mkvirtualenv test1 >/dev/null 2>&1 + mkvirtualenv test2 >/dev/null 2>&1 + deactivate +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +tearDown () { + deactivate >/dev/null 2>&1 +} + +test_allvirtualenv_all() { + assertTrue "Did not find test1" "allvirtualenv pwd | grep -q 'test1$'" + assertTrue "Did not find test2" "allvirtualenv pwd | grep -q 'test2$'" +} + +. "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index fa2c91c..80707e1 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -592,10 +592,11 @@ function lsvirtualenv { if $long_mode then - for env_name in $(virtualenvwrapper_show_workon_options) - do - showvirtualenv "$env_name" - done + allenvs showvirtualenv "$env_name" + # for env_name in $(virtualenvwrapper_show_workon_options) + # do + + # done else virtualenvwrapper_show_workon_options fi @@ -616,7 +617,6 @@ function showvirtualenv { env_name=$(basename "$VIRTUAL_ENV") fi - echo -n "$env_name" virtualenvwrapper_run_hook "get_env_details" "$env_name" echo } @@ -1157,6 +1157,27 @@ function wipeenv { rm -f "$req_file" } +# +# Run a command in each virtualenv +# +function allvirtualenv { + virtualenvwrapper_verify_workon_home || return 1 + typeset d + + virtualenvwrapper_show_workon_options | while read d + do + [ ! -d "$WORKON_HOME/$d" ] && continue + echo "$d" + echo "$d" | sed 's/./=/g' + # Activate the environment, but not with workon + # because we don't want to trigger any hooks. + (source "$WORKON_HOME/$d/bin/activate"; + cd "$VIRTUAL_ENV"; + $@) + echo + done +} + # # Invoke the initialization functions # From 19513410498d40bf8db996e8c1f37f2e7db7e283 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 19 May 2013 15:31:52 -0400 Subject: [PATCH 659/947] Fix problem lsvirtualenv after previous commit lsvirtualenv was reimplemented to use allvirtualenv, but using a temporary name that function had in development. Fix it to use the right name. Signed-off-by: Doug Hellmann --- virtualenvwrapper.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 80707e1..51f0c9b 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -592,11 +592,7 @@ function lsvirtualenv { if $long_mode then - allenvs showvirtualenv "$env_name" - # for env_name in $(virtualenvwrapper_show_workon_options) - # do - - # done + allvirtualenv showvirtualenv "$env_name" else virtualenvwrapper_show_workon_options fi From 3b1b3a2d32f0b56739e5a5c6f73b0fdd959c1180 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 19 May 2013 15:34:32 -0400 Subject: [PATCH 660/947] add license file Signed-off-by: Doug Hellmann --- LICENSE | 17 +++++++++++++++++ MANIFEST.in | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c0dfc2e --- /dev/null +++ b/LICENSE @@ -0,0 +1,17 @@ +Copyright Doug Hellmann, All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Doug Hellmann not be used +in advertising or publicity pertaining to distribution of the software +without specific, written prior permission. + +DOUG HELLMANN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL DOUG HELLMANN BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/MANIFEST.in b/MANIFEST.in index 06238d2..e1482b1 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -8,4 +8,4 @@ include tests/testtemplate/setup.py include tests/testtemplate/mytemplates/*.py recursive-include docs *.rst *.py *.html *.css *.js *.png *.txt include tox.ini - +include LICENSE From 8d0e1e6189cab62fc1bd6f864466283f7b02699e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 17 Jul 2013 09:06:26 -0400 Subject: [PATCH 661/947] Fix virtualenv detection with spaces in WORKON_HOME Fixes issue #194 Change-Id: I9021fbecd15f0626b948c810a3fb2dcf8e800802 Signed-off-by: Doug Hellmann --- docs/source/history.rst | 4 +++- tests/test_lsvirtualenv.sh | 42 ++++++++++++++++++++++++++++++++++++++ virtualenvwrapper.sh | 3 +-- 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100755 tests/test_lsvirtualenv.sh diff --git a/docs/source/history.rst b/docs/source/history.rst index 7fc394d..3e8a5a3 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -5,7 +5,7 @@ Release History dev === -- Ensure that all $() style commands that produce paths are +- Ensure that all ``$()`` style commands that produce paths are quoted. Addresses :bbissue:`164`. - Add :ref:`command-wipeenv` command for removing all packages installed in the virtualenv. @@ -17,6 +17,8 @@ dev :ref:`command-mkvirtualenv`. Resolves :bbissue:`190`. - Add :ref:`command-allvirtualenv` command to run a command across all virtualenvs. Suggested by Dave Coutts in :bbissue:`186`. +- Fix :ref:`command-lsvirtualenv` when there are spaces in + ``WORKON_HOME``. Resolves :bbissue:`194`. 4.0 === diff --git a/tests/test_lsvirtualenv.sh b/tests/test_lsvirtualenv.sh new file mode 100755 index 0000000..201f039 --- /dev/null +++ b/tests/test_lsvirtualenv.sh @@ -0,0 +1,42 @@ +# -*- mode: shell-script -*- + +test_dir=$(cd $(dirname $0) && pwd) +source "$test_dir/setup.sh" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + source "$test_dir/../virtualenvwrapper.sh" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + rm -f "$test_dir/catch_output" +} + +test_no_workon_home () { + old_home="$WORKON_HOME" + export WORKON_HOME="$WORKON_HOME/not_there" + lsvirtualenv >"$old_home/output" 2>&1 + output=$(cat "$old_home/output") + assertTrue "Did not see expected message" "echo $output | grep 'does not exist'" + WORKON_HOME="$old_home" +} + +test_space_in_workon_home () { + old_home="$WORKON_HOME" + export WORKON_HOME="$WORKON_HOME/with space" + mkdir "$WORKON_HOME" + (cd "$WORKON_HOME"; virtualenv testenv) 2>&1 + lsvirtualenv -b >"$old_home/output" + output=$(cat "$old_home/output") + assertTrue "Did not see expected message in \"$output\"" "echo $output | grep 'testenv'" + WORKON_HOME="$old_home" +} + + +. "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 51f0c9b..b38c5c2 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -534,8 +534,7 @@ function virtualenvwrapper_show_workon_options { # 4. Format the output to show one name on a line. # 5. Eliminate any lines with * on them because that means there # were no envs. - (echo $WORKON_HOME/*/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate) 2>/dev/null \ - | command \sed "s|$WORKON_HOME/||g" \ + (cd "$WORKON_HOME" && echo */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate) 2>/dev/null \ | command \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate||g" \ | command \fmt -w 1 \ | (unset GREP_OPTIONS; command \egrep -v '^\*$') 2>/dev/null From 63fac444fe9a4cf53ea835224fd04385cbbe7245 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 20 Jul 2013 16:29:37 -0400 Subject: [PATCH 662/947] Allow tests to run in parallel Update the test implementations so the different test environments can be run in parallel under detox. Change-Id: Ia4a017e32d231b066dd1ae6027c6644bb4e1d611 --- tests/run_tests | 2 ++ tests/setup.sh | 8 ++++--- tests/test.sh | 7 +++--- tests/test_add2virtualenv.sh | 1 - tests/test_allvirtualenv.sh | 1 - tests/test_cd.sh | 1 - tests/test_cp.sh | 14 +++++------- tests/test_cpvirtualenv.sh | 3 +-- tests/test_deactivate.sh | 10 ++++----- tests/test_derive_workon_home.sh | 1 - tests/test_hook_dir.sh | 1 - tests/test_lazy.sh | 1 - tests/test_lazy_extending.sh | 1 - tests/test_lazy_loaded.sh | 6 ++--- tests/test_lazy_run.sh | 1 - tests/test_ls.sh | 1 - tests/test_lsvirtualenv.sh | 1 - tests/test_mktmpenv.sh | 1 - tests/test_mkvirtualenv.sh | 30 +++++++++++-------------- tests/test_mkvirtualenv_associate.sh | 14 ++++++------ tests/test_mkvirtualenv_install.sh | 1 - tests/test_mkvirtualenv_requirements.sh | 1 - tests/test_project.sh | 1 - tests/test_project_activate.sh | 1 - tests/test_project_cd.sh | 1 - tests/test_project_mk.sh | 8 +++---- tests/test_project_templates.sh | 1 - tests/test_rmvirtualenv.sh | 1 - tests/test_run_hook.sh | 22 +++++++++--------- tests/test_support.sh | 1 - tests/test_tempfile.sh | 9 ++++---- tests/test_toggleglobalsitepackages.sh | 1 - tests/test_wipeenv.sh | 1 - tests/test_workon.sh | 12 +++++----- 34 files changed, 69 insertions(+), 97 deletions(-) diff --git a/tests/run_tests b/tests/run_tests index 4b6f7fa..5724cd6 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -1,3 +1,4 @@ +# -*- mode: shell-script -*- #set -x envdir="$1" @@ -59,6 +60,7 @@ do echo " KSH_VERSION=$KSH_VERSION" echo " virtualenv=$(which virtualenv)" echo " ZSH=$ZSH_NAME $ZSH_EVAL_CONTEXT" + echo " TMPDIR=$TMPDIR" echo SHUNIT_PARENT="$test_script" export SHUNIT_PARENT diff --git a/tests/setup.sh b/tests/setup.sh index 402f0d5..decab8f 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -2,9 +2,11 @@ #set -x -tmplocation=${TMPDIR:-/tmp} +# tmplocation=${TMPDIR:-/tmp} +# export WORKON_HOME="$(echo ${tmplocation}/WORKON_HOME.$$ | sed 's|//|/|g')" +# export PROJECT_HOME="$(echo ${tmplocation}/PROJECT_HOME.$$ | sed 's|//|/|g')" -export WORKON_HOME="$(echo ${tmplocation}/WORKON_HOME.$$ | sed 's|//|/|g')" -export PROJECT_HOME="$(echo ${tmplocation}/PROJECT_HOME.$$ | sed 's|//|/|g')" +export WORKON_HOME=$(mktemp -d -t "WORKON_HOME.$$") +export PROJECT_HOME=$(mktemp -d -t "PROJECT_HOME.$$") #unset HOOK_VERBOSE_OPTION diff --git a/tests/test.sh b/tests/test.sh index 16426e7..a37b11d 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -15,8 +15,8 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" unset VIRTUALENVWRAPPER_INITIALIZED + rm -f "$TMPDIR/catch_output" } test_virtualenvwrapper_initialize() { @@ -26,10 +26,9 @@ test_virtualenvwrapper_initialize() { assertTrue "Global $WORKON_HOME/$hook was not created" "[ -f $WORKON_HOME/$hook ]" assertTrue "Global $WORKON_HOME/$hook is not executable" "[ -x $WORKON_HOME/$hook ]" done - export pre_test_dir=$(cd "$test_dir"; pwd) - echo "echo GLOBAL initialize >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/initialize" + echo "echo GLOBAL initialize >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/initialize" virtualenvwrapper_initialize - output=$(cat "$test_dir/catch_output") + output=$(cat "$TMPDIR/catch_output") expected="GLOBAL initialize" assertSame "$expected" "$output" } diff --git a/tests/test_add2virtualenv.sh b/tests/test_add2virtualenv.sh index 28115e1..fedba20 100755 --- a/tests/test_add2virtualenv.sh +++ b/tests/test_add2virtualenv.sh @@ -15,7 +15,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" } test_add2virtualenv () { diff --git a/tests/test_allvirtualenv.sh b/tests/test_allvirtualenv.sh index 06666f1..4aab461 100755 --- a/tests/test_allvirtualenv.sh +++ b/tests/test_allvirtualenv.sh @@ -19,7 +19,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" } tearDown () { diff --git a/tests/test_cd.sh b/tests/test_cd.sh index 15dc4d7..15729e7 100755 --- a/tests/test_cd.sh +++ b/tests/test_cd.sh @@ -18,7 +18,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" workon cd-test } diff --git a/tests/test_cp.sh b/tests/test_cp.sh index 0015853..b64ac2c 100755 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -7,7 +7,7 @@ setUp () { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" source "$test_dir/../virtualenvwrapper.sh" - rm -f "$test_dir/catch_output" + rm -f "$TMPDIR/catch_output" echo } @@ -107,27 +107,25 @@ test_source_does_not_exist () { test_hooks () { mkvirtualenv "source" >/dev/null 2>&1 - export pre_test_dir=$(cd "$test_dir"; pwd) - # Set the interpreter of the hook script to the simple shell echo "#!/bin/sh" > "$WORKON_HOME/premkvirtualenv" - echo "echo GLOBAL premkvirtualenv \`pwd\` \"\$@\" >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" + echo "echo GLOBAL premkvirtualenv \`pwd\` \"\$@\" >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" chmod +x "$WORKON_HOME/premkvirtualenv" - echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" + echo "echo GLOBAL postmkvirtualenv >> $TMPDIR/catch_output" > "$WORKON_HOME/postmkvirtualenv" # Set the interpreter of the hook script to the simple shell echo "#!/bin/sh" > "$WORKON_HOME/precpvirtualenv" - echo "echo GLOBAL precpvirtualenv \`pwd\` \"\$@\" >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/precpvirtualenv" + echo "echo GLOBAL precpvirtualenv \`pwd\` \"\$@\" >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/precpvirtualenv" chmod +x "$WORKON_HOME/precpvirtualenv" # Set the interpreter of the hook script to the simple shell echo "#!/bin/sh" > "$WORKON_HOME/postcpvirtualenv" - echo "echo GLOBAL postcpvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postcpvirtualenv" + echo "echo GLOBAL postcpvirtualenv >> $TMPDIR/catch_output" > "$WORKON_HOME/postcpvirtualenv" cpvirtualenv "source" "destination" >/dev/null 2>&1 - output=$(cat "$test_dir/catch_output") + output=$(cat "$TMPDIR/catch_output") workon_home_as_pwd=$(cd $WORKON_HOME; pwd) expected="GLOBAL precpvirtualenv $workon_home_as_pwd $workon_home_as_pwd/source destination diff --git a/tests/test_cpvirtualenv.sh b/tests/test_cpvirtualenv.sh index 2a21b57..ad7803f 100755 --- a/tests/test_cpvirtualenv.sh +++ b/tests/test_cpvirtualenv.sh @@ -7,7 +7,6 @@ setUp () { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" source "$test_dir/../virtualenvwrapper.sh" - rm -f "$test_dir/catch_output" echo } @@ -202,7 +201,7 @@ test_clone_venv_using_vars () { assertTrue "Cloned virtualenv already exists" "[ ! -d $WORKON_HOME/cpvenv_test ]" $VIRTUALENVWRAPPER_VIRTUALENV "$TMPDIR/cpvenv_test" >/dev/null 2>&1 - touch "$tmplocation/cpvenv_test/mytestpackage" + touch "$TMPDIR/cpvenv_test/mytestpackage" assertTrue "Virtualenv to clone didn't get created" "[ -d $TMPDIR/cpvenv_test ]" assertTrue "Cloned virtualenv already exists" "[ ! -d $WORKON_HOME/cpvenv_test ]" diff --git a/tests/test_deactivate.sh b/tests/test_deactivate.sh index 10f05bd..a0afa11 100755 --- a/tests/test_deactivate.sh +++ b/tests/test_deactivate.sh @@ -16,7 +16,7 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" + rm -f "$TMPDIR/catch_output" } test_deactivate () { @@ -32,15 +32,15 @@ test_deactivate_hooks () { for t in pre post do - echo "echo GLOBAL ${t}deactivate \$VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV >> $test_dir/catch_output" > "$WORKON_HOME/${t}deactivate" - echo "echo ENV ${t}deactivate \$VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV >> $test_dir/catch_output" > "$WORKON_HOME/env1/bin/${t}deactivate" + echo "echo GLOBAL ${t}deactivate \$VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV >> $TMPDIR/catch_output" > "$WORKON_HOME/${t}deactivate" + echo "echo ENV ${t}deactivate \$VIRTUALENVWRAPPER_LAST_VIRTUAL_ENV >> $TMPDIR/catch_output" > "$WORKON_HOME/env1/bin/${t}deactivate" done - touch "$test_dir/catch_output" + touch "$TMPDIR/catch_output" deactivate - output=$(cat "$test_dir/catch_output") + output=$(cat "$TMPDIR/catch_output") expected="ENV predeactivate GLOBAL predeactivate ENV postdeactivate $WORKON_HOME/env1 diff --git a/tests/test_derive_workon_home.sh b/tests/test_derive_workon_home.sh index 7bed753..01b22ba 100755 --- a/tests/test_derive_workon_home.sh +++ b/tests/test_derive_workon_home.sh @@ -17,7 +17,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" WORKON_HOME="$TMP_WORKON_HOME" } diff --git a/tests/test_hook_dir.sh b/tests/test_hook_dir.sh index 2669348..33bdcb2 100755 --- a/tests/test_hook_dir.sh +++ b/tests/test_hook_dir.sh @@ -15,7 +15,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" rm -f "$WORKON_HOME/hooks/*" } diff --git a/tests/test_lazy.sh b/tests/test_lazy.sh index e81961c..e46370e 100755 --- a/tests/test_lazy.sh +++ b/tests/test_lazy.sh @@ -17,7 +17,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" } function_defined_lazy() { diff --git a/tests/test_lazy_extending.sh b/tests/test_lazy_extending.sh index 9320bf4..f3b3716 100755 --- a/tests/test_lazy_extending.sh +++ b/tests/test_lazy_extending.sh @@ -15,7 +15,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" } function_defined_lazy() { diff --git a/tests/test_lazy_loaded.sh b/tests/test_lazy_loaded.sh index d4bc20f..930c7b9 100755 --- a/tests/test_lazy_loaded.sh +++ b/tests/test_lazy_loaded.sh @@ -16,7 +16,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" } function_defined_normal() { @@ -98,10 +97,9 @@ test_mktmpenv_defined_normal() { # assertTrue "Global $WORKON_HOME/$hook is not executable" "[ -x $WORKON_HOME/$hook ]" # done # assertTrue "Log file was not created" "[ -f $WORKON_HOME/hook.log ]" -# export pre_test_dir=$(cd "$test_dir"; pwd) -# echo "echo GLOBAL initialize >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/initialize" +# echo "echo GLOBAL initialize >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/initialize" # virtualenvwrapper_initialize -# output=$(cat "$test_dir/catch_output") +# output=$(cat "$TMPDIR/catch_output") # expected="GLOBAL initialize" # assertSame "$expected" "$output" # } diff --git a/tests/test_lazy_run.sh b/tests/test_lazy_run.sh index da3f169..4c75f11 100755 --- a/tests/test_lazy_run.sh +++ b/tests/test_lazy_run.sh @@ -16,7 +16,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" } test_workon_changes_defs() { diff --git a/tests/test_ls.sh b/tests/test_ls.sh index 8c95392..25d8c78 100755 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -15,7 +15,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" } test_get_site_packages_dir () { diff --git a/tests/test_lsvirtualenv.sh b/tests/test_lsvirtualenv.sh index 201f039..ad93946 100755 --- a/tests/test_lsvirtualenv.sh +++ b/tests/test_lsvirtualenv.sh @@ -15,7 +15,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" } test_no_workon_home () { diff --git a/tests/test_mktmpenv.sh b/tests/test_mktmpenv.sh index 98b81d5..678b7cd 100755 --- a/tests/test_mktmpenv.sh +++ b/tests/test_mktmpenv.sh @@ -16,7 +16,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" } test_mktmpenv_no_name() { diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index e471e9e..c54cfd3 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -15,7 +15,7 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" + rm -f "$TMPDIR/catch_output" } test_create() { @@ -35,15 +35,13 @@ test_activates () { } test_hooks () { - export pre_test_dir=$(cd "$test_dir"; pwd) - echo "#!/bin/sh" > "$WORKON_HOME/premkvirtualenv" - echo "echo GLOBAL premkvirtualenv \`pwd\` \"\$@\" >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" + echo "echo GLOBAL premkvirtualenv \`pwd\` \"\$@\" >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" chmod +x "$WORKON_HOME/premkvirtualenv" - echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" + echo "echo GLOBAL postmkvirtualenv >> $TMPDIR/catch_output" > "$WORKON_HOME/postmkvirtualenv" mkvirtualenv "env3" >/dev/null 2>&1 - output=$(cat "$test_dir/catch_output") + output=$(cat "$TMPDIR/catch_output") workon_home_as_pwd=$(cd $WORKON_HOME; pwd) expected="GLOBAL premkvirtualenv $workon_home_as_pwd env3 GLOBAL postmkvirtualenv" @@ -111,15 +109,13 @@ test_mkvirtualenv_sitepackages () { test_mkvirtualenv_hooks_system_site_packages () { # See issue #189 - export pre_test_dir=$(cd "$test_dir"; pwd) - echo "#!/bin/sh" > "$WORKON_HOME/premkvirtualenv" - echo "echo GLOBAL premkvirtualenv \`pwd\` \"\$@\" >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" + echo "echo GLOBAL premkvirtualenv \`pwd\` \"\$@\" >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" chmod +x "$WORKON_HOME/premkvirtualenv" - echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" + echo "echo GLOBAL postmkvirtualenv >> $TMPDIR/catch_output" > "$WORKON_HOME/postmkvirtualenv" mkvirtualenv --system-site-packages "env189" >/dev/null 2>&1 - output=$(cat "$test_dir/catch_output") + output=$(cat "$TMPDIR/catch_output") workon_home_as_pwd=$(cd $WORKON_HOME; pwd) expected="GLOBAL premkvirtualenv $workon_home_as_pwd env189 GLOBAL postmkvirtualenv" @@ -145,12 +141,12 @@ test_no_such_virtualenv () { VIRTUALENVWRAPPER_VIRTUALENV=/path/to/missing/program echo "#!/bin/sh" > "$WORKON_HOME/premkvirtualenv" - echo "echo GLOBAL premkvirtualenv \`pwd\` \"\$@\" >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" + echo "echo GLOBAL premkvirtualenv \`pwd\` \"\$@\" >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" chmod +x "$WORKON_HOME/premkvirtualenv" - echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" + echo "echo GLOBAL postmkvirtualenv >> $TMPDIR/catch_output" > "$WORKON_HOME/postmkvirtualenv" mkvirtualenv "env3" >/dev/null 2>&1 - output=$(cat "$test_dir/catch_output" 2>/dev/null) + output=$(cat "$TMPDIR/catch_output" 2>/dev/null) workon_home_as_pwd=$(cd $WORKON_HOME; pwd) expected="" assertSame "$expected" "$output" @@ -173,12 +169,12 @@ test_virtualenv_fails () { VIRTUALENVWRAPPER_VIRTUALENV=false echo "#!/bin/sh" > "$WORKON_HOME/premkvirtualenv" - echo "echo GLOBAL premkvirtualenv \`pwd\` \"\$@\" >> \"$pre_test_dir/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" + echo "echo GLOBAL premkvirtualenv \`pwd\` \"\$@\" >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/premkvirtualenv" chmod +x "$WORKON_HOME/premkvirtualenv" - echo "echo GLOBAL postmkvirtualenv >> $test_dir/catch_output" > "$WORKON_HOME/postmkvirtualenv" + echo "echo GLOBAL postmkvirtualenv >> $TMPDIR/catch_output" > "$WORKON_HOME/postmkvirtualenv" mkvirtualenv "env3" >/dev/null 2>&1 - output=$(cat "$test_dir/catch_output" 2>/dev/null) + output=$(cat "$TMPDIR/catch_output" 2>/dev/null) workon_home_as_pwd=$(cd $WORKON_HOME; pwd) expected="" assertSame "$expected" "$output" diff --git a/tests/test_mkvirtualenv_associate.sh b/tests/test_mkvirtualenv_associate.sh index 2fe28c0..dc005a7 100755 --- a/tests/test_mkvirtualenv_associate.sh +++ b/tests/test_mkvirtualenv_associate.sh @@ -16,9 +16,9 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" echo "#!/bin/sh" > "$WORKON_HOME/preactivate" echo "#!/bin/sh" > "$WORKON_HOME/postactivate" + rm -f "$TMPDIR/catch_output" } test_associate() { @@ -38,14 +38,14 @@ test_preactivate() { #!/bin/sh if [ -f "$ptrfile" ] then - echo exists >> "$test_dir/catch_output" + echo exists >> "$TMPDIR/catch_output" else - echo noexists >> "$test_dir/catch_output" + echo noexists >> "$TMPDIR/catch_output" fi EOF chmod +x "$WORKON_HOME/preactivate" mkvirtualenv -a "$project" "$env" >/dev/null 2>&1 - assertSame "preactivate did not find file" "exists" "$(cat $test_dir/catch_output)" + assertSame "preactivate did not find file" "exists" "$(cat $TMPDIR/catch_output)" } test_postactivate() { @@ -56,14 +56,14 @@ cat - >"$WORKON_HOME/postactivate" <> "$test_dir/catch_output" + echo exists >> "$TMPDIR/catch_output" else - echo noexists >> "$test_dir/catch_output" + echo noexists >> "$TMPDIR/catch_output" fi EOF chmod +x "$WORKON_HOME/postactivate" mkvirtualenv -a "$project" "$env" >/dev/null 2>&1 - assertSame "postactivate did not find file" "exists" "$(cat $test_dir/catch_output)" + assertSame "postactivate did not find file" "exists" "$(cat $TMPDIR/catch_output)" } . "$test_dir/shunit2" diff --git a/tests/test_mkvirtualenv_install.sh b/tests/test_mkvirtualenv_install.sh index 9915a1d..4cebd28 100755 --- a/tests/test_mkvirtualenv_install.sh +++ b/tests/test_mkvirtualenv_install.sh @@ -16,7 +16,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" } test_single_package () { diff --git a/tests/test_mkvirtualenv_requirements.sh b/tests/test_mkvirtualenv_requirements.sh index bf5bcf9..015d933 100755 --- a/tests/test_mkvirtualenv_requirements.sh +++ b/tests/test_mkvirtualenv_requirements.sh @@ -16,7 +16,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" } test_requirements_file () { diff --git a/tests/test_project.sh b/tests/test_project.sh index 9f7ce5f..256ed16 100755 --- a/tests/test_project.sh +++ b/tests/test_project.sh @@ -17,7 +17,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" unset VIRTUALENVWRAPPER_INITIALIZED } diff --git a/tests/test_project_activate.sh b/tests/test_project_activate.sh index 93bb9e9..0e832d7 100755 --- a/tests/test_project_activate.sh +++ b/tests/test_project_activate.sh @@ -18,7 +18,6 @@ oneTimeSetUp() { setUp () { echo - rm -f "$TMPDIR/catch_output" } test_activate () { diff --git a/tests/test_project_cd.sh b/tests/test_project_cd.sh index f4cc879..a6849c3 100755 --- a/tests/test_project_cd.sh +++ b/tests/test_project_cd.sh @@ -18,7 +18,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$TMPDIR/catch_output" } test_with_project () { diff --git a/tests/test_project_mk.sh b/tests/test_project_mk.sh index bd3d178..96f823d 100755 --- a/tests/test_project_mk.sh +++ b/tests/test_project_mk.sh @@ -18,7 +18,7 @@ oneTimeTearDown() { setUp () { echo - rm -f "$WORKON_HOME/catch_output" + rm -f "$TMPDIR/catch_output" } tearDown () { @@ -38,13 +38,13 @@ test_create_virtualenv () { } test_hooks () { - echo "echo GLOBAL premkproject \`pwd\` \"\$@\" >> \"$WORKON_HOME/catch_output\"" >> "$VIRTUALENVWRAPPER_HOOK_DIR/premkproject" + echo "echo GLOBAL premkproject \`pwd\` \"\$@\" >> \"$TMPDIR/catch_output\"" >> "$VIRTUALENVWRAPPER_HOOK_DIR/premkproject" chmod +x "$VIRTUALENVWRAPPER_HOOK_DIR/premkproject" - echo "echo GLOBAL postmkproject \`pwd\` >> $WORKON_HOME/catch_output" > "$VIRTUALENVWRAPPER_HOOK_DIR/postmkproject" + echo "echo GLOBAL postmkproject \`pwd\` >> $TMPDIR/catch_output" > "$VIRTUALENVWRAPPER_HOOK_DIR/postmkproject" mkproject myproject3 >/dev/null 2>&1 - output=$(cat "$WORKON_HOME/catch_output") + output=$(cat "$TMPDIR/catch_output") expected="GLOBAL premkproject $WORKON_HOME myproject3 GLOBAL postmkproject $PROJECT_HOME/myproject3" diff --git a/tests/test_project_templates.sh b/tests/test_project_templates.sh index 18194ac..f75b777 100755 --- a/tests/test_project_templates.sh +++ b/tests/test_project_templates.sh @@ -19,7 +19,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$TMPDIR/catch_output" } test_list_templates () { diff --git a/tests/test_rmvirtualenv.sh b/tests/test_rmvirtualenv.sh index 9aa903a..3f730ba 100755 --- a/tests/test_rmvirtualenv.sh +++ b/tests/test_rmvirtualenv.sh @@ -15,7 +15,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" } test_remove () { diff --git a/tests/test_run_hook.sh b/tests/test_run_hook.sh index 5790fa3..2d6983d 100755 --- a/tests/test_run_hook.sh +++ b/tests/test_run_hook.sh @@ -15,50 +15,50 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" rm -f "$WORKON_HOME/initialize" rm -f "$WORKON_HOME/prermvirtualenv" + rm -f "$TMPDIR/catch_output" } test_virtualenvwrapper_run_hook() { - echo "echo run >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/initialize" + echo "echo run >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/initialize" chmod +x "$WORKON_HOME/initialize" virtualenvwrapper_run_hook "initialize" - output=$(cat "$test_dir/catch_output") + output=$(cat "$TMPDIR/catch_output") expected="run" assertSame "$expected" "$output" } test_virtualenvwrapper_run_hook_alternate_dir() { mkdir "$WORKON_HOME/hooks" - echo "echo WORKON_HOME >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/initialize" - echo "echo WORKON_HOME/hooks >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/hooks/initialize" + echo "echo WORKON_HOME >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/initialize" + echo "echo WORKON_HOME/hooks >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/hooks/initialize" chmod +x "$WORKON_HOME/initialize" chmod +x "$WORKON_HOME/hooks/initialize" VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME/hooks" virtualenvwrapper_run_hook "initialize" - output=$(cat "$test_dir/catch_output") + output=$(cat "$TMPDIR/catch_output") expected="WORKON_HOME/hooks" assertSame "$expected" "$output" VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME" } test_virtualenvwrapper_source_hook_permissions() { - echo "echo run >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/initialize" + echo "echo run >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/initialize" chmod -x "$WORKON_HOME/initialize" virtualenvwrapper_run_hook "initialize" - output=$(cat "$test_dir/catch_output") + output=$(cat "$TMPDIR/catch_output") expected="run" assertSame "$expected" "$output" } test_virtualenvwrapper_run_hook_permissions() { echo "#!/bin/sh" > "$WORKON_HOME/prermvirtualenv" - echo "echo run $@ >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/prermvirtualenv" + echo "echo run $@ >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/prermvirtualenv" chmod 0444 "$WORKON_HOME/prermvirtualenv" - touch "$test_dir/catch_output" + touch "$TMPDIR/catch_output" error=$(virtualenvwrapper_run_hook "pre_rmvirtualenv" "foo" 2>&1 | grep "could not run" | cut -f2- -d'[') - output=$(cat "$test_dir/catch_output") + output=$(cat "$TMPDIR/catch_output") expected="" assertSame "$expected" "$output" assertSame "Errno 13] Permission denied" "$error" diff --git a/tests/test_support.sh b/tests/test_support.sh index 65aaf8c..20552d7 100755 --- a/tests/test_support.sh +++ b/tests/test_support.sh @@ -15,7 +15,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" } test_get_python_version () { diff --git a/tests/test_tempfile.sh b/tests/test_tempfile.sh index e7a26c8..9fb6b79 100755 --- a/tests/test_tempfile.sh +++ b/tests/test_tempfile.sh @@ -18,7 +18,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" } test_tempfile () { @@ -26,9 +25,9 @@ test_tempfile () { assertTrue "Filename is empty" "[ ! -z \"$filename\" ]" assertTrue "File doesn't exist" "[ -f \"$filename\" ]" rm -f $filename - comparable_tmpdir=$(echo $tmplocation | sed 's|/$||') + comparable_tmpdir=$(echo $TMPDIR | sed 's|/$||') comparable_dirname=$(dirname $filename | sed 's|/$||') - assertSame "Temporary directory \"$tmplocation\" and path not the same for $filename" "$comparable_tmpdir" "$comparable_dirname" + assertSame "Temporary directory \"$TMPDIR\" and path not the same for $filename" "$comparable_tmpdir" "$comparable_dirname" assertTrue "virtualenvwrapper-hook not in filename." "echo $filename | grep virtualenvwrapper-hook" } @@ -54,7 +53,7 @@ test_bad_mktemp() { test_no_such_tmpdir () { old_tmpdir="$TMPDIR" - export TMPDIR="$tmplocation/does-not-exist" + export TMPDIR="$TMPDIR/does-not-exist" virtualenvwrapper_run_hook "initialize" >/dev/null 2>&1 RC=$? assertSame "Unexpected exit code $RC" "1" "$RC" @@ -63,7 +62,7 @@ test_no_such_tmpdir () { test_tmpdir_not_writable () { old_tmpdir="$TMPDIR" - export TMPDIR="$tmplocation/cannot-write" + export TMPDIR="$TMPDIR/cannot-write" mkdir "$TMPDIR" chmod ugo-w "$TMPDIR" virtualenvwrapper_run_hook "initialize" >/dev/null 2>&1 diff --git a/tests/test_toggleglobalsitepackages.sh b/tests/test_toggleglobalsitepackages.sh index 00434d5..c1d3d82 100755 --- a/tests/test_toggleglobalsitepackages.sh +++ b/tests/test_toggleglobalsitepackages.sh @@ -15,7 +15,6 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" } tearDown () { diff --git a/tests/test_wipeenv.sh b/tests/test_wipeenv.sh index 3ebc723..aa76044 100755 --- a/tests/test_wipeenv.sh +++ b/tests/test_wipeenv.sh @@ -7,7 +7,6 @@ setUp () { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" source "$test_dir/../virtualenvwrapper.sh" - rm -f "$test_dir/catch_output" echo } diff --git a/tests/test_workon.sh b/tests/test_workon.sh index 943d5e8..df7ac69 100755 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -18,7 +18,7 @@ oneTimeTearDown() { setUp () { echo - rm -f "$test_dir/catch_output" + rm -f "$TMPDIR/catch_output" } tearDown () { @@ -35,20 +35,20 @@ test_workon_activate_hooks () { for t in pre post do echo "#!/bin/sh" > "$WORKON_HOME/${t}activate" - echo "echo GLOBAL ${t}activate >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/${t}activate" + echo "echo GLOBAL ${t}activate >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/${t}activate" chmod +x "$WORKON_HOME/${t}activate" echo "#!/bin/sh" > "$WORKON_HOME/env2/bin/${t}activate" - echo "echo ENV ${t}activate >> \"$test_dir/catch_output\"" >> "$WORKON_HOME/env1/bin/${t}activate" + echo "echo ENV ${t}activate >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/env1/bin/${t}activate" chmod +x "$WORKON_HOME/env1/bin/${t}activate" done - rm -f "$test_dir/catch_output" - touch "$test_dir/catch_output" + rm -f "$TMPDIR/catch_output" + touch "$TMPDIR/catch_output" workon env1 - output=$(cat "$test_dir/catch_output") + output=$(cat "$TMPDIR/catch_output") expected="GLOBAL preactivate ENV preactivate GLOBAL postactivate From 1d295bd92a9a1fb7f52987b94b81840abbd3cf5c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 20 Jul 2013 18:39:16 -0400 Subject: [PATCH 663/947] use pbr for packaging Change-Id: I9c23be3a155fe6952ff7c4b0868892eb5ec087ce --- .gitignore | 2 + .hgtags | 91 ---------------- ChangeLog | 200 ----------------------------------- MANIFEST.in | 10 -- README.rst => README.txt | 0 docs/source/history.rst | 3 + requirements.txt | 3 + setup.cfg | 73 +++++++++++++ setup.py | 222 +-------------------------------------- 9 files changed, 84 insertions(+), 520 deletions(-) delete mode 100644 .hgtags delete mode 100644 ChangeLog rename README.rst => README.txt (100%) create mode 100644 requirements.txt create mode 100644 setup.cfg diff --git a/.gitignore b/.gitignore index 747ea91..4a4ae28 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,8 @@ virtualenvwrapper/docs .tox *.orig TAGS +ChangeLog +AUTHORS syntax: re .DS_Store diff --git a/.hgtags b/.hgtags deleted file mode 100644 index c709255..0000000 --- a/.hgtags +++ /dev/null @@ -1,91 +0,0 @@ -6172dee8bf6a2babf689f01288d843ab21dc6284 1.0 -8c46828abec08903275727ac4cae20e3dfa5c0c2 1.3.1 -8c46828abec08903275727ac4cae20e3dfa5c0c2 1.3.2 -8c46828abec08903275727ac4cae20e3dfa5c0c2 1.4 -8c46828abec08903275727ac4cae20e3dfa5c0c2 1.5 -8c46828abec08903275727ac4cae20e3dfa5c0c2 1.6 -8c46828abec08903275727ac4cae20e3dfa5c0c2 1.6.1 -b39eeb3dd437ec6c4ab29ed9b020061a639032fe 1.1 -b39eeb3dd437ec6c4ab29ed9b020061a639032fe 1.2 -b39eeb3dd437ec6c4ab29ed9b020061a639032fe 1.3 -54aa96a1c09f4e6474dcbee8f6fbbf811c97987d 1.7 -32f2a081d64997ec7bd863132978043a43b7f64a 1.7 -ea5f27af83bb54128e7fa8752c61de074efec2ca 1.8 -dca76424222e4f5184aab2c64129029bebd3b378 1.8.1 -8417344df8ff4ea1ddfe563956e7e36cddfd732d 1.8.1 -d8112e52eadcb83bc72d76a421ceab325711a369 1.9 -274d4576d606596a2c9f27b69fd4bc454614c299 1.10 -511994f15d58deb14deeee969677ca132aae83e2 1.11 -dda0e4d36a9150968ea6d2d7778d58dbfaf34ba4 1.12 -8e73805a97e118524b77da40f25cc42d1ad03e6c 1.13 -7c40caf6ce6f9e5bffe4ec35969ba2f19d308f00 1.13 -e31542a0d9464a4cb8594958dd70cb56c32cf455 1.14 -caf3f2a31fdd39539e413390720dff419121f568 1.14 -6e54ea32a9d1c0a73550b6baec0190e894536512 1.14 -bddfac3c8fde9c860c6e942435cff297f989060d 1.15 -7d9dbc84f25da33c7c458c13874f99535bb6bfa7 1.16 -749030a692a0b8bfe580b9ec86a1911580a8b3fa 1.17 -10fbaab7da41d5a0ef70e46fd53cc450e3d91a3d 1.17.1 -24190e878fa8e6caf37f67b5c42b1b52304baa62 1.18 -8af191bfa3c823bd5528ce99d0fb8fe72cc1a5d6 1.19 -ed873ac408ff14b8e40137bd4caedbd798c96cb8 1.20 -c11ee79132302cf9f6c229f336dcaea5e1dea474 1.21 -c11ee79132302cf9f6c229f336dcaea5e1dea474 1.21 -2190584becc72c84c2bdcd3daed4b51377a414f2 1.21 -eddb2921783cbf2c8f04f896f8e861e70c5f1068 1.22 -eddb2921783cbf2c8f04f896f8e861e70c5f1068 1.22 -c50385e9c99b207f56a968926b0f7e21a2b09366 1.22 -e55e8a54de7be78b8400632ab004abb29aaa8899 1.23 -b243d023094b6b0ef1b834dcc100f8c342c67537 1.24 -4a8870326d84f97d5539b586b21419ba330fea48 1.24.1 -f318697791416cf0897091718d542e8045854233 1.24.2 -06229877a640ecb490faf46f923d8be916a0ebed 1.25 -51eef82a39d431cee156fea7005fa1631e21655e 1.26 -3edf5f22481587608f8c172f8758014446a2d888 1.27 -3edf5f22481587608f8c172f8758014446a2d888 1.27 -d64869519c2e0553303cfeeb0918271564c72beb 1.27 -485e1999adf0d388340aec42bae4d87f93b8da92 2.0 -485e1999adf0d388340aec42bae4d87f93b8da92 2.0 -54713c4552c2bcf0155071c87cfca84ed1ea5f6e 2.0 -91e1124c68315f8cdc6578c4f72e3ed9c44e1fca 2.0.1 -6a51a81454ae9dde5d923668ad5f034b3467fe11 2.0.2 -241df6c36860c13fae5468881457a27840ee9d72 2.1 -7540fc7d8e63cafe6c3126e0855ed8c277b450cf 2.1.1 -d5c5faecc92daef3d15510f0314d4d5e6c95e234 2.2 -66a89d019905aa7b697b7ce69303201f50e1d4e7 2.2.1 -66a89d019905aa7b697b7ce69303201f50e1d4e7 2.2.1 -87d60f20a715e5641e819d127cfdc31f8003c4f2 2.2.1 -266a166f80da390a22e684497f971b6b22776cb9 2.2.2 -b9d4591458bbaf41d4e40104e8f19c19d76b4664 2.3 -64f858d461d449601d6bc3e2521b34dbd1c916a5 2.4 -64f858d461d449601d6bc3e2521b34dbd1c916a5 2.4 -a85d80e88996c15e2e2b832e2956811eea73ee34 2.4 -80e2fcda77acd85500159e3e688e5acfa3d99bd3 2.5 -2ab678413a290410ed4c8a1b72a567d79caa5ae5 2.5.1 -f71ffbb996c41606aea15b2114120d9fca3adfc6 2.5.2 -dc74f106d8d2dd58031b2dbac31b1e068f780de4 2.5.3 -b0f27c65fa64627599c2a022a076ae5ee7157ae4 2.6 -445a58d5a05a1426cefb47e54b692b6a58fdcc4f 2.6.1 -625d85d3136ff746accc490c5f9210b1b0074533 2.6.2 -e7582879df06689ec54cd820c377e89114b75ee2 2.6.3 -e7582879df06689ec54cd820c377e89114b75ee2 2.6.3 -246ce68795ea9caeb88ec2fa17e4f3151c58cf3f 2.6.3 -ea378ef00313cd77d251e61b4c0422503972b79f 2.7 -b20cf787d8e1c167853709ca01731a3efb4b5fe8 2.7.1 -7e0abe005937033aaf5d00fe3db3c94addecef7b 2.8 -7e0abe005937033aaf5d00fe3db3c94addecef7b 2.8 -279244c0fa41a327cc534fc40e9e7fadea180c23 2.8 -9e10c201a5005cc2d6c6728dfb0cda56deb4339d 2.10.1 -ff4d492c873c324ccfb71bc71118a67aa6195ad2 2.11 -12a1e0b65313944c3a28d9e71fdef1c7cd41b930 2.11.1 -434b87ebc24ae24e6928c72d79764379aae87130 3.0 -14cf7e58d32174c8e90cf6914a6604f3cff9f279 3.0.1 -ebbb3ba8168703861c016ed66f443fb898f0b06b 3.1 -dccf1a1abf4ea97589e9fa141167771049f031e0 3.2 -45877370548ee7c2581a6c81df22b12fcc3f4891 3.3 -07905d9135ac3ca8460143b40dc39aa8823d3691 3.4 -c93b81815391a939601ac455a07b6f006825838a 3.5 -002a0ccdcc7aea6ecee76685425bccbbe1b45bfa 3.6 -c180ccae77b40c2728e53612648dab7e0356584f 3.6.1 -303ff1485acb605720408d092cd375ef0d2b17d3 3.7 -2ba65a13f804584d49df12ccedcbd20422fa85f9 4.0 diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index caaecc6..0000000 --- a/ChangeLog +++ /dev/null @@ -1,200 +0,0 @@ -2011-04-13 Doug Hellmann - - * virtualenvwrapper.sh (rmvirtualenv): Move to a safe directory - before removing the virtual environment, and only move back if the - previously occupied directory still exists. - -2011-04-10 Doug Hellmann - - * virtualenvwrapper.sh: Initialize VIRTUALENVWRAPPER_LOG_DIR and - VIRTUALENVWRAPPER_HOOK_DIR. - - * virtualenvwrapper/hook_loader.py (main): Use - VIRTUALENVWRAPPER_LOG_DIR for logs instead of assuming - WORKON_HOME. - - * virtualenvwrapper/user_scripts.py (make_hook): Change verbosity - of message telling the user we have created a new hook script for - them. - -2011-02-26 Doug Hellmann - - * docs/sphinx/conf.py: Just hard-code the version. - - * setup.py: Just hard-code the version. - - * virtualenvwrapper/version.py: Put the version info inside the - package so it is available to the doc build and packaging - script. This also makes the readthedocs.org build work properly. - - * setup.py: Import the version information from the package. - - * docs/sphinx/conf.py: Import the version information from the - package. - - * Makefile: Remove rule to get the version from the installer for - the doc build. - -2011-01-24 Doug Hellmann - - * virtualenvwrapper.sh: Replace hard-coded name "virtualenv" with - the variable VIRTUALENVWRAPPER_VIRTUALENV to allow tests (and - users) to override it. - - * tests/test_mkvirtualenv.sh (test_virtualenv_fails): Add a test - to reproduce the conditions reported in issue #76. - -2010-12-27 Doug Hellmann - - * virtualenvwrapper.sh (virtualenvwrapper_get_python_version): - Only include the major and minor numbers, not the patch level. - -2010-12-26 Doug Hellmann - - * virtualenvwrapper/user_scripts.py (make_hook): Do not specify - text mode when creating the files so cygwin will not replace \n - with \r\n. - - * setup.py: Change "requires" to "install_requires" so pip will - try to install virtualenv if it is not already there. Add trove - classifiers for the supported Python versions. - - * virtualenvwrapper.sh (virtualenvwrapper_get_python_version): Use - python's -V option and cut to get the version instead of a python - one-liner. - -2010-12-24 Doug Hellmann - - * virtualenvwrapper.sh (cpvirtualenv): Ensure that both pre hooks - are run, even if one produces an error. - - * virtualenvwrapper/user_scripts.py: Change log message format. - - * tox.ini: Configuration file for running tests under tox. - - * tests/test_run_hook.sh (test_virtualenvwrapper_run_hook_permissions): - Fix the expected output message. - - * tests/*: Make sure all of the test scripts have execute permission. - - * tests/test.sh (test_virtualenvwrapper_verify_workon_home_missing_dir_quiet_init): - Use source instead of starting another shell, since zsh doesn't - play nicely with inheriting environment settings otherwise. - (test_python_interpreter_set_incorrectly): Force - VIRTUALENVWRAPPER_PYTHON before running the script in a sub-shell. - - * tests/run_tests: Script to run through all of the other test - scripts one at a time. - -2010-09-18 Doug Hellmann - - * virtualenvwrapper.sh: Apply patch from Zach Voase to fix - lsvirtualenv under zsh. - -2010-09-14 Doug Hellmann - - * virtualenvwrapper.sh (workon): Use the brief list format by - default. - -2010-08-16 Doug Hellmann - - * virtualenvwrapper/user_scripts.py (get_env_details): New hook to - optionally give more detail than the name of an environment when - the user requests a list. - - * virtualenvwrapper.sh: Update workon to use the get_env_details - hook to print more details, if the user provides scripts to give - them. - -2010-06-03 Doug Hellmann - - * virtualenvwrapper.sh: Escape the call to "which" so we don't use - an alias by accident. - -2010-05-22 Doug Hellmann - - * tests/test_cp.sh: Clarify some of the tests by breaking up, - renaming, and rewriting some functions. - - * Makefile (PYTHON26): If we're in a virtualenv when the tests - start, use a hard-coded path to the binary to get the global - version. - -2010-05-18 Doug Hellmann - - * virtualenvwrapper.sh (virtualenvwrapper_tempfile): Use a trap to - ensure the temporary file is removed when we exit. - -2010-05-16 Doug Hellmann - - * virtualenvwrapper.sh (virtualenvwrapper_tempfile): Set a default - suffix of "hook" and explicitly report when we detect an error - condition. - - * Makefile (PYTHON26): Use which to find python2.6, the default - interpreter, so we can run the tests as "make test-quick" on other - hosts. - - * tests/test_tempfile.sh (test_tempfile): Normalize the paths so - we don't depend on the value of TMPDIR or behavior of dirname. - - * tests/test_cd.sh: Make sure the virtualenv from the caller does - not influence test behaviors by establishing our own virtualenv - locally. - - * virtualenvwrapper/hook_loader.py (main): Add more debug logging - to try to narrow down the tempfile issue (#35). - (run_hooks): Insert a comment into the output file to show which - hook we are running. - - * virtualenvwrapper.sh (virtualenvwrapper_run_hook): Add more - debugging error reporting to try to narrow down the tempfile - issue (#35). - -2010-05-09 Doug Hellmann - - * virtualenvwrapper.sh: Tweak path normalization code so double - slashes are also removed from WORKON_HOME. Use typeset for local - variables. - (virtualenvwrapper_tempfile): Add -t option to mktemp so the new - files are always created in the user's temporary directory. - (virtualenvwrapper_run_hook): Add the hook name to the temporary - file name. - - * tests/test_tempfile.sh: Remove obsolete test. Fix assertions - for remaining test. - - * tests/test_mkvirtualenv.sh (test_hooks): Use pwd to convert - WORKON_HOME to the expected value. - - * tests/test.sh (test_python_interpreter_set_incorrectly): Rework - grep-based assertion to actually pass. - - * Makefile (test-bash test-ksh test-sh): Remove wildcard build - rule so test-quick target works. - -2010-05-02 Doug Hellmann - - * virtualenvwrapper.sh (virtualenvwrapper_run_hook): Instead of - -m, use -c so hooks can be run under Python 2.4. - -2010-04-29 Doug Hellmann - - * tests/test_workon.sh: Refactor deactivate tests into their own - script. - - * tests/test_deactivate.sh: Refactor deactivate tests into their - own script. - - * virtualenvwrapper.sh (virtualenvwrapper_get_python_version): Add - a comment about why we're using the $PATH python instead of the - one where the wrappers are installed. - (add2virtualenv): Use the install-tree python instead of the one - from $PATH. - (deactivate): Ignore errors from redundant unset calls. - -2010-04-26 Doug Hellmann - - * virtualenvwrapper.sh (virtualenvwrapper_tempfile): Add a suffix - to the tempfile name so we know the tempfile module isn't going to - erase it. diff --git a/MANIFEST.in b/MANIFEST.in index e1482b1..7634892 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,11 +1 @@ -include setup.py -include distribute_setup.py -include tests/* -include tests/testpackage/setup.py -include tests/testpackage/testscript.py -include tests/testtemplate/distribute_setup.py -include tests/testtemplate/setup.py -include tests/testtemplate/mytemplates/*.py recursive-include docs *.rst *.py *.html *.css *.js *.png *.txt -include tox.ini -include LICENSE diff --git a/README.rst b/README.txt similarity index 100% rename from README.rst rename to README.txt diff --git a/docs/source/history.rst b/docs/source/history.rst index 3e8a5a3..fb57ca6 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -19,6 +19,9 @@ dev virtualenvs. Suggested by Dave Coutts in :bbissue:`186`. - Fix :ref:`command-lsvirtualenv` when there are spaces in ``WORKON_HOME``. Resolves :bbissue:`194`. +- Switch to `pbr`_ for packaging. + +.. _pbr: https://github.com/openstack-dev/pbr 4.0 === diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8f54551 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +virtualenv +virtualenv-clone +stevedore diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..090c8f1 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,73 @@ +[metadata] +name = virtualenvwrapper +author = Doug Hellmann +author-email = doug.hellmann@gmail.com +summary = Enhancements to virtualenv +description-file = README.txt +license = MIT +classifier = + Development Status :: 5 - Production/Stable + License :: OSI Approved :: MIT License + Programming Language :: Python + Programming Language :: Python :: 2 + Programming Language :: Python :: 2.6 + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.2 + Programming Language :: Python :: 3.3 + Intended Audience :: Developers + Environment :: Console +keywords = + virtualenv +home-page = http://virtualenvwrapper.readthedocs.org/ +zip_safe = False +provides_dist = + virtualenvwrapper + virtualenvwrapper.user_scripts + virtualenvwrapper.project + +[files] +packages = + virtualenvwrapper +scripts = + virtualenvwrapper.sh + virtualenvwrapper_lazy.sh + +[global] +zip_safe = False +setup-hooks = + pbr.hooks.setup_hook + +[entry_points] +virtualenvwrapper.initialize = + user_scripts = virtualenvwrapper.user_scripts:initialize + project = virtualenvwrapper.project:initialize +virtualenvwrapper.initialize_source = + user_scripts = virtualenvwrapper.user_scripts:initialize_source +virtualenvwrapper.pre_mkvirtualenv = + user_scripts = virtualenvwrapper.user_scripts:pre_mkvirtualenv +virtualenvwrapper.post_mkvirtualenv_source = + user_scripts = virtualenvwrapper.user_scripts:post_mkvirtualenv_source +virtualenvwrapper.pre_cpvirtualenv = + user_scripts = virtualenvwrapper.user_scripts:pre_cpvirtualenv +virtualenvwrapper.post_cpvirtualenv_source = + user_scripts = virtualenvwrapper.user_scripts:post_cpvirtualenv_source +virtualenvwrapper.pre_rmvirtualenv = + user_scripts = virtualenvwrapper.user_scripts:pre_rmvirtualenv +virtualenvwrapper.post_rmvirtualenv = + user_scripts = virtualenvwrapper.user_scripts:post_rmvirtualenv +virtualenvwrapper.project.pre_mkproject = + project = virtualenvwrapper.project:pre_mkproject +virtualenvwrapper.project.post_mkproject_source = + project = virtualenvwrapper.project:post_mkproject_source +virtualenvwrapper.pre_activate = + user_scripts = virtualenvwrapper.user_scripts:pre_activate +virtualenvwrapper.post_activate_source = + user_scripts = virtualenvwrapper.user_scripts:post_activate_source + project = virtualenvwrapper.project:post_activate_source +virtualenvwrapper.pre_deactivate_source = + user_scripts = virtualenvwrapper.user_scripts:pre_deactivate_source +virtualenvwrapper.post_deactivate_source = + user_scripts = virtualenvwrapper.user_scripts:post_deactivate_source +virtualenvwrapper.get_env_details = + user_scripts = virtualenvwrapper.user_scripts:get_env_details diff --git a/setup.py b/setup.py index 3c7bd41..52931fb 100644 --- a/setup.py +++ b/setup.py @@ -1,225 +1,9 @@ #!/usr/bin/env python -PROJECT = 'virtualenvwrapper' -VERSION = '4.0' - -from setuptools import setup, find_packages - -from distutils.util import convert_path -from fnmatch import fnmatchcase -import os -import sys - -try: - long_description = open('README.rst', 'rt').read() -except IOError: - long_description = '' - -############################################################################# -# find_package_data is an Ian Bicking creation. - -# Provided as an attribute, so you can append to these instead -# of replicating them: -standard_exclude = ('*.py', '*.pyc', '*~', '.*', '*.bak', '*.swp*') -standard_exclude_directories = ('.*', 'CVS', '_darcs', './build', - './dist', 'EGG-INFO', '*.egg-info') - - -def find_package_data(where='.', - package='', - exclude=standard_exclude, - exclude_directories=standard_exclude_directories, - only_in_packages=True, - show_ignored=False, - ): - """ - Return a dictionary suitable for use in ``package_data`` - in a distutils ``setup.py`` file. - - The dictionary looks like:: - - {'package': [files]} - - Where ``files`` is a list of all the files in that package that - don't match anything in ``exclude``. - - If ``only_in_packages`` is true, then top-level directories that - are not packages won't be included (but directories under packages - will). - - Directories matching any pattern in ``exclude_directories`` will - be ignored; by default directories with leading ``.``, ``CVS``, - and ``_darcs`` will be ignored. - - If ``show_ignored`` is true, then all the files that aren't - included in package data are shown on stderr (for debugging - purposes). - - Note patterns use wildcards, or can be exact paths (including - leading ``./``), and all searching is case-insensitive. - - This function is by Ian Bicking. - """ - - out = {} - stack = [(convert_path(where), '', package, only_in_packages)] - while stack: - where, prefix, package, only_in_packages = stack.pop(0) - for name in os.listdir(where): - fn = os.path.join(where, name) - if os.path.isdir(fn): - bad_name = False - for pattern in exclude_directories: - if (fnmatchcase(name, pattern) - or fn.lower() == pattern.lower()): - bad_name = True - if show_ignored: - print >> sys.stderr, ( - "Directory %s ignored by pattern %s" - % (fn, pattern)) - break - if bad_name: - continue - if os.path.isfile(os.path.join(fn, '__init__.py')): - if not package: - new_package = name - else: - new_package = package + '.' + name - stack.append((fn, '', new_package, False)) - else: - stack.append((fn, - prefix + name + '/', - package, - only_in_packages)) - elif package or not only_in_packages: - # is a file - bad_name = False - for pattern in exclude: - if (fnmatchcase(name, pattern) - or fn.lower() == pattern.lower()): - bad_name = True - if show_ignored: - print >> sys.stderr, ( - "File %s ignored by pattern %s" - % (fn, pattern)) - break - if bad_name: - continue - out.setdefault(package, []).append(prefix + name) - return out -############################################################################ - -us_pkg = 'virtualenvwrapper.user_scripts' - -entry_points = { - 'virtualenvwrapper.initialize': [ - 'user_scripts = %s:initialize' % us_pkg, - 'project = virtualenvwrapper.project:initialize', - ], - 'virtualenvwrapper.initialize_source': [ - 'user_scripts = %s:initialize_source' % us_pkg, - ], - - 'virtualenvwrapper.pre_mkvirtualenv': [ - 'user_scripts = %s:pre_mkvirtualenv' % us_pkg, - ], - 'virtualenvwrapper.post_mkvirtualenv_source': [ - 'user_scripts = %s:post_mkvirtualenv_source' % us_pkg, - ], - - 'virtualenvwrapper.pre_cpvirtualenv': [ - 'user_scripts = %s:pre_cpvirtualenv' % us_pkg, - ], - 'virtualenvwrapper.post_cpvirtualenv_source': [ - 'user_scripts = %s:post_cpvirtualenv_source' % us_pkg, - ], - - 'virtualenvwrapper.pre_rmvirtualenv': [ - 'user_scripts = %s:pre_rmvirtualenv' % us_pkg, - ], - 'virtualenvwrapper.post_rmvirtualenv': [ - 'user_scripts = %s:post_rmvirtualenv' % us_pkg, - ], - - 'virtualenvwrapper.project.pre_mkproject': [ - 'project = virtualenvwrapper.project:pre_mkproject', - ], - 'virtualenvwrapper.project.post_mkproject_source': [ - 'project = virtualenvwrapper.project:post_mkproject_source', - ], - - 'virtualenvwrapper.pre_activate': [ - 'user_scripts = %s:pre_activate' % us_pkg, - ], - 'virtualenvwrapper.post_activate_source': [ - 'user_scripts = %s:post_activate_source' % us_pkg, - 'project = virtualenvwrapper.project:post_activate_source', - ], - - 'virtualenvwrapper.pre_deactivate_source': [ - 'user_scripts = %s:pre_deactivate_source' % us_pkg, - ], - 'virtualenvwrapper.post_deactivate_source': [ - 'user_scripts = %s:post_deactivate_source' % us_pkg, - ], - - 'virtualenvwrapper.get_env_details': [ - 'user_scripts = %s:get_env_details' % us_pkg, - ], -} +from setuptools import setup setup( - name=PROJECT, - version=VERSION, - - description='Enhancements to virtualenv', - long_description=long_description, - - author='Doug Hellmann', - author_email='doug.hellmann@gmail.com', - - url='http://%s.readthedocs.org' % PROJECT, - - classifiers=['Development Status :: 5 - Production/Stable', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.6', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.2', - 'Programming Language :: Python :: 3.3', - 'Intended Audience :: Developers', - 'Environment :: Console', - ], - - platforms=['Any'], - - scripts=['virtualenvwrapper.sh', - 'virtualenvwrapper_lazy.sh', - ], - - provides=['virtualenvwrapper', - 'virtualenvwrapper.user_scripts', - 'virtualenvwrapper.project', - ], - install_requires=['virtualenv', - 'virtualenv-clone', - 'stevedore', - ], - + setup_requires=['pbr'], + d2to1=True, namespace_packages=['virtualenvwrapper'], - packages=find_packages(), - include_package_data=True, - # Scan the input for package information - # to grab any data files (text, images, etc.) - # associated with sub-packages. - package_data=find_package_data(PROJECT, - package=PROJECT, - only_in_packages=False, - ), - - entry_points=entry_points, - - zip_safe=False, ) From 977a115e9eedec7c620adcdef0ed975fe1b776ef Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 20 Jul 2013 18:39:52 -0400 Subject: [PATCH 664/947] one more parallel test issue Change-Id: Ic7999946ab4b2b66ad18f69db831eb9a21d84bd8 --- tests/test_mkvirtualenv_requirements.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_mkvirtualenv_requirements.sh b/tests/test_mkvirtualenv_requirements.sh index 015d933..84ac5ac 100755 --- a/tests/test_mkvirtualenv_requirements.sh +++ b/tests/test_mkvirtualenv_requirements.sh @@ -11,7 +11,7 @@ oneTimeSetUp() { oneTimeTearDown() { rm -rf "$WORKON_HOME" - rm -f "$test_dir/requirements.txt" + rm -f "$TMPDIR/requirements.txt" } setUp () { @@ -19,8 +19,8 @@ setUp () { } test_requirements_file () { - echo "IPy" > "$test_dir/requirements.txt" - mkvirtualenv -r "$test_dir/requirements.txt" "env3" >/dev/null 2>&1 + echo "IPy" > "$TMPDIR/requirements.txt" + mkvirtualenv -r "$TMPDIR/requirements.txt" "env3" >/dev/null 2>&1 installed=$(pip freeze) assertTrue "IPy not found in $installed" "pip freeze | grep IPy" } From 2996a80e73d494aff1da5f2ada92447ac8936e30 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 20 Jul 2013 18:40:05 -0400 Subject: [PATCH 665/947] quiet cdproject test Change-Id: I67700228454b3a5b2cf8a5a83f819523479bb164 --- tests/test_project_cd.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_project_cd.sh b/tests/test_project_cd.sh index a6849c3..2c57fae 100755 --- a/tests/test_project_cd.sh +++ b/tests/test_project_cd.sh @@ -40,7 +40,6 @@ test_without_project () { test_space_in_path () { ( - set -x set -e PROJECT_HOME="$PROJECT_HOME/with spaces" mkdir -p "$PROJECT_HOME" From 72c8f5e890db2e7e63e804d402accdf248c74bda Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 20 Jul 2013 18:40:19 -0400 Subject: [PATCH 666/947] fix pep8 issue in user_scripts.py Change-Id: Ie02d87705c47876f1011d9015750c7f9fe737c2d --- virtualenvwrapper/user_scripts.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index bd66634..fc04579 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -123,12 +123,10 @@ def make_hook(filename, comment): log.info('creating %s', filename) f = open(filename, 'w') try: - f.write("""#!%(shell)s -# %(comment)s - -""" % {'comment': comment, - 'shell': os.environ.get('SHELL', '/bin/sh'), - }) + f.write("#!%(shell)s\n# %(comment)s\n\n" % { + 'comment': comment, + 'shell': os.environ.get('SHELL', '/bin/sh'), + }) finally: f.close() os.chmod(filename, PERMISSIONS) From 12447fede92b407d693828d3ef6926175b1d6279 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 21 Jul 2013 10:06:40 -0400 Subject: [PATCH 667/947] prep for 4.1 release Change-Id: I966eb2d5531484fa4f8a8933d077fbbc4513ce1b --- announce.es.rst | 45 ----------------------------------------- announce.rst | 30 ++++++++++++++++----------- docs/source/history.rst | 2 +- 3 files changed, 19 insertions(+), 58 deletions(-) delete mode 100644 announce.es.rst diff --git a/announce.es.rst b/announce.es.rst deleted file mode 100644 index e9cec37..0000000 --- a/announce.es.rst +++ /dev/null @@ -1,45 +0,0 @@ -¿Qué es virtualenvwrapper? -========================== - -virtualenvwrapper es un conjunto de extensiones de la herramienta de Ian -Bicking `virtualenv `_. Las extensiones -incluyen funciones para la creación y eliminación de entornos virtuales y por otro -lado administración de tu rutina de desarrollo, haciendo fácil trabajar en más -de un proyecto al mismo tiempo sin introducir conflictos entre sus dependencias. - - -¿Qué es lo nuevo en 2.1? -======================== - -El principal propósito de esta *release* es un conjunto de mejoras para soportar -virtualenvwrapper.project_, una nueva extensión para administrar los directorios -de trabajo para los proyectos con plantillas. 2.1 también incluye pequeños -cambios y corrección de bugs. - -- Agregado soporte para ksh. Gracias a Doug Latornell por hacer la investigación - sobre qué era necesario cambiar. -- Testeo de importación de virtualenvwrapper.hook_loader en el inicio que reporta - el error de manera que debería ayudar al usuario a resolver cómo solucionarlo - (ticket #33). -- Actualizada la documentación de mkvirtualenv para incluir el hecho de que un - nuevo entorno es activado inmediatamente luego de que es creado (ticket #30). -- Agregados ganchos alrededor cpvirtualenv. -- *deactivation* es más robusto, especialmente bajo ksh. -- Uso del módulo de Python ``tempfile`` para creación de archivos temporales - de forma segura y portable. -- Corregido un problema con ``virtualenvwrapper_show_workon_options`` que - causaba que este muestre ``*`` como el nombre de un virtualenv cuando no había - entornos creados todavía. -- Cambio en el cargador de ganchos para que pueda ejecutar sólo un conjunto de - ganchos nombrados. -- Agregado soporte para listar los ganchos disponibles, para ser usado en la - ayuda de los comandos como mkproject en virtualenvwrapper.project. -- Corregida la opción -h de mkvirtualenv. -- Cambiado el registro para que $WORKON_HOME/hook.log rote después de 10KiB. - - -.. _virtualenv: http://pypi.python.org/pypi/virtualenv - -.. _virtualenvwrapper: http://www.doughellmann.com/projects/virtualenvwrapper/ - -.. _virtualenvwrapper.project: http://www.doughellmann.com/projects/virtualenvwrapper.project/ diff --git a/announce.rst b/announce.rst index 33a83b8..c2fee92 100644 --- a/announce.rst +++ b/announce.rst @@ -1,5 +1,5 @@ ======================= - virtualenvwrapper 4.0 + virtualenvwrapper 4.1 ======================= .. tags:: virtualenvwrapper release python @@ -16,17 +16,23 @@ introducing conflicts in their dependencies. What's New? =========== -**Warning:** This release includes some potentially incompatible -changes for extensions. The python modules for extensions are now -*always* run with ``PWD=$WORKON_HOME`` (previously the value of PWD -varied depending on the hook). The *shell* portion of any hook -(anything sourced by the user's shell when the hook is run) is still -run in the same place as before. - -- All tests pass under Python 2.6, 2.7, 3.2 and 3.3. -- Fix the name of the script in an error message produced - by ``virtualenvwrapper_lazy.sh``. (Contributed by - scottstvnsn.) +- Ensure that all ``$()`` style commands that produce paths are + quoted; addresses issue 164. +- Add ``wipeenv`` command for removing all packages installed in the + virtualenv. +- Allow users of ``virtualenvwrapper_lazy.sh`` to extend the list of + API commands that trigger the lazy-loader by extending + ``_VIRTUALENVWRAPPER_API``. Patch contributed by John Purnell, see + issue 188. +- Fix detection of ``--python`` option to ``mkvirtualenv``. Resolves + issue 190. +- Add ``allvirtualenv`` command to run a command across all + virtualenvs. Suggested by Dave Coutts in issue 186. +- Fix ``lsvirtualenv`` when there are spaces in + ``WORKON_HOME``. Resolves issue 194. +- Switch to `pbr`_ for packaging. + +.. _pbr: https://github.com/openstack-dev/pbr Installing ========== diff --git a/docs/source/history.rst b/docs/source/history.rst index fb57ca6..5cd90b1 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -2,7 +2,7 @@ Release History =============== -dev +4.1 === - Ensure that all ``$()`` style commands that produce paths are From 963a35cc4dffe0e2636e08eb5d5e8a665c319656 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 21 Jul 2013 12:13:01 -0400 Subject: [PATCH 668/947] Working on packaging issue with 4.1 release Change-Id: I11a1a71c1074c1258799d4e985171edce3643a05 --- setup.cfg | 2 ++ setup.py | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 090c8f1..d522701 100644 --- a/setup.cfg +++ b/setup.cfg @@ -29,6 +29,8 @@ provides_dist = [files] packages = virtualenvwrapper +namespace_packages = + virtualenvwrapper scripts = virtualenvwrapper.sh virtualenvwrapper_lazy.sh diff --git a/setup.py b/setup.py index 52931fb..6e96fa9 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,6 @@ from setuptools import setup setup( - setup_requires=['pbr'], + setup_requires=['pbr>=0.5.19'], d2to1=True, - namespace_packages=['virtualenvwrapper'], ) From 59d6a2c17e2ec20cb4ffbb21dfdafc169ba92c6b Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sun, 21 Jul 2013 09:20:24 -0700 Subject: [PATCH 669/947] Take advantage of pbr 0.5.19 namespace_packages in setup.cfg works now. Also, d2to1 has been merged, so pbr=True will now work, removing the last references to d2to1 from the source tree. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6e96fa9..82d3ae3 100644 --- a/setup.py +++ b/setup.py @@ -4,5 +4,5 @@ setup( setup_requires=['pbr>=0.5.19'], - d2to1=True, + pbr=True, ) From a933b98cded25b7bebbf894d494174cd3984f113 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 21 Jul 2013 12:27:26 -0400 Subject: [PATCH 670/947] update history for 4.1.1 Change-Id: Idcc09eeb813b2e29bd1f5731128b5472cb80c698 --- docs/source/history.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/source/history.rst b/docs/source/history.rst index 5cd90b1..af1e796 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -2,6 +2,11 @@ Release History =============== +4.1.1 +===== + +- Fix packaging issue with 4.1. + 4.1 === From 95554322b67ecf5a0b7df94dada8d12e931c4ab3 Mon Sep 17 00:00:00 2001 From: Clay McClure Date: Thu, 25 Jul 2013 10:47:29 -0400 Subject: [PATCH 671/947] Remove extraneous punctuation --- virtualenvwrapper.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index b38c5c2..53ba68b 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -975,13 +975,13 @@ function setvirtualenvproject { # Show help for mkproject function virtualenvwrapper_mkproject_help { echo "Usage: mkproject [-t template] [virtualenv options] project_name" - echo "" + echo echo "Multiple templates may be selected. They are applied in the order" echo "specified on the command line." - echo; + echo echo "mkvirtualenv help:" echo - mkvirtualenv -h; + mkvirtualenv -h echo echo "Available project templates:" echo From 0a4fcd0983956b2a2ce46ab9192add4b6ca0d337 Mon Sep 17 00:00:00 2001 From: Clay McClure Date: Thu, 25 Jul 2013 21:58:32 -0400 Subject: [PATCH 672/947] Add `mkproject --force` option This allows `mkproject` to create a virtualenv for a project directory that already exists, which is something I frequently find the need to do. --- tests/test_project_mk.sh | 2 ++ virtualenvwrapper.sh | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/test_project_mk.sh b/tests/test_project_mk.sh index 96f823d..15e2a78 100755 --- a/tests/test_project_mk.sh +++ b/tests/test_project_mk.sh @@ -66,6 +66,8 @@ test_project_exists () { mkproject myproject4 >/dev/null 2>&1 output=`mkproject myproject4 2>&1` assertTrue "Did not see expected message 'already exists' in: $output" "echo $output | grep 'already exists'" + output=`mkproject -f myproject4 2>&1` + assertFalse "Saw unexpected message 'already exists' in: $output" "echo $output | grep 'already exists'" } test_same_workon_and_project_home () { diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 53ba68b..fbf5582 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -974,7 +974,10 @@ function setvirtualenvproject { # Show help for mkproject function virtualenvwrapper_mkproject_help { - echo "Usage: mkproject [-t template] [virtualenv options] project_name" + echo "Usage: mkproject [-f|--force] [-t template] [virtualenv options] project_name" + echo + echo "-f, --force Create the project even if the project directory" + echo " already exists" echo echo "Multiple templates may be selected. They are applied in the order" echo "specified on the command line." @@ -996,9 +999,11 @@ function mkproject { typeset tst typeset a typeset t + typeset force typeset templates in_args=( "$@" ) + force=0 if [ -n "$ZSH_VERSION" ] then @@ -1015,6 +1020,8 @@ function mkproject { -h|--help) virtualenvwrapper_mkproject_help; return;; + -f|--force) + force=1;; -t) i=$(( $i + 1 )); templates="$templates ${in_args[$i]}";; @@ -1038,7 +1045,7 @@ function mkproject { eval "typeset envname=\$$#" virtualenvwrapper_verify_project_home || return 1 - if [ -d "$PROJECT_HOME/$envname" ] + if [ -d "$PROJECT_HOME/$envname" -a $force -eq 0 ] then echo "Project $envname already exists." >&2 return 1 From 55f94cedee7ea5f90e5395321bb93f5271485e50 Mon Sep 17 00:00:00 2001 From: dbr Date: Fri, 26 Jul 2013 17:12:32 +0930 Subject: [PATCH 673/947] Preserve quoting for allvirtualenv command arguments E.g allvirtualenv python -c 'import this' --- tests/test_allvirtualenv.sh | 4 ++++ virtualenvwrapper.sh | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_allvirtualenv.sh b/tests/test_allvirtualenv.sh index 4aab461..3d7214d 100755 --- a/tests/test_allvirtualenv.sh +++ b/tests/test_allvirtualenv.sh @@ -30,4 +30,8 @@ test_allvirtualenv_all() { assertTrue "Did not find test2" "allvirtualenv pwd | grep -q 'test2$'" } +test_allvirtualenv_spaces() { + assertTrue "Command did not output The Zen of Python" "allvirtualenv python -c 'import this' | grep -q 'The Zen of Python'" +} + . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index b38c5c2..bd83b54 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -1168,7 +1168,7 @@ function allvirtualenv { # because we don't want to trigger any hooks. (source "$WORKON_HOME/$d/bin/activate"; cd "$VIRTUAL_ENV"; - $@) + "$@") echo done } From 92737bd004516820273567befc35391fec95505d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 26 Jul 2013 09:06:52 -0400 Subject: [PATCH 674/947] add tmp- prefix to temporary envs Change-Id: Iaa07effd87dd2400ab79727379175bd80fd9bae6 --- docs/source/history.rst | 6 ++++++ virtualenvwrapper.sh | 1 + 2 files changed, 7 insertions(+) diff --git a/docs/source/history.rst b/docs/source/history.rst index af1e796..b4ef117 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -2,6 +2,12 @@ Release History =============== +dev +=== + +- Add ``tmp-`` prefix to temporary environment names created by + :ref:`command-mktmpenv`. + 4.1.1 ===== diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index b38c5c2..1c0d6ae 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -1106,6 +1106,7 @@ function mktmpenv { # This python does not support uuid tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import random,sys; sys.stdout.write(hex(random.getrandbits(64))[2:-1]+"\n")' 2>/dev/null) fi + tmpenvname="tmp-$tmpenvname" # Create the environment mkvirtualenv "$@" "$tmpenvname" From 80fbd6b17197fb97b043cb284776a0e502a96bcf Mon Sep 17 00:00:00 2001 From: Clay McClure Date: Fri, 26 Jul 2013 16:10:48 -0400 Subject: [PATCH 675/947] Mention sphinxcontrib-bitbucket requirement --- docs/source/developers.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/developers.rst b/docs/source/developers.rst index 8f3ba2b..9b3347c 100644 --- a/docs/source/developers.rst +++ b/docs/source/developers.rst @@ -24,6 +24,7 @@ docs: - Sphinx - docutils +- sphinxcontrib-bitbucket Once all of the tools are installed into a virtualenv using pip, run ``make html`` to generate the HTML version of the From dcd6aa4ab6e7416976bfd3eb71a60b33a19b6277 Mon Sep 17 00:00:00 2001 From: Clay McClure Date: Fri, 26 Jul 2013 16:12:02 -0400 Subject: [PATCH 676/947] Document `mkproject --force` usage --- docs/source/command_ref.rst | 5 ++++- virtualenvwrapper.sh | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index f175aab..ef46607 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -489,7 +489,10 @@ PROJECT_HOME. Syntax:: - mkproject [-t template] [virtualenv_options] ENVNAME + mkproject [-f|--force] [-t template] [virtualenv_options] ENVNAME + +-f, --force Create the virtualenv even if the project directory + already exists The template option may be repeated to have several templates used to create a new project. The templates are applied in the order named on diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index fbf5582..31076b7 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -976,7 +976,7 @@ function setvirtualenvproject { function virtualenvwrapper_mkproject_help { echo "Usage: mkproject [-f|--force] [-t template] [virtualenv options] project_name" echo - echo "-f, --force Create the project even if the project directory" + echo "-f, --force Create the virtualenv even if the project directory" echo " already exists" echo echo "Multiple templates may be selected. They are applied in the order" From db8e5818eaae24d9efd78b32154e153be03bc40e Mon Sep 17 00:00:00 2001 From: Andy Dirnberger Date: Sun, 4 Aug 2013 03:46:44 +0000 Subject: [PATCH 677/947] Fix documentation for allvirtualenv The samples for the `allvirtualenv` command are being correct to use 'allvirtualenv' instead of 'allenv'. --- docs/source/command_ref.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index f175aab..0962031 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -213,7 +213,7 @@ Run a command in all virtualenvs under WORKON_HOME. Syntax:: - allenvs command with arguments + allvirtualenv command with arguments Each virtualenv is activated, bypassing activation hooks, the current working directory is changed to the current virtualenv, and then the @@ -222,7 +222,7 @@ can modify the virtualenv. :: - $ allenvs pip install -U pip + $ allvirtualenv pip install -U pip ================================== From 868a4ee4778081e346d314cd24dbe3ec45484253 Mon Sep 17 00:00:00 2001 From: Ismail Badawi Date: Fri, 9 Aug 2013 19:36:08 -0700 Subject: [PATCH 678/947] Always use virtualenvwrapper_cd instead of cd. --- virtualenvwrapper.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index bb1a035..c48fcf6 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -207,7 +207,7 @@ function virtualenvwrapper_run_hook { # Python 3 interpreter decide that its "prefix" is the virtualenv # if we happen to be inside the virtualenv when we start. ( \ - cd "$WORKON_HOME" && + virtualenvwrapper_cd "$WORKON_HOME" && "$VIRTUALENVWRAPPER_PYTHON" -m 'virtualenvwrapper.hook_loader' \ $HOOK_VERBOSE_OPTION --script "$hook_script" "$@" \ ) @@ -534,7 +534,7 @@ function virtualenvwrapper_show_workon_options { # 4. Format the output to show one name on a line. # 5. Eliminate any lines with * on them because that means there # were no envs. - (cd "$WORKON_HOME" && echo */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate) 2>/dev/null \ + (virtualenvwrapper_cd "$WORKON_HOME" && echo */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate) 2>/dev/null \ | command \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate||g" \ | command \fmt -w 1 \ | (unset GREP_OPTIONS; command \egrep -v '^\*$') 2>/dev/null @@ -1046,7 +1046,7 @@ function mkproject { mkvirtualenv "$@" || return 1 - cd "$PROJECT_HOME" + virtualenvwrapper_cd "$PROJECT_HOME" virtualenvwrapper_run_hook "project.pre_mkproject" $envname @@ -1054,7 +1054,7 @@ function mkproject { mkdir -p "$PROJECT_HOME/$envname" setvirtualenvproject "$VIRTUAL_ENV" "$PROJECT_HOME/$envname" - cd "$PROJECT_HOME/$envname" + virtualenvwrapper_cd "$PROJECT_HOME/$envname" for t in $templates do @@ -1078,7 +1078,7 @@ function cdproject { typeset project_dir="$(cat "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME")" if [ ! -z "$project_dir" ] then - cd "$project_dir" + virtualenvwrapper_cd "$project_dir" else echo "Project directory $project_dir does not exist" 1>&2 return 1 @@ -1168,7 +1168,7 @@ function allvirtualenv { # Activate the environment, but not with workon # because we don't want to trigger any hooks. (source "$WORKON_HOME/$d/bin/activate"; - cd "$VIRTUAL_ENV"; + virtualenvwrapper_cd "$VIRTUAL_ENV"; "$@") echo done From 0de3e7a17f293e7197fffdde5c9e3446fb2aedac Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 10 Aug 2013 14:09:51 -0400 Subject: [PATCH 679/947] add tests to make sure we override cd properly Change-Id: Ifb96741a872e257d8f350d8e8b6c0bbe2b6c409c # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch pr/5 # Changes to be committed: # (use "git reset HEAD^1 ..." to unstage) # # modified: tests/test_cd.sh # new file: tests/test_cd_alias.sh # modified: tests/test_ls.sh # # Changes not staged for commit: # (use "git add ..." to update what will be committed) # (use "git checkout -- ..." to discard changes in working directory) # # modified: tox.ini # --- tests/test_cd.sh | 14 +++++++++----- tests/test_cd_alias.sh | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 5 deletions(-) create mode 100755 tests/test_cd_alias.sh diff --git a/tests/test_cd.sh b/tests/test_cd.sh index 15729e7..a4cada2 100755 --- a/tests/test_cd.sh +++ b/tests/test_cd.sh @@ -8,7 +8,7 @@ oneTimeSetUp() { mkdir -p "$WORKON_HOME" unset VIRTUAL_ENV source "$test_dir/../virtualenvwrapper.sh" - mkvirtualenv cd-test + mkvirtualenv cd-test >/dev/null 2>&1 deactivate } @@ -25,13 +25,17 @@ tearDown () { deactivate >/dev/null 2>&1 } +cd () { + fail "Should not be using override cd function" +} + test_cdvirtual() { start_dir="$(pwd)" cdvirtualenv assertSame "$VIRTUAL_ENV" "$(pwd)" cdvirtualenv bin assertSame "$VIRTUAL_ENV/bin" "$(pwd)" - cd "$start_dir" + virtualenvwrapper_cd "$start_dir" } test_cdsitepackages () { @@ -40,7 +44,7 @@ test_cdsitepackages () { pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" assertSame "$sitepackages" "$(pwd)" - cd "$start_dir" + virtualenvwrapper_cd "$start_dir" } test_cdsitepackages_with_arg () { @@ -50,7 +54,7 @@ test_cdsitepackages_with_arg () { mkdir -p "${sitepackage_subdir}" cdsitepackages subdir assertSame "$sitepackage_subdir" "$(pwd)" - cd "$start_dir" + virtualenvwrapper_cd "$start_dir" } test_cdvirtualenv_no_workon_home () { @@ -65,7 +69,7 @@ test_cdvirtualenv_no_workon_home () { test_cdsitepackages_no_workon_home () { deactivate 2>&1 old_home="$WORKON_HOME" - cd "$WORKON_HOME" + virtualenvwrapper_cd "$WORKON_HOME" export WORKON_HOME="$WORKON_HOME/not_there" assertFalse "Was able to change to site-packages" cdsitepackages assertSame "$old_home" "$(pwd)" diff --git a/tests/test_cd_alias.sh b/tests/test_cd_alias.sh new file mode 100755 index 0000000..4c100fc --- /dev/null +++ b/tests/test_cd_alias.sh @@ -0,0 +1,36 @@ +# -*- mode: shell-script -*- + +test_dir=$(cd $(dirname $0) && pwd) +source "$test_dir/setup.sh" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + unset VIRTUAL_ENV + source "$test_dir/../virtualenvwrapper.sh" + mkvirtualenv cd-test >/dev/null 2>&1 + deactivate + alias cd='fail "Should not be using override cd function"' +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + workon cd-test +} + +tearDown () { + deactivate >/dev/null 2>&1 +} + +test_cd() { + start_dir="$(pwd)" + virtualenvwrapper_cd "$VIRTUAL_ENV" + assertSame "$VIRTUAL_ENV" "$(pwd)" + virtualenvwrapper_cd "$start_dir" +} + +. "$test_dir/shunit2" From 2d474d9eb905042a531833a14a390954e4d4cf5e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 10 Aug 2013 11:41:56 -0400 Subject: [PATCH 680/947] ignore any egg directories created while packaging Change-Id: Ice237d05ec1d5f75bdf2696722f920e9b45ec5b6 --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4a4ae28..dbd2d93 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ syntax: glob README.html build dist -distribute*.egg +*.egg distribute*.tar.gz docs/build docs/html From 0845b820bb6d568d98ab98006b21137e2f3457ce Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 10 Aug 2013 11:42:15 -0400 Subject: [PATCH 681/947] update test to handle change easy_install Either the new pip or the new setuptools changes the virtualenv so easy-install.pth is no longer present when the test runs, so look for easy_install itself. Change-Id: I9c3da40725d7efd6f7377df27d4666578beeb41c --- tests/test_ls.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_ls.sh b/tests/test_ls.sh index 25d8c78..7d469cb 100755 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -28,9 +28,7 @@ test_get_site_packages_dir () { test_lssitepackages () { mkvirtualenv "lssitepackagestest" >/dev/null 2>&1 contents="$(lssitepackages)" - actual=$(echo $contents | grep easy-install.pth) - expected=$(echo $contents) - assertSame "$expected" "$actual" + assertTrue "did not find easy_install in site-packages" "echo $contents | grep -q easy_install" deactivate } From fdfab8cbbd454419144d125371c6e3f67b49f4a7 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 10 Aug 2013 12:44:24 -0400 Subject: [PATCH 682/947] consolidate 'ls' tests Change-Id: I11402fbb2672ae276652fdc415d5b8ee7cdafa84 --- tests/test_ls.sh | 24 +++++++++++++++++++++- tests/test_lsvirtualenv.sh | 41 -------------------------------------- 2 files changed, 23 insertions(+), 42 deletions(-) delete mode 100755 tests/test_lsvirtualenv.sh diff --git a/tests/test_ls.sh b/tests/test_ls.sh index 7d469cb..528596c 100755 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -44,14 +44,36 @@ test_lssitepackages_add2virtualenv () { deactivate } -test_no_workon_home () { +test_lssitepackages_no_workon_home () { old_home="$WORKON_HOME" export WORKON_HOME="$WORKON_HOME/not_there" + rm -rf "$WORKON_HOME" lssitepackages >"$old_home/output" 2>&1 output=$(cat "$old_home/output") assertTrue "Did not see expected message" "echo $output | grep 'does not exist'" WORKON_HOME="$old_home" } +test_lsvirtualenv_no_workon_home () { + old_home="$WORKON_HOME" + export WORKON_HOME="$WORKON_HOME/not_there" + rm -rf "$WORKON_HOME" + lsvirtualenv >"$old_home/output" 2>&1 + output=$(cat "$old_home/output") + assertTrue "Did not see expected message" "echo $output | grep -q 'does not exist'" + WORKON_HOME="$old_home" +} + +test_lsvirtualenv_space_in_workon_home () { + old_home="$WORKON_HOME" + export WORKON_HOME="$WORKON_HOME/with space" + mkdir "$WORKON_HOME" + (cd "$WORKON_HOME"; virtualenv testenv) 2>&1 + lsvirtualenv -b >"$old_home/output" + output=$(cat "$old_home/output") + assertTrue "Did not see expected message in \"$output\"" "echo $output | grep -q 'testenv'" + WORKON_HOME="$old_home" +} + . "$test_dir/shunit2" diff --git a/tests/test_lsvirtualenv.sh b/tests/test_lsvirtualenv.sh deleted file mode 100755 index ad93946..0000000 --- a/tests/test_lsvirtualenv.sh +++ /dev/null @@ -1,41 +0,0 @@ -# -*- mode: shell-script -*- - -test_dir=$(cd $(dirname $0) && pwd) -source "$test_dir/setup.sh" - -oneTimeSetUp() { - rm -rf "$WORKON_HOME" - mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" -} - -oneTimeTearDown() { - rm -rf "$WORKON_HOME" -} - -setUp () { - echo -} - -test_no_workon_home () { - old_home="$WORKON_HOME" - export WORKON_HOME="$WORKON_HOME/not_there" - lsvirtualenv >"$old_home/output" 2>&1 - output=$(cat "$old_home/output") - assertTrue "Did not see expected message" "echo $output | grep 'does not exist'" - WORKON_HOME="$old_home" -} - -test_space_in_workon_home () { - old_home="$WORKON_HOME" - export WORKON_HOME="$WORKON_HOME/with space" - mkdir "$WORKON_HOME" - (cd "$WORKON_HOME"; virtualenv testenv) 2>&1 - lsvirtualenv -b >"$old_home/output" - output=$(cat "$old_home/output") - assertTrue "Did not see expected message in \"$output\"" "echo $output | grep 'testenv'" - WORKON_HOME="$old_home" -} - - -. "$test_dir/shunit2" From 7927d1094166f629b8d497f1e06bdd86f2eaf835 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 10 Aug 2013 16:19:15 -0400 Subject: [PATCH 683/947] update history for cd command fix Change-Id: I5ff361c73c9256a4b86d7a3be6b9bd7142c17e34 --- docs/source/history.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/history.rst b/docs/source/history.rst index b4ef117..d5a780d 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -7,6 +7,8 @@ dev - Add ``tmp-`` prefix to temporary environment names created by :ref:`command-mktmpenv`. +- Fix some uses of ``cd`` that did not account for possible + aliasing. Contributed by Ismail Badawi (:bbuser:`ibadawi`). 4.1.1 ===== From 6031a9c8d2b25d9799f435465597395f1dd4e250 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 10 Aug 2013 16:20:55 -0400 Subject: [PATCH 684/947] update history for doc fix from dirn Change-Id: I364fd9d5b7b527d2509124393992778f8abd7196 --- docs/source/history.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/history.rst b/docs/source/history.rst index d5a780d..3dab3f9 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -9,6 +9,8 @@ dev :ref:`command-mktmpenv`. - Fix some uses of ``cd`` that did not account for possible aliasing. Contributed by Ismail Badawi (:bbuser:`ibadawi`). +- Fix documentation for :ref:`command-allvirtualenv`, contributed by + Andy Dirnberger (:bbuser:`dirn`). 4.1.1 ===== From 2fa26432c5fa7357798970902ff36520f7d1a6cb Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 10 Aug 2013 17:19:32 -0400 Subject: [PATCH 685/947] document new force option in history Change-Id: I5c5200f65f92c574d408e0aec68afbf74012d8d8 --- docs/source/history.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/history.rst b/docs/source/history.rst index 3dab3f9..ed140f1 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -11,6 +11,8 @@ dev aliasing. Contributed by Ismail Badawi (:bbuser:`ibadawi`). - Fix documentation for :ref:`command-allvirtualenv`, contributed by Andy Dirnberger (:bbuser:`dirn`). +- Add ``--force`` option to :ref:`command-mkproject`, contributed by + Clay McClure (:bbuser:`claymcclure`). 4.1.1 ===== From f0f0077888c00aa1f3cc810c3de7767a8441a679 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 10 Aug 2013 18:46:28 -0400 Subject: [PATCH 686/947] use virtualenvwrapper_cd in project plugin Change-Id: If75e95fb7b29207496906a166dd7bd5bd97549b5 --- virtualenvwrapper/project.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/virtualenvwrapper/project.py b/virtualenvwrapper/project.py index 61c9749..0d9769d 100644 --- a/virtualenvwrapper/project.py +++ b/virtualenvwrapper/project.py @@ -58,5 +58,6 @@ def post_activate_source(args): # Change to the project directory # [ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" ] && \ - cd "$(cat \"$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME\")" + virtualenvwrapper_cd \ + "$(cat \"$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME\")" """ From 9cb762aac3184f3303fd7371d88b5696537693f9 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Tue, 15 Oct 2013 16:05:13 +0200 Subject: [PATCH 687/947] Fix `which` with virtualenvwrapper_lazy.sh `command \which` is used in virtualenvwrapper.sh, and it fixes an infinite loop, because VIRTUALENVWRAPPER_SCRIPT is not being setup correctly. In my zsh setup: % which virtualenvwrapper.sh sh: suffix aliased to zsh-mime-handler % command which virtualenvwrapper.sh /usr/local/bin/virtualenvwrapper.sh An alternative might be to use `which -p`, but that is probably zsh-only (not portable). --- virtualenvwrapper_lazy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper_lazy.sh b/virtualenvwrapper_lazy.sh index 4f859ca..bd657e1 100644 --- a/virtualenvwrapper_lazy.sh +++ b/virtualenvwrapper_lazy.sh @@ -5,7 +5,7 @@ export _VIRTUALENVWRAPPER_API="$_VIRTUALENVWRAPPER_API mkvirtualenv rmvirtualenv if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ] then - export VIRTUALENVWRAPPER_SCRIPT="$(which virtualenvwrapper.sh)" + export VIRTUALENVWRAPPER_SCRIPT="$(command \which virtualenvwrapper.sh)" fi if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ] then From b42552bfbc2b19777620f9d686af502f549c2a6b Mon Sep 17 00:00:00 2001 From: Stephen McQuay Date: Thu, 31 Oct 2013 12:42:29 -0700 Subject: [PATCH 688/947] changed spelling of proj_name calculation I found the echo|awk to be a bit harder to reason about. --- docs/source/tips.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/tips.rst b/docs/source/tips.rst index 2d08521..b999079 100644 --- a/docs/source/tips.rst +++ b/docs/source/tips.rst @@ -67,7 +67,7 @@ In the ``postmkvirtualenv`` script I have the following to create a directory based on the project name, add that directory to the python path and then cd into it:: - proj_name=$(echo $VIRTUAL_ENV|awk -F'/' '{print $NF}') + proj_name=$(basename $VIRTUAL_ENV) mkdir $HOME/projects/$proj_name add2virtualenv $HOME/projects/$proj_name cd $HOME/projects/$proj_name @@ -76,7 +76,7 @@ path and then cd into it:: In the ``postactivate`` script I have it set to automatically change to the project directory when I use the workon command:: - proj_name=$(echo $VIRTUAL_ENV|awk -F'/' '{print $NF}') + proj_name=$(basename $VIRTUAL_ENV) cd ~/projects/$proj_name Automatically Run workon When Entering a Directory From c75687878285e9702fd384f25995536a04f2e7dd Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 3 Nov 2013 00:42:24 +0100 Subject: [PATCH 689/947] Fix hint in error message, when virtualenvwrapper_run_hook failed This error happens, if you are using virtualenvwrapper_lazy.sh and then spawn a new shell install (`zsh`) in a virtualenv (spawned with `workon` before). --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 406d986..27e1bd2 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -229,7 +229,7 @@ function virtualenvwrapper_run_hook { virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, -check that virtualenv has been installed for +check that virtualenvwrapper has been installed for VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON and that PATH is set properly. EOF From 6a21bcd8c12e3f10dcf2797e0d08d91814a00138 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 10 Jan 2014 01:16:04 +0100 Subject: [PATCH 690/947] Fix zsh crash caused by lazily loading the completions Should be considered work in progress: please pick it up. See https://bitbucket.org/dhellmann/virtualenvwrapper/issue/215 --- virtualenvwrapper_lazy.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/virtualenvwrapper_lazy.sh b/virtualenvwrapper_lazy.sh index 4f859ca..4dd1cba 100644 --- a/virtualenvwrapper_lazy.sh +++ b/virtualenvwrapper_lazy.sh @@ -14,7 +14,17 @@ fi # Load the real implementation of the API from virtualenvwrapper.sh function virtualenvwrapper_load { - source "$VIRTUALENVWRAPPER_SCRIPT" + # Only source the script once. + # We might get called multiple times, because not all of _VIRTUALENVWRAPPER_API gets + # a real completion. + if [ -z $VIRTUALENVWRAPPER_LAZY_LOADED ]; then + if [ -n "$ZSH_VERSION" ] ; then + # Tried to unset any auto-load completion, does not appear to work/triggers a crash + # compctl + $(echo ${_VIRTUALENVWRAPPER_API}) + fi + source "$VIRTUALENVWRAPPER_SCRIPT" + VIRTUALENVWRAPPER_LAZY_LOADED=1 + fi } # Set up "alias" functions based on the API definition. @@ -41,4 +51,6 @@ function virtualenvwrapper_setup_lazy_completion { } virtualenvwrapper_setup_lazy_loader +# Does not really work. Cannot be reset in zsh to fallback to files (e.g. mkvirtualenv). +# It also needs a second invocation, because the first one only sets up the real completion. virtualenvwrapper_setup_lazy_completion From a8f330aacf2323e1946cd39a17fe8d6fb583f187 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 10 Jan 2014 01:31:40 +0100 Subject: [PATCH 691/947] minor: tabs to spaces --- virtualenvwrapper_lazy.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/virtualenvwrapper_lazy.sh b/virtualenvwrapper_lazy.sh index bd657e1..95f73c6 100644 --- a/virtualenvwrapper_lazy.sh +++ b/virtualenvwrapper_lazy.sh @@ -5,11 +5,11 @@ export _VIRTUALENVWRAPPER_API="$_VIRTUALENVWRAPPER_API mkvirtualenv rmvirtualenv if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ] then - export VIRTUALENVWRAPPER_SCRIPT="$(command \which virtualenvwrapper.sh)" + export VIRTUALENVWRAPPER_SCRIPT="$(command \which virtualenvwrapper.sh)" fi if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ] then - echo "ERROR: virtualenvwrapper_lazy.sh: Could not find virtualenvwrapper.sh" 1>&2 + echo "ERROR: virtualenvwrapper_lazy.sh: Could not find virtualenvwrapper.sh" 1>&2 fi # Load the real implementation of the API from virtualenvwrapper.sh @@ -20,15 +20,15 @@ function virtualenvwrapper_load { # Set up "alias" functions based on the API definition. function virtualenvwrapper_setup_lazy_loader { typeset venvw_name - for venvw_name in $(echo ${_VIRTUALENVWRAPPER_API}) - do - eval " + for venvw_name in $(echo ${_VIRTUALENVWRAPPER_API}) + do + eval " function $venvw_name { - virtualenvwrapper_load - ${venvw_name} \"\$@\" + virtualenvwrapper_load + ${venvw_name} \"\$@\" } " - done + done } # Set up completion functions to virtualenvwrapper_load From 9c004a336adcabe940b50704bf7bc6cfe2781f3b Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Jan 2014 10:51:00 -0500 Subject: [PATCH 692/947] Fix mkvirtualenv -a relative paths Ensure that the path passed to mkvirtualenv -a is a directory and expand the path before writing it to the .project file in case the value given was a relative directory name. Change-Id: I4abd72b87be7edc0785387dc1bb7f99dc2f4b500 --- docs/source/history.rst | 2 + tests/test_mkvirtualenv_associate.sh | 67 +++++++++++++++++++++++++--- virtualenvwrapper.sh | 7 +++ 3 files changed, 70 insertions(+), 6 deletions(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index ed140f1..20d17a7 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -13,6 +13,8 @@ dev Andy Dirnberger (:bbuser:`dirn`). - Add ``--force`` option to :ref:`command-mkproject`, contributed by Clay McClure (:bbuser:`claymcclure`). +- Fix handling for project directory argument ``-a`` to + :ref:`command-mkvirtualenv`, based on work by Xupeng Yun. 4.1.1 ===== diff --git a/tests/test_mkvirtualenv_associate.sh b/tests/test_mkvirtualenv_associate.sh index dc005a7..614d328 100755 --- a/tests/test_mkvirtualenv_associate.sh +++ b/tests/test_mkvirtualenv_associate.sh @@ -19,20 +19,57 @@ setUp () { echo "#!/bin/sh" > "$WORKON_HOME/preactivate" echo "#!/bin/sh" > "$WORKON_HOME/postactivate" rm -f "$TMPDIR/catch_output" + cd "$WORKON_HOME" } test_associate() { - project="/dev/null" - env="env1" + n=1 + project="$WORKON_HOME/project$n" + mkdir "$project" + env="env$n" ptrfile="$WORKON_HOME/$env/.project" mkvirtualenv -a "$project" "$env" >/dev/null 2>&1 assertTrue ".project not found" "[ -f $ptrfile ]" assertEquals "$ptrfile contains wrong content" "$project" "$(cat $ptrfile)" } +test_associate_relative_path() { + n=2 + project="project$n" + mkdir "$project" + env="env$n" + ptrfile="$WORKON_HOME/$env/.project" + mkvirtualenv -a "$project" "$env" >/dev/null 2>&1 + assertTrue ".project not found" "[ -f $ptrfile ]" + assertEquals "$ptrfile contains wrong content" "$WORKON_HOME/$project" "$(cat $ptrfile)" +} + +test_associate_not_a_directory() { + n=3 + project="project$n" + touch "$project" + env="env$n" + ptrfile="$WORKON_HOME/$env/.project" + mkvirtualenv -a "$project" "$env" >/dev/null 2>&1 + RC=$? + assertTrue "mkvirtualenv should have failed" "[ $RC -ne 0 ]" +} + +test_associate_does_not_exist() { + n=4 + project="project$n" + env="env$n" + ptrfile="$WORKON_HOME/$env/.project" + mkvirtualenv -a "$project" "$env" >/dev/null 2>&1 + RC=$? + assertTrue "mkvirtualenv should have failed" "[ $RC -ne 0 ]" +} + test_preactivate() { - project="/dev/null" - env="env2" + n=5 + project="project$n" + mkdir "$project" + env="env$n" ptrfile="$WORKON_HOME/$env/.project" cat - >"$WORKON_HOME/preactivate" <"$WORKON_HOME/postactivate" </dev/null 2>&1 + assertTrue ".project not found" "[ -f $ptrfile ]" + assertEquals "$ptrfile contains wrong content" "$WORKON_HOME/project$n" "$(cat $ptrfile)" +} + . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 406d986..a864795 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -383,6 +383,7 @@ function mkvirtualenv { typeset requirements typeset packages typeset interpreter + typeset project in_args=( "$@" ) @@ -402,6 +403,12 @@ function mkvirtualenv { -a) i=$(( $i + 1 )); project="${in_args[$i]}";; + if [ ! -d "$project" ] + then + echo "$project is not a directory" 1>&2 + return 1 + fi + project="$(virtualenvwrapper_absolutepath ${project})";; -h|--help) virtualenvwrapper_mkvirtualenv_help $a; return;; From 75cb21e7b577bec07743883b0335679272a07848 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Jan 2014 11:01:00 -0500 Subject: [PATCH 693/947] fix merge issue from previous commit Change-Id: If9a6af3fa78abd6fe98dcd77d274910f802937d5 --- virtualenvwrapper.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index a864795..763d07f 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -401,8 +401,8 @@ function mkvirtualenv { # echo "arg $i : $a" case "$a" in -a) - i=$(( $i + 1 )); - project="${in_args[$i]}";; + i=$(( $i + 1 )) + project="${in_args[$i]}" if [ ! -d "$project" ] then echo "$project is not a directory" 1>&2 From a01c5e04365a7c2216a7eb09235b33c48a3135f6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Jan 2014 13:12:12 -0500 Subject: [PATCH 694/947] stop using distribute for packaging the test templates --- tests/testtemplate/distribute_setup.py | 477 ------------------------- tests/testtemplate/setup.py | 74 ++-- 2 files changed, 36 insertions(+), 515 deletions(-) delete mode 100644 tests/testtemplate/distribute_setup.py diff --git a/tests/testtemplate/distribute_setup.py b/tests/testtemplate/distribute_setup.py deleted file mode 100644 index 0021336..0000000 --- a/tests/testtemplate/distribute_setup.py +++ /dev/null @@ -1,477 +0,0 @@ -#!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 sys -import time -import fnmatch -import tempfile -import tarfile -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.10" -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): - # 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'): - log.warn('Something went wrong during the installation.') - log.warn('See the error message above.') - finally: - os.chdir(old_wd) - - -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) - # 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 _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 - - -def _same_content(path, content): - return open(path).read() == content - -def _no_sandbox(function): - def __no_sandbox(*args, **kw): - try: - from setuptools.sandbox import DirectorySandbox - def violation(*args): - pass - DirectorySandbox._old = DirectorySandbox._violation - DirectorySandbox._violation = violation - patched = True - except ImportError: - patched = False - - try: - return function(*args, **kw) - finally: - if patched: - DirectorySandbox._violation = DirectorySandbox._old - del DirectorySandbox._old - - return __no_sandbox - -@_no_sandbox -def _rename_path(path): - new_name = path + '.OLD.%s' % time.time() - log.warn('Renaming %s into %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('Removing 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 - - -def _after_install(dist): - log.warn('After install bootstrap.') - placeholder = dist.get_command_obj('install').install_purelib - _create_fake_setuptools_pkg_info(placeholder) - -@_no_sandbox -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) - f = open(pkg_info, 'w') - 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() - -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 - - -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) - elif option == '--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('Patched done.') - _relaunch() - - -def _relaunch(): - log.warn('Relaunching...') - # we have to relaunch the process - 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 main(argv, version=DEFAULT_VERSION): - """Install or upgrade setuptools and EasyInstall""" - tarball = download_setuptools() - _install(tarball) - - -if __name__ == '__main__': - main(sys.argv[1:]) diff --git a/tests/testtemplate/setup.py b/tests/testtemplate/setup.py index 75032c1..f18835e 100644 --- a/tests/testtemplate/setup.py +++ b/tests/testtemplate/setup.py @@ -3,10 +3,6 @@ PROJECT = 'testtemplate' VERSION = '1.0' -# Bootstrap installation of Distribute -import distribute_setup -distribute_setup.use_setuptools() - from setuptools import setup, find_packages from distutils.util import convert_path @@ -15,7 +11,7 @@ import os import sys -################################################################################ +############################################################################## # find_package_data is an Ian Bicking creation. # Provided as an attribute, so you can append to these instead @@ -24,12 +20,13 @@ standard_exclude_directories = ('.*', 'CVS', '_darcs', './build', './dist', 'EGG-INFO', '*.egg-info') + def find_package_data( - where='.', package='', - exclude=standard_exclude, - exclude_directories=standard_exclude_directories, - only_in_packages=True, - show_ignored=False): + where='.', package='', + exclude=standard_exclude, + exclude_directories=standard_exclude_directories, + only_in_packages=True, + show_ignored=False): """ Return a dictionary suitable for use in ``package_data`` in a distutils ``setup.py`` file. @@ -55,7 +52,7 @@ def find_package_data( Note patterns use wildcards, or can be exact paths (including leading ``./``), and all searching is case-insensitive. - + This function is by Ian Bicking. """ @@ -102,27 +99,28 @@ def find_package_data( continue out.setdefault(package, []).append(prefix+name) return out -################################################################################ +############################################################################## setup( - name = PROJECT, - version = VERSION, - - description = 'template for testing mkproject', - - author = 'Doug Hellmann', - author_email = 'doug.hellmann@gmail.com', + name=PROJECT, + version=VERSION, + + description='template for testing mkproject', + + author='Doug Hellmann', + author_email='doug.hellmann@gmail.com', - url = 'http://www.doughellmann.com/projects/virtualenvwrapper/', + url='http://www.doughellmann.com/projects/virtualenvwrapper/', - classifiers = [ 'Development Status :: 5 - Production/Stable', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: Python', - 'Intended Audience :: Developers', - 'Environment :: Console', - ], + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'License :: OSI Approved :: BSD License', + 'Programming Language :: Python', + 'Intended Audience :: Developers', + 'Environment :: Console', + ], - platforms = ['Any'], + platforms=['Any'], provides=['testtemplate', ], @@ -130,21 +128,21 @@ def find_package_data( 'virtualenvwrapper (>=2.9)', ], - packages = find_packages(), - include_package_data = True, + packages=find_packages(), + include_package_data=True, # Scan the input for package information - # to grab any data files (text, images, etc.) + # to grab any data files (text, images, etc.) # associated with sub-packages. - package_data = find_package_data('mytemplates', - package='mytemplates', - only_in_packages=False, - ), + package_data=find_package_data('mytemplates', + package='mytemplates', + only_in_packages=False, + ), - entry_points = { + entry_points={ 'virtualenvwrapper.project.template': [ 'test = mytemplates.main:template', - ], - }, + ], + }, zip_safe=False, - ) +) From 76fde8bb800227545b335f159eee676c12e3f339 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Jan 2014 13:14:33 -0500 Subject: [PATCH 695/947] stop python 3.2 tests Change-Id: Iea9e3020b73deefdf5ac978f7912748c03337ef7 --- docs/source/history.rst | 1 + setup.cfg | 1 - tox.ini | 7 +------ 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index 20d17a7..de850c4 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -15,6 +15,7 @@ dev Clay McClure (:bbuser:`claymcclure`). - Fix handling for project directory argument ``-a`` to :ref:`command-mkvirtualenv`, based on work by Xupeng Yun. +- Dropped python 3.2 testing. 4.1.1 ===== diff --git a/setup.cfg b/setup.cfg index d522701..ccab286 100644 --- a/setup.cfg +++ b/setup.cfg @@ -13,7 +13,6 @@ classifier = Programming Language :: Python :: 2.6 Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 - Programming Language :: Python :: 3.2 Programming Language :: Python :: 3.3 Intended Audience :: Developers Environment :: Console diff --git a/tox.ini b/tox.ini index 2972049..eb0df1d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py26,py32,py33,zsh,ksh,style +envlist = py27,py26,py33,zsh,ksh,style [testenv] commands = bash ./tests/run_tests {envdir} [] @@ -31,11 +31,6 @@ setenv = SHELL = /bin/bash commands = bash ./tests/run_tests {envdir} [] -[testenv:py32] -setenv = - SHELL = /bin/bash -commands = bash ./tests/run_tests {envdir} [] - [testenv:py33] setenv = SHELL = /bin/bash From f96beafe7750e22a8e66a27b65f7488e9f71ac7c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Jan 2014 13:14:52 -0500 Subject: [PATCH 696/947] use valid syntax for creating tmpdir under linux Change-Id: I73b22a7803ffcf08f6bd3f46147b46be33d718c2 --- docs/source/history.rst | 1 + tests/setup.sh | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index de850c4..a226dae 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -16,6 +16,7 @@ dev - Fix handling for project directory argument ``-a`` to :ref:`command-mkvirtualenv`, based on work by Xupeng Yun. - Dropped python 3.2 testing. +- Updated test configuration so they work properly under Linux. 4.1.1 ===== diff --git a/tests/setup.sh b/tests/setup.sh index decab8f..6e006fb 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -6,7 +6,7 @@ # export WORKON_HOME="$(echo ${tmplocation}/WORKON_HOME.$$ | sed 's|//|/|g')" # export PROJECT_HOME="$(echo ${tmplocation}/PROJECT_HOME.$$ | sed 's|//|/|g')" -export WORKON_HOME=$(mktemp -d -t "WORKON_HOME.$$") -export PROJECT_HOME=$(mktemp -d -t "PROJECT_HOME.$$") +export WORKON_HOME=$(mktemp -d -t "WORKON_HOME.XXXX.$$") +export PROJECT_HOME=$(mktemp -d -t "PROJECT_HOME.XXXX.$$") #unset HOOK_VERBOSE_OPTION From ff1edc4cdd6ff994b358a12bac2d469b9259000e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Jan 2014 13:55:00 -0500 Subject: [PATCH 697/947] fix indentation in virtualenvwrapper_lazy.sh Change-Id: I9e5df375e8575cd39cb3a92bee9f986ff93f9f52 --- virtualenvwrapper_lazy.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/virtualenvwrapper_lazy.sh b/virtualenvwrapper_lazy.sh index 4f859ca..d9417ab 100644 --- a/virtualenvwrapper_lazy.sh +++ b/virtualenvwrapper_lazy.sh @@ -5,11 +5,11 @@ export _VIRTUALENVWRAPPER_API="$_VIRTUALENVWRAPPER_API mkvirtualenv rmvirtualenv if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ] then - export VIRTUALENVWRAPPER_SCRIPT="$(which virtualenvwrapper.sh)" + export VIRTUALENVWRAPPER_SCRIPT="$(which virtualenvwrapper.sh)" fi if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ] then - echo "ERROR: virtualenvwrapper_lazy.sh: Could not find virtualenvwrapper.sh" 1>&2 + echo "ERROR: virtualenvwrapper_lazy.sh: Could not find virtualenvwrapper.sh" 1>&2 fi # Load the real implementation of the API from virtualenvwrapper.sh @@ -20,15 +20,15 @@ function virtualenvwrapper_load { # Set up "alias" functions based on the API definition. function virtualenvwrapper_setup_lazy_loader { typeset venvw_name - for venvw_name in $(echo ${_VIRTUALENVWRAPPER_API}) - do - eval " + for venvw_name in $(echo ${_VIRTUALENVWRAPPER_API}) + do + eval " function $venvw_name { - virtualenvwrapper_load - ${venvw_name} \"\$@\" + virtualenvwrapper_load + ${venvw_name} \"\$@\" } " - done + done } # Set up completion functions to virtualenvwrapper_load From f47faa6b8f26500a47df3c9287c1d8c5ca3bfbcb Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Jan 2014 14:07:26 -0500 Subject: [PATCH 698/947] Ensure hook directory exists If the VIRTUALENVWRAPPER_HOOK_DIR does not exist, create it before initializing the hooks. --- virtualenvwrapper.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 763d07f..567bea2 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -288,6 +288,8 @@ function virtualenvwrapper_initialize { export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME" fi + mkdir -p "$VIRTUALENVWRAPPER_HOOK_DIR" + virtualenvwrapper_run_hook "initialize" virtualenvwrapper_setup_tab_completion From 8b95f34cc34fcdfc8ce622f9ae90f7631634db1c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Jan 2014 14:46:53 -0500 Subject: [PATCH 699/947] make setvirtualenvproject honor relative paths Resolve relative paths before storing the project directory reference. Fixes #207 Change-Id: I9bd37207a5ecf2aec09f0d0e32a95ddee881315f --- docs/source/history.rst | 2 + tests/test_setvirtualenvproject.sh | 89 ++++++++++++++++++++++++++++++ virtualenvwrapper.sh | 26 ++++++++- 3 files changed, 116 insertions(+), 1 deletion(-) create mode 100755 tests/test_setvirtualenvproject.sh diff --git a/docs/source/history.rst b/docs/source/history.rst index a226dae..1af3f4a 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -17,6 +17,8 @@ dev :ref:`command-mkvirtualenv`, based on work by Xupeng Yun. - Dropped python 3.2 testing. - Updated test configuration so they work properly under Linux. +- Resolve relative paths before storing the project directory + reference in :ref:`command-setvirtualenvproject`. (:bbissue:`207`) 4.1.1 ===== diff --git a/tests/test_setvirtualenvproject.sh b/tests/test_setvirtualenvproject.sh new file mode 100755 index 0000000..5fc7be3 --- /dev/null +++ b/tests/test_setvirtualenvproject.sh @@ -0,0 +1,89 @@ +# -*- mode: shell-script -*- + +test_dir=$(dirname $0) +source "$test_dir/setup.sh" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + rm -rf "$PROJECT_HOME" + mkdir -p "$PROJECT_HOME" + source "$test_dir/../virtualenvwrapper.sh" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" + rm -rf "$PROJECT_HOME" +} + +setUp () { + echo +} + +test_setvirtualenvproject() { + n=1 + project="$WORKON_HOME/project$n" + mkdir "$project" + env="env$n" + ptrfile="$WORKON_HOME/$env/.project" + mkvirtualenv "$env" >/dev/null 2>&1 + setvirtualenvproject "$env" "$project" >/dev/null 2>&1 + assertTrue ".project not found" "[ -f $ptrfile ]" + assertEquals "$ptrfile contains wrong content" "$project" "$(cat $ptrfile)" +} + +test_setvirtualenvproject_relative_path() { + cd "$WORKON_HOME" + n=2 + project="project$n" + mkdir "$project" + env="env$n" + ptrfile="$WORKON_HOME/$env/.project" + mkvirtualenv "$env" >/dev/null 2>&1 + setvirtualenvproject "$env" "$project" >/dev/null 2>&1 + assertTrue ".project not found" "[ -f $ptrfile ]" + assertEquals "$ptrfile contains wrong content" "$WORKON_HOME/$project" "$(cat $ptrfile)" +} + +test_setvirtualenvproject_not_a_directory() { + cd "$WORKON_HOME" + n=3 + project="project$n" + touch "$project" + env="env$n" + ptrfile="$WORKON_HOME/$env/.project" + mkvirtualenv "$env" >/dev/null 2>&1 + setvirtualenvproject "$env" "$project" >/dev/null 2>&1 + RC=$? + assertTrue "setvirtualenvproject should have failed" "[ $RC -ne 0 ]" +} + +test_setvirtualenvproject_does_not_exist() { + n=4 + project="project$n" + env="env$n" + ptrfile="$WORKON_HOME/$env/.project" + mkvirtualenv "$env" >/dev/null 2>&1 + setvirtualenvproject "$env" "$project" >/dev/null 2>&1 + RC=$? + assertTrue "setvirtualenvproject should have failed" "[ $RC -ne 0 ]" +} + +test_setvirtualenvproject_relative_with_dots() { + cd "$WORKON_HOME" + n=5 + project="project$n" + mkdir $project + mkdir $project.sibling + cd $project.sibling + # Change the reference to a sibling directory + project="../$project" + env="env$n" + ptrfile="$WORKON_HOME/$env/.project" + mkvirtualenv "$env" >/dev/null 2>&1 + setvirtualenvproject "$env" "$project" >/dev/null 2>&1 + assertTrue ".project not found" "[ -f $ptrfile ]" + assertEquals "$ptrfile contains wrong content" "$WORKON_HOME/project$n" "$(cat $ptrfile)" +} + +. "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 567bea2..b7c1240 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -407,7 +407,7 @@ function mkvirtualenv { project="${in_args[$i]}" if [ ! -d "$project" ] then - echo "$project is not a directory" 1>&2 + echo "Cannot associate project with $project, it is not a directory" 1>&2 return 1 fi project="$(virtualenvwrapper_absolutepath ${project})";; @@ -471,6 +471,8 @@ function mkvirtualenv { if [ ! -z "$project" ] then setvirtualenvproject "$WORKON_HOME/$envname" "$project" + RC=$? + [ $RC -ne 0 ] && return $RC fi # Now activate the new environment @@ -976,7 +978,29 @@ function setvirtualenvproject { if [ -z "$prj" ] then prj="$(pwd)" + else + prj=$(virtualenvwrapper_absolutepath "${prj}") fi + + # If what we were given isn't a directory, see if it is under + # $WORKON_HOME. + if [ ! -d "$venv" ] + then + venv="$WORKON_HOME/$venv" + fi + if [ ! -d "$venv" ] + then + echo "No virtualenv $(basename $venv)" 1>&2 + return 1 + fi + + # Make sure we have a valid project setting + if [ ! -d "$prj" ] + then + echo "Cannot associate virtualenv with \"$prj\", it is not a directory" 1>&2 + return 1 + fi + echo "Setting project for $(basename $venv) to $prj" echo "$prj" > "$venv/$VIRTUALENVWRAPPER_PROJECT_FILENAME" } From b34dcc12024e18f4de8ee3dfcdd5d626abef335f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Jan 2014 14:53:37 -0500 Subject: [PATCH 700/947] Do not create hooks for rmproject There is no rmproject command, so it does not need hooks. Fixes #203 Change-Id: I69f4bf032eef01cd5dbfe0e33df86b17a77cf198 --- docs/source/history.rst | 1 + tests/test_project.sh | 4 ++-- virtualenvwrapper/project.py | 6 ------ 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index 1af3f4a..28dd75d 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -19,6 +19,7 @@ dev - Updated test configuration so they work properly under Linux. - Resolve relative paths before storing the project directory reference in :ref:`command-setvirtualenvproject`. (:bbissue:`207`) +- Do not create hooks for commands that don't exist. (:bbissue:`203`) 4.1.1 ===== diff --git a/tests/test_project.sh b/tests/test_project.sh index 256ed16..f58d5c5 100755 --- a/tests/test_project.sh +++ b/tests/test_project.sh @@ -22,7 +22,7 @@ setUp () { test_initialize() { source "$test_dir/../virtualenvwrapper.sh" - for hook in premkproject postmkproject prermproject postrmproject + for hook in premkproject postmkproject do assertTrue "Global $hook was not created" "[ -f $WORKON_HOME/$hook ]" assertTrue "Global $hook is not executable" "[ -x $WORKON_HOME/$hook ]" @@ -33,7 +33,7 @@ test_initialize_hook_dir() { export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME/hooks" mkdir -p "$VIRTUALENVWRAPPER_HOOK_DIR" source "$test_dir/../virtualenvwrapper.sh" - for hook in premkproject postmkproject prermproject postrmproject + for hook in premkproject postmkproject do assertTrue "Global $hook was not created" "[ -f $VIRTUALENVWRAPPER_HOOK_DIR/$hook ]" assertTrue "Global $hook is not executable" "[ -x $VIRTUALENVWRAPPER_HOOK_DIR/$hook ]" diff --git a/virtualenvwrapper/project.py b/virtualenvwrapper/project.py index 0d9769d..9c3f8fa 100644 --- a/virtualenvwrapper/project.py +++ b/virtualenvwrapper/project.py @@ -19,12 +19,6 @@ "and before it is activated."), ("postmkproject", "This hook is run after a new project is activated."), - - # rmproject - ("prermproject", - "This hook is run before a project is deleted."), - ("postrmproject", - "This hook is run after a project is deleted."), ] From b97e1b9e66df8d47b3d956288cf33d2745471af4 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 12 Jan 2014 12:02:22 -0500 Subject: [PATCH 701/947] update history Change-Id: I3a38d16bc6deec3b1343e5204e47f787e5cd5ba3 --- docs/source/history.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index 28dd75d..e852d54 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -19,7 +19,10 @@ dev - Updated test configuration so they work properly under Linux. - Resolve relative paths before storing the project directory reference in :ref:`command-setvirtualenvproject`. (:bbissue:`207`) -- Do not create hooks for commands that don't exist. (:bbissue:`203`) +- Do not create hooks for rmproject, since there is no such + command. (:bbissue:`203`) +- Update the tests to use a valid template for creating temporary + directories under Linux. 4.1.1 ===== From 1f93c03819010696776144dd80f1f30f6352dcbe Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 12 Jan 2014 12:13:21 -0500 Subject: [PATCH 702/947] update history for previous change; fix syntax issue in previous change Change-Id: Ia9842213c5a4fc86c9c36019f13c37c139da8965 --- docs/source/history.rst | 4 ++++ virtualenvwrapper_lazy.sh | 12 +++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index e852d54..1077c62 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -23,6 +23,10 @@ dev command. (:bbissue:`203`) - Update the tests to use a valid template for creating temporary directories under Linux. +- Fix the use of ``which`` in ``virtualenvwrapper_lazy.sh`` in case it + is aliased. +- Fix an issue with recursion in completion expansion crashing zsh, + contributed by :bbuser:`blueyed`. 4.1.1 ===== diff --git a/virtualenvwrapper_lazy.sh b/virtualenvwrapper_lazy.sh index 5987cac..1d28efb 100644 --- a/virtualenvwrapper_lazy.sh +++ b/virtualenvwrapper_lazy.sh @@ -17,11 +17,13 @@ function virtualenvwrapper_load { # Only source the script once. # We might get called multiple times, because not all of _VIRTUALENVWRAPPER_API gets # a real completion. - if [ -z $VIRTUALENVWRAPPER_LAZY_LOADED ]; then - if [ -n "$ZSH_VERSION" ] ; then - # Tried to unset any auto-load completion, does not appear to work/triggers a crash - # compctl + $(echo ${_VIRTUALENVWRAPPER_API}) - fi + if [ -z $VIRTUALENVWRAPPER_LAZY_LOADED ] + then + # if [ -n "$ZSH_VERSION" ] + # then + # # Tried to unset any auto-load completion, does not appear to work/triggers a crash + # # compctl + $(echo ${_VIRTUALENVWRAPPER_API}) + # fi source "$VIRTUALENVWRAPPER_SCRIPT" VIRTUALENVWRAPPER_LAZY_LOADED=1 fi From b1f020bd54c1cbcdff6b01c3655b5aaabe9bcece Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 12 Jan 2014 12:22:41 -0500 Subject: [PATCH 703/947] update docs for 4.2 release Change-Id: Ie4e1997b2c19e9dd8dfb19ae3508f150895da11e --- announce.rst | 37 +++++++++++++++++++------------------ docs/source/history.rst | 2 +- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/announce.rst b/announce.rst index c2fee92..0ac4156 100644 --- a/announce.rst +++ b/announce.rst @@ -1,5 +1,5 @@ ======================= - virtualenvwrapper 4.1 + virtualenvwrapper 4.2 ======================= .. tags:: virtualenvwrapper release python @@ -16,23 +16,24 @@ introducing conflicts in their dependencies. What's New? =========== -- Ensure that all ``$()`` style commands that produce paths are - quoted; addresses issue 164. -- Add ``wipeenv`` command for removing all packages installed in the - virtualenv. -- Allow users of ``virtualenvwrapper_lazy.sh`` to extend the list of - API commands that trigger the lazy-loader by extending - ``_VIRTUALENVWRAPPER_API``. Patch contributed by John Purnell, see - issue 188. -- Fix detection of ``--python`` option to ``mkvirtualenv``. Resolves - issue 190. -- Add ``allvirtualenv`` command to run a command across all - virtualenvs. Suggested by Dave Coutts in issue 186. -- Fix ``lsvirtualenv`` when there are spaces in - ``WORKON_HOME``. Resolves issue 194. -- Switch to `pbr`_ for packaging. - -.. _pbr: https://github.com/openstack-dev/pbr +- Add ``tmp-`` prefix to temporary environment names created by + ``mktmpenv``. +- Fix some uses of ``cd`` that did not account for possible + aliasing. Contributed by Ismail Badawi. +- Fix documentation for ``allvirtualenv``, contributed by + Andy Dirnberger. +- Add ``--force`` option to ``mkproject``, contributed by + Clay McClure. +- Fix handling for project directory argument ``-a`` to + ``mkvirtualenv``, based on work by Xupeng Yun. +- Dropped python 3.2 testing. +- Updated test configuration so they work properly under Linux. +- Resolve relative paths before storing the project directory + reference in ``setvirtualenvproject``. (issue 207) +- Do not create hooks for rmproject, since there is no such + command. (issue 203) +- Update the tests to use a valid template for creating temporary + directories under Linux. Installing ========== diff --git a/docs/source/history.rst b/docs/source/history.rst index e852d54..d9f95f2 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -2,7 +2,7 @@ Release History =============== -dev +4.2 === - Add ``tmp-`` prefix to temporary environment names created by From 6a8c168518f9daa0bda573fb74302530c95c44d1 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 12 Jan 2014 20:14:17 +0100 Subject: [PATCH 704/947] Fix syntax error (empty `if` block) Ref: https://bitbucket.org/dhellmann/virtualenvwrapper/pull-request/10/fix-zsh-crash-caused-by-lazily-loading-the/diff#comment-1046076 --- virtualenvwrapper_lazy.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/virtualenvwrapper_lazy.sh b/virtualenvwrapper_lazy.sh index 4dd1cba..37aec18 100644 --- a/virtualenvwrapper_lazy.sh +++ b/virtualenvwrapper_lazy.sh @@ -18,10 +18,10 @@ function virtualenvwrapper_load { # We might get called multiple times, because not all of _VIRTUALENVWRAPPER_API gets # a real completion. if [ -z $VIRTUALENVWRAPPER_LAZY_LOADED ]; then - if [ -n "$ZSH_VERSION" ] ; then - # Tried to unset any auto-load completion, does not appear to work/triggers a crash - # compctl + $(echo ${_VIRTUALENVWRAPPER_API}) - fi + # NOTE: For Zsh, I have tried to unset any auto-load completion. + # (via `compctl + $(echo ${_VIRTUALENVWRAPPER_API})`. + # But this does not appear to work / triggers a crash. + source "$VIRTUALENVWRAPPER_SCRIPT" VIRTUALENVWRAPPER_LAZY_LOADED=1 fi From 664aee21dbe28c6e09fec294e75c3f054b8c4eea Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 12 Jan 2014 15:46:21 -0500 Subject: [PATCH 705/947] update author email Change-Id: Ia08d00e7594e35bb9a395ac6b51692914b1edf06 --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index ccab286..35450c8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ [metadata] name = virtualenvwrapper author = Doug Hellmann -author-email = doug.hellmann@gmail.com +author-email = doug@doughellmann.com summary = Enhancements to virtualenv description-file = README.txt license = MIT From 1db25a4f3cfd8ac3e446055ce0f49336c5f24afa Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 18 Jan 2014 18:55:35 -0500 Subject: [PATCH 706/947] Add list of commands as basic help output Add a 'virtualenvwrapper' command to print a list of the wrapper commands and a one-liner description. Based on a contribution by Eugene Sajine. Change-Id: I441ce2576ff3ad7bb8cc5812b5898ba04ad65637 --- docs/source/command_ref.rst | 16 +++++++++++ docs/source/history.rst | 6 +++++ virtualenvwrapper.sh | 54 +++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 6b68bf5..026bf67 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -586,3 +586,19 @@ virtualenv. Syntax:: wipeenv + + +============== +Other Commands +============== + +.. _command-virtualenvwrapper: + +virtualenvwrapper +----------------- + +Print a list of commands and their descriptions as basic help output. + +Syntax:: + + virtualenvwrapper diff --git a/docs/source/history.rst b/docs/source/history.rst index bfa1e5b..ebb69e9 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -2,6 +2,12 @@ Release History =============== +dev +=== + +- Add :ref:`command-virtualenvwrapper` to print basic help and a list + of commands. + 4.2 === diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index dd5230b..f73affa 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -1214,6 +1214,60 @@ function allvirtualenv { done } +function virtualenvwrapper { + cat < Date: Sat, 18 Jan 2014 19:29:34 -0500 Subject: [PATCH 707/947] Extract basic help text from the script Instead of listing all of the commands separately in the help text body, extract the information from the shell script directly. Change-Id: I3c20c682e719f4292bdf6b6c2abac0f25ca3db6f --- virtualenvwrapper.sh | 82 +++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 50 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index f73affa..417769b 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -78,6 +78,12 @@ then export VIRTUALENVWRAPPER_PROJECT_FILENAME=".project" fi +# Remember where we are running from. +if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ] +then + export VIRTUALENVWRAPPER_SCRIPT="$0" +fi + # Portable shell scripting is hard, let's go shopping. # # People insist on aliasing commands like 'cd', either with a real @@ -375,6 +381,7 @@ function virtualenvwrapper_mkvirtualenv_help { # Usage: mkvirtualenv [options] ENVNAME # (where the options are passed directly to virtualenv) # +#:help:mkvirtualenv: Create a new virtualenv in $WORKON_HOME function mkvirtualenv { typeset -a in_args typeset -a out_args @@ -491,7 +498,7 @@ function mkvirtualenv { virtualenvwrapper_run_hook "post_mkvirtualenv" } -# Remove an environment, in the WORKON_HOME. +#:help:rmvirtualenv: Remove a virtualenv function rmvirtualenv { virtualenvwrapper_verify_workon_home || return 1 if [ ${#@} = 0 ] @@ -558,9 +565,7 @@ function _lsvirtualenv_usage { echo " -h -- this help message" } -# List virtual environments -# -# Usage: lsvirtualenv [-l] +#:help:lsvirtualenv: list virtualenvs function lsvirtualenv { typeset long_mode=true @@ -608,9 +613,7 @@ function lsvirtualenv { fi } -# Show details of a virtualenv -# -# Usage: showvirtualenv [env] +#:help:showvirtualenv: show details of a single virtualenv function showvirtualenv { typeset env_name="$1" if [ -z "$env_name" ] @@ -646,10 +649,7 @@ function virtualenvwrapper_workon_help { echo "" } -# List or change working virtual environments -# -# Usage: workon [environment_name] -# +#:help:workon: list or change working virtualenvs function workon { in_args=( "$@" ) @@ -765,6 +765,8 @@ function virtualenvwrapper_get_site_packages_dir { # "virtualenv_path_extensions.pth" inside the virtualenv's # site-packages directory; if this file does not exist, it will be # created first. +# +#:help:add2virtualenv: add directory to the import path function add2virtualenv { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 @@ -829,6 +831,7 @@ function add2virtualenv { # Does a ``cd`` to the site-packages directory of the currently-active # virtualenv. +#:help:cdsitepackages: change to the site-packages directory function cdsitepackages { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 @@ -837,6 +840,7 @@ function cdsitepackages { } # Does a ``cd`` to the root of the currently-active virtualenv. +#:help:cdvirtualenv: change to the $VIRTUAL_ENV directory function cdvirtualenv { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 @@ -845,6 +849,7 @@ function cdvirtualenv { # Shows the content of the site-packages directory of the currently-active # virtualenv +#:help:lssitepackages: list contents of the site-packages directory function lssitepackages { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 @@ -862,6 +867,7 @@ function lssitepackages { # Toggles the currently-active virtualenv between having and not having # access to the global site-packages. +#:help:toggleglobalsitepackages: turn access to global site-packages on/off function toggleglobalsitepackages { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 @@ -875,7 +881,7 @@ function toggleglobalsitepackages { fi } -# Duplicate the named virtualenv to make a new one. +#:help:cpvirtualenv: duplicate the named virtualenv to make a new one function cpvirtualenv { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_virtualenv_clone || return 1 @@ -968,6 +974,7 @@ function virtualenvwrapper_verify_project_home { # Given a virtualenv directory and a project directory, # set the virtualenv up to be associated with the # project +#:help:setvirtualenvproject: associate a project directory with a virtualenv function setvirtualenvproject { typeset venv="$1" typeset prj="$2" @@ -1024,7 +1031,7 @@ function virtualenvwrapper_mkproject_help { "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' -l project.template } -# Create a new project directory and its associated virtualenv. +#:help:mkproject: create a new project directory and its associated virtualenv function mkproject { typeset -a in_args typeset -a out_args @@ -1109,7 +1116,7 @@ function mkproject { virtualenvwrapper_run_hook "project.post_mkproject" } -# Change directory to the active project +#:help:cdproject: change directory to the active project function cdproject { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 @@ -1135,6 +1142,7 @@ function cdproject { # # Originally part of virtualenvwrapper.tmpenv plugin # +#:help:mktmpenv: create a temporary virtualenv function mktmpenv { typeset tmpenvname typeset RC @@ -1175,6 +1183,7 @@ EOF # # Remove all installed packages from the env # +#:help:wipeenv: remove all packages installed in the current virtualenv function wipeenv { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 @@ -1196,6 +1205,7 @@ function wipeenv { # # Run a command in each virtualenv # +#:help:allvirtualenv: run a command in all virtualenvs function allvirtualenv { virtualenvwrapper_verify_workon_home || return 1 typeset d @@ -1214,6 +1224,7 @@ function allvirtualenv { done } +#:help:virtualenvwrapper: show this help message function virtualenvwrapper { cat < Date: Tue, 11 Mar 2014 20:59:06 -0700 Subject: [PATCH 708/947] use VIRTUALENVWRAPPER_ENV_BIN_DIR throughout --- virtualenvwrapper.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 417769b..b7ac613 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -746,7 +746,7 @@ function virtualenvwrapper_get_python_version { # VIRTUALENVWRAPPER_PYTHON because we're trying to determine the # version installed there so we can build up the path to the # site-packages directory. - "$VIRTUAL_ENV/bin/python" -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d. + "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/python" -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d. } # Prints the path to the site-packages directory for the current environment. @@ -1171,7 +1171,7 @@ function mktmpenv { echo "This is a temporary environment. It will be deleted when you run 'deactivate'." | tee "$VIRTUAL_ENV/README.tmpenv" # Update the postdeactivate script - cat - >> "$VIRTUAL_ENV/bin/postdeactivate" <> "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/postdeactivate" < Date: Sat, 22 Mar 2014 20:06:44 -0400 Subject: [PATCH 709/947] do not specify a version for pbr Change-Id: Ia4192201e4a38fb711911e2501a4f719c84e3576 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 82d3ae3..aa2d8a0 100644 --- a/setup.py +++ b/setup.py @@ -3,6 +3,6 @@ from setuptools import setup setup( - setup_requires=['pbr>=0.5.19'], + setup_requires=['pbr'], pbr=True, ) From f42e26c0889da5517a788c86e68c0efc24ce897d Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 18 Apr 2014 18:01:38 +0200 Subject: [PATCH 710/947] mode constant for sourced-only files for sourced scripts, no executable bits are necessary --- virtualenvwrapper/user_scripts.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index fc04579..37d9442 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -51,7 +51,16 @@ def run_global(script_name, *args): return -PERMISSIONS = stat.S_IRWXU | stat.S_IRWXG | stat.S_IROTH | stat.S_IXOTH +PERMISSIONS = (stat.S_IRWXU # read/write/execute, user + | stat.S_IRWXG # read/write/execute, group + | stat.S_IROTH # read, others + | stat.S_IXOTH) # execute, others +PERMISSIONS_SOURCED = ( + stat.S_IRUSR # read, user + | stat.S_IWUSR # write, user + | stat.S_IRGRP # read, group + | stat.S_IWGRP # write, group + | stat.S_IROTH) # read, others GLOBAL_HOOKS = [ From 8c64859aa7cbfa44f0758a563bb10d18b7269f7a Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 18 Apr 2014 18:05:29 +0200 Subject: [PATCH 711/947] ignore bin, include, lib --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index dbd2d93..37bb684 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,9 @@ virtualenvwrapper/docs TAGS ChangeLog AUTHORS +bin +include +lib syntax: re .DS_Store From 2df1960bdfed51cd85fca3485c26e120f6010ae6 Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 18 Apr 2014 19:05:00 +0200 Subject: [PATCH 712/947] changed comments and mode for sourced scripts the comment of sourced scripts now tells about this fact (they are not run but sourced), and they are not made executable --- virtualenvwrapper/user_scripts.py | 46 +++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 37d9442..efa4cc7 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -66,61 +66,84 @@ def run_global(script_name, *args): GLOBAL_HOOKS = [ # initialize ("initialize", - "This hook is run during the startup phase " + "This hook is sourced during the startup phase " "when loading virtualenvwrapper.sh."), # mkvirtualenv ("premkvirtualenv", "This hook is run after a new virtualenv is created " "and before it is activated."), + # argument: name of new environment ("postmkvirtualenv", - "This hook is run after a new virtualenv is activated."), + "This hook is sourced after a new virtualenv is activated."), + + # cpvirtualenv: + # precpvirtualenv (run), + # postcpvirtualenv (sourced) # rmvirtualenv ("prermvirtualenv", "This hook is run before a virtualenv is deleted."), + # argument: full path to environment directory ("postrmvirtualenv", "This hook is run after a virtualenv is deleted."), + # argument: full path to environment directory # deactivate ("predeactivate", - "This hook is run before every virtualenv is deactivated."), + "This hook is sourced before every virtualenv is deactivated."), ("postdeactivate", - "This hook is run after every virtualenv is deactivated."), + "This hook is sourced after every virtualenv is deactivated."), # activate ("preactivate", "This hook is run before every virtualenv is activated."), + # argument: environment name ("postactivate", - "This hook is run after every virtualenv is activated."), + "This hook is sourced after every virtualenv is activated."), + + # mkproject: + # premkproject (run), + # postmkproject (sourced) # get_env_details ("get_env_details", "This hook is run when the list of virtualenvs is printed " "so each name can include details."), + # argument: environment name ] LOCAL_HOOKS = [ # deactivate ("predeactivate", - "This hook is run before this virtualenv is deactivated."), + "This hook is sourced before this virtualenv is deactivated."), ("postdeactivate", - "This hook is run after this virtualenv is deactivated."), + "This hook is sourced after this virtualenv is deactivated."), # activate ("preactivate", "This hook is run before this virtualenv is activated."), ("postactivate", - "This hook is run after this virtualenv is activated."), + "This hook is sourced after this virtualenv is activated."), # get_env_details ("get_env_details", "This hook is run when the list of virtualenvs is printed " "in 'long' mode so each name can include details."), + # argument: environment name ] +SOURCED = ('initialize', + 'postactivate', + 'predeactivate', + 'postdeactivate', + 'postmkproject', + 'postmkvirtualenv', + ) + + def make_hook(filename, comment): """Create a hook script. @@ -132,13 +155,18 @@ def make_hook(filename, comment): log.info('creating %s', filename) f = open(filename, 'w') try: + # for sourced scripts, the shebang line won't be used; + # it is useful for editors to recognize the file type, though f.write("#!%(shell)s\n# %(comment)s\n\n" % { 'comment': comment, 'shell': os.environ.get('SHELL', '/bin/sh'), }) finally: f.close() - os.chmod(filename, PERMISSIONS) + os.chmod(filename, + os.path.basename(filename) in SOURCED + and PERMISSIONS_SOURCED + or PERMISSIONS) return From 1f996c80bb0aa5072300b0d34cb7307fa8d96953 Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 18 Apr 2014 19:42:08 +0200 Subject: [PATCH 713/947] tabs expanded; mode difference --- virtualenvwrapper/user_scripts.py | 33 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index efa4cc7..903b008 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -55,12 +55,11 @@ def run_global(script_name, *args): | stat.S_IRWXG # read/write/execute, group | stat.S_IROTH # read, others | stat.S_IXOTH) # execute, others -PERMISSIONS_SOURCED = ( - stat.S_IRUSR # read, user - | stat.S_IWUSR # write, user - | stat.S_IRGRP # read, group - | stat.S_IWGRP # write, group - | stat.S_IROTH) # read, others +PERMISSIONS_SOURCED = PERMISSIONS \ + & ~ ( # remove executable bits for + stat.S_IXUSR # ... user + | stat.S_IXGRP # ... + | stat.S_IXOTH) GLOBAL_HOOKS = [ @@ -136,12 +135,12 @@ def run_global(script_name, *args): SOURCED = ('initialize', - 'postactivate', - 'predeactivate', - 'postdeactivate', - 'postmkproject', - 'postmkvirtualenv', - ) + 'postactivate', + 'predeactivate', + 'postdeactivate', + 'postmkproject', + 'postmkvirtualenv', + ) def make_hook(filename, comment): @@ -155,8 +154,8 @@ def make_hook(filename, comment): log.info('creating %s', filename) f = open(filename, 'w') try: - # for sourced scripts, the shebang line won't be used; - # it is useful for editors to recognize the file type, though + # for sourced scripts, the shebang line won't be used; + # it is useful for editors to recognize the file type, though f.write("#!%(shell)s\n# %(comment)s\n\n" % { 'comment': comment, 'shell': os.environ.get('SHELL', '/bin/sh'), @@ -164,9 +163,9 @@ def make_hook(filename, comment): finally: f.close() os.chmod(filename, - os.path.basename(filename) in SOURCED - and PERMISSIONS_SOURCED - or PERMISSIONS) + os.path.basename(filename) in SOURCED + and PERMISSIONS_SOURCED + or PERMISSIONS) return From 56e13d8a9e5ca8605ede380b42a4799b1295fe1c Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 18 Apr 2014 19:54:43 +0200 Subject: [PATCH 714/947] trailing whitespace removed --- virtualenvwrapper/user_scripts.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 903b008..34031fd 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -58,7 +58,7 @@ def run_global(script_name, *args): PERMISSIONS_SOURCED = PERMISSIONS \ & ~ ( # remove executable bits for stat.S_IXUSR # ... user - | stat.S_IXGRP # ... + | stat.S_IXGRP # ... | stat.S_IXOTH) @@ -78,7 +78,7 @@ def run_global(script_name, *args): # cpvirtualenv: # precpvirtualenv (run), - # postcpvirtualenv (sourced) + # postcpvirtualenv (sourced) # rmvirtualenv ("prermvirtualenv", @@ -103,7 +103,7 @@ def run_global(script_name, *args): # mkproject: # premkproject (run), - # postmkproject (sourced) + # postmkproject (sourced) # get_env_details ("get_env_details", @@ -155,7 +155,7 @@ def make_hook(filename, comment): f = open(filename, 'w') try: # for sourced scripts, the shebang line won't be used; - # it is useful for editors to recognize the file type, though + # it is useful for editors to recognize the file type, though f.write("#!%(shell)s\n# %(comment)s\n\n" % { 'comment': comment, 'shell': os.environ.get('SHELL', '/bin/sh'), From aa4a3242d724d09024b592c30f8a1af5dc0b78c1 Mon Sep 17 00:00:00 2001 From: Tobias Date: Fri, 18 Apr 2014 22:00:33 +0200 Subject: [PATCH 715/947] forgotten comment --- virtualenvwrapper/user_scripts.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 34031fd..74d10bb 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -56,10 +56,10 @@ def run_global(script_name, *args): | stat.S_IROTH # read, others | stat.S_IXOTH) # execute, others PERMISSIONS_SOURCED = PERMISSIONS \ - & ~ ( # remove executable bits for - stat.S_IXUSR # ... user - | stat.S_IXGRP # ... - | stat.S_IXOTH) + & ~ (# remove executable bits for + stat.S_IXUSR # ... user + | stat.S_IXGRP # ... group + | stat.S_IXOTH) # ... others GLOBAL_HOOKS = [ From 04f897165c1eb84e6fe52442b0a8fc9f01915aa6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 27 Apr 2014 17:33:49 -0400 Subject: [PATCH 716/947] clean up script mode changes Change-Id: Ibaf3590f7929c9f7230fe96358934e6bb49f25d0 --- tests/test.sh | 12 +++- tests/test_hook_dir.sh | 14 +++- tests/test_mkvirtualenv.sh | 2 +- virtualenvwrapper/project.py | 12 ++-- virtualenvwrapper/user_scripts.py | 108 ++++++++++++++++-------------- 5 files changed, 87 insertions(+), 61 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index a37b11d..0bd26e9 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -19,12 +19,20 @@ setUp () { rm -f "$TMPDIR/catch_output" } +SOURCE_SCRIPTS="initialize postmkvirtualenv predeactivate postdeactivate postactivate " +RUN_SCRIPTS="premkvirtualenv prermvirtualenv postrmvirtualenv preactivate get_env_details" + test_virtualenvwrapper_initialize() { assertTrue "Initialized" virtualenvwrapper_initialize - for hook in premkvirtualenv postmkvirtualenv prermvirtualenv postrmvirtualenv preactivate postactivate predeactivate postdeactivate + for hook in $SOURCE_SCRIPTS + do + assertTrue "Global $WORKON_HOME/$hook was not created" "[ -f $WORKON_HOME/$hook ]" + assertFalse "Global $WORKON_HOME/$hook is executable" "[ -x $WORKON_HOME/$hook ]" + done + for hook in $RUN_SCRIPTS do assertTrue "Global $WORKON_HOME/$hook was not created" "[ -f $WORKON_HOME/$hook ]" - assertTrue "Global $WORKON_HOME/$hook is not executable" "[ -x $WORKON_HOME/$hook ]" + assertTrue "Global $WORKON_HOME/$hook is executable" "[ -x $WORKON_HOME/$hook ]" done echo "echo GLOBAL initialize >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/initialize" virtualenvwrapper_initialize diff --git a/tests/test_hook_dir.sh b/tests/test_hook_dir.sh index 33bdcb2..f83b235 100755 --- a/tests/test_hook_dir.sh +++ b/tests/test_hook_dir.sh @@ -18,13 +18,21 @@ setUp () { rm -f "$WORKON_HOME/hooks/*" } +SOURCE_SCRIPTS="initialize postmkvirtualenv predeactivate postdeactivate postactivate " +RUN_SCRIPTS="premkvirtualenv prermvirtualenv postrmvirtualenv preactivate get_env_details" + test_virtualenvwrapper_initialize() { export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME/hooks" source "$test_dir/../virtualenvwrapper.sh" - for hook in premkvirtualenv postmkvirtualenv prermvirtualenv postrmvirtualenv preactivate postactivate predeactivate postdeactivate + for hook in $SOURCE_SCRIPTS + do + assertTrue "Global $WORKON_HOME/$hook was not created" "[ -f $WORKON_HOME/hooks/$hook ]" + assertFalse "Global $WORKON_HOME/$hook is executable" "[ -x $WORKON_HOME/hooks/$hook ]" + done + for hook in $RUN_SCRIPTS do - assertTrue "Global $hook was not created" "[ -f $WORKON_HOME/hooks/$hook ]" - assertTrue "Global $hook is not executable" "[ -x $WORKON_HOME/hooks/$hook ]" + assertTrue "Global $WORKON_HOME/$hook was not created" "[ -f $WORKON_HOME/hooks/$hook ]" + assertTrue "Global $WORKON_HOME/$hook is executable" "[ -x $WORKON_HOME/hooks/$hook ]" done } diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index c54cfd3..a81f4a5 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -24,7 +24,7 @@ test_create() { for hook in postactivate predeactivate postdeactivate do assertTrue "env1 $hook was not created" "[ -f $WORKON_HOME/env1/bin/$hook ]" - assertTrue "env1 $hook is not executable" "[ -x $WORKON_HOME/env1/bin/$hook ]" + assertFalse "env1 $hook is executable" "[ -x $WORKON_HOME/env1/bin/$hook ]" done } diff --git a/virtualenvwrapper/project.py b/virtualenvwrapper/project.py index 9c3f8fa..2afc4eb 100644 --- a/virtualenvwrapper/project.py +++ b/virtualenvwrapper/project.py @@ -8,7 +8,7 @@ import logging import os -from virtualenvwrapper.user_scripts import make_hook, run_global +from virtualenvwrapper.user_scripts import make_hook, run_global, PERMISSIONS log = logging.getLogger(__name__) @@ -16,18 +16,20 @@ # mkproject ("premkproject", "This hook is run after a new project is created " - "and before it is activated."), + "and before it is activated.", + PERMISSIONS), ("postmkproject", - "This hook is run after a new project is activated."), + "This hook is run after a new project is activated.", + PERMISSIONS), ] def initialize(args): """Set up user hooks """ - for filename, comment in GLOBAL_HOOKS: + for filename, comment, permissions in GLOBAL_HOOKS: make_hook(os.path.join('$VIRTUALENVWRAPPER_HOOK_DIR', filename), - comment) + comment, permissions) return diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 74d10bb..3e1d799 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -51,30 +51,37 @@ def run_global(script_name, *args): return -PERMISSIONS = (stat.S_IRWXU # read/write/execute, user - | stat.S_IRWXG # read/write/execute, group - | stat.S_IROTH # read, others - | stat.S_IXOTH) # execute, others -PERMISSIONS_SOURCED = PERMISSIONS \ - & ~ (# remove executable bits for - stat.S_IXUSR # ... user - | stat.S_IXGRP # ... group - | stat.S_IXOTH) # ... others +PERMISSIONS = ( + stat.S_IRWXU # read/write/execute, user + | stat.S_IRGRP # read, group + | stat.S_IXGRP # execute, group + | stat.S_IROTH # read, others + | stat.S_IXOTH # execute, others +) +PERMISSIONS_SOURCED = PERMISSIONS & ~( + # remove executable bits for + stat.S_IXUSR # ... user + | stat.S_IXGRP # ... group + | stat.S_IXOTH # ... others +) GLOBAL_HOOKS = [ # initialize ("initialize", "This hook is sourced during the startup phase " - "when loading virtualenvwrapper.sh."), + "when loading virtualenvwrapper.sh.", + PERMISSIONS_SOURCED), # mkvirtualenv ("premkvirtualenv", "This hook is run after a new virtualenv is created " - "and before it is activated."), - # argument: name of new environment + "and before it is activated.\n" + "# argument: name of new environment", + PERMISSIONS), ("postmkvirtualenv", - "This hook is sourced after a new virtualenv is activated."), + "This hook is sourced after a new virtualenv is activated.", + PERMISSIONS_SOURCED), # cpvirtualenv: # precpvirtualenv (run), @@ -82,24 +89,30 @@ def run_global(script_name, *args): # rmvirtualenv ("prermvirtualenv", - "This hook is run before a virtualenv is deleted."), - # argument: full path to environment directory + "This hook is run before a virtualenv is deleted.\n" + "# argument: full path to environment directory", + PERMISSIONS), ("postrmvirtualenv", - "This hook is run after a virtualenv is deleted."), - # argument: full path to environment directory + "This hook is run after a virtualenv is deleted.\n" + "# argument: full path to environment directory", + PERMISSIONS), # deactivate ("predeactivate", - "This hook is sourced before every virtualenv is deactivated."), + "This hook is sourced before every virtualenv is deactivated.", + PERMISSIONS_SOURCED), ("postdeactivate", - "This hook is sourced after every virtualenv is deactivated."), + "This hook is sourced after every virtualenv is deactivated.", + PERMISSIONS_SOURCED), # activate ("preactivate", - "This hook is run before every virtualenv is activated."), - # argument: environment name + "This hook is run before every virtualenv is activated.\n" + "# argument: environment name", + PERMISSIONS), ("postactivate", - "This hook is sourced after every virtualenv is activated."), + "This hook is sourced after every virtualenv is activated.", + PERMISSIONS_SOURCED), # mkproject: # premkproject (run), @@ -108,42 +121,39 @@ def run_global(script_name, *args): # get_env_details ("get_env_details", "This hook is run when the list of virtualenvs is printed " - "so each name can include details."), - # argument: environment name + "so each name can include details.\n" + "# argument: environment name", + PERMISSIONS), ] LOCAL_HOOKS = [ # deactivate ("predeactivate", - "This hook is sourced before this virtualenv is deactivated."), + "This hook is sourced before this virtualenv is deactivated.", + PERMISSIONS_SOURCED), ("postdeactivate", - "This hook is sourced after this virtualenv is deactivated."), + "This hook is sourced after this virtualenv is deactivated.", + PERMISSIONS_SOURCED), # activate ("preactivate", - "This hook is run before this virtualenv is activated."), + "This hook is run before this virtualenv is activated.", + PERMISSIONS), ("postactivate", - "This hook is sourced after this virtualenv is activated."), + "This hook is sourced after this virtualenv is activated.", + PERMISSIONS_SOURCED), # get_env_details ("get_env_details", "This hook is run when the list of virtualenvs is printed " - "in 'long' mode so each name can include details."), - # argument: environment name + "in 'long' mode so each name can include details.\n" + "# argument: environment name", + PERMISSIONS), ] -SOURCED = ('initialize', - 'postactivate', - 'predeactivate', - 'postdeactivate', - 'postmkproject', - 'postmkvirtualenv', - ) - - -def make_hook(filename, comment): +def make_hook(filename, comment, permissions): """Create a hook script. :param filename: The name of the file to write. @@ -162,10 +172,7 @@ def make_hook(filename, comment): }) finally: f.close() - os.chmod(filename, - os.path.basename(filename) in SOURCED - and PERMISSIONS_SOURCED - or PERMISSIONS) + os.chmod(filename, permissions) return @@ -173,8 +180,9 @@ def make_hook(filename, comment): def initialize(args): - for filename, comment in GLOBAL_HOOKS: - make_hook(get_path('$VIRTUALENVWRAPPER_HOOK_DIR', filename), comment) + for filename, comment, permissions in GLOBAL_HOOKS: + make_hook(get_path('$VIRTUALENVWRAPPER_HOOK_DIR', filename), + comment, permissions) return @@ -191,9 +199,9 @@ def initialize_source(args): def pre_mkvirtualenv(args): log.debug('pre_mkvirtualenv %s', str(args)) envname = args[0] - for filename, comment in LOCAL_HOOKS: + for filename, comment, permissions in LOCAL_HOOKS: make_hook(get_path('$WORKON_HOME', envname, script_folder, filename), - comment) + comment, permissions) run_global('premkvirtualenv', *args) return @@ -211,9 +219,9 @@ def post_mkvirtualenv_source(args): def pre_cpvirtualenv(args): log.debug('pre_cpvirtualenv %s', str(args)) envname = args[0] - for filename, comment in LOCAL_HOOKS: + for filename, comment, permissions in LOCAL_HOOKS: make_hook(get_path('$WORKON_HOME', envname, script_folder, filename), - comment) + comment, permissions) run_global('precpvirtualenv', *args) return From 463d527de50f33b9499af6b38f29bbdf6c1a224c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 27 Apr 2014 17:44:38 -0400 Subject: [PATCH 717/947] updated pep8 Change-Id: Ic2c9662172823fbb63d3a6b2520386c7e123cd39 --- docs/source/conf.py | 68 +++++++++++++++---------------- virtualenvwrapper/hook_loader.py | 2 +- virtualenvwrapper/user_scripts.py | 2 +- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 71a912a..00ec17b 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -18,7 +18,7 @@ # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.append(os.path.abspath('.')) +# sys.path.append(os.path.abspath('.')) # -- General configuration --------------------------------------------------- @@ -30,13 +30,13 @@ bitbucket_project_url = 'http://bitbucket.org/dhellmann/virtualenvwrapper/' # Add any paths that contain templates here, relative to this directory. -#templates_path = ['pkg/templates'] +# templates_path = ['pkg/templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. -#source_encoding = 'utf-8' +# source_encoding = 'utf-8' # The master toctree document. master_doc = 'index' @@ -60,16 +60,16 @@ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -#language = None +# language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of documents that shouldn't be included in the build. -#unused_docs = [] +# unused_docs = [] # List of directories, relative to source directory, that shouldn't be searched # for source files. @@ -77,24 +77,24 @@ # The reST default role (used for this markup: `text`) to use for all # documents. -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # -- Options for HTML output ------------------------------------------------- @@ -106,46 +106,46 @@ # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +# html_favicon = None # 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, # 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, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. html_use_modindex = False @@ -154,18 +154,18 @@ html_use_index = False # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = '' +# html_file_suffix = '' # Output file base name for HTML help builder. htmlhelp_basename = 'virtualenvwrapperdoc' @@ -174,10 +174,10 @@ # -- Options for LaTeX output ------------------------------------------------ # The paper size ('letter' or 'a4'). -#latex_paper_size = 'letter' +# latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). -#latex_font_size = '10pt' +# latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass @@ -189,17 +189,17 @@ # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # Additional stuff for the LaTeX preamble. -#latex_preamble = '' +# latex_preamble = '' # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_use_modindex = True +# latex_use_modindex = True diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 42f92ca..7b505f1 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -108,7 +108,7 @@ def main(): console.setFormatter(formatter) root_logger.addHandler(console) - #logging.getLogger(__name__).debug('cli args %s', args) + # logging.getLogger(__name__).debug('cli args %s', args) # Determine which hook we're running if not args: diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 3e1d799..611dff0 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -39,7 +39,7 @@ def run_script(script_path, *args): except OSError: _, msg, _ = sys.exc_info() log.error('could not run "%s": %s', script_path, str(msg)) - #log.debug('Returned %s', return_code) + # log.debug('Returned %s', return_code) return From e8b61a5f410575a7abaa503b43683fcf8dea5dbe Mon Sep 17 00:00:00 2001 From: Nishikar Sapkota Date: Thu, 15 May 2014 16:06:58 -0500 Subject: [PATCH 718/947] added no such environment prompt to rmvirtualenv if it does not exist --- virtualenvwrapper.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index b7ac613..8fab813 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -513,6 +513,9 @@ function rmvirtualenv { do echo "Removing $env_name..." typeset env_dir="$WORKON_HOME/$env_name" + if [ ! -d "$env_dir" ]; then + echo "Cannot remove '$env_name'. No such environment." >&2 + fi if [ "$VIRTUAL_ENV" = "$env_dir" ] then echo "ERROR: You cannot remove the active environment ('$env_name')." >&2 From 4ce11e70a1e95b40645692847d2cbc8bc9cca5cf Mon Sep 17 00:00:00 2001 From: Nishikar Sapkota Date: Thu, 15 May 2014 16:30:29 -0500 Subject: [PATCH 719/947] moved environment exists check below active environment check. --- virtualenvwrapper.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 8fab813..bf269ff 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -513,9 +513,6 @@ function rmvirtualenv { do echo "Removing $env_name..." typeset env_dir="$WORKON_HOME/$env_name" - if [ ! -d "$env_dir" ]; then - echo "Cannot remove '$env_name'. No such environment." >&2 - fi if [ "$VIRTUAL_ENV" = "$env_dir" ] then echo "ERROR: You cannot remove the active environment ('$env_name')." >&2 @@ -523,6 +520,10 @@ function rmvirtualenv { return 1 fi + if [ ! -d "$env_dir" ]; then + echo "Cannot remove '$env_name'. No such environment." >&2 + fi + # Move out of the current directory to one known to be # safe, in case we are inside the environment somewhere. typeset prior_dir="$(pwd)" From 8f511b2f4f8a040f67e464393843bb0c4ac78ab8 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 26 May 2014 17:34:23 -0400 Subject: [PATCH 720/947] add link to sublimetext extension Change-Id: I99d1136914592c0d78586f8adc6dd2471d8395b2 --- docs/source/extensions.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/source/extensions.rst b/docs/source/extensions.rst index 6c59902..fe8f4a2 100644 --- a/docs/source/extensions.rst +++ b/docs/source/extensions.rst @@ -64,6 +64,15 @@ The django_ extension automatically creates a new Django project. .. _django: http://www.doughellmann.com/projects/virtualenvwrapper.django/ +SublimeText +----------- + +Song Jin has created a template plugin for automatically generating +the project files used by SublimeText. See the +sublime_projectfile_maker_ page for details. + +.. _sublime_projectfile_maker: https://github.com/SongGithub/sublime_projectfile_maker + .. seealso:: * :ref:`developer-templates` From 981af0f26da4d3fdd5a72a9defd78fa43a3db846 Mon Sep 17 00:00:00 2001 From: Erik B Date: Wed, 28 May 2014 10:19:32 +0000 Subject: [PATCH 721/947] Run User Postactivate after changing dirs Resolves #235 --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 35450c8..f802bdf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -64,8 +64,8 @@ virtualenvwrapper.project.post_mkproject_source = virtualenvwrapper.pre_activate = user_scripts = virtualenvwrapper.user_scripts:pre_activate virtualenvwrapper.post_activate_source = - user_scripts = virtualenvwrapper.user_scripts:post_activate_source project = virtualenvwrapper.project:post_activate_source + user_scripts = virtualenvwrapper.user_scripts:post_activate_source virtualenvwrapper.pre_deactivate_source = user_scripts = virtualenvwrapper.user_scripts:pre_deactivate_source virtualenvwrapper.post_deactivate_source = From 58c2459e5b27e3876b99842f323222349d1b6ed1 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 31 May 2014 10:11:18 -0400 Subject: [PATCH 722/947] remove announce.rst; move to blogging repository Change-Id: I6509ee578d909ef53a16acf2c59cfdd9307e4498 --- announce.rst | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 announce.rst diff --git a/announce.rst b/announce.rst deleted file mode 100644 index 0ac4156..0000000 --- a/announce.rst +++ /dev/null @@ -1,46 +0,0 @@ -======================= - virtualenvwrapper 4.2 -======================= - -.. tags:: virtualenvwrapper release python - -What is virtualenvwrapper? -========================== - -virtualenvwrapper_ is a set of extensions to virtualenv_. The -extensions include wrappers for creating and deleting virtual -environments and otherwise managing your development workflow, making -it easier to work on more than one project at a time without -introducing conflicts in their dependencies. - -What's New? -=========== - -- Add ``tmp-`` prefix to temporary environment names created by - ``mktmpenv``. -- Fix some uses of ``cd`` that did not account for possible - aliasing. Contributed by Ismail Badawi. -- Fix documentation for ``allvirtualenv``, contributed by - Andy Dirnberger. -- Add ``--force`` option to ``mkproject``, contributed by - Clay McClure. -- Fix handling for project directory argument ``-a`` to - ``mkvirtualenv``, based on work by Xupeng Yun. -- Dropped python 3.2 testing. -- Updated test configuration so they work properly under Linux. -- Resolve relative paths before storing the project directory - reference in ``setvirtualenvproject``. (issue 207) -- Do not create hooks for rmproject, since there is no such - command. (issue 203) -- Update the tests to use a valid template for creating temporary - directories under Linux. - -Installing -========== - -Visit the virtualenvwrapper_ project page for download links and -installation instructions. - -.. _virtualenv: http://pypi.python.org/pypi/virtualenv - -.. _virtualenvwrapper: http://virtualenvwrapper.readthedocs.org/en/latest/ From cf9105d9c6db27477c428b04efca2eab756b98b4 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 22 Jun 2014 11:45:00 -0400 Subject: [PATCH 723/947] Update doc build to fail if there are warnings Update the documentation build to use a tox environment and pass through pbr and to use the flag to have the build fail if there are any warnings. Fix existing warnings in the documentation by adding a glossary with two referenced terms and correcting a few other minor issues. Change-Id: I082d8d73debca891811fb2f0c1116f9bf5bee54e --- Makefile | 2 +- docs/source/command_ref.rst | 2 ++ docs/source/glossary.rst | 16 ++++++++++++++++ docs/source/history.rst | 3 +-- docs/source/index.rst | 1 + setup.cfg | 3 +++ tox.ini | 7 +++++++ 7 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 docs/source/glossary.rst diff --git a/Makefile b/Makefile index cf7ac67..6c6370c 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ sdist: html # Documentation .PHONY: html html: - (cd docs && $(MAKE) html) + tox -e docs .PHONY: docclean docclean: diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 026bf67..893d79b 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -413,6 +413,8 @@ Syntax:: Path Management =============== +.. _command-add2virtualenv: + add2virtualenv -------------- diff --git a/docs/source/glossary.rst b/docs/source/glossary.rst new file mode 100644 index 0000000..677c8f0 --- /dev/null +++ b/docs/source/glossary.rst @@ -0,0 +1,16 @@ +========== + Glossary +========== + +.. glossary:: + + project directory + + Directory associated with a virtualenv, usually located elsewhere + and containing more permanent development artifacts such as local + source files, test data, etc. (see :ref:`variable-PROJECT_HOME`) + + template + + Input to :ref:`command-mkproject` that configures the *project + directory* to contain default files. (see :ref:`plugins`) diff --git a/docs/source/history.rst b/docs/source/history.rst index ebb69e9..64579a3 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -327,8 +327,7 @@ run in the same place as before. - Implement suggestion by Van Lindberg to have :ref:`VIRTUALENVWRAPPER_HOOK_DIR ` and - :ref:`VIRTUALENVWRAPPER_LOG_DIR - ` variables to control the + ``VIRTUALENVWRAPPER_LOG_DIR`` variables to control the locations of hooks and logs. - Enabled tab completion for :ref:`command-showvirtualenv` (:bbissue:`78`). diff --git a/docs/source/index.rst b/docs/source/index.rst index 44f3afa..d6450b6 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -181,6 +181,7 @@ Details extensions design history + glossary .. _references: diff --git a/setup.cfg b/setup.cfg index f802bdf..955c96b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -72,3 +72,6 @@ virtualenvwrapper.post_deactivate_source = user_scripts = virtualenvwrapper.user_scripts:post_deactivate_source virtualenvwrapper.get_env_details = user_scripts = virtualenvwrapper.user_scripts:get_env_details + +[pbr] +warnerrors = true diff --git a/tox.ini b/tox.ini index eb0df1d..c30be00 100644 --- a/tox.ini +++ b/tox.ini @@ -47,3 +47,10 @@ basepython=python2.7 setenv = SHELL = /bin/ksh commands = ksh ./tests/run_tests {envdir} [] + +[testenv:docs] +basepython=python2.7 +deps = + -r{toxinidir}/requirements.txt + -r{toxinidir}/docs/requirements.txt +commands = python setup.py build_sphinx \ No newline at end of file From 44d10704c130b5547f5fe917f02d884c0d867e8c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 22 Jun 2014 12:07:13 -0400 Subject: [PATCH 724/947] Replace manually maintained history with ChangeLog Replace the contents of the history file in the documentation with the ChangeLog generated by pbr. Fixes bug #240 Change-Id: I648719dff97f798e38196502e7715bcf3a867e9f --- docs/source/history.rst | 695 +--------------------------------------- 1 file changed, 1 insertion(+), 694 deletions(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index 64579a3..69ed4fe 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -1,694 +1 @@ -=============== -Release History -=============== - -dev -=== - -- Add :ref:`command-virtualenvwrapper` to print basic help and a list - of commands. - -4.2 -=== - -- Add ``tmp-`` prefix to temporary environment names created by - :ref:`command-mktmpenv`. -- Fix some uses of ``cd`` that did not account for possible - aliasing. Contributed by Ismail Badawi (:bbuser:`ibadawi`). -- Fix documentation for :ref:`command-allvirtualenv`, contributed by - Andy Dirnberger (:bbuser:`dirn`). -- Add ``--force`` option to :ref:`command-mkproject`, contributed by - Clay McClure (:bbuser:`claymcclure`). -- Fix handling for project directory argument ``-a`` to - :ref:`command-mkvirtualenv`, based on work by Xupeng Yun. -- Dropped python 3.2 testing. -- Updated test configuration so they work properly under Linux. -- Resolve relative paths before storing the project directory - reference in :ref:`command-setvirtualenvproject`. (:bbissue:`207`) -- Do not create hooks for rmproject, since there is no such - command. (:bbissue:`203`) -- Update the tests to use a valid template for creating temporary - directories under Linux. -- Fix the use of ``which`` in ``virtualenvwrapper_lazy.sh`` in case it - is aliased. -- Fix an issue with recursion in completion expansion crashing zsh, - contributed by :bbuser:`blueyed`. - -4.1.1 -===== - -- Fix packaging issue with 4.1. - -4.1 -=== - -- Ensure that all ``$()`` style commands that produce paths are - quoted. Addresses :bbissue:`164`. -- Add :ref:`command-wipeenv` command for removing all packages - installed in the virtualenv. -- Allow users of ``virtualenvwrapper_lazy.sh`` to extend the list of - API commands that trigger the lazy-loader by extending - ``_VIRTUALENVWRAPPER_API``. Patch contributed by John Purnell, see - :bbissue:`188`. -- Fix detection of ``--python`` option to - :ref:`command-mkvirtualenv`. Resolves :bbissue:`190`. -- Add :ref:`command-allvirtualenv` command to run a command across all - virtualenvs. Suggested by Dave Coutts in :bbissue:`186`. -- Fix :ref:`command-lsvirtualenv` when there are spaces in - ``WORKON_HOME``. Resolves :bbissue:`194`. -- Switch to `pbr`_ for packaging. - -.. _pbr: https://github.com/openstack-dev/pbr - -4.0 -=== - -**Warning:** This release includes some potentially incompatible -changes for extensions. The python modules for extensions are now -*always* run with ``PWD=$WORKON_HOME`` (previously the value of PWD -varied depending on the hook). The *shell* portion of any hook -(anything sourced by the user's shell when the hook is run) is still -run in the same place as before. - -- All tests pass under Python 2.6, 2.7, 3.2 and 3.3. -- Fix the name of the script in an error message produced - by ``virtualenvwrapper_lazy.sh``. (Contributed by - :bbuser:`scottstvnsn`.) - -3.7.1 -===== - - - Rename functions for generating help so they do not pollute the - global namespace, and especially so they do not interfere with tab - completion. Contributed by :bbuser:`davidszotten`. - - Fix an issue with listing project templates if none are - installed. (:bbissue:`179`) - - Fix an issue with the ``--python`` option to ``mkvirtualenv`` - becoming *sticky* for future calls that do not explicitly specify - the option. (:bbissue:`178`) - -3.7 -=== - - - Improve tab-completion support for users of the lazy-loading - mode. (:bbuser:`upsuper`) - - Add ``--help`` option to ``mkproject``. - - Add ``--help`` option to ``workon``. - - Turn off logging from the hook loader by default, and replace - ``VIRTUALENVWRAPPER_LOG_DIR`` environment variable with - ``VIRTUALENVWRAPPER_LOG_FILE``. The rotating log behavior remains - the same. The motivation for this change is the race condition - caused by that rotating behavior, especially when the wrappers are - being used by users with different permissions and - umasks. (:bbissue:`152`) - - Use flake8_ for style checking. - -.. _flake8: https://pypi.python.org/pypi/flake8 - -3.6.1 -===== - - - Replace realpath with a more portable way of converting a relative - path to an absolute path, used with the ``--python`` option to - mkvirtualenv (contributed by Radu Voicilas, :bbuser:`rvoicilas`). - - Posted release to PyPI, resolving download redirect - issue. (:bbissue:`171` and :bbissue:`172`) - -3.6 -=== - - - Switch to stevedore_ for plugin management - - mkvirtualenv_help should use ``$VIRTUALENVWRAPPER_PYTHON`` instead - of calling ``virtualenv`` directly (:bbissue:`148`). - - Fix issue with lazy-loader code under zsh (:bbissue:`144`). - - Fix issue with ``noclobber`` option under zsh - (:bbissue:`137`). Fix based on patch from :bbuser:`rob_b`. - - Fix documentation for ``add2virtualenv`` to show the correct name - for the file containing the new path entry. (contributed by - :bbuser:`rvoicilas`) - - Fix problem with ``virtualenvwrapper_show_workon_options`` under - zsh with ``chpwd`` functions that produce output. (:bbissue:`153`) - -.. _stevedore: http://pypi.python.org/pypi/stevedore - -3.5 -=== - - - Rewrite :ref:`command-cpvirtualenv` to use `virtualenv-clone`_ - instead of making the new environment relocatable. Contributed by - Justin Barber (:bbuser:`barberj`). This also resolves a problem - with cpvirtualenv not honoring the ``--no-site-packages`` flag - (:bbissue:`102`). - - Update docs with link to `virtualenvwrapper-win`_ port by David - Marble. - - Use ``command`` to avoid functions named the same as common - utilities. (:bbissue:`119`) - -.. _virtualenv-clone: http://pypi.python.org/pypi/virtualenv-clone -.. _virtualenvwrapper-win: http://pypi.python.org/pypi/virtualenvwrapper-win - - -3.4 -=== - - - Add :ref:`install-lazy-loader` option. - -3.3 -=== - - - Clean up file permissions and remove shebangs from scripts not - intended to be executed on the command line. (contributed by - :bbuser:`ralphbean`) - - Worked on some brittle tests. - - Received updates to Japanese translation of the documentation from - :bbuser:`t2y`. - - Fix the test script and runner so the user's ``$WORKON_HOME`` is - not erased if they do not have some test shells installed. - (big thanks to :bbuser:`agriffis`). - - If the hook loader is told to list plugins but is not given a hook - name, it prints the list of core hooks. - - Merge several fixes for path and variable handling for MSYS users - from :bbuser:`bwanamarko`. Includes a fix for :bbissue:`138`. - - Change :ref:`command-mkvirtualenv` so it catches both ``-h`` and - ``--help``. - - Fix some issues with the way temporary files are used for hook - scripts. (contributed by :bbuser:`agriffis`) - - Allow relative path to requirements file with - :ref:`command-mkvirtualenv` and ``-r`` option. (:bbuser:`barberj`) - - Make whitespace consistent. (:bbuser:`agriffis`) - -3.2 -=== - - - Make ``project_dir`` a local variable so that - :ref:`command-cdproject` does not interfere with other variables - the user might have set. (contributed by :bbuser:`slackorama`) - - Fix typo in documentation reported by Nick Martin. - - Change trove classifier for license "MIT" to reflect the license - text presented in the documentation. *This does not indicate a - change in the license, just a correction to the expression of that - intent. See :ref:`license`* (contributed by :bbuser:`ralphbean` as - fix for :bbissue:`134`) - - Extend :ref:`command-rmvirtualenv` to allow removing more than one - environment at a time. (contributed by :bbuser:`ciberglo`) - - Change the definition of - ``virtualenvwrapper_get_site_packages_dir`` to ask ``distutils`` - for the ``site-packages`` directory instead of trying to build the - path ourselves in the shell script. This should resolve - :bbissue:`112` and improve support for Python interpreters other - than C Python. Thanks to Carl Meyer and Dario Bertini for their - contributions toward the fix. - -3.1 -=== - - - Fix a problem with activation hooks when associating a new - virtualenv with an existing project directory. (:bbissue:`122`) - - Fix a problem with :ref:`command-add2virtualenv` and paths - containing "special" characters such as ``&``. (:bbissue:`132`) - -3.0.1 -===== - - - Fix some packaging issues that made it more difficult to run the - tests directly from the sdist package. (:bbissue:`126`) - -3.0 -=== - - - Add Python 3 support, thanks in large part to the efforts of - Daniel Kraus (:bbuser:`dakra`). Tested under Python 2.6, 2.7, and - 3.2. - -2.11.1 -====== - - - Remove the initialization shortcut because it breaks tab - completion in sub-shell environments like screen and - tmux. (:bbissue:`121`) - -2.11 -==== - - - Add ``-a`` option to :ref:`command-mkvirtualenv` to associate a - new virtualenv with an existing project directory. Contributed by - Mike Fogel (:bbuser:`mfogel`). - - Drops support for Python 2.4 and 2.5. The tools may still work, - but I no longer have a development environment set up for testing - them, so I do not officially support them. - - Shortcut initialization if it has run before. - - Set hook log file permissions to be group-writable. (:bbissue:`62` - reported by :bbuser:`hedgeddown`) - - Add ``VIRTUALENVWRAPPER_PROJECT_FILENAME`` variable so the - ``.project`` file used to link a virtualenv to a project can be - renamed to avoid conflicts with other tools. (:bbissue:`120` - reported by :bbuser:`arthuralvim`) - -2.10.1 -====== - - - Changed arguments to :ref:`command-mktmpenv` so it always creates - an environment name for you. (:bbissue:`114` reported by - :bbuser:`alex_gaynor`) - -2.10 -==== - - - Incorporated patch to add ``-d`` option to - :ref:`command-add2virtualenv`, contributed by :bbuser:`miracle2k`. - - Add ``-i`` option to :ref:`command-mkvirtualenv`. - - Add :ref:`command-mktmpenv` command for creating temporary - environments that are automatically removed when they are - deactivated. - - Fixed a problem with hook_loader that prevented it from working - under Python 2.5 and 2.4. - - Fix a problem with the way template names were processed under - zsh. (:bbissue:`111`) - -2.9 -=== - - - Change the shell function shell definition syntax so that ksh will - treat typeset-declared variables as local. No kidding. - - Merge the "project directory" features of the - ``virtualenvwrapper.project`` plugin into the main project, adding - :ref:`command-mkproject`, :ref:`command-cdproject`, and - :ref:`command-setvirtualenvproject` commands. - - Add ``-r`` option to :ref:`command-mkvirtualenv` to install - dependencies using a pip requirements file. - -2.8 -=== - - - Use VIRTUALENVWRAPPER_VIRTUALENV in `cpvirtualenv` (:bbissue:`104`). - - Add support for `MSYS `_ - environment under Windows. Contributed by Axel - H. (:bbuser:`noirbizarre`). - -2.7.2 -===== - - - Move setup code for tab completion later in the startup code so - all of the needed variables are configured. (:bbissue:`97`) - - Expand tab completion for zsh to work for all commands. - -2.7.1 -===== - - - When testing for WORKON_HOME during startup, dereference any - symlink to make sure it is a directory. - - Set VIRTUALENVWRAPPER_HOOK_DIR and VIRTUALENV_WRAPPER_LOG DIR in - virtualenvwrapper_initialize after WORKON_HOME is set - (:bbissue:`94`). - - Update the :ref:`install-basic` instructions to be more explicit - about needing to install virtualenvwrapper globally (or at least - outside of a virtualenv). - -2.7 -=== - - - Fix problem with space in WORKON_HOME path (:bbissue:`79`). - - Fix problem with argument processing in lsvirtualenv under zsh - (:bbissue:`86`). Thanks to Nat Williams (:bbuser:`natw`) for the - bug report and patch. - - If WORKON_HOME does not exist, create it. Patch from Carl Karsten - (:bbuser:`CarlFK`). Test updates based on patches from Matt Austin - (:bbuser:`maafy6`) and Hugo Lopes Tavares (:bbuser:`hltbra`). - - Merge in contributions from Paul McLanahan (:bbuser:`pmclanahan`) - to fix the test harness to ensure that the test scripts are - actually running under the expected shell. - - Merge in new shell command :ref:`command-toggleglobalsitepackages` - from Paul McLanahan (:bbuser:`pmclanahan`). The new command - changes the configuration of the active virtualenv to enable or - disable the global ``site-packages`` directory. - - Fixed some tests that were failing under ksh on Ubuntu 10.10. - - Document the :ref:`VIRTUALENVWRAPPER_VIRTUALENV - ` variable. - - Implement suggestion by Van Lindberg to have - :ref:`VIRTUALENVWRAPPER_HOOK_DIR - ` and - ``VIRTUALENVWRAPPER_LOG_DIR`` variables to control the - locations of hooks and logs. - - Enabled tab completion for :ref:`command-showvirtualenv` - (:bbissue:`78`). - - Fixed a problem with running :ref:`command-rmvirtualenv` from - within the environment being removed (:bbissue:`83`). - - Removed use of -e option in calls to grep for better portability - (:bbissue:`85`). - -2.6.3 -===== - - - Hard-code the version information in the setup.py and conf.py - scripts. This still doesn't work for http://readthedocs.org, since - the doc build needs the sphinxcontrib.bitbucket extension, but - will make it easier to transition the docs to another site later. - -2.6.2 -===== - - - Attempted to make the doc build work with http://readthedocs.org. - - Merged in `Japanese translation of the documentation - `__ from - Tetsuya Morimoto. - - Incorporate a suggestion from Ales Zoulek to let the user specify - the virtualenv binary through an environment variable - (:ref:`VIRTUALENVWRAPPER_VIRTUALENV `). - -2.6.1 -===== - - - Fixed virtualenvwrapper_get_python_version (:bbissue:`73`). - -2.6 -=== - - - Fixed a problem with hook script line endings under Cygwin - (:bbissue:`68`). - - Updated documentation to include a list of the compatible shells - (:ref:`supported-shells`) and Python versions - (:ref:`supported-versions`) (:bbissue:`70`). - - Fixed installation dependency on virtualenv (:bbissue:`60`). - - Fixed the method for determining the Python version so it works - under Python 2.4 (:bbissue:`61`). - - Converted the test infrastructure to use `tox - `_ instead of home-grown - scripts in the Makefile. - -2.5.3 -===== - - - Point release uploaded to PyPI during outage on doughellmann.com. - -2.5.2 -===== - - - Apply patch from Zach Voase to fix :ref:`command-lsvirtualenv` - under zsh. Resolves :bbissue:`64`. - -2.5.1 -===== - - - Make :ref:`command-workon` list brief environment details when run - without argument, instead of full details. - -2.5 -=== - - - Add :ref:`command-showvirtualenv` command. Modify - :ref:`command-lsvirtualenv` to make verbose output the default. - -2.4 -=== - - - Add :ref:`command-lsvirtualenv` command with ``-l`` option to run - :ref:`scripts-get_env_details` hook instead of always running it - when :ref:`command-workon` has no arguments. - -2.3 -=== - - - Added ``get_env_details`` hook. - -2.2.2 -===== - - - Integrate Fred Palmer's patch to escape more shell commands to - avoid aliases. Resolves :bbissue:`57`. - - Fix a problem with egrep argument escaping (:bbissue:`55`). - - Fix a problem with running mkvirtualenv without arguments (:bbissue:`56`). - -2.2.1 -===== - - - Escape ``which`` calls to avoid aliases. Resolves :bbissue:`46`. - - Integrate Manuel Kaufmann's patch to unset GREP_OPTIONS before - calling grep. Resolves :bbissue:`51`. - - Escape ``$`` in regex to resolve :bbissue:`53`. - - Escape ``rm`` to avoid issues with aliases and resolve - :bbissue:`50`. - -2.2 -=== - - - Switched hook loader execution to a form that works with Python - 2.4 to resolve :bbissue:`43`. - - Tested under Python 2.7b1. See :bbissue:`44`. - - Incorporated performance improvements from David Wolever. See - :bbissue:`38`. - - Added some debug instrumentation for :bbissue:`35`. - -2.1.1 -===== - - - Added `Spanish translation for the documentation - `__ via - Manuel Kaufmann's fork at - http://bitbucket.org/humitos/virtualenvwrapper-es-translation/ - - Fixed improper use of python from ``$PATH`` instead of the - location where the wrappers are installed. See :bbissue:`41`. - - Quiet spurrious error/warning messages when deactivating a - virtualenv under zsh. See :bbissue:`42`. - -2.1 -=== - - - Add support for ksh. Thanks to Doug Latornell for doing the - research on what needed to be changed. - - Test import of virtualenvwrapper.hook_loader on startup and report - the error in a way that should help the user figure out how to fix - it (:bbissue:`33`). - - Update :ref:`command-mkvirtualenv` documentation to include the - fact that a new environment is activated immediately after it is - created (:bbissue:`30`). - - Added hooks around :ref:`command-cpvirtualenv`. - - Made deactivation more robust, especially under ksh. - - Use Python's ``tempfile`` module for creating temporary filenames - safely and portably. - - Fix a problem with ``virtualenvwrapper_show_workon_options`` that - caused it to show ``*`` as the name of a virtualenv when no - environments had yet been created. - - Change the hook loader so it can be told to run only a set of - named hooks. - - Add support for listing the available hooks, to be used in help - output of commands like virtualenvwrapper.project's mkproject. - - Fix mkvirtualenv -h option behavior. - - Change logging so the $WORKON_HOME/hook.log file rotates after - 10KiB. - -2.0.2 -===== - - - Fixed :bbissue:`32`, making virtualenvwrapper.user_scripts compatible - with Python 2.5 again. - -2.0.1 -===== - - - Fixed :bbissue:`29`, to use a default value for ``TMPDIR`` if it - is not set in the user's shell environment. - -2.0 -=== - - - Rewrote hook management using Distribute_ entry points to make it - easier to share extensions. - -.. _Distribute: http://packages.python.org/distribute/ - -1.27 -==== - - - Added cpvirtualenv command [Thomas Desvenain] - -1.26 -==== - - - Fix a problem with error messages showing up during init for users - with the wrappers installed site-wide but who are not actually - using them. See :bbissue:`26`. - - Split up the tests into multiple files. - - Run all tests with all supported shells. - -1.25 -==== - - - Merged in changes to cdsitepackages from William McVey. It now - takes an argument and supports tab-completion for directories - within site-packages. - -1.24.2 -====== - - - Add user provided :ref:`tips-and-tricks` section. - - Add link to Rich Leland's screencast to :ref:`references` section. - -1.24.1 -====== - - - Add license text to the header of the script. - -1.24 -==== - - - Resolve a bug with the preactivate hook not being run properly. - Refer to :bbissue:`21` for complete details. - -1.23 -==== - - - Resolve a bug with the postmkvirtualenv hook not being run - properly. Refer to :bbissue:`19` and :bbissue:`20` for complete - details. - -1.22 -==== - - - Automatically create any missing hook scripts as stubs with - comments to expose the feature in case users are not aware of it. - -1.21 -==== - - - Better protection of ``$WORKON_HOME`` does not exist when the - wrapper script is sourced. - -1.20 -==== - - - Incorporate lssitepackages feature from Sander Smits. - - Refactor some of the functions that were using copy-and-paste code - to build path names. - - Add a few tests. - -1.19 -==== - - - Fix problem with add2virtualenv and relative paths. Thanks to Doug - Latornell for the bug report James Bennett for the suggested fix. - -1.18.1 -====== - - - Incorporate patch from Sascha Brossmann to fix a - :bbissue:`15`. Directory normalization was causing ``WORKON_HOME`` - to appear to be a missing directory if there were control - characters in the output of ``pwd``. - -1.18 -==== - - - Remove warning during installation if sphinxcontrib.paverutils is - not installed. (:bbissue:`10`) - - Added some basic developer information to the documentation. - - Added documentation for deactivate command. - -1.17 -==== - - - Added documentation updates provided by Steve Steiner. - -1.16 -==== - - - Merged in changes to ``cdvirtualenv`` from wam and added tests and - docs. - - Merged in changes to make error messages go to stderr, also - provided by wam. - -1.15 -==== - - - Better error handling in mkvirtualenv. - - Remove bogus VIRTUALENV_WRAPPER_BIN variable. - -1.14 -==== - - - Wrap the virtualenv version of deactivate() with one that lets us - invoke the predeactivate hooks. - - Fix virtualenvwrapper_show_workon_options for colorized versions - of ls and write myself a note so I don't break it again later. - - Convert test.sh to use true tests with `shunit2 - `_ - -1.13 -==== - - - Fix :bbissue:`5` by correctly handling symlinks and limiting the - list of envs to things that look like they can be activated. - -1.12 -==== - - - Check return value of virtualenvwrapper_verify_workon_home - everywhere, thanks to Jeff Forcier for pointing out the errors. - - Fix instructions at top of README, pointed out by Matthew Scott. - - Add cdvirtualenv and cdsitepackages, contributed by James Bennett. - - Enhance test.sh. - -1.11 -==== - - - Optimize virtualenvwrapper_show_workon_options. - - Add global postactivate hook. - -1.10 -==== - - - Pull in fix for colorized ls from Jeff Forcier - (:bbchangeset:`b42a25f7b74a`). - -1.9 -=== - - - Add more hooks for operations to run before and after creating or - deleting environments based on changes from Chris Hasenpflug. - -1.8.1 -===== - - - Corrected a problem with change to mkvirtualenv that lead to - release 1.8 by using an alternate fix proposed by James in - comments on release 1.4. - -1.8 -=== - - - Fix for processing the argument list in mkvirtualenv from - jorgevargas (:bbissue:`1`) - -1.7 -=== - - - Move to bitbucket.org for hosting - - clean up TODO list and svn keywords - - add license section below - -1.6.1 -===== - - - More zsh support (fixes to rmvirtualenv) from Byron Clark. - -1.6 -=== - - - Add completion support for zsh, courtesy of Ted Leung. - -1.5 -=== - - - Fix some issues with spaces in directory or env names. They still - don't really work with virtualenv, though. - - Added documentation for the postactivate and predeactivate scripts. - -1.4 -=== - - - Includes a new .pth management function based on work contributed - by James Bennett and Jannis Leidel. - -1.3.x -===== - - - Includes a fix for a nasty bug in rmvirtualenv identified by John Shimek. +.. include:: ../../ChangeLog From 567674ee11481b4dcefbc65affbc777013688067 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 22 Jun 2014 15:02:51 -0400 Subject: [PATCH 725/947] Remove obsolete information about pip environment vars Remove obsolete instructions about integrating with pip using environment variables that are no longer supported. Fixes bug #225 Change-Id: I0e10f79a2c4cd6c1ef85c1f88e203521f03bbbef --- docs/source/tips.rst | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/docs/source/tips.rst b/docs/source/tips.rst index b999079..7d708d7 100644 --- a/docs/source/tips.rst +++ b/docs/source/tips.rst @@ -39,25 +39,6 @@ I also added the command 'rehash' to ``$WORKON_HOME/postactivate`` and ``$WORKON_HOME/postdeactivate`` as I was having some problems with zsh not picking up the new paths immediately. -Tying to pip's virtualenv support -================================= - -Via http://becomingguru.com/: - -Add this to your shell login script to make pip use the same directory -for virtualenvs as virtualenvwrapper:: - - export PIP_VIRTUALENV_BASE=$WORKON_HOME - -and Via Nat: - -in addition to what becomingguru said, this line is key:: - - export PIP_RESPECT_VIRTUALENV=true - -That makes pip detect an active virtualenv and install to it, without -having to pass it the -E parameter. - Creating Project Work Directories ================================= From f163dd3d82d72351b2da0497c38db7ec19042d4f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 22 Jun 2014 15:18:05 -0400 Subject: [PATCH 726/947] Add tests for wipenv with editable packages Addresses bug #211 Change-Id: I6051e53034f4251e4bdeaa36d7f1d3187c8b2501 --- tests/test_wipeenv.sh | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/tests/test_wipeenv.sh b/tests/test_wipeenv.sh index aa76044..2dbd9cf 100755 --- a/tests/test_wipeenv.sh +++ b/tests/test_wipeenv.sh @@ -12,7 +12,7 @@ setUp () { tearDown() { if type deactivate >/dev/null 2>&1 - then + then deactivate fi rm -rf "$WORKON_HOME" @@ -28,6 +28,38 @@ test_wipeenv () { assertFalse "testpackage still installed" "pip freeze | grep testpackage" } +test_wipeenv_pip_e () { + mkvirtualenv "wipetest" >/dev/null 2>&1 + (cd tests/testpackage && pip install -e .) >/dev/null 2>&1 + before="$(pip freeze)" + assertTrue "testpackage not installed" "pip freeze | grep testpackage" + wipeenv >/dev/null 2>&1 + after="$(pip freeze)" + assertFalse "testpackage still installed" "pip freeze | grep testpackage" +} + +# test_wipeenv_pip_e_url () { +# mkvirtualenv "wipetest" >/dev/null 2>&1 +# (cd tests/testpackage && pip install -e 'git+https://github.com/kennethreitz/legit.git@3c4d3214811c7892edf903682fdbb44f4050b99a#egg=legit-origin') +# # >/dev/null 2>&1 +# before="$(pip freeze)" +# pip freeze +# assertTrue "legit not installed" "pip freeze | grep legit" +# wipeenv >/dev/null 2>&1 +# after="$(pip freeze)" +# assertFalse "legit still installed" "pip freeze | grep legit" +# } + +test_wipeenv_develop () { + mkvirtualenv "wipetest" >/dev/null 2>&1 + (cd tests/testpackage && python setup.py develop) >/dev/null 2>&1 + before="$(pip freeze)" + assertTrue "testpackage not installed" "pip freeze | grep testpackage" + wipeenv >/dev/null 2>&1 + after="$(pip freeze)" + assertFalse "testpackage still installed" "pip freeze | grep testpackage" +} + test_empty_env () { mkvirtualenv "wipetest" >/dev/null 2>&1 before="$(pip freeze)" From d74de98a00c37a14b89d87295116bcc5dbd4b492 Mon Sep 17 00:00:00 2001 From: Nishikar Sapkota Date: Mon, 23 Jun 2014 10:01:37 -0500 Subject: [PATCH 727/947] changed phrasing of environment not found message. --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index bf269ff..9bbc9eb 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -521,7 +521,7 @@ function rmvirtualenv { fi if [ ! -d "$env_dir" ]; then - echo "Cannot remove '$env_name'. No such environment." >&2 + echo "Did not find environment $env_dir to remove." >&2 fi # Move out of the current directory to one known to be From a6c12dd56ca197d7e57e434ec010bedb508ec196 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 6 Jul 2014 08:32:25 -0400 Subject: [PATCH 728/947] Set VIRTUALENVWRAPPER_SCRIPT correctly for different shells The VIRTUALENVWRAPPER_SCRIPT variable was being set incorrectly. Each shell has its own way to identify the script being sourced, so use the right method based on which shell is in use. Reported by Alexandre de Verteuil , with an initial patch for bash. Change-Id: Ia0dbb1ebae726fa3bee2e23cc63bf25196a8a0fa --- tests/test_virtualenvwrapper.sh | 29 +++++++++++++++++++++++++++++ virtualenvwrapper.sh | 10 +++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100755 tests/test_virtualenvwrapper.sh diff --git a/tests/test_virtualenvwrapper.sh b/tests/test_virtualenvwrapper.sh new file mode 100755 index 0000000..529dff1 --- /dev/null +++ b/tests/test_virtualenvwrapper.sh @@ -0,0 +1,29 @@ +# -*- mode: shell-script -*- +# +# Tests for help function 'virtualenvwrapper' + +test_dir=$(cd $(dirname $0) && pwd) +source "$test_dir/setup.sh" + +oneTimeSetUp() { + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo + unset VIRTUALENVWRAPPER_SCRIPT + rm -f "$TMPDIR/catch_output" +} + +test_virtualenvwrapper_script_set() { + source "$test_dir/../virtualenvwrapper.sh" + assertTrue "VIRTUALENVWRAPPER_SCRIPT is not right: $VIRTUALENVWRAPPER_SCRIPT" \ + "echo $VIRTUALENVWRAPPER_SCRIPT | grep -q /virtualenvwrapper.sh" +} + +. "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 9bbc9eb..9578ad5 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -81,7 +81,15 @@ fi # Remember where we are running from. if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ] then - export VIRTUALENVWRAPPER_SCRIPT="$0" + if [ -n "$BASH" ] + then + export VIRTUALENVWRAPPER_SCRIPT="$BASH_SOURCE" + elif [ -n "$ZSH_VERSION" ] + then + export VIRTUALENVWRAPPER_SCRIPT="$0" + else + export VIRTUALENVWRAPPER_SCRIPT="${.sh.file}" + fi fi # Portable shell scripting is hard, let's go shopping. From 8822c26ff0e4593b2441a544ffb56455e60d5f08 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 6 Jul 2014 08:35:54 -0400 Subject: [PATCH 729/947] Tell tox it is ok to run shells not installed in the virtualenv Change-Id: I626c94b41869c34b04f647d6ab213ea2e63357c0 --- tox.ini | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tox.ini b/tox.ini index c30be00..3e7c567 100644 --- a/tox.ini +++ b/tox.ini @@ -9,6 +9,10 @@ deps = distribute stevedore setenv = TOXIC = true +whitelist_externals = + bash + zsh + ksh [testenv:style] deps = flake8 From 06c8b3c02969a9f324963e0f06fe0eff7fd4891e Mon Sep 17 00:00:00 2001 From: OmeGak Date: Sun, 20 Jul 2014 12:55:11 +0200 Subject: [PATCH 730/947] Make postmkproject use VIRTUALENVWRAPPER_HOOK_DIR --- virtualenvwrapper/project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper/project.py b/virtualenvwrapper/project.py index 2afc4eb..42d77d1 100644 --- a/virtualenvwrapper/project.py +++ b/virtualenvwrapper/project.py @@ -44,7 +44,7 @@ def post_mkproject_source(args): # # Run user-provided scripts # -[ -f "$WORKON_HOME/postmkproject" ] && source "$WORKON_HOME/postmkproject" +[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postmkproject" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/postmkproject" """ From bde7ba80196f8d407e8329d7eb5cdec9e4f284d2 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 20 Jul 2014 14:30:11 -0400 Subject: [PATCH 731/947] pep8 and test updates for previous commit Change-Id: I6f66b373b5d00ccb25de727e8033d6b71e043f80 --- tests/test_project_mk.sh | 1 + virtualenvwrapper/project.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_project_mk.sh b/tests/test_project_mk.sh index 15e2a78..1e7eb1f 100755 --- a/tests/test_project_mk.sh +++ b/tests/test_project_mk.sh @@ -8,6 +8,7 @@ oneTimeSetUp() { mkdir -p "$WORKON_HOME" rm -rf "$PROJECT_HOME" mkdir -p "$PROJECT_HOME" + export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME/hooks" source "$test_dir/../virtualenvwrapper.sh" } diff --git a/virtualenvwrapper/project.py b/virtualenvwrapper/project.py index 42d77d1..21775bd 100644 --- a/virtualenvwrapper/project.py +++ b/virtualenvwrapper/project.py @@ -44,7 +44,8 @@ def post_mkproject_source(args): # # Run user-provided scripts # -[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postmkproject" ] && source "$VIRTUALENVWRAPPER_HOOK_DIR/postmkproject" +[ -f "$VIRTUALENVWRAPPER_HOOK_DIR/postmkproject" ] && \ + source "$VIRTUALENVWRAPPER_HOOK_DIR/postmkproject" """ From a0e73c96a7527b637780e4dc364b7cbabf7dd742 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 26 Jul 2014 15:10:19 -0400 Subject: [PATCH 732/947] make run_tests use the SHELL var to run test script Change-Id: I108147219be7d5c869a7455d805f89c0343d9646 --- tests/run_tests | 6 ++++-- tox.ini | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/run_tests b/tests/run_tests index 5724cd6..aa2e55c 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -49,7 +49,7 @@ do echo echo '********************************************************************************' - echo "Running $test_script" + echo "Running $SHELL $test_shell_opts $test_script" echo " VIRTUAL_ENV=$VIRTUAL_ENV" echo " VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON" echo " $($VIRTUALENVWRAPPER_PYTHON -V 2>&1)" @@ -59,12 +59,14 @@ do echo " ZSH_VERSION=$ZSH_VERSION" echo " KSH_VERSION=$KSH_VERSION" echo " virtualenv=$(which virtualenv)" + echo " test_shell_opts=$test_shell_opts" echo " ZSH=$ZSH_NAME $ZSH_EVAL_CONTEXT" echo " TMPDIR=$TMPDIR" + echo SHUNIT_PARENT="$test_script" export SHUNIT_PARENT - $test_shell_opts $test_script || exit 1 + $SHELL $test_shell_opts $test_script || exit 1 echo done diff --git a/tox.ini b/tox.ini index 3e7c567..124d3d0 100644 --- a/tox.ini +++ b/tox.ini @@ -44,6 +44,7 @@ commands = bash ./tests/run_tests {envdir} [] basepython=python2.7 setenv = SHELL = /bin/zsh + test_shell_opts = -o shwordsplit commands = zsh -o shwordsplit ./tests/run_tests {envdir} [] [testenv:ksh] From 6570539e27ef7eb47472e548a60d6529c9e2bf9f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 26 Jul 2014 15:10:40 -0400 Subject: [PATCH 733/947] add -q option to cd for zsh fixes bug #242 Change-Id: I7176290b6d49a0420adea805549d3896c37b95b3 --- tests/test_cd_alias.sh | 18 +++++++++++++++++- virtualenvwrapper.sh | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/test_cd_alias.sh b/tests/test_cd_alias.sh index 4c100fc..4af8f70 100755 --- a/tests/test_cd_alias.sh +++ b/tests/test_cd_alias.sh @@ -10,7 +10,6 @@ oneTimeSetUp() { source "$test_dir/../virtualenvwrapper.sh" mkvirtualenv cd-test >/dev/null 2>&1 deactivate - alias cd='fail "Should not be using override cd function"' } oneTimeTearDown() { @@ -27,10 +26,27 @@ tearDown () { } test_cd() { + alias cd='fail "Should not be using override cd function"' start_dir="$(pwd)" virtualenvwrapper_cd "$VIRTUAL_ENV" assertSame "$VIRTUAL_ENV" "$(pwd)" virtualenvwrapper_cd "$start_dir" + unalias cd +} + +# Define hook function to make cd break +chpwd () { + return 1 +} +# Run a test that uses cd to ensure the hook is not called +test_cd_zsh_chpwd_not_called () { + if [ -n "$ZSH_VERSION" ]; then + start_dir="$(pwd)" + virtualenvwrapper_cd "$VIRTUAL_ENV" + assertSame "$VIRTUAL_ENV" "$(pwd)" + virtualenvwrapper_cd "$start_dir" + fi + unset -f chpwd >/dev/null 2>&1 } . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 9578ad5..2784562 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -109,7 +109,7 @@ function virtualenvwrapper_cd { builtin \cd "$@" elif [ -n "$ZSH_VERSION" ] then - builtin \cd "$@" + builtin \cd -q "$@" else command \cd "$@" fi From 866ef2e9992dbd8df1996fb9e296d8a7ad2cf08c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 26 Jul 2014 16:15:28 -0400 Subject: [PATCH 734/947] Fix test invocation for zsh Replace [] with test to make it work properly with zsh Change-Id: I5316105e1ae82a2612e2f4f2a8d840854b84cc09 --- tests/test_project_cd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_project_cd.sh b/tests/test_project_cd.sh index 2c57fae..77a2bae 100755 --- a/tests/test_project_cd.sh +++ b/tests/test_project_cd.sh @@ -46,7 +46,7 @@ test_space_in_path () { mkproject "myproject" >/dev/null 2>&1 cd "$WORKON_HOME" cdproject - [ "$PROJECT_HOME/myproject" == "$(pwd)" ] + test "$PROJECT_HOME/myproject" = "$PWD" ) assertTrue "Did not cd to project directory" $? } From 5e97aa01ff7be0a8eb7b1036ade3cea335885caa Mon Sep 17 00:00:00 2001 From: Raphael Das Gupta Date: Mon, 13 Oct 2014 13:53:34 +0000 Subject: [PATCH 735/947] removed gratuitous preposition --- docs/source/projects.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/projects.rst b/docs/source/projects.rst index 66a8b54..6b976a6 100644 --- a/docs/source/projects.rst +++ b/docs/source/projects.rst @@ -23,7 +23,7 @@ A new project directory can be created empty, or populated using one or more :term:`template` plugins. Templates should be specified as arguments to :ref:`command-mkproject`. Multiple values can be provided to apply more than one template. For example, to check out a Mercurial -repository from on a project on bitbucket and create a new Django +repository from a project on bitbucket and create a new Django site, combine the :ref:`templates-bitbucket` and :ref:`templates-django` templates. From fef957c533745a4eea451cb749995ab88049f168 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 2 Jan 2015 12:38:59 -0500 Subject: [PATCH 736/947] build universal wheels Change-Id: If92b38db0056190f6d793350f3a20b8be48ca9f5 --- setup.cfg | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.cfg b/setup.cfg index 955c96b..b79d4b8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -75,3 +75,6 @@ virtualenvwrapper.get_env_details = [pbr] warnerrors = true + +[wheel] +universal = true From 70ec5e56ee5f63e381110fe39e3201ab972dffbb Mon Sep 17 00:00:00 2001 From: Peter Bittner Date: Mon, 5 Jan 2015 12:43:09 +0100 Subject: [PATCH 737/947] Update issue tracker URL --- README.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.txt b/README.txt index ec8a686..f044ff0 100644 --- a/README.txt +++ b/README.txt @@ -74,7 +74,7 @@ Join the `virtualenvwrapper Google Group issues and features. Report bugs via the `bug tracker on BitBucket -`__. +`__. Shell Aliases ============= From 371e46648648716fa7fb0aa46d83acde3796ac7b Mon Sep 17 00:00:00 2001 From: Peter Bittner Date: Mon, 5 Jan 2015 12:46:16 +0100 Subject: [PATCH 738/947] Correct spelling of "Bitbucket" --- README.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.txt b/README.txt index f044ff0..29fae47 100644 --- a/README.txt +++ b/README.txt @@ -73,7 +73,7 @@ Join the `virtualenvwrapper Google Group `__ to discuss issues and features. -Report bugs via the `bug tracker on BitBucket +Report bugs via the `bug tracker on Bitbucket `__. Shell Aliases From 9c702672f47cb72f84a1471c3e46ad80286230ed Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 5 Jan 2015 09:47:39 -0500 Subject: [PATCH 739/947] do not install distribute in test environments Change-Id: I2fa2ae43e284d390cb30e5cb359c0441268880ff --- tox.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 124d3d0..616f486 100644 --- a/tox.ini +++ b/tox.ini @@ -3,8 +3,7 @@ envlist = py27,py26,py33,zsh,ksh,style [testenv] commands = bash ./tests/run_tests {envdir} [] -deps = distribute - virtualenv +deps = virtualenv virtualenv-clone stevedore setenv = From 21bf8b9e007a060b8d574f0f1f359c445de3aabe Mon Sep 17 00:00:00 2001 From: Jessamyn Smith Date: Sat, 7 Feb 2015 20:10:17 -0500 Subject: [PATCH 740/947] Reworded the documentation around user scripts vs plugin creation, to make it more clear which one you need. Also added a simple example of user scripts. --- docs/source/hooks.rst | 5 ++++- docs/source/plugins.rst | 13 +++++++------ docs/source/scripts.rst | 22 +++++++++++++++++++++- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/docs/source/hooks.rst b/docs/source/hooks.rst index 3114e32..6cd0cef 100644 --- a/docs/source/hooks.rst +++ b/docs/source/hooks.rst @@ -5,7 +5,10 @@ virtualenvwrapper adds several hook points you can use to change your settings, shell environment, or other configuration values when creating, deleting, or moving between environments. These hooks are -exposed in two ways: +exposed in two ways. :ref:`scripts` allows a user to perform generic actions +for every virtualenv in your environment, including customization of +virtualenv creation. :ref:`plugins` makes it possible to share common +behaviors between systems and developers. .. toctree:: :maxdepth: 1 diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index 300c8f4..fe8d52c 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -12,6 +12,13 @@ virtualenvwrapper continues the tradition of encouraging a craftsman to modify their tools to work the way they want, rather than the other way around. +There are two ways to attach your code so that virtualenvwrapper will +run it: End-users can use shell scripts or other programs for personal +customization, e.g. automatically performing an action on every new +virtualenv (see :ref:`scripts`). Extensions can also be +implemented in Python by using Distribute_ *entry points*, making it +possible to share common behaviors between systems and developers. + Use the hooks provided to eliminate repetitive manual operations and streamline your development workflow. For example, set up the :ref:`plugins-pre_activate` and :ref:`plugins-post_activate` hooks to @@ -25,12 +32,6 @@ install basic requirements into each new development environment, initialize a source code control repository, or otherwise set up a new project. -There are two ways to attach your code so that virtualenvwrapper will -run it: End-users can use shell scripts or other programs for personal -customization (see :ref:`scripts`). Extensions can also be -implemented in Python by using Distribute_ *entry points*, making it -possible to share common behaviors between systems and developers. - Defining an Extension ===================== diff --git a/docs/source/scripts.rst b/docs/source/scripts.rst index a54bd57..4363f8a 100644 --- a/docs/source/scripts.rst +++ b/docs/source/scripts.rst @@ -10,9 +10,29 @@ the appropriate trigger time. The global scripts applied to all environments should be placed in the directory named by :ref:`VIRTUALENVWRAPPER_HOOK_DIR -`. The local scripts should be +`, which by default will be equal +to :ref:`WORKON_HOME `. The local scripts should be placed in the ``bin`` directory of the virtualenv. +Example Usage +=============== + +As a Django developer, you likely want DJANGO_SETTINGS_MODULE to be set, and +if you work on multiple projects, you want it to be specific to the project +you are currently working on. Wouldn't it be nice if it was set based on the +active virtualenv? You can achieve this with :ref:`scripts` as follows. + +If your :ref:`WORKON_HOME ` is set to ~/.virtualenvs: + + vim ~/.virtualenvs/premkvirtualenv + +Edit the file so it contains the following (for a default Django setup): + + # Automatically set django settings for the virtualenv + echo "export DJANGO_SETTINGS_MODULE=$1.settings" >> "$1/bin/activate" + +Create a new virtualenv, and you should see DJANGO_SETTINGS_MODULE in your env! + .. _scripts-get_env_details: get_env_details From e20a4d94d61c2ac6f0c69d57cab14843510632c1 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 9 Feb 2015 14:51:51 -0500 Subject: [PATCH 741/947] Override tox's desire to install pre-releases Define an installation command in tox.ini to avoid using the --pre argument to pip, which installs a bad version of Sphinx that doesn't work with pbr. Change-Id: I09b6ab97cc197cd74857cf6ee4a34a2694523411 --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 616f486..05f0cdb 100644 --- a/tox.ini +++ b/tox.ini @@ -2,6 +2,7 @@ envlist = py27,py26,py33,zsh,ksh,style [testenv] +install_command = pip install -U {opts} {packages} commands = bash ./tests/run_tests {envdir} [] deps = virtualenv virtualenv-clone From 897ae171d909683db7e5cf770da9ca67ea795717 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 9 Feb 2015 15:05:26 -0500 Subject: [PATCH 742/947] Change "distribute" to "setuptools" in docs Replace several out-dated references to Distribute with setuptools. Change-Id: I8ddd56f0364dee31fd684d3e324f61adf6f95941 --- docs/source/command_ref.rst | 28 +++++++++---------- docs/source/index.rst | 8 +++--- docs/source/plugins.rst | 56 ++++++++++--------------------------- 3 files changed, 33 insertions(+), 59 deletions(-) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 893d79b..36ef124 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -33,7 +33,7 @@ activated after being initialized. $ workon $ mkvirtualenv mynewenv New python executable in mynewenv/bin/python - Installing distribute............................................. + Installing setuptools............................................. .................................................................. .................................................................. done. @@ -79,7 +79,7 @@ A unique virtualenv name is generated. New python executable in 1e513ac6-616e-4d56-9aa5-9d0a3b305e20/bin/python Overwriting 1e513ac6-616e-4d56-9aa5-9d0a3b305e20/lib/python2.7/distutils/__init__.py with new content - Installing distribute............................................... + Installing setuptools............................................... .................................................................... .................................................................done. This is a temporary environment. It will be deleted when deactivated. @@ -180,7 +180,7 @@ Syntax:: $ workon $ mkvirtualenv source New python executable in source/bin/python - Installing distribute............................................. + Installing setuptools............................................. .................................................................. .................................................................. done. @@ -248,13 +248,13 @@ is printed to stdout. $ workon $ mkvirtualenv env1 New python executable in env1/bin/python - Installing distribute............................................. + Installing setuptools............................................. .................................................................. .................................................................. done. (env1)$ mkvirtualenv env2 New python executable in env2/bin/python - Installing distribute............................................. + Installing setuptools............................................. .................................................................. .................................................................. done. @@ -301,7 +301,7 @@ Syntax:: $ mkvirtualenv env1 New python executable in env1/bin/python - Installing distribute............................................. + Installing setuptools............................................. .................................................................. .................................................................. done. @@ -342,7 +342,7 @@ subdirectory. $ mkvirtualenv env1 New python executable in env1/bin/python - Installing distribute............................................. + Installing setuptools............................................. .................................................................. .................................................................. done. @@ -376,7 +376,7 @@ directory to change into. $ mkvirtualenv env1 New python executable in env1/bin/python - Installing distribute............................................. + Installing setuptools............................................. .................................................................. .................................................................. done. @@ -400,13 +400,13 @@ Syntax:: $ mkvirtualenv env1 New python executable in env1/bin/python - Installing distribute............................................. + Installing setuptools............................................. .................................................................. .................................................................. done. (env1)$ $ workon env1 (env1)$ lssitepackages - distribute-0.6.10-py2.6.egg pip-0.6.3-py2.6.egg + setuptools-0.6.10-py2.6.egg pip-0.6.3-py2.6.egg easy-install.pth setuptools.pth =============== @@ -462,7 +462,7 @@ output. $ mkvirtualenv env1 New python executable in env1/bin/python - Installing distribute............................................. + Installing setuptools............................................. .................................................................. .................................................................. done. @@ -505,7 +505,7 @@ create a virtual environment with the same name as the project. $ mkproject myproj New python executable in myproj/bin/python - Installing distribute............................................. + Installing setuptools............................................. .................................................................. .................................................................. done. @@ -540,14 +540,14 @@ virtualenv and project directory. An association is made so that when $ mkproject myproj New python executable in myproj/bin/python - Installing distribute............................................. + Installing setuptools............................................. .................................................................. .................................................................. done. Creating /Users/dhellmann/Devel/myproj (myproj)$ mkvirtualenv myproj_new_libs New python executable in myproj/bin/python - Installing distribute............................................. + Installing setuptools............................................. .................................................................. .................................................................. done. diff --git a/docs/source/index.rst b/docs/source/index.rst index d6450b6..5c0a0f8 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -50,7 +50,7 @@ installed by pip. $ source /usr/local/bin/virtualenvwrapper.sh $ mkvirtualenv env1 Installing - distribute.......................................... + setuptools.......................................... .................................................... .................................................... ...............................done. @@ -79,7 +79,7 @@ We can see the new package with ``lssitepackages``:: (env1)$ lssitepackages Django-1.1.1-py2.6.egg-info easy-install.pth - distribute-0.6.10-py2.6.egg pip-0.6.3-py2.6.egg + setuptools-0.6.10-py2.6.egg pip-0.6.3-py2.6.egg django setuptools.pth Of course we are not limited to a single virtualenv:: @@ -87,7 +87,7 @@ Of course we are not limited to a single virtualenv:: (env1)$ ls $WORKON_HOME env1 hook.log (env1)$ mkvirtualenv env2 - Installing distribute............................... + Installing setuptools............................... .................................................... .................................................... ........... ...............................done. @@ -124,7 +124,7 @@ created, letting you automatically install commonly-used tools. (env2)$ echo 'pip install sphinx' >> $WORKON_HOME/postmkvirtualenv (env3)$ mkvirtualenv env3 New python executable in env3/bin/python - Installing distribute............................... + Installing setuptools............................... .................................................... .................................................... ........... ...............................done. diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index fe8d52c..974b9f0 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -16,7 +16,7 @@ There are two ways to attach your code so that virtualenvwrapper will run it: End-users can use shell scripts or other programs for personal customization, e.g. automatically performing an action on every new virtualenv (see :ref:`scripts`). Extensions can also be -implemented in Python by using Distribute_ *entry points*, making it +implemented in Python by using `Setuptools entry points`_, making it possible to share common behaviors between systems and developers. Use the hooks provided to eliminate repetitive manual operations and @@ -162,48 +162,22 @@ Registering Entry Points The functions defined in the plugin need to be registered as *entry points* in order for virtualenvwrapper's hook loader to find them. -Distribute_ entry points are configured in the ``setup.py`` for your -package by mapping the entry point name to the function in the package -that implements it. +Entry points are configured in the ``setup.py`` (or ``setup.cfg`` when +using pbr) for your package by mapping the entry point name to the +function in the package that implements it. -This partial copy of virtualenvwrapper's ``setup.py`` illustrates how +This partial copy of virtualenvwrapper's ``setup.cfg`` illustrates how the ``initialize()`` and ``initialize_source()`` entry points are configured. -:: - - # Bootstrap installation of Distribute - import distribute_setup - distribute_setup.use_setuptools() - - from setuptools import setup - - setup( - name = 'virtualenvwrapper', - version = '2.0', - - description = 'Enhancements to virtualenv', - - # ... details omitted ... - - namespace_packages = [ 'virtualenvwrapper' ], - - entry_points = { - 'virtualenvwrapper.initialize': [ - 'user_scripts = virtualenvwrapper.user_scripts:initialize', - ], - 'virtualenvwrapper.initialize_source': [ - 'user_scripts = virtualenvwrapper.user_scripts:initialize_source', - ], - - # ... details omitted ... - }, - ) +.. include:: ../../setup.cfg + :literal: + :start-after: [entry_points] -The ``entry_points`` argument to ``setup()`` is a dictionary mapping -the entry point *group names* to lists of entry point specifiers. A -different group name is defined by virtualenvwrapper for each -extension point (see :ref:`plugins-extension-points`). +The ``entry_points`` section maps the *group names* to lists of entry +point specifiers. A different group name is defined by +virtualenvwrapper for each extension point (see +:ref:`plugins-extension-points`). The entry point specifiers are strings with the syntax ``name = package.module:function``. By convention, the *name* of each entry @@ -212,8 +186,8 @@ used). .. seealso:: - * `namespace packages `__ - * `Extensible Applications and Frameworks `__ + * `namespace packages `__ + * `Extensible Applications and Frameworks `__ The Hook Loader --------------- @@ -420,6 +394,6 @@ and:: respectively. -.. _Distribute: http://packages.python.org/distribute/ +.. _Setuptools entry points: http://pythonhosted.org//setuptools/pkg_resources.html#entry-points .. _project: http://www.doughellmann.com/projects/virtualenvwrapper.project/ From 30ee22fe6b9c7da559498b4d72d6da010c0d7503 Mon Sep 17 00:00:00 2001 From: Harry Date: Sun, 5 Apr 2015 03:06:07 +0100 Subject: [PATCH 743/947] hacked attempt to get round MSYS_HOME environ dependency on windows/git-bash/msys --- virtualenvwrapper/user_scripts.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 611dff0..d82fa3d 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -26,13 +26,23 @@ script_folder = 'bin' +def _get_msys_shell(): + if 'MSYS_HOME' in os.environ: + return [get_path(os.environ['MSYS_HOME'], 'bin', 'sh.exe')] + else: + for path in os.environ['PATH'].split(';'): + if os.path.exists(os.path.join(path, 'sh.exe')): + return [get_path(path, 'sh.exe')] + raise Exception('Could not find sh.exe') + + def run_script(script_path, *args): """Execute a script in a subshell. """ if os.path.exists(script_path): cmd = [script_path] + list(args) if is_msys: - cmd = [get_path(os.environ['MSYS_HOME'], 'bin', 'sh.exe')] + cmd + cmd = _get_msys_shell() + cmd log.debug('running %s', str(cmd)) try: subprocess.call(cmd) From 585e1202415d2969498a1dfd214b33fe48c5a359 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 9 Apr 2015 10:44:51 -0400 Subject: [PATCH 744/947] ignore -f lines in pip freeze output Newer versions of pip include the wheelhouse specification in the pip freeze output, which then breaks the call to pip uninstall. Ignore the line starting with "-f" to avoid the error and make wipeenv work properly again. Change-Id: Ibff7e40f620b08e685d5c6691576e527cbeb5510 --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 2784562..1a0186e 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -1207,7 +1207,7 @@ function wipeenv { echo "Uninstalling packages:" cat "$req_file" echo - pip uninstall -y $(cat "$req_file" | sed 's/>/=/g' | cut -f1 -d=) + pip uninstall -y $(cat "$req_file" | grep -v '^-f' | sed 's/>/=/g' | cut -f1 -d=) else echo "Nothing to remove." fi From 327c8b2cf081fe8cb78170fb02bf4c1ebc952229 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 9 Apr 2015 11:11:39 -0400 Subject: [PATCH 745/947] Stop mangling the python argument to virtualenv Pass the value given by the user for the --python option directly through to virtualenv without trying to expand it. Change-Id: Ia65bea1777f1c69524cb5685f0eaeabc1f7f50fe Fixes: #255 --- tests/test_mkvirtualenv.sh | 6 +++--- virtualenvwrapper.sh | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index a81f4a5..461a3b3 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -196,7 +196,7 @@ test_mkvirtualenv_python_short_option () { typeset _save=$VIRTUALENVWRAPPER_VIRTUALENV VIRTUALENVWRAPPER_VIRTUALENV=echo output="$(mkvirtualenv -p python foo)" - assertSame "--python=$(pwd)/python foo" "$output" + assertSame "--python=python foo" "$output" VIRTUALENVWRAPPER_VIRTUALENV=$_save } @@ -204,7 +204,7 @@ test_mkvirtualenv_python_long_option () { typeset _save=$VIRTUALENVWRAPPER_VIRTUALENV VIRTUALENVWRAPPER_VIRTUALENV=echo output="$(mkvirtualenv --python python foo)" - assertSame "--python=$(pwd)/python foo" "$output" + assertSame "--python=python foo" "$output" VIRTUALENVWRAPPER_VIRTUALENV=$_save } @@ -212,7 +212,7 @@ test_mkvirtualenv_python_long_option_equal () { typeset _save=$VIRTUALENVWRAPPER_VIRTUALENV VIRTUALENVWRAPPER_VIRTUALENV=echo output="$(mkvirtualenv --python=python foo)" - assertSame "--python=$(pwd)/python foo" "$output" + assertSame "--python=python foo" "$output" VIRTUALENVWRAPPER_VIRTUALENV=$_save } diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 1a0186e..e4bad27 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -439,8 +439,7 @@ function mkvirtualenv { else i=$(( $i + 1 )) interpreter="${in_args[$i]}" - fi; - interpreter="$(virtualenvwrapper_absolutepath "$interpreter")";; + fi;; -r) i=$(( $i + 1 )); requirements="${in_args[$i]}"; From 057ea9f2eda74ed255850bbdfa1571b41d5d868b Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 10 Apr 2015 17:22:47 -0400 Subject: [PATCH 746/947] fix sphinx build Change-Id: Ia92eda346032cb58f16066e714aeaf6ff2388448 --- docs/requirements.txt | 1 + setup.cfg | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/docs/requirements.txt b/docs/requirements.txt index a35bfac..7acfbd9 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1 +1,2 @@ sphinxcontrib-bitbucket +sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3 diff --git a/setup.cfg b/setup.cfg index b79d4b8..7d1b2d4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -78,3 +78,8 @@ warnerrors = true [wheel] universal = true + +[build_sphinx] +source-dir = docs/source +build-dir = docs/build +all_files = 1 From 4a6aab0e4a5c6a00c7a71c18839086c365a96c05 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 10 Apr 2015 17:23:03 -0400 Subject: [PATCH 747/947] make cd after workon optional Provide an environment variable and command line option to control whether the project plugin changes the working directory during the post-activate phase. Addresses #246 Change-Id: If710959339e17a6960ae12f9023088460f546daa --- docs/source/command_ref.rst | 11 ++++++++- docs/source/install.rst | 14 +++++++++++ docs/source/projects.rst | 1 + tests/test_project_activate.sh | 44 ++++++++++++++++++++++++++++++++++ virtualenvwrapper.sh | 36 +++++++++++++++++++++++++++- virtualenvwrapper/project.py | 4 ++-- 6 files changed, 106 insertions(+), 4 deletions(-) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 36ef124..6232215 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -238,11 +238,19 @@ List or change working virtual environments Syntax:: - workon [environment_name] + workon [(-c|--cd)|(-n|--no-cd)] [environment_name] If no ``environment_name`` is given the list of available environments is printed to stdout. +If ``-c`` or ``--cd`` is specified the working directory is changed to +the project directory during the post-activate phase, regardless of +the value of ``VIRTUALENVWRAPPER_WORKON_CD``. + +If ``-n`` or ``--no-cd`` is specified the working directory is **not** +changed to the project directory during the post-activate phase, +regardless of the value of ``VIRTUALENVWRAPPER_WORKON_CD``. + :: $ workon @@ -276,6 +284,7 @@ is printed to stdout. * :ref:`scripts-postdeactivate` * :ref:`scripts-preactivate` * :ref:`scripts-postactivate` + * :ref:`variable-VIRTUALENVWRAPPER_WORKON_CD` .. _command-deactivate: diff --git a/docs/source/install.rst b/docs/source/install.rst index 0693376..5f35b1a 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -207,6 +207,20 @@ project working directory. The default is ``.project``. * :ref:`project-management` +.. _variable-VIRTUALENVWRAPPER_WORKON_CD: + +Enable Project Directory Switching +---------------------------------- + +The variable ``VIRTUALENVWRAPPER_WORKON_CD`` controls whether the +working directory is changed during the post activate phase. The +default is ``1``, to enable changing directories. Set the value to +``0`` to disable this behavior for all invocations of ``workon``. + +.. seealso:: + + * :ref:`command-workon` + .. _variable-VIRTUALENVWRAPPER_HOOK_DIR: Location of Hook Scripts diff --git a/docs/source/projects.rst b/docs/source/projects.rst index 6b976a6..c08ea33 100644 --- a/docs/source/projects.rst +++ b/docs/source/projects.rst @@ -36,3 +36,4 @@ site, combine the :ref:`templates-bitbucket` and * :ref:`extensions-templates` * :ref:`variable-PROJECT_HOME` * :ref:`variable-VIRTUALENVWRAPPER_PROJECT_FILENAME` + * :ref:`variable-VIRTUALENVWRAPPER_WORKON_CD` diff --git a/tests/test_project_activate.sh b/tests/test_project_activate.sh index 0e832d7..b566568 100755 --- a/tests/test_project_activate.sh +++ b/tests/test_project_activate.sh @@ -18,6 +18,13 @@ oneTimeSetUp() { setUp () { echo + # In case the user has the value set, we need to force it to the default + VIRTUALENVWRAPPER_WORKON_CD=1 +} + +tearDown () { + # In case a test has changed the value, we need to force it to the default + VIRTUALENVWRAPPER_WORKON_CD=1 } test_activate () { @@ -31,6 +38,43 @@ test_activate () { deactivate } +test_activate_n () { + mkproject myproject_n >/dev/null 2>&1 + assertTrue $? + deactivate + cd $TMPDIR + assertSame "" "$VIRTUAL_ENV" + workon -n myproject_n + assertSame "myproject_n" "$(basename $VIRTUAL_ENV)" + assertSame "$TMPDIR" "$(pwd)" + deactivate +} + +test_activate_no_cd () { + mkproject myproject_no_cd >/dev/null 2>&1 + assertTrue $? + deactivate + cd $TMPDIR + assertSame "" "$VIRTUAL_ENV" + workon --no-cd myproject_no_cd + assertSame "myproject_no_cd" "$(basename $VIRTUAL_ENV)" + assertSame "$TMPDIR" "$(pwd)" + deactivate +} + +test_activate_workon_cd_disabled () { + export VIRTUALENVWRAPPER_WORKON_CD=0 + mkproject myproject_cd_disabled >/dev/null 2>&1 + assertTrue $? + deactivate + cd $TMPDIR + assertSame "" "$VIRTUAL_ENV" + workon myproject_cd_disabled + assertSame "myproject_cd_disabled" "$(basename $VIRTUAL_ENV)" + assertSame "$TMPDIR" "$(pwd)" + deactivate +} + test_space_in_path () { old_project_home="$PROJECT_HOME" PROJECT_HOME="$PROJECT_HOME/with spaces" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index e4bad27..90fe2ed 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -78,6 +78,13 @@ then export VIRTUALENVWRAPPER_PROJECT_FILENAME=".project" fi +# Let the user tell us they never want to cd to projects +# automatically. +if [ "$VIRTUALENVWRAPPER_WORKON_CD" = "" ] +then + export VIRTUALENVWRAPPER_WORKON_CD=1 +fi + # Remember where we are running from. if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ] then @@ -658,10 +665,23 @@ function virtualenvwrapper_workon_help { echo "" echo " Show this help message." echo "" + echo " workon (-c|--cd) envname" + echo "" + echo " After activating the environment, cd to the associated" + echo " project directory if it is set." + echo "" + echo " workon (-n|--no-cd) envname" + echo "" + echo " After activating the environment, do not cd to the" + echo " associated project directory." + echo "" } #:help:workon: list or change working virtualenvs function workon { + typeset -a in_args + typeset -a out_args + in_args=( "$@" ) if [ -n "$ZSH_VERSION" ] @@ -672,6 +692,7 @@ function workon { i=0 tst="-lt" fi + typeset cd_after_activate=$VIRTUALENVWRAPPER_WORKON_CD while [ $i $tst $# ] do a="${in_args[$i]}" @@ -679,10 +700,23 @@ function workon { -h|--help) virtualenvwrapper_workon_help; return 0;; + -n|--no-cd) + cd_after_activate=0;; + -c|--cd) + cd_after_activate=1;; + *) + if [ ${#out_args} -gt 0 ] + then + out_args=( "${out_args[@]-}" "$a" ) + else + out_args=( "$a" ) + fi;; esac i=$(( $i + 1 )) done + set -- "${out_args[@]}" + typeset env_name="$1" if [ "$env_name" = "" ] then @@ -745,7 +779,7 @@ function workon { }' - virtualenvwrapper_run_hook "post_activate" + VIRTUALENVWRAPPER_PROJECT_CD=$cd_after_activate virtualenvwrapper_run_hook "post_activate" return 0 } diff --git a/virtualenvwrapper/project.py b/virtualenvwrapper/project.py index 21775bd..48e3a31 100644 --- a/virtualenvwrapper/project.py +++ b/virtualenvwrapper/project.py @@ -52,9 +52,9 @@ def post_mkproject_source(args): def post_activate_source(args): return """ # -# Change to the project directory +# Change to the project directory, as long as we haven't been told not to. # -[ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" ] && \ +[ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" -a "$VIRTUALENVWRAPPER_PROJECT_CD" = 1 ] && \ virtualenvwrapper_cd \ "$(cat \"$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME\")" """ From b380f2f14f0a6a17b3a1730883c533cd07ce84b6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 10 Apr 2015 23:54:14 -0400 Subject: [PATCH 748/947] fix pep8 error Change-Id: Ic9fcd36276910cc85c4941c1712a4f90e0e08831 --- virtualenvwrapper/project.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/virtualenvwrapper/project.py b/virtualenvwrapper/project.py index 48e3a31..51ec50b 100644 --- a/virtualenvwrapper/project.py +++ b/virtualenvwrapper/project.py @@ -54,7 +54,8 @@ def post_activate_source(args): # # Change to the project directory, as long as we haven't been told not to. # -[ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" -a "$VIRTUALENVWRAPPER_PROJECT_CD" = 1 ] && \ +[ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" \ + -a "$VIRTUALENVWRAPPER_PROJECT_CD" = 1 ] && \ virtualenvwrapper_cd \ "$(cat \"$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME\")" """ From f32241d6d887cc556d3591d7611576eab3d00a9f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Apr 2015 14:11:31 -0400 Subject: [PATCH 749/947] Support "workon ." If the literal string "." is passed to workon, use the current working directory to derive the virtualenv name. Activation happens normally, which may involve changing directories out of the current directory (possibly even changing back, depending on what postactivate hooks do). Change-Id: Ia2de0bf05a52a95e4979c58bd868ae309f23540d --- tests/test_workon.sh | 7 +++++++ virtualenvwrapper.sh | 3 +++ 2 files changed, 10 insertions(+) diff --git a/tests/test_workon.sh b/tests/test_workon.sh index df7ac69..57104f1 100755 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -116,4 +116,11 @@ test_no_workon_home () { WORKON_HOME="$old_home" } +test_workon_dot () { + cd $WORKON_HOME/env1 + workon . + assertTrue virtualenvwrapper_verify_active_environment + assertSame "env1" $(basename "$VIRTUAL_ENV") +} + . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 90fe2ed..8938840 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -722,6 +722,9 @@ function workon { then lsvirtualenv -b return 1 + elif [ "$env_name" = "." ] + then + env_name=$(basename $(pwd)) fi virtualenvwrapper_verify_workon_home || return 1 From dc06f764052c8a3ac77a622bc756579cbd7168a4 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Apr 2015 14:17:20 -0400 Subject: [PATCH 750/947] document 'workon .' and give attribution Change-Id: Ib62ce77cc8fb07e31df29ab44eb4f7bf84c7efaf --- docs/source/command_ref.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 6232215..7d28d16 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -238,7 +238,7 @@ List or change working virtual environments Syntax:: - workon [(-c|--cd)|(-n|--no-cd)] [environment_name] + workon [(-c|--cd)|(-n|--no-cd)] [environment_name|"."] If no ``environment_name`` is given the list of available environments is printed to stdout. @@ -251,6 +251,10 @@ If ``-n`` or ``--no-cd`` is specified the working directory is **not** changed to the project directory during the post-activate phase, regardless of the value of ``VIRTUALENVWRAPPER_WORKON_CD``. +If ``"."`` is passed as the environment name, the name is derived from +the base name of the current working directory (contributed by Matias +Saguir). + :: $ workon From 7a8a268652423f7cdbecc8ac905aeb89235a86ac Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Apr 2015 14:39:26 -0400 Subject: [PATCH 751/947] Touch temporary file after a name is created There's an issue when trying to run virtualenvwrapper.sh on windows with MinGw. The full issue was posted to http://stackoverflow.com/questions/24478623/error-virtualenvwrapper-in-gitbash/28522399 Basically, it's either windows or mktemp that's not creating the tmp file but just returning the full path of it, so just "touch"ing the file seems to solve this issue. Based on work by Abelardo Mendoza in: https://bitbucket.org/dhellmann/virtualenvwrapper/pull-request/24/touch-tmp-file-to-force-windows-to-create/diff Change-Id: I4c788686ed23c31facd7fd5538f5fabe86849a8a --- virtualenvwrapper.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 8938840..fdf773c 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -207,6 +207,7 @@ function virtualenvwrapper_tempfile { typeset file file="$(virtualenvwrapper_mktemp -t virtualenvwrapper-$suffix-XXXXXXXXXX)" + touch "$file" if [ $? -ne 0 ] || [ -z "$file" ] || [ ! -f "$file" ] then echo "ERROR: virtualenvwrapper could not create a temporary file name." 1>&2 From 4a675e3aadef72e0364eb7a348c41ab4760653f6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Apr 2015 17:16:04 -0400 Subject: [PATCH 752/947] Add test for creating venv with space in name Create a virtualenv with a space in the name of the env, not just the WORKON_HOME. Addresses #248 Change-Id: I385163fda808b146b5863826b79a2bd337aadc7a --- tests/test_mkvirtualenv.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index 461a3b3..fa197bc 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -28,6 +28,16 @@ test_create() { done } +test_create_space_in_name() { + mkvirtualenv "env with space" >/dev/null 2>&1 + assertTrue "Environment directory was not created" "[ -d \"$WORKON_HOME/env with space\" ]" + for hook in postactivate predeactivate postdeactivate + do + assertTrue "$hook was not created" "[ -f \"$WORKON_HOME/env with space/bin/$hook\" ]" + assertFalse "$hook is executable" "[ -x \"$WORKON_HOME/env with space/bin/$hook\" ]" + done +} + test_activates () { mkvirtualenv "env2" >/dev/null 2>&1 assertTrue virtualenvwrapper_verify_active_environment From 5b61cb5db7fab9fb5b316c160636f6fafa27769e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Apr 2015 17:43:39 -0400 Subject: [PATCH 753/947] update mktmpenv test to assert changed directory Change-Id: Iaad6b92a0ffe7139dc6b2f92b2c951fdefa0b116 --- tests/test_mktmpenv.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_mktmpenv.sh b/tests/test_mktmpenv.sh index 678b7cd..39928b0 100755 --- a/tests/test_mktmpenv.sh +++ b/tests/test_mktmpenv.sh @@ -23,6 +23,7 @@ test_mktmpenv_no_name() { mktmpenv >/dev/null 2>&1 after=$(lsvirtualenv -b) assertFalse "Environment was not created" "[ \"$before\" = \"$after\" ]" + assertSame "$VIRTUAL_ENV" "$(pwd)" } test_mktmpenv_name() { From da01a8c3cedad98948f7d3313ace614262aabd73 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 12 Apr 2015 09:04:07 -0400 Subject: [PATCH 754/947] Add -c/-n options to mktmpenv Add options to control whether to cd to the virtualenv when creating a temporary env. Closes #220 Change-Id: I2a1fdfb9705ab30f13a6a6c3af9582e413655652 --- docs/source/command_ref.rst | 10 +++++++++- tests/test_mktmpenv.sh | 10 ++++++++++ virtualenvwrapper.sh | 36 +++++++++++++++++++++++++++++++++++- 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 7d28d16..0b7469e 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -68,10 +68,18 @@ Create a new virtualenv in the ``WORKON_HOME`` directory. Syntax:: - mktmpenv [VIRTUALENV_OPTIONS] + mktmpenv [(-c|--cd)|(-n|--no-cd)] [VIRTUALENV_OPTIONS] A unique virtualenv name is generated. +If ``-c`` or ``--cd`` is specified the working directory is changed to +the virtualenv directory during the post-activate phase, regardless of +the value of ``VIRTUALENVWRAPPER_WORKON_CD``. + +If ``-n`` or ``--no-cd`` is specified the working directory is **not** +changed to the virtualenv directory during the post-activate phase, +regardless of the value of ``VIRTUALENVWRAPPER_WORKON_CD``. + :: $ mktmpenv diff --git a/tests/test_mktmpenv.sh b/tests/test_mktmpenv.sh index 39928b0..c8989bc 100755 --- a/tests/test_mktmpenv.sh +++ b/tests/test_mktmpenv.sh @@ -32,6 +32,16 @@ test_mktmpenv_name() { assertTrue "Error was not detected" "[ $RC -ne 0 ]" } +test_mktmpenv_n() { + mktmpenv -n >/dev/null 2>&1 + assertNotSame "$VIRTUAL_ENV" "$(pwd)" +} + +test_mktmpenv_no_cd() { + mktmpenv --no-cd >/dev/null 2>&1 + assertNotSame "$VIRTUAL_ENV" "$(pwd)" +} + test_mktmpenv_virtualenv_args() { mktmpenv --no-site-packages >/dev/null 2>&1 ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index fdf773c..fe5cc20 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -1195,6 +1195,40 @@ function cdproject { function mktmpenv { typeset tmpenvname typeset RC + typeset -a in_args + typeset -a out_args + + in_args=( "$@" ) + + if [ -n "$ZSH_VERSION" ] + then + i=1 + tst="-le" + else + i=0 + tst="-lt" + fi + typeset cd_after_activate=$VIRTUALENVWRAPPER_WORKON_CD + while [ $i $tst $# ] + do + a="${in_args[$i]}" + case "$a" in + -n|--no-cd) + cd_after_activate=0;; + -c|--cd) + cd_after_activate=1;; + *) + if [ ${#out_args} -gt 0 ] + then + out_args=( "${out_args[@]-}" "$a" ) + else + out_args=( "$a" ) + fi;; + esac + i=$(( $i + 1 )) + done + + set -- "${out_args[@]}" # Generate a unique temporary name tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import uuid,sys; sys.stdout.write(uuid.uuid4()+"\n")' 2>/dev/null) @@ -1214,7 +1248,7 @@ function mktmpenv { fi # Change working directory - cdvirtualenv + [ "$cd_after_activate" = "1" ] && cdvirtualenv # Create the tmpenv marker file echo "This is a temporary environment. It will be deleted when you run 'deactivate'." | tee "$VIRTUAL_ENV/README.tmpenv" From 5a440b0cd398dd8ab835a32d12b180759e8906d6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 25 Apr 2015 11:17:19 -0400 Subject: [PATCH 755/947] fix default for VIRTUALENVWRAPPER_WORKON_CD Change-Id: I307e01fd333351795418f759f6b99b656c58ec33 --- virtualenvwrapper.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index fe5cc20..0b952af 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -80,10 +80,7 @@ fi # Let the user tell us they never want to cd to projects # automatically. -if [ "$VIRTUALENVWRAPPER_WORKON_CD" = "" ] -then - export VIRTUALENVWRAPPER_WORKON_CD=1 -fi +export VIRTUALENVWRAPPER_WORKON_CD=${VIRTUALENVWRAPPER_WORKON_CD:-1} # Remember where we are running from. if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ] From d4139aafed6cec74e828affed3df4024d8dd388d Mon Sep 17 00:00:00 2001 From: Jessamyn Smith Date: Sat, 25 Apr 2015 13:40:08 -0400 Subject: [PATCH 756/947] Made workon fully support virtualenvs with spaces in names --- tests/test_mkvirtualenv.sh | 3 +++ tests/test_workon.sh | 22 +++++++++++++++++++--- virtualenvwrapper.sh | 6 ++++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index fa197bc..0f3e7a2 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -36,6 +36,9 @@ test_create_space_in_name() { assertTrue "$hook was not created" "[ -f \"$WORKON_HOME/env with space/bin/$hook\" ]" assertFalse "$hook is executable" "[ -x \"$WORKON_HOME/env with space/bin/$hook\" ]" done + assertTrue virtualenvwrapper_verify_active_environment + env_name=$(basename "$VIRTUAL_ENV") + assertSame "env with space" "$env_name" } test_activates () { diff --git a/tests/test_workon.sh b/tests/test_workon.sh index 57104f1..8c2352b 100755 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -9,6 +9,7 @@ oneTimeSetUp() { source "$test_dir/../virtualenvwrapper.sh" mkvirtualenv "env1" >/dev/null 2>&1 mkvirtualenv "env2" >/dev/null 2>&1 + mkvirtualenv "env with space" >/dev/null 2>&1 deactivate >/dev/null 2>&1 } @@ -67,7 +68,7 @@ test_virtualenvwrapper_show_workon_options () { mkdir "$WORKON_HOME/not_env" (cd "$WORKON_HOME"; ln -s env1 link_env) envs=$(virtualenvwrapper_show_workon_options | tr '\n' ' ') - assertSame "env1 env2 link_env " "$envs" + assertSame "env1 env2 link_env env with space " "$envs" rmdir "$WORKON_HOME/not_env" rm -f "$WORKON_HOME/link_env" } @@ -78,7 +79,7 @@ test_virtualenvwrapper_show_workon_options_grep_options () { export GREP_OPTIONS="--count" envs=$(virtualenvwrapper_show_workon_options | tr '\n' ' ') unset GREP_OPTIONS - assertSame "env1 env2 link_env " "$envs" + assertSame "env1 env2 link_env env with space " "$envs" rmdir "$WORKON_HOME/not_env" rm -f "$WORKON_HOME/link_env" } @@ -94,7 +95,7 @@ test_virtualenvwrapper_show_workon_options_chpwd () { } mkdir "$WORKON_HOME/not_env" envs=$(virtualenvwrapper_show_workon_options | tr '\n' ' ') - assertSame "env1 env2 " "$envs" + assertSame "env1 env2 env with space " "$envs" rmdir "$WORKON_HOME/not_env" rm -f "$WORKON_HOME/link_env" } @@ -123,4 +124,19 @@ test_workon_dot () { assertSame "env1" $(basename "$VIRTUAL_ENV") } +test_workon_dot_with_space () { + cd $WORKON_HOME/"env with space" + workon . + assertTrue virtualenvwrapper_verify_active_environment + env_name=$(basename "$VIRTUAL_ENV") + assertSame "env with space" "$env_name" +} + +test_workon_with_space () { + workon "env with space" + assertTrue virtualenvwrapper_verify_active_environment + env_name=$(basename "$VIRTUAL_ENV") + assertSame "env with space" "$env_name" +} + . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 0b952af..6e53699 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -722,11 +722,13 @@ function workon { return 1 elif [ "$env_name" = "." ] then - env_name=$(basename $(pwd)) + IFS='%' + env_name="$(basename $(pwd))" + unset IFS fi virtualenvwrapper_verify_workon_home || return 1 - virtualenvwrapper_verify_workon_environment $env_name || return 1 + virtualenvwrapper_verify_workon_environment "$env_name" || return 1 activate="$WORKON_HOME/$env_name/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate" if [ ! -f "$activate" ] From 0225913f3004f621a3e05c47341c07913bc8846e Mon Sep 17 00:00:00 2001 From: Jessamyn Smith Date: Sat, 25 Apr 2015 14:18:40 -0400 Subject: [PATCH 757/947] Fixed ordering in asserts for workon tests --- tests/test_workon.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_workon.sh b/tests/test_workon.sh index 8c2352b..cb44c3e 100755 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -68,7 +68,7 @@ test_virtualenvwrapper_show_workon_options () { mkdir "$WORKON_HOME/not_env" (cd "$WORKON_HOME"; ln -s env1 link_env) envs=$(virtualenvwrapper_show_workon_options | tr '\n' ' ') - assertSame "env1 env2 link_env env with space " "$envs" + assertSame "env with space env1 env2 link_env " "$envs" rmdir "$WORKON_HOME/not_env" rm -f "$WORKON_HOME/link_env" } @@ -79,7 +79,7 @@ test_virtualenvwrapper_show_workon_options_grep_options () { export GREP_OPTIONS="--count" envs=$(virtualenvwrapper_show_workon_options | tr '\n' ' ') unset GREP_OPTIONS - assertSame "env1 env2 link_env env with space " "$envs" + assertSame "env with space env1 env2 link_env " "$envs" rmdir "$WORKON_HOME/not_env" rm -f "$WORKON_HOME/link_env" } @@ -95,7 +95,7 @@ test_virtualenvwrapper_show_workon_options_chpwd () { } mkdir "$WORKON_HOME/not_env" envs=$(virtualenvwrapper_show_workon_options | tr '\n' ' ') - assertSame "env1 env2 env with space " "$envs" + assertSame "env with space env1 env2 " "$envs" rmdir "$WORKON_HOME/not_env" rm -f "$WORKON_HOME/link_env" } From 6443c18d88a84b300e7b1af0fccebebf2913c05c Mon Sep 17 00:00:00 2001 From: Jessamyn Smith Date: Sat, 25 Apr 2015 14:29:35 -0400 Subject: [PATCH 758/947] Made cd command work with space in virtualenv name --- tests/test_cd.sh | 21 +++++++++++++++++++++ virtualenvwrapper.sh | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/test_cd.sh b/tests/test_cd.sh index a4cada2..bb58b10 100755 --- a/tests/test_cd.sh +++ b/tests/test_cd.sh @@ -9,6 +9,7 @@ oneTimeSetUp() { unset VIRTUAL_ENV source "$test_dir/../virtualenvwrapper.sh" mkvirtualenv cd-test >/dev/null 2>&1 + mkvirtualenv "env with space" >/dev/null 2>&1 deactivate } @@ -38,6 +39,16 @@ test_cdvirtual() { virtualenvwrapper_cd "$start_dir" } +test_cdvirtual_space_in_name() { + workon "env with space" + start_dir="$(pwd)" + cdvirtualenv + assertSame "$VIRTUAL_ENV" "$(pwd)" + cdvirtualenv bin + assertSame "$VIRTUAL_ENV/bin" "$(pwd)" + virtualenvwrapper_cd "$start_dir" +} + test_cdsitepackages () { start_dir="$(pwd)" cdsitepackages @@ -47,6 +58,16 @@ test_cdsitepackages () { virtualenvwrapper_cd "$start_dir" } +test_cdsitepackages_space_in_name () { + workon "env with space" + start_dir="$(pwd)" + cdsitepackages + pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) + sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" + assertSame "$sitepackages" "$(pwd)" + virtualenvwrapper_cd "$start_dir" +} + test_cdsitepackages_with_arg () { start_dir="$(pwd)" pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 6e53699..11e8061 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -892,7 +892,7 @@ function cdsitepackages { function cdvirtualenv { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 - virtualenvwrapper_cd $VIRTUAL_ENV/$1 + virtualenvwrapper_cd "$VIRTUAL_ENV"/$1 } # Shows the content of the site-packages directory of the currently-active From 7958430177886c06829f6b4fb5a2787f04f52d49 Mon Sep 17 00:00:00 2001 From: Jessamyn Smith Date: Sat, 25 Apr 2015 16:47:48 -0400 Subject: [PATCH 759/947] Made lsvirtualenv and allvirtualenv work with spaces in env names --- tests/test_allvirtualenv.sh | 3 +++ tests/test_ls.sh | 6 ++++++ virtualenvwrapper.sh | 7 +++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/test_allvirtualenv.sh b/tests/test_allvirtualenv.sh index 3d7214d..7021357 100755 --- a/tests/test_allvirtualenv.sh +++ b/tests/test_allvirtualenv.sh @@ -10,6 +10,7 @@ oneTimeSetUp() { source "$test_dir/../virtualenvwrapper.sh" mkvirtualenv test1 >/dev/null 2>&1 mkvirtualenv test2 >/dev/null 2>&1 + mkvirtualenv " env with space " >/dev/null 2>&1 deactivate } @@ -28,6 +29,8 @@ tearDown () { test_allvirtualenv_all() { assertTrue "Did not find test1" "allvirtualenv pwd | grep -q 'test1$'" assertTrue "Did not find test2" "allvirtualenv pwd | grep -q 'test2$'" + allvirtualenv pwd + assertTrue "Did not find ' env with space '" "allvirtualenv pwd | grep -q ' env with space '" } test_allvirtualenv_spaces() { diff --git a/tests/test_ls.sh b/tests/test_ls.sh index 528596c..817f79f 100755 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -75,5 +75,11 @@ test_lsvirtualenv_space_in_workon_home () { WORKON_HOME="$old_home" } +test_lsvirtualenv_space_in_env_name () { + mkvirtualenv " env with space " + lsvirtualenv -b >"$WORKON_HOME/output" 2>&1 + assertTrue "Did not see expected message in \"$output\"" "cat \"$WORKON_HOME/output\" | grep -q ' env with space '" +} + . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 11e8061..0af6453 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -569,8 +569,9 @@ function virtualenvwrapper_show_workon_options { # 5. Eliminate any lines with * on them because that means there # were no envs. (virtualenvwrapper_cd "$WORKON_HOME" && echo */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate) 2>/dev/null \ - | command \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate||g" \ - | command \fmt -w 1 \ + | command \tr "\n" " " \ + | command \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate |/|g" \ + | command \tr "/" "\n" \ | (unset GREP_OPTIONS; command \egrep -v '^\*$') 2>/dev/null } @@ -1292,6 +1293,7 @@ function allvirtualenv { virtualenvwrapper_verify_workon_home || return 1 typeset d + IFS='' virtualenvwrapper_show_workon_options | while read d do [ ! -d "$WORKON_HOME/$d" ] && continue @@ -1304,6 +1306,7 @@ function allvirtualenv { "$@") echo done + unset IFS } #:help:virtualenvwrapper: show this help message From d3137a2f19554b3cc18b457886df4ab245d21ade Mon Sep 17 00:00:00 2001 From: Jessamyn Smith Date: Sat, 25 Apr 2015 15:40:14 -0400 Subject: [PATCH 760/947] Added tests for leading spaces (trailing spaces don't work in Linux, so don't test them). --- tests/test_allvirtualenv.sh | 7 ++--- tests/test_cd.sh | 8 +++--- tests/test_ls.sh | 6 +++-- tests/test_mkvirtualenv.sh | 12 +++++---- tests/test_workon.sh | 52 +++++++++++++++++++++---------------- 5 files changed, 49 insertions(+), 36 deletions(-) diff --git a/tests/test_allvirtualenv.sh b/tests/test_allvirtualenv.sh index 7021357..9a37e39 100755 --- a/tests/test_allvirtualenv.sh +++ b/tests/test_allvirtualenv.sh @@ -10,7 +10,9 @@ oneTimeSetUp() { source "$test_dir/../virtualenvwrapper.sh" mkvirtualenv test1 >/dev/null 2>&1 mkvirtualenv test2 >/dev/null 2>&1 - mkvirtualenv " env with space " >/dev/null 2>&1 + # Only test with leading and internal spaces. Directory names with trailing spaces are legal, + # and work with virtualenv on OSX, but error out on Linux. + mkvirtualenv " env with space" >/dev/null 2>&1 deactivate } @@ -29,8 +31,7 @@ tearDown () { test_allvirtualenv_all() { assertTrue "Did not find test1" "allvirtualenv pwd | grep -q 'test1$'" assertTrue "Did not find test2" "allvirtualenv pwd | grep -q 'test2$'" - allvirtualenv pwd - assertTrue "Did not find ' env with space '" "allvirtualenv pwd | grep -q ' env with space '" + assertTrue "Did not find ' env with space'" "allvirtualenv pwd | grep -q ' env with space'" } test_allvirtualenv_spaces() { diff --git a/tests/test_cd.sh b/tests/test_cd.sh index bb58b10..a08c057 100755 --- a/tests/test_cd.sh +++ b/tests/test_cd.sh @@ -9,7 +9,9 @@ oneTimeSetUp() { unset VIRTUAL_ENV source "$test_dir/../virtualenvwrapper.sh" mkvirtualenv cd-test >/dev/null 2>&1 - mkvirtualenv "env with space" >/dev/null 2>&1 + # Only test with leading and internal spaces. Directory names with trailing spaces are legal, + # and work with virtualenv on OSX, but error out on Linux. + mkvirtualenv " env with space" >/dev/null 2>&1 deactivate } @@ -40,7 +42,7 @@ test_cdvirtual() { } test_cdvirtual_space_in_name() { - workon "env with space" + workon " env with space" start_dir="$(pwd)" cdvirtualenv assertSame "$VIRTUAL_ENV" "$(pwd)" @@ -59,7 +61,7 @@ test_cdsitepackages () { } test_cdsitepackages_space_in_name () { - workon "env with space" + workon " env with space" start_dir="$(pwd)" cdsitepackages pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) diff --git a/tests/test_ls.sh b/tests/test_ls.sh index 817f79f..7a9c211 100755 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -76,9 +76,11 @@ test_lsvirtualenv_space_in_workon_home () { } test_lsvirtualenv_space_in_env_name () { - mkvirtualenv " env with space " + # Only test with leading and internal spaces. Directory names with trailing spaces are legal, + # and work with virtualenv on OSX, but error out on Linux. + mkvirtualenv " env with space" lsvirtualenv -b >"$WORKON_HOME/output" 2>&1 - assertTrue "Did not see expected message in \"$output\"" "cat \"$WORKON_HOME/output\" | grep -q ' env with space '" + assertTrue "Did not see expected message in \"$output\"" "cat \"$WORKON_HOME/output\" | grep -q ' env with space'" } diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index 0f3e7a2..bbfd543 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -29,16 +29,18 @@ test_create() { } test_create_space_in_name() { - mkvirtualenv "env with space" >/dev/null 2>&1 - assertTrue "Environment directory was not created" "[ -d \"$WORKON_HOME/env with space\" ]" + # Only test with leading and internal spaces. Directory names with trailing spaces are legal, + # and work with virtualenv on OSX, but error out on Linux. + mkvirtualenv " env with space" >/dev/null 2>&1 + assertTrue "Environment directory was not created" "[ -d \"$WORKON_HOME/ env with space\" ]" for hook in postactivate predeactivate postdeactivate do - assertTrue "$hook was not created" "[ -f \"$WORKON_HOME/env with space/bin/$hook\" ]" - assertFalse "$hook is executable" "[ -x \"$WORKON_HOME/env with space/bin/$hook\" ]" + assertTrue "$hook was not created" "[ -f \"$WORKON_HOME/ env with space/bin/$hook\" ]" + assertFalse "$hook is executable" "[ -x \"$WORKON_HOME/ env with space/bin/$hook\" ]" done assertTrue virtualenvwrapper_verify_active_environment env_name=$(basename "$VIRTUAL_ENV") - assertSame "env with space" "$env_name" + assertSame " env with space" "$env_name" } test_activates () { diff --git a/tests/test_workon.sh b/tests/test_workon.sh index cb44c3e..20b09e4 100755 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -7,10 +7,12 @@ oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" source "$test_dir/../virtualenvwrapper.sh" - mkvirtualenv "env1" >/dev/null 2>&1 - mkvirtualenv "env2" >/dev/null 2>&1 - mkvirtualenv "env with space" >/dev/null 2>&1 - deactivate >/dev/null 2>&1 + mkvirtualenv "test1" >/dev/null 2>&1 + mkvirtualenv "test2" >/dev/null 2>&1 + # Only test with leading and internal spaces. Directory names with trailing spaces are legal, + # and work with virtualenv on OSX, but error out on Linux. + mkvirtualenv " env with space" >/dev/null 2>&1 + deactivate >/dev/null 2>&1 } oneTimeTearDown() { @@ -27,9 +29,9 @@ tearDown () { } test_workon () { - workon env1 + workon test1 assertTrue virtualenvwrapper_verify_active_environment - assertSame "env1" $(basename "$VIRTUAL_ENV") + assertSame "test1" $(basename "$VIRTUAL_ENV") } test_workon_activate_hooks () { @@ -39,15 +41,15 @@ test_workon_activate_hooks () { echo "echo GLOBAL ${t}activate >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/${t}activate" chmod +x "$WORKON_HOME/${t}activate" - echo "#!/bin/sh" > "$WORKON_HOME/env2/bin/${t}activate" - echo "echo ENV ${t}activate >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/env1/bin/${t}activate" - chmod +x "$WORKON_HOME/env1/bin/${t}activate" + echo "#!/bin/sh" > "$WORKON_HOME/test2/bin/${t}activate" + echo "echo ENV ${t}activate >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/test1/bin/${t}activate" + chmod +x "$WORKON_HOME/test1/bin/${t}activate" done rm -f "$TMPDIR/catch_output" touch "$TMPDIR/catch_output" - workon env1 + workon test1 output=$(cat "$TMPDIR/catch_output") expected="GLOBAL preactivate @@ -59,27 +61,29 @@ ENV postactivate" for t in pre post do - rm -f "$WORKON_HOME/env1/bin/${t}activate" + rm -f "$WORKON_HOME/test1/bin/${t}activate" rm -f "$WORKON_HOME/${t}activate" done } test_virtualenvwrapper_show_workon_options () { mkdir "$WORKON_HOME/not_env" - (cd "$WORKON_HOME"; ln -s env1 link_env) + (cd "$WORKON_HOME"; ln -s test1 link_env) envs=$(virtualenvwrapper_show_workon_options | tr '\n' ' ') - assertSame "env with space env1 env2 link_env " "$envs" + # On OSX there are two trailing spaces, on Linux one, so compare substring + assertSame " env with space link_env test1 test2 " "${envs:0:37}" rmdir "$WORKON_HOME/not_env" rm -f "$WORKON_HOME/link_env" } test_virtualenvwrapper_show_workon_options_grep_options () { mkdir "$WORKON_HOME/not_env" - (cd "$WORKON_HOME"; ln -s env1 link_env) + (cd "$WORKON_HOME"; ln -s test1 link_env) export GREP_OPTIONS="--count" envs=$(virtualenvwrapper_show_workon_options | tr '\n' ' ') unset GREP_OPTIONS - assertSame "env with space env1 env2 link_env " "$envs" + # On OSX there are two trailing spaces, on Linux one, so compare substring + assertSame " env with space link_env test1 test2 " "${envs:0:37}" rmdir "$WORKON_HOME/not_env" rm -f "$WORKON_HOME/link_env" } @@ -95,7 +99,8 @@ test_virtualenvwrapper_show_workon_options_chpwd () { } mkdir "$WORKON_HOME/not_env" envs=$(virtualenvwrapper_show_workon_options | tr '\n' ' ') - assertSame "env with space env1 env2 " "$envs" + # On OSX there are two trailing spaces, on Linux one, so compare substring + assertSame " env with space test1 test2 " "${envs:0:28}" rmdir "$WORKON_HOME/not_env" rm -f "$WORKON_HOME/link_env" } @@ -103,7 +108,8 @@ test_virtualenvwrapper_show_workon_options_chpwd () { test_virtualenvwrapper_show_workon_options_no_envs () { old_home="$WORKON_HOME" export WORKON_HOME=${TMPDIR:-/tmp}/$$ - envs=$(virtualenvwrapper_show_workon_options 2>/dev/null | tr '\n' ' ') + envs=$(virtualenvwrapper_show_workon_options 2>/dev/null\ + | tr '\n' '' 2>/dev/null | tr ' ' '' 2>/dev/null) assertSame "" "$envs" export WORKON_HOME="$old_home" } @@ -118,25 +124,25 @@ test_no_workon_home () { } test_workon_dot () { - cd $WORKON_HOME/env1 + cd $WORKON_HOME/test1 workon . assertTrue virtualenvwrapper_verify_active_environment - assertSame "env1" $(basename "$VIRTUAL_ENV") + assertSame "test1" $(basename "$VIRTUAL_ENV") } test_workon_dot_with_space () { - cd $WORKON_HOME/"env with space" + cd $WORKON_HOME/" env with space" workon . assertTrue virtualenvwrapper_verify_active_environment env_name=$(basename "$VIRTUAL_ENV") - assertSame "env with space" "$env_name" + assertSame " env with space" "$env_name" } test_workon_with_space () { - workon "env with space" + workon " env with space" assertTrue virtualenvwrapper_verify_active_environment env_name=$(basename "$VIRTUAL_ENV") - assertSame "env with space" "$env_name" + assertSame " env with space" "$env_name" } . "$test_dir/shunit2" From f4f2370d0fb520786ee6b9edbd90dce12d4df744 Mon Sep 17 00:00:00 2001 From: Jessamyn Smith Date: Sat, 25 Apr 2015 22:50:28 -0400 Subject: [PATCH 761/947] Made rmvirtualenv work with spaces --- tests/test_rmvirtualenv.sh | 38 ++++++++++++++++++++------------------ virtualenvwrapper.sh | 2 +- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/tests/test_rmvirtualenv.sh b/tests/test_rmvirtualenv.sh index 3f730ba..a1bbe78 100755 --- a/tests/test_rmvirtualenv.sh +++ b/tests/test_rmvirtualenv.sh @@ -14,51 +14,53 @@ oneTimeTearDown() { } setUp () { - echo + mkvirtualenv "deleteme" >/dev/null 2>&1 + # Only test with leading and internal spaces. Directory names with trailing spaces are legal, + # and work with virtualenv on OSX, but error out on Linux. + mkvirtualenv " env with space" >/dev/null 2>&1 + deactivate >/dev/null 2>&1 } test_remove () { - mkvirtualenv "deleteme" >/dev/null 2>&1 assertTrue "[ -d $WORKON_HOME/deleteme ]" - deactivate rmvirtualenv "deleteme" assertFalse "[ -d $WORKON_HOME/deleteme ]" } +test_remove_space_in_name () { + assertTrue "[ -d $WORKON_HOME/\" env with space\" ]" + rmvirtualenv " env with space" + assertFalse "[ -d $WORKON_HOME/\" env with space\" ]" +} + test_remove_several_envs () { - mkvirtualenv "deleteme" >/dev/null 2>&1 assertTrue "[ -d $WORKON_HOME/deleteme ]" - deactivate - mkvirtualenv "deleteme2" >/dev/null 2>&1 - assertTrue "[ -d $WORKON_HOME/deleteme2 ]" - deactivate - rmvirtualenv "deleteme deleteme2" + assertTrue "[ -d $WORKON_HOME/\" env with space\" ]" + rmvirtualenv deleteme " env with space" assertFalse "[ -d $WORKON_HOME/deleteme ]" - assertFalse "[ -d $WORKON_HOME/deleteme2 ]" + assertFalse "[ -d $WORKON_HOME/\" env with space\" ]" } test_within_virtualenv () { - mkvirtualenv "deleteme" >/dev/null 2>&1 - assertTrue "[ -d $WORKON_HOME/deleteme ]" + mkvirtualenv "deleteme2" >/dev/null 2>&1 + assertTrue "[ -d $WORKON_HOME/deleteme2 ]" cdvirtualenv assertSame "$VIRTUAL_ENV" "$(pwd)" deactivate - rmvirtualenv "deleteme" + rmvirtualenv "deleteme2" assertSame "$WORKON_HOME" "$(pwd)" - assertFalse "[ -d $WORKON_HOME/deleteme ]" + assertFalse "[ -d $WORKON_HOME/deleteme2 ]" } test_rm_aliased () { - mkvirtualenv "deleteme" >/dev/null 2>&1 - deactivate alias rm='rm -i' rmvirtualenv "deleteme" unalias rm } test_no_such_env () { - assertFalse "[ -d $WORKON_HOME/deleteme ]" - assertTrue "rmvirtualenv deleteme" + assertFalse "[ -d $WORKON_HOME/deleteme2 ]" + assertTrue "rmvirtualenv deleteme2" } test_no_workon_home () { diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 0af6453..170ca48 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -521,7 +521,7 @@ function rmvirtualenv { # support to remove several environments typeset env_name - for env_name in $@ + for env_name in "$@" do echo "Removing $env_name..." typeset env_dir="$WORKON_HOME/$env_name" From 04664ca22229d469c29734bcd291e6d9a82acef3 Mon Sep 17 00:00:00 2001 From: Jessamyn Smith Date: Sun, 26 Apr 2015 11:22:02 -0400 Subject: [PATCH 762/947] Added tests to verify that cpvirtualenv, lsvirtualenv, and mkproject work with spaces in env names. --- tests/test_cp.sh | 8 ++++---- tests/test_ls.sh | 4 ++-- virtualenvwrapper.sh | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/test_cp.sh b/tests/test_cp.sh index b64ac2c..1071dd8 100755 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -33,10 +33,10 @@ test_new_env_activated () { assertTrue virtualenvwrapper_verify_active_environment } -test_virtual_env_variable () { - mkvirtualenv "source" >/dev/null 2>&1 - cpvirtualenv "source" "destination" >/dev/null 2>&1 - assertSame "Wrong virtualenv name" "destination" $(basename "$VIRTUAL_ENV") +test_virtual_env_variable_space_in_name () { + mkvirtualenv " space source" >/dev/null 2>&1 + cpvirtualenv " space source" " space destination" >/dev/null 2>&1 + assertSame "Wrong virtualenv name" " space destination" "$(basename "$VIRTUAL_ENV")" assertTrue "$WORKON_HOME not in $VIRTUAL_ENV" "echo $VIRTUAL_ENV | grep -q $WORKON_HOME" } diff --git a/tests/test_ls.sh b/tests/test_ls.sh index 7a9c211..26a3b5c 100755 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -25,8 +25,8 @@ test_get_site_packages_dir () { deactivate } -test_lssitepackages () { - mkvirtualenv "lssitepackagestest" >/dev/null 2>&1 +test_lssitepackages_space_in_name () { + mkvirtualenv " space lssitepackagestest" >/dev/null 2>&1 contents="$(lssitepackages)" assertTrue "did not find easy_install in site-packages" "echo $contents | grep -q easy_install" deactivate diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 170ca48..4f847f2 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -945,9 +945,9 @@ function cpvirtualenv { echo "Please provide a valid virtualenv to copy." return 1 else - # see if its already in workon + # see if it's already in workon if [ ! -e "$WORKON_HOME/$src_name" ]; then - # so its a virtualenv we are importing + # so it's a virtualenv we are importing # make sure we have a full path # and get the name src="$(virtualenvwrapper_expandpath "$src_name")" From 0eb367c326135e574dc9abe9d8a3115ee99e3f28 Mon Sep 17 00:00:00 2001 From: Jessamyn Smith Date: Sun, 26 Apr 2015 13:01:06 -0400 Subject: [PATCH 763/947] Changes as per code review. --- tests/test_allvirtualenv.sh | 2 ++ tests/test_cd.sh | 23 -------------- tests/test_cd_space_in_name.sh | 55 ++++++++++++++++++++++++++++++++++ tests/test_cp.sh | 9 ++++++ tests/test_ls.sh | 9 ++++++ tests/test_workon.sh | 4 +-- virtualenvwrapper.sh | 22 ++++++++++---- 7 files changed, 93 insertions(+), 31 deletions(-) create mode 100755 tests/test_cd_space_in_name.sh diff --git a/tests/test_allvirtualenv.sh b/tests/test_allvirtualenv.sh index 9a37e39..fd7b027 100755 --- a/tests/test_allvirtualenv.sh +++ b/tests/test_allvirtualenv.sh @@ -8,6 +8,8 @@ oneTimeSetUp() { mkdir -p "$WORKON_HOME" unset VIRTUAL_ENV source "$test_dir/../virtualenvwrapper.sh" + # These three env names must sort the same whether the OS considers leading whitespace or not. + # "test" is after " env" and after "env", so the asserts work on OSX and Linux. mkvirtualenv test1 >/dev/null 2>&1 mkvirtualenv test2 >/dev/null 2>&1 # Only test with leading and internal spaces. Directory names with trailing spaces are legal, diff --git a/tests/test_cd.sh b/tests/test_cd.sh index a08c057..a4cada2 100755 --- a/tests/test_cd.sh +++ b/tests/test_cd.sh @@ -9,9 +9,6 @@ oneTimeSetUp() { unset VIRTUAL_ENV source "$test_dir/../virtualenvwrapper.sh" mkvirtualenv cd-test >/dev/null 2>&1 - # Only test with leading and internal spaces. Directory names with trailing spaces are legal, - # and work with virtualenv on OSX, but error out on Linux. - mkvirtualenv " env with space" >/dev/null 2>&1 deactivate } @@ -41,16 +38,6 @@ test_cdvirtual() { virtualenvwrapper_cd "$start_dir" } -test_cdvirtual_space_in_name() { - workon " env with space" - start_dir="$(pwd)" - cdvirtualenv - assertSame "$VIRTUAL_ENV" "$(pwd)" - cdvirtualenv bin - assertSame "$VIRTUAL_ENV/bin" "$(pwd)" - virtualenvwrapper_cd "$start_dir" -} - test_cdsitepackages () { start_dir="$(pwd)" cdsitepackages @@ -60,16 +47,6 @@ test_cdsitepackages () { virtualenvwrapper_cd "$start_dir" } -test_cdsitepackages_space_in_name () { - workon " env with space" - start_dir="$(pwd)" - cdsitepackages - pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) - sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" - assertSame "$sitepackages" "$(pwd)" - virtualenvwrapper_cd "$start_dir" -} - test_cdsitepackages_with_arg () { start_dir="$(pwd)" pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) diff --git a/tests/test_cd_space_in_name.sh b/tests/test_cd_space_in_name.sh new file mode 100755 index 0000000..157371d --- /dev/null +++ b/tests/test_cd_space_in_name.sh @@ -0,0 +1,55 @@ +# -*- mode: shell-script -*- + +test_dir=$(cd $(dirname $0) && pwd) +source "$test_dir/setup.sh" + +oneTimeSetUp() { + export WORKON_HOME="$WORKON_HOME/ this has spaces" + rm -rf "$WORKON_HOME" + mkdir -p "$WORKON_HOME" + unset VIRTUAL_ENV + source "$test_dir/../virtualenvwrapper.sh" + # Only test with leading and internal spaces. Directory names with trailing spaces are legal, + # and work with virtualenv on OSX, but error out on Linux. + mkvirtualenv " env with space" >/dev/null 2>&1 + deactivate +} + +oneTimeTearDown() { + rm -rf "$WORKON_HOME" +} + +setUp () { + echo +} + +tearDown () { + deactivate >/dev/null 2>&1 +} + +cd () { + fail "Should not be using override cd function" +} + +test_cdvirtual_space_in_workon_home_space_in_name() { + workon " env with space" + start_dir="$(pwd)" + cdvirtualenv + assertSame "$VIRTUAL_ENV" "$(pwd)" + cdvirtualenv bin + assertSame "$VIRTUAL_ENV/bin" "$(pwd)" + virtualenvwrapper_cd "$start_dir" +} + +test_cdsitepackages_space_in_name () { + workon " env with space" + start_dir="$(pwd)" + cdsitepackages + pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.) + sitepackages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages" + assertSame "$sitepackages" "$(pwd)" + virtualenvwrapper_cd "$start_dir" +} + + +. "$test_dir/shunit2" diff --git a/tests/test_cp.sh b/tests/test_cp.sh index 1071dd8..fc93ec1 100755 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -33,7 +33,16 @@ test_new_env_activated () { assertTrue virtualenvwrapper_verify_active_environment } +test_virtual_env_variable () { + mkvirtualenv "source" >/dev/null 2>&1 + cpvirtualenv "source" "destination" >/dev/null 2>&1 + assertSame "Wrong virtualenv name" "destination" $(basename "$VIRTUAL_ENV") + assertTrue "$WORKON_HOME not in $VIRTUAL_ENV" "echo $VIRTUAL_ENV | grep -q $WORKON_HOME" +} + test_virtual_env_variable_space_in_name () { + # Only test with leading and internal spaces. Directory names with trailing spaces are legal, + # and work with virtualenv on OSX, but error out on Linux. mkvirtualenv " space source" >/dev/null 2>&1 cpvirtualenv " space source" " space destination" >/dev/null 2>&1 assertSame "Wrong virtualenv name" " space destination" "$(basename "$VIRTUAL_ENV")" diff --git a/tests/test_ls.sh b/tests/test_ls.sh index 26a3b5c..6a52f6f 100755 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -25,7 +25,16 @@ test_get_site_packages_dir () { deactivate } +test_lssitepackages () { + mkvirtualenv "lssitepackagestest" >/dev/null 2>&1 + contents="$(lssitepackages)" + assertTrue "did not find easy_install in site-packages" "echo $contents | grep -q easy_install" + deactivate +} + test_lssitepackages_space_in_name () { + # Only test with leading and internal spaces. Directory names with trailing spaces are legal, + # and work with virtualenv on OSX, but error out on Linux. mkvirtualenv " space lssitepackagestest" >/dev/null 2>&1 contents="$(lssitepackages)" assertTrue "did not find easy_install in site-packages" "echo $contents | grep -q easy_install" diff --git a/tests/test_workon.sh b/tests/test_workon.sh index 20b09e4..17656bb 100755 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -108,8 +108,8 @@ test_virtualenvwrapper_show_workon_options_chpwd () { test_virtualenvwrapper_show_workon_options_no_envs () { old_home="$WORKON_HOME" export WORKON_HOME=${TMPDIR:-/tmp}/$$ - envs=$(virtualenvwrapper_show_workon_options 2>/dev/null\ - | tr '\n' '' 2>/dev/null | tr ' ' '' 2>/dev/null) + # On OSX there is a space and on Linux there is not, so strip all spaces + envs=$(virtualenvwrapper_show_workon_options 2>/dev/null | sed 's/\n //g') assertSame "" "$envs" export WORKON_HOME="$old_home" } diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 4f847f2..acef791 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -521,6 +521,7 @@ function rmvirtualenv { # support to remove several environments typeset env_name + # Must quote the parameters, as environments could have spaces in their names for env_name in "$@" do echo "Removing $env_name..." @@ -559,13 +560,18 @@ function virtualenvwrapper_show_workon_options { # NOTE: DO NOT use ls or cd here because colorized versions spew control # characters into the output list. # echo seems a little faster than find, even with -depth 3. + # Note that this is a little tricky, as there may be spaces in the path. # # 1. Look for environments by finding the activate scripts. # Use a subshell so we can suppress the message printed # by zsh if the glob pattern fails to match any files. - # 2. Strip the WORKON_HOME prefix from each name. - # 3. Strip the bindir/activate script suffix. - # 4. Format the output to show one name on a line. + # This yields a single, space-separated line containing all matches. + # 2. Replace the trailing newline with a space, so every + # possible env has a space following it. + # 3. Strip the bindir/activate script suffix, replacing it with + # a slash, as that is an illegal character in a directory name. + # This yields a slash-separated list of possible env names. + # 4. Replace each slash with a newline to show the output one name per line. # 5. Eliminate any lines with * on them because that means there # were no envs. (virtualenvwrapper_cd "$WORKON_HOME" && echo */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate) 2>/dev/null \ @@ -723,6 +729,8 @@ function workon { return 1 elif [ "$env_name" = "." ] then + # The IFS default of breaking on whitespace causes issues if there + # are spaces in the env_name, so change it. IFS='%' env_name="$(basename $(pwd))" unset IFS @@ -885,7 +893,7 @@ function cdsitepackages { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 typeset site_packages="`virtualenvwrapper_get_site_packages_dir`" - virtualenvwrapper_cd "$site_packages"/$1 + virtualenvwrapper_cd "$site_packages/$1" } # Does a ``cd`` to the root of the currently-active virtualenv. @@ -893,7 +901,7 @@ function cdsitepackages { function cdvirtualenv { virtualenvwrapper_verify_workon_home || return 1 virtualenvwrapper_verify_active_environment || return 1 - virtualenvwrapper_cd "$VIRTUAL_ENV"/$1 + virtualenvwrapper_cd "$VIRTUAL_ENV/$1" } # Shows the content of the site-packages directory of the currently-active @@ -1293,7 +1301,9 @@ function allvirtualenv { virtualenvwrapper_verify_workon_home || return 1 typeset d - IFS='' + # The IFS default of breaking on whitespace causes issues if there + # are spaces in the env_name, so change it. + IFS='%' virtualenvwrapper_show_workon_options | while read d do [ ! -d "$WORKON_HOME/$d" ] && continue From 3b85da5461e11c6e0e45bcf1bcb8b3124a20b76c Mon Sep 17 00:00:00 2001 From: Jessamyn Smith Date: Tue, 28 Apr 2015 16:16:55 -0400 Subject: [PATCH 764/947] Added testing and updated docs for python 3.4. --- README.txt | 2 +- docs/source/install.rst | 2 +- setup.cfg | 1 + tox.ini | 7 ++++++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.txt b/README.txt index 29fae47..d034f7e 100644 --- a/README.txt +++ b/README.txt @@ -63,7 +63,7 @@ from this page. Python Versions =============== -virtualenvwrapper is tested under Python 2.6 - 3.3. +virtualenvwrapper is tested under Python 2.6 - 3.4. ======= Support diff --git a/docs/source/install.rst b/docs/source/install.rst index 5f35b1a..6ff354b 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -76,7 +76,7 @@ can download virtualenvwrapper-powershell_ from PyPI. Python Versions =============== -virtualenvwrapper is tested under Python 2.6-3.3. +virtualenvwrapper is tested under Python 2.6-3.4. .. _install-basic: diff --git a/setup.cfg b/setup.cfg index 7d1b2d4..2c46f04 100644 --- a/setup.cfg +++ b/setup.cfg @@ -14,6 +14,7 @@ classifier = Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 Programming Language :: Python :: 3.3 + Programming Language :: Python :: 3.4 Intended Audience :: Developers Environment :: Console keywords = diff --git a/tox.ini b/tox.ini index 05f0cdb..ceac2f4 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py26,py33,zsh,ksh,style +envlist = py27,py26,py33,py34,zsh,ksh,style [testenv] install_command = pip install -U {opts} {packages} @@ -40,6 +40,11 @@ setenv = SHELL = /bin/bash commands = bash ./tests/run_tests {envdir} [] +[testenv:py34] +setenv = + SHELL = /bin/bash +commands = bash ./tests/run_tests {envdir} [] + [testenv:zsh] basepython=python2.7 setenv = From b1d0cb0087400f3a821429e5d2157eae81e4e3f4 Mon Sep 17 00:00:00 2001 From: Justin Abrahms Date: Mon, 18 May 2015 20:53:29 +0000 Subject: [PATCH 765/947] Update links and name for venv post. --- docs/source/tips.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/tips.rst b/docs/source/tips.rst index 7d708d7..fd58259 100644 --- a/docs/source/tips.rst +++ b/docs/source/tips.rst @@ -63,8 +63,8 @@ to the project directory when I use the workon command:: Automatically Run workon When Entering a Directory ================================================== -`Justin Lily posted -`__ +`Justin Abrahms posted +`__ about some code he added to his shell environment to look at the directory each time he runs ``cd``. If it finds a ``.venv`` file, it activates the environment named within. On leaving that directory, From ec5d410a8c5b36441f92555fde70113df8bb3a27 Mon Sep 17 00:00:00 2001 From: Robson Peixoto Date: Thu, 4 Jun 2015 18:26:57 -0300 Subject: [PATCH 766/947] Removes empty when list all virtualenvs Fixes #265 --- virtualenvwrapper.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index acef791..51df8d8 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -578,6 +578,7 @@ function virtualenvwrapper_show_workon_options { | command \tr "\n" " " \ | command \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate |/|g" \ | command \tr "/" "\n" \ + | command \sed "/^\s*$/d" \ | (unset GREP_OPTIONS; command \egrep -v '^\*$') 2>/dev/null } From 5326298ee0bf971710302197e91b854cab86922f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 7 Jun 2015 11:36:01 -0400 Subject: [PATCH 767/947] add test for previous patch verify that virtualenvwrapper_show_workon_options does not include blank lines in its output Change-Id: I630f94b8462c1f55cfad339f42c564d5fe65aae3 --- tests/test_ls.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_ls.sh b/tests/test_ls.sh index 6a52f6f..5e7c5a4 100755 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -92,5 +92,11 @@ test_lsvirtualenv_space_in_env_name () { assertTrue "Did not see expected message in \"$output\"" "cat \"$WORKON_HOME/output\" | grep -q ' env with space'" } +test_lsvirtualenv_blank_lines () { + # There should be no blank lines in the list of virtualenvs + mkvirtualenv "at-least-one-env" >/dev/null 2>&1 + assertFalse "Found blank line in virtualenvwrapper_show_workon_options output" "virtualenvwrapper_show_workon_options | grep -q '^$'" +} + . "$test_dir/shunit2" From 144f0a32f250dc248c2b46ff97180d1d366bd678 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 7 Jun 2015 11:36:34 -0400 Subject: [PATCH 768/947] quiet some of the lsvirtualenv tests Change-Id: I913e28f14e1c85308b1849056230495682508fc0 --- tests/test_ls.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_ls.sh b/tests/test_ls.sh index 5e7c5a4..8d26b3a 100755 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -77,7 +77,7 @@ test_lsvirtualenv_space_in_workon_home () { old_home="$WORKON_HOME" export WORKON_HOME="$WORKON_HOME/with space" mkdir "$WORKON_HOME" - (cd "$WORKON_HOME"; virtualenv testenv) 2>&1 + (cd "$WORKON_HOME"; virtualenv testenv) >/dev/null 2>&1 lsvirtualenv -b >"$old_home/output" output=$(cat "$old_home/output") assertTrue "Did not see expected message in \"$output\"" "echo $output | grep -q 'testenv'" @@ -87,7 +87,7 @@ test_lsvirtualenv_space_in_workon_home () { test_lsvirtualenv_space_in_env_name () { # Only test with leading and internal spaces. Directory names with trailing spaces are legal, # and work with virtualenv on OSX, but error out on Linux. - mkvirtualenv " env with space" + mkvirtualenv " env with space" >/dev/null 2>&1 lsvirtualenv -b >"$WORKON_HOME/output" 2>&1 assertTrue "Did not see expected message in \"$output\"" "cat \"$WORKON_HOME/output\" | grep -q ' env with space'" } From 92a411652e38e351ae44a8c85f2c164093fa3eb3 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 7 Jun 2015 11:53:18 -0400 Subject: [PATCH 769/947] remove some explicit tox environments Tox knows about different python versions without us having to be explicit, so consolidate some of the configuration to take advantage of tox's feature. Change-Id: I1b83cf23ad2a513c7b22c8ac5e19f3d9b54e8cb1 --- tox.ini | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/tox.ini b/tox.ini index ceac2f4..0b03067 100644 --- a/tox.ini +++ b/tox.ini @@ -9,6 +9,7 @@ deps = virtualenv stevedore setenv = TOXIC = true + SHELL = /bin/bash whitelist_externals = bash zsh @@ -18,11 +19,6 @@ whitelist_externals = deps = flake8 commands = flake8 virtualenvwrapper docs/source/conf.py -[testenv:py27] -setenv = - SHELL = /bin/bash -commands = bash ./tests/run_tests {envdir} [] - # Not sure why the basepython setting is needed, but on my system if # it isn't included then the python version picked up for 2.6 is # actually 2.7. @@ -35,16 +31,6 @@ setenv = SHELL = /bin/bash commands = bash ./tests/run_tests {envdir} [] -[testenv:py33] -setenv = - SHELL = /bin/bash -commands = bash ./tests/run_tests {envdir} [] - -[testenv:py34] -setenv = - SHELL = /bin/bash -commands = bash ./tests/run_tests {envdir} [] - [testenv:zsh] basepython=python2.7 setenv = From ca7ca2a43824317afc73551d0eb6b1a21c81d022 Mon Sep 17 00:00:00 2001 From: Kevin Deldycke Date: Tue, 23 Jun 2015 15:37:27 +0000 Subject: [PATCH 770/947] Restore overridden cd command to its default builtin behaviour. --- docs/source/tips.rst | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/source/tips.rst b/docs/source/tips.rst index fd58259..e075492 100644 --- a/docs/source/tips.rst +++ b/docs/source/tips.rst @@ -117,7 +117,7 @@ Via `mae `__: This is supposed to be executed after workon, that is as a ``postactivate`` hook. It basically overrides ``cd`` to know about the VENV so instead of doing ``cd`` to go to ``~`` you will go to the venv -root, IMO very handy and I can't live without it anymore. if you pass +root, IMO very handy and I can't live without it anymore. If you pass it a proper path then it will do the right thing. :: @@ -132,3 +132,12 @@ it a proper path then it will do the right thing. } cd + +And to finally restore the default behaviour of ``cd`` once you +bailout of a VENV via a ``deactivate`` command, you need to add this +as a ``postdeactivate`` hook (`source +`_):: + + cd () { + builtin cd "$@" + } \ No newline at end of file From 72cf81916455f0a964c13f76bea79187351408b2 Mon Sep 17 00:00:00 2001 From: Martin Etnestad Johansen Date: Fri, 21 Aug 2015 21:56:40 +0200 Subject: [PATCH 771/947] Detect MSYS if MSYSTEM is MINGW64 --- virtualenvwrapper.sh | 2 +- virtualenvwrapper/user_scripts.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 51df8d8..2104cb4 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -64,7 +64,7 @@ fi # Define script folder depending on the platorm (Win32/Unix) VIRTUALENVWRAPPER_ENV_BIN_DIR="bin" -if [ "$OS" = "Windows_NT" ] && [ "$MSYSTEM" = "MINGW32" ] +if [ "$OS" = "Windows_NT" ] && ([ "$MSYSTEM" = "MINGW32" ] || [ "$MSYSTEM" = "MINGW64" ]) then # Only assign this for msys, cygwin use standard Unix paths # and its own python installation diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index d82fa3d..abd0422 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -18,7 +18,7 @@ # Are we running under msys if sys.platform == 'win32' and \ os.environ.get('OS') == 'Windows_NT' and \ - os.environ.get('MSYSTEM') == 'MINGW32': + os.environ.get('MSYSTEM') in ('MINGW32', 'MINGW64'): is_msys = True script_folder = 'Scripts' else: From 2401e016036b29303fdbd272d8ce32d9e0e9aad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Sun, 30 Aug 2015 18:09:53 +0200 Subject: [PATCH 772/947] Change install docs to use --user This changes the install docs to use `pip install --user` instead of `pip install --install-option="--user"`. `--user` is indeed the option to use for a user-scheme installation. See http://pip.readthedocs.org/en/latest/user_guide.html#user-installs. --- docs/source/install.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/install.rst b/docs/source/install.rst index 6ff354b..ba316fc 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -104,12 +104,12 @@ or:: An alternative to installing it into the global site-packages is to add it to `your user local directory -`__ +`__ (usually `~/.local`). :: - $ pip install --install-option="--user" virtualenvwrapper + $ pip install --user virtualenvwrapper .. _install-shell-config: From a60920e466d60ee94392e69fd83c6f801ded751b Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 13 Sep 2015 08:03:21 -0400 Subject: [PATCH 773/947] enhance verbose output of hook loader Fix the logging configuration so the console output actually appears. Move the console log output to stderr. Clean up some of the indivual log messages. Change-Id: I55d1bda61eca7435c3cc776cade8920412f31e03 --- virtualenvwrapper/hook_loader.py | 12 +++++++++--- virtualenvwrapper/user_scripts.py | 8 +++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 7b505f1..84a4712 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -82,7 +82,7 @@ def main(): parser.disable_interspersed_args() # stop when on option without an '-' options, args = parser.parse_args() - root_logger = logging.getLogger('') + root_logger = logging.getLogger('virtualenvwrapper') # Set up logging to a file logfile = os.environ.get('VIRTUALENVWRAPPER_LOG_FILE') @@ -98,7 +98,7 @@ def main(): root_logger.addHandler(file_handler) # Send higher-level messages to the console, too - console = logging.StreamHandler() + console = logging.StreamHandler(stream=sys.stderr) console_level = [logging.WARNING, logging.INFO, logging.DEBUG, @@ -107,6 +107,7 @@ def main(): formatter = logging.Formatter('%(name)s %(message)s') console.setFormatter(formatter) root_logger.addHandler(console) + root_logger.setLevel(console_level) # logging.getLogger(__name__).debug('cli args %s', args) @@ -125,7 +126,7 @@ def main(): if options.sourcing: hook += '_source' - log = logging.getLogger(__name__) + log = logging.getLogger('virtualenvwrapper.hook_loader') log.debug('Running %s hooks', hook) run_hooks(hook, options, args) @@ -147,13 +148,16 @@ def main(): def run_hooks(hook, options, args, output=None): + log = logging.getLogger('virtualenvwrapper.hook_loader') if output is None: output = sys.stdout namespace = 'virtualenvwrapper.%s' % hook if options.names: + log.debug('looking for %s hooks %s' % (namespace, options.names)) hook_mgr = NamedExtensionManager(namespace, options.names) else: + log.debug('looking for %s hooks' % namespace) hook_mgr = ExtensionManager(namespace) if options.listing: @@ -169,6 +173,7 @@ def show(ext): def get_source(ext, args): # Show the shell commands so they can # be run in the calling shell. + log.debug('getting source instructions for %s' % ext.name) contents = (ext.plugin(args) or '').strip() if contents: output.write('# %s\n' % ext.name) @@ -182,6 +187,7 @@ def get_source(ext, args): else: # Just run the plugin ourselves def invoke(ext, args): + log.debug('running %s' % ext.name) ext.plugin(args) try: hook_mgr.map(invoke, args[1:]) diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index abd0422..8a5eedc 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -217,6 +217,7 @@ def pre_mkvirtualenv(args): def post_mkvirtualenv_source(args): + log.debug('post_mkvirtualenv_source %s', str(args)) return """ # # Run user-provided scripts @@ -237,6 +238,7 @@ def pre_cpvirtualenv(args): def post_cpvirtualenv_source(args): + log.debug('post_cpvirtualenv_source %s', str(args)) return """ # # Run user-provided scripts @@ -268,7 +270,7 @@ def pre_activate(args): def post_activate_source(args): - log.debug('post_activate') + log.debug('post_activate_source') return """ # # Run user-provided scripts @@ -281,7 +283,7 @@ def post_activate_source(args): def pre_deactivate_source(args): - log.debug('pre_deactivate') + log.debug('pre_deactivate_source') return """ # # Run user-provided scripts @@ -294,7 +296,7 @@ def pre_deactivate_source(args): def post_deactivate_source(args): - log.debug('post_deactivate') + log.debug('post_deactivate_source') return """ # # Run user-provided scripts From 6b582de4ede15a2ce3d5b9e3472eab44c72e438c Mon Sep 17 00:00:00 2001 From: Jason Veatch Date: Tue, 3 Nov 2015 19:39:03 -0500 Subject: [PATCH 774/947] Pass stream as arg rather than kwarg to avoid py26 conflict. Fixes issue #274. StreamHandler arg was named strm in python 2.6 --- virtualenvwrapper/hook_loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 84a4712..542ee1d 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -98,7 +98,7 @@ def main(): root_logger.addHandler(file_handler) # Send higher-level messages to the console, too - console = logging.StreamHandler(stream=sys.stderr) + console = logging.StreamHandler(sys.stderr) console_level = [logging.WARNING, logging.INFO, logging.DEBUG, From 9a98b700bdc9b40cfd64c68123807e2877cb4cb6 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 8 Nov 2015 17:01:30 -0500 Subject: [PATCH 775/947] update to work with tox 2.1.1 --- tests/setup.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/setup.sh b/tests/setup.sh index 6e006fb..a28d360 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -10,3 +10,8 @@ export WORKON_HOME=$(mktemp -d -t "WORKON_HOME.XXXX.$$") export PROJECT_HOME=$(mktemp -d -t "PROJECT_HOME.XXXX.$$") #unset HOOK_VERBOSE_OPTION + +# tox no longer exports these variables by default, so set them +# ourselves to ensure the tests that rely on the values work +export USER=$(id -u -n) +export HOME=$(id -P | cut -f9 -d:) From 37084bd863d441fcd2862219f0e59d47e5147aa5 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 8 Nov 2015 17:01:54 -0500 Subject: [PATCH 776/947] temporary dir fixes for OS X El Capitan (10.11) --- tests/test_mkvirtualenv_associate.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/test_mkvirtualenv_associate.sh b/tests/test_mkvirtualenv_associate.sh index 614d328..98526e0 100755 --- a/tests/test_mkvirtualenv_associate.sh +++ b/tests/test_mkvirtualenv_associate.sh @@ -41,7 +41,10 @@ test_associate_relative_path() { ptrfile="$WORKON_HOME/$env/.project" mkvirtualenv -a "$project" "$env" >/dev/null 2>&1 assertTrue ".project not found" "[ -f $ptrfile ]" - assertEquals "$ptrfile contains wrong content" "$WORKON_HOME/$project" "$(cat $ptrfile)" + assertEquals \ + "$ptrfile contains wrong content" \ + "$WORKON_HOME/$project" \ + "$(cat $ptrfile | sed 's|^/private||')" } test_associate_not_a_directory() { @@ -118,7 +121,13 @@ test_associate_relative_with_dots() { ptrfile="$WORKON_HOME/$env/.project" mkvirtualenv -a "$project" "$env" >/dev/null 2>&1 assertTrue ".project not found" "[ -f $ptrfile ]" - assertEquals "$ptrfile contains wrong content" "$WORKON_HOME/project$n" "$(cat $ptrfile)" + # Sometimes OS X prepends /private on the front of the temporary + # directory, but the directory is the same as without it, so strip + # it if we see the value in the project file. + assertEquals \ + "$ptrfile contains wrong content" \ + "$WORKON_HOME/project$n" \ + "$(cat $ptrfile | sed 's|^/private||')" } . "$test_dir/shunit2" From bb994ceeb5afb34af6aa40508295dc4b408c4239 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 8 Nov 2015 17:02:30 -0500 Subject: [PATCH 777/947] add testing for python 3.5 --- setup.cfg | 1 + tox.ini | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 2c46f04..d38e298 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,6 +15,7 @@ classifier = Programming Language :: Python :: 3 Programming Language :: Python :: 3.3 Programming Language :: Python :: 3.4 + Programming Language :: Python :: 3.5 Intended Audience :: Developers Environment :: Console keywords = diff --git a/tox.ini b/tox.ini index 0b03067..cd69916 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py26,py33,py34,zsh,ksh,style +envlist = py27,py26,py33,py34,py35,zsh,ksh,style [testenv] install_command = pip install -U {opts} {packages} From ef4ec8c72fe62bf114cdc441a5a1fcd80bc2ddc9 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 8 Nov 2015 17:13:34 -0500 Subject: [PATCH 778/947] more dir fixes for El Capitan --- tests/test_setvirtualenvproject.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/test_setvirtualenvproject.sh b/tests/test_setvirtualenvproject.sh index 5fc7be3..766036c 100755 --- a/tests/test_setvirtualenvproject.sh +++ b/tests/test_setvirtualenvproject.sh @@ -42,7 +42,10 @@ test_setvirtualenvproject_relative_path() { mkvirtualenv "$env" >/dev/null 2>&1 setvirtualenvproject "$env" "$project" >/dev/null 2>&1 assertTrue ".project not found" "[ -f $ptrfile ]" - assertEquals "$ptrfile contains wrong content" "$WORKON_HOME/$project" "$(cat $ptrfile)" + assertEquals \ + "$ptrfile contains wrong content" \ + "$WORKON_HOME/$project" \ + "$(cat $ptrfile | sed 's|^/private||')" } test_setvirtualenvproject_not_a_directory() { @@ -83,7 +86,10 @@ test_setvirtualenvproject_relative_with_dots() { mkvirtualenv "$env" >/dev/null 2>&1 setvirtualenvproject "$env" "$project" >/dev/null 2>&1 assertTrue ".project not found" "[ -f $ptrfile ]" - assertEquals "$ptrfile contains wrong content" "$WORKON_HOME/project$n" "$(cat $ptrfile)" + assertEquals \ + "$ptrfile contains wrong content" \ + "$WORKON_HOME/project$n" \ + "$(cat $ptrfile | sed 's|^/private||')" } . "$test_dir/shunit2" From 5c88ad1fbd749f473784b3346b949fb35d9459a0 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 12 Jan 2016 10:15:42 -0500 Subject: [PATCH 779/947] update REAMDE with new bug tracker URL --- README.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.txt b/README.txt index d034f7e..17dd07c 100644 --- a/README.txt +++ b/README.txt @@ -74,7 +74,7 @@ Join the `virtualenvwrapper Google Group issues and features. Report bugs via the `bug tracker on Bitbucket -`__. +`__. Shell Aliases ============= From 98f148ee67f9aefe779f2ef3214e390f8e629d85 Mon Sep 17 00:00:00 2001 From: "Michael A. Smith" Date: Wed, 27 Jan 2016 20:01:21 -0500 Subject: [PATCH 780/947] Add Deactivate-on-Logout Tip --- docs/source/tips.rst | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/source/tips.rst b/docs/source/tips.rst index e075492..517fcf7 100644 --- a/docs/source/tips.rst +++ b/docs/source/tips.rst @@ -140,4 +140,18 @@ as a ``postdeactivate`` hook (`source cd () { builtin cd "$@" - } \ No newline at end of file + } + +Clean up environments on exit +======================================= + +Via `Michael `__: + +When you use a temporary virtualenv via ``mktmpenv`` or if you have +a `deactivate `_ hook, you have to actually run +``deactivate`` to clean up the temporary environment or run the hook, +respectively. It's easy to forget and just exit the shell. Put the +following in ``~/.bash_logout`` (or your shell's equivalent file) to +always deactivate environments before exiting the shell:: + + [ "$VIRTUAL_ENV" ] && deactivate From 5f0e5fbc009ef687c0fea5cdc9e6525af50b4a6e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 30 Jan 2016 10:34:16 -0500 Subject: [PATCH 781/947] use a ref instead of hard-coded link in new tip Use a ref role instead of a hard-coded link to let the link work no matter where the documentation is being served from. --- docs/source/tips.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/tips.rst b/docs/source/tips.rst index 517fcf7..7a3aef1 100644 --- a/docs/source/tips.rst +++ b/docs/source/tips.rst @@ -147,8 +147,8 @@ Clean up environments on exit Via `Michael `__: -When you use a temporary virtualenv via ``mktmpenv`` or if you have -a `deactivate `_ hook, you have to actually run +When you use a temporary virtualenv via ``mktmpenv`` or if you have a +:ref:`plugins-post_deactivate` hook, you have to actually run ``deactivate`` to clean up the temporary environment or run the hook, respectively. It's easy to forget and just exit the shell. Put the following in ``~/.bash_logout`` (or your shell's equivalent file) to From 68a735c2d3006a76f1a653c7215331a4013b3429 Mon Sep 17 00:00:00 2001 From: Ismail Sunni Date: Tue, 2 Feb 2016 01:51:57 +0000 Subject: [PATCH 782/947] command_ref.rst edited online with Bitbucket Adding -d for remove extra path --- docs/source/command_ref.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 0b7469e..6a54d11 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -457,6 +457,7 @@ in a ``.pth`` file inside ``site-packages`` using ``add2virtualenv``. 2. Run: ``add2virtualenv path_to_source``. 3. Run: ``add2virtualenv``. 4. A usage message and list of current "extra" paths is printed. +5. Use option ``-d`` to remove the added path. The directory names are added to a path file named ``_virtualenv_path_extensions.pth`` inside the site-packages directory From 56517a0ecadc98290f8a5d55df56025fa8873e3c Mon Sep 17 00:00:00 2001 From: lonetwin Date: Mon, 15 Aug 2016 11:34:57 +0200 Subject: [PATCH 783/947] Unset previously defined cd function rather than redefine it It is cleaner to unset the previously defined cd function in postdeactivate rather than redefine it since to avoids leaving an unexpected function in the environment after a deactivate. Change-Id: Iac40287ec5290f2f4523004a9d8f0b2a2b981f90 --- docs/source/tips.rst | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/source/tips.rst b/docs/source/tips.rst index 7a3aef1..3f523cf 100644 --- a/docs/source/tips.rst +++ b/docs/source/tips.rst @@ -135,12 +135,9 @@ it a proper path then it will do the right thing. And to finally restore the default behaviour of ``cd`` once you bailout of a VENV via a ``deactivate`` command, you need to add this -as a ``postdeactivate`` hook (`source -`_):: +as a ``postdeactivate`` hook:: - cd () { - builtin cd "$@" - } + unset -f cd Clean up environments on exit ======================================= From 526a465b67ab7fe535f796102043da2974ec0bcd Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Thu, 18 Aug 2016 20:32:54 -0500 Subject: [PATCH 784/947] Updating to virtualenvwrapper Signed-off-by: Jason Myers --- docs/source/conf.py | 2 +- docs/source/developers.rst | 10 +++++----- docs/source/index.rst | 8 ++++---- docs/source/install.rst | 4 ++-- docs/source/tips.rst | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 00ec17b..edc3055 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -27,7 +27,7 @@ # ones. extensions = ['sphinxcontrib.bitbucket'] -bitbucket_project_url = 'http://bitbucket.org/dhellmann/virtualenvwrapper/' +bitbucket_project_url = 'http://bitbucket.org/virtualenvwrapper/virtualenvwrapper/' # Add any paths that contain templates here, relative to this directory. # templates_path = ['pkg/templates'] diff --git a/docs/source/developers.rst b/docs/source/developers.rst index 9b3347c..632507c 100644 --- a/docs/source/developers.rst +++ b/docs/source/developers.rst @@ -5,7 +5,7 @@ For Developers If you would like to contribute to virtualenvwrapper directly, these instructions should help you get started. Patches, bug reports, and feature requests are all welcome through the `BitBucket site -`_. Contributions +`_. Contributions in the form of patches or pull requests are easier to integrate and will receive priority attention. @@ -40,7 +40,7 @@ documentation:: updating environment: 0 added, 2 changed, 0 removed reading sources... [ 50%] command_ref reading sources... [100%] developers - + looking for now-outdated files... none found pickling environment... done checking consistency... done @@ -48,17 +48,17 @@ documentation:: writing output... [ 33%] command_ref writing output... [ 66%] developers writing output... [100%] index - + writing additional files... search copying static files... WARNING: static directory '/Users/dhellmann/Devel/virtualenvwrapper/plugins/docs/sphinx/pkg/static' does not exist done dumping search index... done dumping object inventory... done build succeeded, 1 warning. - + Build finished. The HTML pages are in build/html. cp -r docs/build/html virtualenvwrapper/docs - + The output version of the documentation ends up in ``./virtualenvwrapper/docs`` inside your sandbox. diff --git a/docs/source/index.rst b/docs/source/index.rst index 5c0a0f8..cd00b54 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -103,7 +103,7 @@ Switch between environments with ``workon``:: (env2)$ workon env1 (env1)$ echo $VIRTUAL_ENV /Users/dhellmann/Envs/env1 - (env1)$ + (env1)$ The ``workon`` command also includes tab completion for the environment names, and invokes customization scripts as an environment @@ -155,7 +155,7 @@ created, letting you automatically install commonly-used tools. Installing sphinx-build script to /Users/dhellmann/Envs/env3/bin Installing sphinx-quickstart script to /Users/dhellmann/Envs/env3/bin Installing sphinx-autogen script to /Users/dhellmann/Envs/env3/bin - Successfully installed docutils Jinja2 Pygments sphinx (env3)$ + Successfully installed docutils Jinja2 Pygments sphinx (env3)$ (venv3)$ which sphinx-build /Users/dhellmann/Envs/env3/bin/sphinx-build @@ -213,10 +213,10 @@ Support Join the `virtualenvwrapper Google Group `__ to discuss -issues and features. +issues and features. Report bugs via the `bug tracker on BitBucket -`__. +`__. Shell Aliases ============= diff --git a/docs/source/install.rst b/docs/source/install.rst index ba316fc..c71d824 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -22,7 +22,7 @@ request through the `bitbucket project page`_. If you write a clone to work with an incompatible shell, let me know and I will link to it from this page. -.. _bitbucket project page: https://bitbucket.org/dhellmann/virtualenvwrapper/ +.. _bitbucket project page: https://bitbucket.org/virtualenvwrapper/virtualenvwrapper/ Windows Command Prompt ---------------------- @@ -32,7 +32,7 @@ which can be run under Microsoft Windows Command Prompt. This is also a separately distributed re-implementation. You can download `virtualenvwrapper-win`_ from PyPI. -.. _virtualenvwrapper-win: http://pypi.python.org/pypi/virtualenvwrapper-win +.. _virtualenvwrapper-win: http://pypi.python.org/pypi/virtualenvwrapper-win MSYS ---- diff --git a/docs/source/tips.rst b/docs/source/tips.rst index 7a3aef1..f3056a0 100644 --- a/docs/source/tips.rst +++ b/docs/source/tips.rst @@ -7,7 +7,7 @@ This is a list of user-contributed tips for making virtualenv and virtualenvwrapper even more useful. If you have tip to share, drop me an email or post a comment on `this blog post -`__ +`__ and I'll add it here. zsh Prompt @@ -135,7 +135,7 @@ it a proper path then it will do the right thing. And to finally restore the default behaviour of ``cd`` once you bailout of a VENV via a ``deactivate`` command, you need to add this -as a ``postdeactivate`` hook (`source +as a ``postdeactivate`` hook (`source `_):: cd () { From 5eb8b7226b540bec90d1a691391364a18a29c4d6 Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Thu, 18 Aug 2016 21:04:06 -0500 Subject: [PATCH 785/947] Docs fixes Signed-off-by: Jason Myers --- docs/source/conf.py | 2 +- docs/source/design.rst | 8 ++++---- docs/source/developers.rst | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index edc3055..40efac7 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -27,7 +27,7 @@ # ones. extensions = ['sphinxcontrib.bitbucket'] -bitbucket_project_url = 'http://bitbucket.org/virtualenvwrapper/virtualenvwrapper/' +bitbucket_project_url = 'https://bitbucket.org/virtualenvwrapper/virtualenvwrapper/' # Add any paths that contain templates here, relative to this directory. # templates_path = ['pkg/templates'] diff --git a/docs/source/design.rst b/docs/source/design.rst index 40562a8..73d5d73 100644 --- a/docs/source/design.rst +++ b/docs/source/design.rst @@ -147,7 +147,7 @@ far I have dealt with the ports by encouraging other developers to handle them, and then trying to link to and otherwise promote the results. -.. _fish: http://ridiculousfish.com/shell/ +.. _fish: https://fishshell.com/ Not As Bad As It Seems ====================== @@ -169,10 +169,10 @@ what virtualenvwrapper is doing, it's a natural fit. * `Environment variable`_ on Wikipedia * `Linux implementation of fork()`_ -.. _Advanced Programming in the UNIX Environment: http://www.amazon.com/gp/product/0321637739/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=0321637739&linkCode=as2&tag=hellflynet-20 +.. _Advanced Programming in the UNIX Environment: https://www.amazon.com/gp/product/0321637739/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=0321637739&linkCode=as2&tag=hellflynet-20 -.. _Fork (operating system): http://en.wikipedia.org/wiki/Fork_(operating_system) +.. _Fork (operating system): https://en.wikipedia.org/wiki/Fork_(operating_system) -.. _Environment variable: http://en.wikipedia.org/wiki/Environment_variable +.. _Environment variable: https://en.wikipedia.org/wiki/Environment_variable .. _Linux implementation of fork(): https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/fork.c?id=refs/tags/v3.9-rc8#n1558 diff --git a/docs/source/developers.rst b/docs/source/developers.rst index 632507c..da019f2 100644 --- a/docs/source/developers.rst +++ b/docs/source/developers.rst @@ -5,7 +5,7 @@ For Developers If you would like to contribute to virtualenvwrapper directly, these instructions should help you get started. Patches, bug reports, and feature requests are all welcome through the `BitBucket site -`_. Contributions +`_. Contributions in the form of patches or pull requests are easier to integrate and will receive priority attention. @@ -91,7 +91,7 @@ the ``tests`` directory. .. _shunit2: http://shunit2.googlecode.com/ -.. _tox: http://codespeak.net/tox +.. _tox: https://tox.testrun.org/ .. _developer-templates: From 5bae9775b4ff5e52391b621d94fa899b138f11b5 Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Thu, 18 Aug 2016 21:04:47 -0500 Subject: [PATCH 786/947] Last set of docs Signed-off-by: Jason Myers --- docs/source/index.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index cd00b54..5c0f75f 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -212,11 +212,11 @@ Support ======= Join the `virtualenvwrapper Google Group -`__ to discuss +`__ to discuss issues and features. Report bugs via the `bug tracker on BitBucket -`__. +`__. Shell Aliases ============= From 27ea6f45f359d16319e66c88f4f7eec1bb5bcb5b Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Thu, 18 Aug 2016 20:32:54 -0500 Subject: [PATCH 787/947] Updating to virtualenvwrapper Signed-off-by: Jason Myers --- docs/source/conf.py | 2 +- docs/source/developers.rst | 10 +++++----- docs/source/index.rst | 8 ++++---- docs/source/install.rst | 4 ++-- docs/source/tips.rst | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 00ec17b..edc3055 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -27,7 +27,7 @@ # ones. extensions = ['sphinxcontrib.bitbucket'] -bitbucket_project_url = 'http://bitbucket.org/dhellmann/virtualenvwrapper/' +bitbucket_project_url = 'http://bitbucket.org/virtualenvwrapper/virtualenvwrapper/' # Add any paths that contain templates here, relative to this directory. # templates_path = ['pkg/templates'] diff --git a/docs/source/developers.rst b/docs/source/developers.rst index 9b3347c..632507c 100644 --- a/docs/source/developers.rst +++ b/docs/source/developers.rst @@ -5,7 +5,7 @@ For Developers If you would like to contribute to virtualenvwrapper directly, these instructions should help you get started. Patches, bug reports, and feature requests are all welcome through the `BitBucket site -`_. Contributions +`_. Contributions in the form of patches or pull requests are easier to integrate and will receive priority attention. @@ -40,7 +40,7 @@ documentation:: updating environment: 0 added, 2 changed, 0 removed reading sources... [ 50%] command_ref reading sources... [100%] developers - + looking for now-outdated files... none found pickling environment... done checking consistency... done @@ -48,17 +48,17 @@ documentation:: writing output... [ 33%] command_ref writing output... [ 66%] developers writing output... [100%] index - + writing additional files... search copying static files... WARNING: static directory '/Users/dhellmann/Devel/virtualenvwrapper/plugins/docs/sphinx/pkg/static' does not exist done dumping search index... done dumping object inventory... done build succeeded, 1 warning. - + Build finished. The HTML pages are in build/html. cp -r docs/build/html virtualenvwrapper/docs - + The output version of the documentation ends up in ``./virtualenvwrapper/docs`` inside your sandbox. diff --git a/docs/source/index.rst b/docs/source/index.rst index 5c0a0f8..cd00b54 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -103,7 +103,7 @@ Switch between environments with ``workon``:: (env2)$ workon env1 (env1)$ echo $VIRTUAL_ENV /Users/dhellmann/Envs/env1 - (env1)$ + (env1)$ The ``workon`` command also includes tab completion for the environment names, and invokes customization scripts as an environment @@ -155,7 +155,7 @@ created, letting you automatically install commonly-used tools. Installing sphinx-build script to /Users/dhellmann/Envs/env3/bin Installing sphinx-quickstart script to /Users/dhellmann/Envs/env3/bin Installing sphinx-autogen script to /Users/dhellmann/Envs/env3/bin - Successfully installed docutils Jinja2 Pygments sphinx (env3)$ + Successfully installed docutils Jinja2 Pygments sphinx (env3)$ (venv3)$ which sphinx-build /Users/dhellmann/Envs/env3/bin/sphinx-build @@ -213,10 +213,10 @@ Support Join the `virtualenvwrapper Google Group `__ to discuss -issues and features. +issues and features. Report bugs via the `bug tracker on BitBucket -`__. +`__. Shell Aliases ============= diff --git a/docs/source/install.rst b/docs/source/install.rst index ba316fc..c71d824 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -22,7 +22,7 @@ request through the `bitbucket project page`_. If you write a clone to work with an incompatible shell, let me know and I will link to it from this page. -.. _bitbucket project page: https://bitbucket.org/dhellmann/virtualenvwrapper/ +.. _bitbucket project page: https://bitbucket.org/virtualenvwrapper/virtualenvwrapper/ Windows Command Prompt ---------------------- @@ -32,7 +32,7 @@ which can be run under Microsoft Windows Command Prompt. This is also a separately distributed re-implementation. You can download `virtualenvwrapper-win`_ from PyPI. -.. _virtualenvwrapper-win: http://pypi.python.org/pypi/virtualenvwrapper-win +.. _virtualenvwrapper-win: http://pypi.python.org/pypi/virtualenvwrapper-win MSYS ---- diff --git a/docs/source/tips.rst b/docs/source/tips.rst index 3f523cf..d29ff4e 100644 --- a/docs/source/tips.rst +++ b/docs/source/tips.rst @@ -7,7 +7,7 @@ This is a list of user-contributed tips for making virtualenv and virtualenvwrapper even more useful. If you have tip to share, drop me an email or post a comment on `this blog post -`__ +`__ and I'll add it here. zsh Prompt From 7107457b6e3e47e5765e73d1f1d7d5e477def0a2 Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Thu, 18 Aug 2016 21:04:06 -0500 Subject: [PATCH 788/947] Docs fixes Signed-off-by: Jason Myers --- docs/source/conf.py | 2 +- docs/source/design.rst | 8 ++++---- docs/source/developers.rst | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index edc3055..40efac7 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -27,7 +27,7 @@ # ones. extensions = ['sphinxcontrib.bitbucket'] -bitbucket_project_url = 'http://bitbucket.org/virtualenvwrapper/virtualenvwrapper/' +bitbucket_project_url = 'https://bitbucket.org/virtualenvwrapper/virtualenvwrapper/' # Add any paths that contain templates here, relative to this directory. # templates_path = ['pkg/templates'] diff --git a/docs/source/design.rst b/docs/source/design.rst index 40562a8..73d5d73 100644 --- a/docs/source/design.rst +++ b/docs/source/design.rst @@ -147,7 +147,7 @@ far I have dealt with the ports by encouraging other developers to handle them, and then trying to link to and otherwise promote the results. -.. _fish: http://ridiculousfish.com/shell/ +.. _fish: https://fishshell.com/ Not As Bad As It Seems ====================== @@ -169,10 +169,10 @@ what virtualenvwrapper is doing, it's a natural fit. * `Environment variable`_ on Wikipedia * `Linux implementation of fork()`_ -.. _Advanced Programming in the UNIX Environment: http://www.amazon.com/gp/product/0321637739/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=0321637739&linkCode=as2&tag=hellflynet-20 +.. _Advanced Programming in the UNIX Environment: https://www.amazon.com/gp/product/0321637739/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=0321637739&linkCode=as2&tag=hellflynet-20 -.. _Fork (operating system): http://en.wikipedia.org/wiki/Fork_(operating_system) +.. _Fork (operating system): https://en.wikipedia.org/wiki/Fork_(operating_system) -.. _Environment variable: http://en.wikipedia.org/wiki/Environment_variable +.. _Environment variable: https://en.wikipedia.org/wiki/Environment_variable .. _Linux implementation of fork(): https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/fork.c?id=refs/tags/v3.9-rc8#n1558 diff --git a/docs/source/developers.rst b/docs/source/developers.rst index 632507c..da019f2 100644 --- a/docs/source/developers.rst +++ b/docs/source/developers.rst @@ -5,7 +5,7 @@ For Developers If you would like to contribute to virtualenvwrapper directly, these instructions should help you get started. Patches, bug reports, and feature requests are all welcome through the `BitBucket site -`_. Contributions +`_. Contributions in the form of patches or pull requests are easier to integrate and will receive priority attention. @@ -91,7 +91,7 @@ the ``tests`` directory. .. _shunit2: http://shunit2.googlecode.com/ -.. _tox: http://codespeak.net/tox +.. _tox: https://tox.testrun.org/ .. _developer-templates: From 9352e0a05d2c0494931bdccac40b32d5c914737a Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Thu, 18 Aug 2016 21:04:47 -0500 Subject: [PATCH 789/947] Last set of docs Signed-off-by: Jason Myers --- docs/source/index.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index cd00b54..5c0f75f 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -212,11 +212,11 @@ Support ======= Join the `virtualenvwrapper Google Group -`__ to discuss +`__ to discuss issues and features. Report bugs via the `bug tracker on BitBucket -`__. +`__. Shell Aliases ============= From 0879d0391d1294327c286212eb5570141d65e3ce Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Mon, 8 Aug 2016 05:18:17 +0300 Subject: [PATCH 790/947] Fix the problem with lazy completion for bash To fix lazy completion bash needs to be instructed to restart completion after virtualenvwrapper loads the real implementation. Code 124 means exactly that: retry completion. See `man bash`. --- virtualenvwrapper_lazy.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/virtualenvwrapper_lazy.sh b/virtualenvwrapper_lazy.sh index 6eaa7b5..325fb89 100644 --- a/virtualenvwrapper_lazy.sh +++ b/virtualenvwrapper_lazy.sh @@ -44,13 +44,16 @@ function $venvw_name { # Set up completion functions to virtualenvwrapper_load function virtualenvwrapper_setup_lazy_completion { if [ -n "$BASH" ] ; then - complete -o nospace -F virtualenvwrapper_load $(echo ${_VIRTUALENVWRAPPER_API}) + function virtualenvwrapper_lazy_load { + virtualenvwrapper_load + return 124 + } + complete -o nospace -F virtualenvwrapper_lazy_load $(echo ${_VIRTUALENVWRAPPER_API}) elif [ -n "$ZSH_VERSION" ] ; then compctl -K virtualenvwrapper_load $(echo ${_VIRTUALENVWRAPPER_API}) fi } virtualenvwrapper_setup_lazy_loader -# Does not really work. Cannot be reset in zsh to fallback to files (e.g. mkvirtualenv). -# It also needs a second invocation, because the first one only sets up the real completion. +# Cannot be reset in zsh to fallback to files (e.g. mkvirtualenv). virtualenvwrapper_setup_lazy_completion From be5b6a0151e95ee293db1e3f45cbd7dd8832d84d Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Mon, 8 Aug 2016 05:21:27 +0300 Subject: [PATCH 791/947] Remove one-time functions from the environment --- virtualenvwrapper_lazy.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/virtualenvwrapper_lazy.sh b/virtualenvwrapper_lazy.sh index 325fb89..4d90c54 100644 --- a/virtualenvwrapper_lazy.sh +++ b/virtualenvwrapper_lazy.sh @@ -57,3 +57,6 @@ function virtualenvwrapper_setup_lazy_completion { virtualenvwrapper_setup_lazy_loader # Cannot be reset in zsh to fallback to files (e.g. mkvirtualenv). virtualenvwrapper_setup_lazy_completion + +unset virtualenvwrapper_setup_lazy_loader +unset virtualenvwrapper_setup_lazy_completion From ef718347e4c7585debe771a03a4093c6310efd18 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 14 Aug 2016 09:51:28 +0300 Subject: [PATCH 792/947] Add wipeenv and allvirtualenv for lazy loading --- tests/test_lazy.sh | 8 ++++++++ tests/test_lazy_loaded.sh | 8 ++++++++ virtualenvwrapper_lazy.sh | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/test_lazy.sh b/tests/test_lazy.sh index e46370e..d7f2ee5 100755 --- a/tests/test_lazy.sh +++ b/tests/test_lazy.sh @@ -96,4 +96,12 @@ test_mktmpenv_defined_lazy() { function_defined_lazy mktmpenv } +test_mktmpenv_defined_lazy() { + function_defined_lazy wipeenv +} + +test_mktmpenv_defined_lazy() { + function_defined_lazy allvirtualenv +} + . "$test_dir/shunit2" diff --git a/tests/test_lazy_loaded.sh b/tests/test_lazy_loaded.sh index 930c7b9..3e80720 100755 --- a/tests/test_lazy_loaded.sh +++ b/tests/test_lazy_loaded.sh @@ -88,6 +88,14 @@ test_mktmpenv_defined_normal() { function_defined_normal mktmpenv } +test_mktmpenv_defined_normal() { + function_defined_normal wipeenv +} + +test_mktmpenv_defined_normal() { + function_defined_normal allvirtualenv +} + # test_virtualenvwrapper_initialize() { # assertTrue "Initialized" virtualenvwrapper_initialize diff --git a/virtualenvwrapper_lazy.sh b/virtualenvwrapper_lazy.sh index 4d90c54..3902d08 100644 --- a/virtualenvwrapper_lazy.sh +++ b/virtualenvwrapper_lazy.sh @@ -1,7 +1,7 @@ #!/bin/sh # Alternative startup script for faster login times. -export _VIRTUALENVWRAPPER_API="$_VIRTUALENVWRAPPER_API mkvirtualenv rmvirtualenv lsvirtualenv showvirtualenv workon add2virtualenv cdsitepackages cdvirtualenv lssitepackages toggleglobalsitepackages cpvirtualenv setvirtualenvproject mkproject cdproject mktmpenv" +export _VIRTUALENVWRAPPER_API="$_VIRTUALENVWRAPPER_API mkvirtualenv rmvirtualenv lsvirtualenv showvirtualenv workon add2virtualenv cdsitepackages cdvirtualenv lssitepackages toggleglobalsitepackages cpvirtualenv setvirtualenvproject mkproject cdproject mktmpenv wipeenv allvirtualenv" if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ] then From 3c5c95144c93bd6130141b96193bbd8fbd72500d Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 19 Aug 2016 18:28:51 +0300 Subject: [PATCH 793/947] Fix docs: fix URLs whenever possible, change protocol to https --- docs/source/command_ref.rst | 2 +- docs/source/developers.rst | 4 ++-- docs/source/extensions.rst | 8 ++++---- docs/source/index.rst | 12 ++++++------ docs/source/install.rst | 10 +++++----- docs/source/plugins.rst | 12 ++++++------ docs/source/tips.rst | 14 +++++++------- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 6a54d11..9606e71 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -57,7 +57,7 @@ installed. * :ref:`scripts-postmkvirtualenv` * `requirements file format`_ -.. _requirements file format: http://www.pip-installer.org/en/latest/requirements.html +.. _requirements file format: https://pip.pypa.io/en/latest/reference/pip_install/#requirements-file-format .. _command-mktmpenv: diff --git a/docs/source/developers.rst b/docs/source/developers.rst index da019f2..259c0c2 100644 --- a/docs/source/developers.rst +++ b/docs/source/developers.rst @@ -89,7 +89,7 @@ Python:: Add new tests by modifying an existing file or creating new script in the ``tests`` directory. -.. _shunit2: http://shunit2.googlecode.com/ +.. _shunit2: https://github.com/kward/shunit2 .. _tox: https://tox.testrun.org/ @@ -100,7 +100,7 @@ Creating a New Template virtualenvwrapper.project templates work like `virtualenvwrapper plugins -`__. +`__. The *entry point* group name is ``virtualenvwrapper.project.template``. Configure your entry point to refer to a function that will **run** (source hooks are not supported diff --git a/docs/source/extensions.rst b/docs/source/extensions.rst index fe8f4a2..8b300f3 100644 --- a/docs/source/extensions.rst +++ b/docs/source/extensions.rst @@ -14,9 +14,9 @@ used as a project file similar to other IDEs. The emacs-desktop_ plugin adds a trigger to save the current desktop file and load a new one when activating a new virtualenv using ``workon``. -.. _desktop-mode: http://www.emacswiki.org/emacs/DeskTop +.. _desktop-mode: https://www.emacswiki.org/emacs/DeskTop -.. _emacs-desktop: http://www.doughellmann.com/projects/virtualenvwrapper-emacs-desktop/ +.. _emacs-desktop: https://pypi.python.org/pypi/virtualenvwrapper-emacs-desktop .. _extensions-user_scripts: @@ -53,7 +53,7 @@ bitbucket The bitbucket_ extension automatically clones a mercurial repository from the specified bitbucket project. -.. _bitbucket: http://www.doughellmann.com/projects/virtualenvwrapper.bitbucket/ +.. _bitbucket: https://pypi.python.org/pypi/virtualenvwrapper.bitbucket .. _templates-django: @@ -62,7 +62,7 @@ django The django_ extension automatically creates a new Django project. -.. _django: http://www.doughellmann.com/projects/virtualenvwrapper.django/ +.. _django: https://pypi.python.org/pypi/virtualenvwrapper.django SublimeText ----------- diff --git a/docs/source/index.rst b/docs/source/index.rst index 5c0f75f..e0cca59 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -8,7 +8,7 @@ virtualenvwrapper |release| ########################### virtualenvwrapper is a set of extensions to Ian Bicking's `virtualenv -`_ tool. The extensions +`_ tool. The extensions include wrappers for creating and deleting virtual environments and otherwise managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in @@ -189,23 +189,23 @@ Details References ========== -`virtualenv `_, from Ian +`virtualenv `_, from Ian Bicking, is a pre-requisite to using these extensions. For more details, refer to the column I wrote for the May 2008 issue of Python Magazine: `virtualenvwrapper | And Now For Something Completely Different -`_. +`_. Rich Leland has created a short `screencast -`__ +`__ showing off the features of virtualenvwrapper. Manuel Kaufmann has `translated this documentation into Spanish -`__. +`__. Tetsuya Morimoto has `translated this documentation into Japanese -`__. +`__. ======= Support diff --git a/docs/source/install.rst b/docs/source/install.rst index c71d824..b06fc62 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -32,7 +32,7 @@ which can be run under Microsoft Windows Command Prompt. This is also a separately distributed re-implementation. You can download `virtualenvwrapper-win`_ from PyPI. -.. _virtualenvwrapper-win: http://pypi.python.org/pypi/virtualenvwrapper-win +.. _virtualenvwrapper-win: https://pypi.python.org/pypi/virtualenvwrapper-win MSYS ---- @@ -58,7 +58,7 @@ or:: Depending on your MSYS setup, you may need to install the `MSYS mktemp binary`_ in the ``MSYS_HOME/bin`` folder. -.. _MSYS mktemp binary: http://sourceforge.net/projects/mingw/files/MSYS/mktemp/ +.. _MSYS mktemp binary: https://sourceforge.net/projects/mingw/files/MSYS/ PowerShell ---------- @@ -69,7 +69,7 @@ with the rest of the extensions, and is largely a re-implementation (rather than an adaptation), it should be distributed separately. You can download virtualenvwrapper-powershell_ from PyPI. -.. _virtualenvwrapper-powershell: http://pypi.python.org/pypi/virtualenvwrapper-powershell/2.7.1 +.. _virtualenvwrapper-powershell: https://pypi.python.org/pypi/virtualenvwrapper-powershell .. _supported-versions: @@ -104,7 +104,7 @@ or:: An alternative to installing it into the global site-packages is to add it to `your user local directory -`__ +`__ (usually `~/.local`). :: @@ -331,4 +331,4 @@ supported. In your startup file, change ``source /usr/local/bin/virtualenvwrapper_bashrc`` to ``source /usr/local/bin/virtualenvwrapper.sh``. -.. _pip: http://pypi.python.org/pypi/pip +.. _pip: https://pypi.python.org/pypi/pip diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index 974b9f0..a27a406 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -186,8 +186,8 @@ used). .. seealso:: - * `namespace packages `__ - * `Extensible Applications and Frameworks `__ + * `namespace packages `__ + * `Extensible Applications and Frameworks `__ The Hook Loader --------------- @@ -256,8 +256,8 @@ messages. .. seealso:: - * `Standard library documentation for logging `__ - * `PyMOTW for logging `__ + * `Standard library documentation for logging `__ + * `PyMOTW for logging `__ .. _plugins-extension-points: @@ -394,6 +394,6 @@ and:: respectively. -.. _Setuptools entry points: http://pythonhosted.org//setuptools/pkg_resources.html#entry-points +.. _Setuptools entry points: https://setuptools.readthedocs.io/en/latest/pkg_resources.html#entry-points -.. _project: http://www.doughellmann.com/projects/virtualenvwrapper.project/ +.. _project: https://bitbucket.org/virtualenvwrapper/virtualenvwrapper diff --git a/docs/source/tips.rst b/docs/source/tips.rst index f3056a0..5c42d0f 100644 --- a/docs/source/tips.rst +++ b/docs/source/tips.rst @@ -13,7 +13,7 @@ and I'll add it here. zsh Prompt ========== -From `Nat `_: +From Nat (was blogger.com/profile/16779944428406910187): Using zsh, I added some bits to ``$WORKON_HOME/post(de)activate`` to show the active virtualenv on the right side of my screen instead. @@ -33,7 +33,7 @@ Adjust colors according to your own personal tastes or environment. Updating cached ``$PATH`` entries ================================= -From `Nat `_: +From Nat (was blogger.com/profile/16779944428406910187): I also added the command 'rehash' to ``$WORKON_HOME/postactivate`` and ``$WORKON_HOME/postdeactivate`` as I was having some problems with zsh @@ -42,7 +42,7 @@ not picking up the new paths immediately. Creating Project Work Directories ================================= -Via `James `_: +Via `James `_: In the ``postmkvirtualenv`` script I have the following to create a directory based on the project name, add that directory to the python @@ -70,14 +70,14 @@ directory each time he runs ``cd``. If it finds a ``.venv`` file, it activates the environment named within. On leaving that directory, the current virtualenv is automatically deactivated. -`Harry Marr `__ +`Harry Marr `__ wrote a similar function that works with `git repositories `__. Installing Common Tools Automatically in New Environments ========================================================= -Via `rizumu `__: +Via rizumu (was rizumu.myopenid.com): I have this ``postmkvirtualenv`` to install the get a basic setup. @@ -112,7 +112,7 @@ PIL, psycopg2, django-apps, numpy, etc. Changing the Default Behavior of ``cd`` ======================================= -Via `mae `__: +Via `mae `__: This is supposed to be executed after workon, that is as a ``postactivate`` hook. It basically overrides ``cd`` to know about the @@ -136,7 +136,7 @@ it a proper path then it will do the right thing. And to finally restore the default behaviour of ``cd`` once you bailout of a VENV via a ``deactivate`` command, you need to add this as a ``postdeactivate`` hook (`source -`_):: +`_):: cd () { builtin cd "$@" From 280f14d867423c6533880da3626d2d50a1f515e2 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 14 Aug 2016 10:47:14 +0300 Subject: [PATCH 794/947] Ignore *.pyo byte-code files --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 37bb684..704ba90 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ syntax: glob *~ -*.pyc +*.py[co] README.html build dist From a258df50069343b55919005edfd2e23f6ebd32e0 Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Sat, 20 Aug 2016 10:18:25 -0500 Subject: [PATCH 795/947] Fixing naming in tests Signed-off-by: Jason Myers --- .gitignore | 2 ++ docs/source/conf.py | 3 ++- tests/test_lazy.sh | 4 ++-- tests/test_lazy_loaded.sh | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 704ba90..606759f 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ lib syntax: re .DS_Store ^web/ +.python-version +.eggs diff --git a/docs/source/conf.py b/docs/source/conf.py index 40efac7..f089f60 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -27,7 +27,8 @@ # ones. extensions = ['sphinxcontrib.bitbucket'] -bitbucket_project_url = 'https://bitbucket.org/virtualenvwrapper/virtualenvwrapper/' +bitbucket_project_url = 'https://bitbucket.org/virtualenvwrapper/virtualenvw' \ + 'rapper/' # Add any paths that contain templates here, relative to this directory. # templates_path = ['pkg/templates'] diff --git a/tests/test_lazy.sh b/tests/test_lazy.sh index d7f2ee5..c475d01 100755 --- a/tests/test_lazy.sh +++ b/tests/test_lazy.sh @@ -96,11 +96,11 @@ test_mktmpenv_defined_lazy() { function_defined_lazy mktmpenv } -test_mktmpenv_defined_lazy() { +test_wipeenv_defined_lazy() { function_defined_lazy wipeenv } -test_mktmpenv_defined_lazy() { +test_allvirtualenv_defined_lazy() { function_defined_lazy allvirtualenv } diff --git a/tests/test_lazy_loaded.sh b/tests/test_lazy_loaded.sh index 3e80720..46e4f58 100755 --- a/tests/test_lazy_loaded.sh +++ b/tests/test_lazy_loaded.sh @@ -88,11 +88,11 @@ test_mktmpenv_defined_normal() { function_defined_normal mktmpenv } -test_mktmpenv_defined_normal() { +test_wipeenv_defined_normal() { function_defined_normal wipeenv } -test_mktmpenv_defined_normal() { +test_allvirtualenv_defined_normal() { function_defined_normal allvirtualenv } From 0b90c35b89ddf3edc2ccd91da5ea59f7b3edcd3b Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Sat, 20 Aug 2016 10:31:14 -0500 Subject: [PATCH 796/947] Baseline testing to python27 Signed-off-by: Jason Myers --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6c6370c..253bab6 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ help: @echo "upload - upload a new release to PyPI" @echo "develop - install development version" @echo "test - run the test suite" - @echo "test-quick - run the test suite for bash and one version of Python ($(PYTHON26))" + @echo "test-quick - run the test suite for bash and one version of Python ($(PYTHON27))" .PHONY: sdist sdist: html From 6559554c3a1749bef018477e264180715d8232fb Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Mon, 29 Aug 2016 20:55:08 -0500 Subject: [PATCH 797/947] Fixes Issues #248 Signed-off-by: Jason Myers --- virtualenvwrapper.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 2104cb4..d960eaa 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -244,8 +244,8 @@ function virtualenvwrapper_run_hook { source "$hook_script" elif [ "${1}" = "initialize" ] then - cat - 1>&2 <&2 <&2 return 1 @@ -557,7 +557,7 @@ function rmvirtualenv { # List the available environments. function virtualenvwrapper_show_workon_options { virtualenvwrapper_verify_workon_home || return 1 - # NOTE: DO NOT use ls or cd here because colorized versions spew control + # NOTE: DO NOT use ls or cd here because colorized versions spew control # characters into the output list. # echo seems a little faster than find, even with -depth 3. # Note that this is a little tricky, as there may be spaces in the path. @@ -572,7 +572,7 @@ function virtualenvwrapper_show_workon_options { # a slash, as that is an illegal character in a directory name. # This yields a slash-separated list of possible env names. # 4. Replace each slash with a newline to show the output one name per line. - # 5. Eliminate any lines with * on them because that means there + # 5. Eliminate any lines with * on them because that means there # were no envs. (virtualenvwrapper_cd "$WORKON_HOME" && echo */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate) 2>/dev/null \ | command \tr "\n" " " \ @@ -947,7 +947,7 @@ function cpvirtualenv { typeset src_name="$1" typeset trg_name="$2" typeset src - typeset trg + typeset trg # without a source there is nothing to do if [ "$src_name" = "" ]; then @@ -991,10 +991,10 @@ function cpvirtualenv { echo "Copying $src_name as $trg_name..." ( - [ -n "$ZSH_VERSION" ] && setopt SH_WORD_SPLIT + [ -n "$ZSH_VERSION" ] && setopt SH_WORD_SPLIT virtualenvwrapper_cd "$WORKON_HOME" && - "$VIRTUALENVWRAPPER_VIRTUALENV_CLONE" "$src" "$trg" - [ -d "$trg" ] && + "$VIRTUALENVWRAPPER_VIRTUALENV_CLONE" "$src" "$trg" + [ -d "$trg" ] && virtualenvwrapper_run_hook "pre_cpvirtualenv" "$src" "$trg_name" && virtualenvwrapper_run_hook "pre_mkvirtualenv" "$trg_name" ) From 737b6e775664c787b5ffe5c7b0e944713f160ca3 Mon Sep 17 00:00:00 2001 From: lendenmc Date: Mon, 12 Sep 2016 15:08:36 +0200 Subject: [PATCH 798/947] Fix .kshrc sourcing error "'&>file' is nonstandard" --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 2104cb4..93b00cb 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -593,7 +593,7 @@ function _lsvirtualenv_usage { function lsvirtualenv { typeset long_mode=true - if command -v "getopts" &> /dev/null + if command -v "getopts" >/dev/null 2>&1 then # Use getopts when possible OPTIND=1 From f60dcbd7be140ffbd8b16433a394ef7fb370b604 Mon Sep 17 00:00:00 2001 From: Sam Brightman Date: Sat, 1 Oct 2016 21:29:43 +0200 Subject: [PATCH 799/947] Fix spelling mistake in error message --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 2104cb4..91b06e2 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -515,7 +515,7 @@ function rmvirtualenv { virtualenvwrapper_verify_workon_home || return 1 if [ ${#@} = 0 ] then - echo "Please specify an enviroment." >&2 + echo "Please specify an environment." >&2 return 1 fi From e76c9eccf08cc9ab1efa3af568c12555e4840c5f Mon Sep 17 00:00:00 2001 From: Doug Harris Date: Fri, 16 Dec 2016 15:26:27 -0500 Subject: [PATCH 800/947] Makes workon more selective in its search for `deactivate` #285 --- virtualenvwrapper.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 91b06e2..fcdf60b 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -749,8 +749,9 @@ function workon { # Deactivate any current environment "destructively" # before switching so we use our override function, - # if it exists. - type deactivate >/dev/null 2>&1 + # if it exists, but make sure it's the deactivate function + # we set up + type deactivate | grep 'typeset env_postdeactivate_hook' >/dev/null 2>&1 if [ $? -eq 0 ] then deactivate From 5d719d0fd7868fade7900df60c7cbd0de4313bf9 Mon Sep 17 00:00:00 2001 From: Doug Harris Date: Tue, 10 Jan 2017 14:56:20 -0500 Subject: [PATCH 801/947] Fixed case where alternate deactivate didn't exist --- virtualenvwrapper.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index fcdf60b..a190802 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -751,11 +751,15 @@ function workon { # before switching so we use our override function, # if it exists, but make sure it's the deactivate function # we set up - type deactivate | grep 'typeset env_postdeactivate_hook' >/dev/null 2>&1 + type deactivate >/dev/null 2>&1 if [ $? -eq 0 ] then - deactivate - unset -f deactivate >/dev/null 2>&1 + type deactivate | grep 'typeset env_postdeactivate_hook' >/dev/null 2>&1 + if [ $? -eq 0 ] + then + deactivate + unset -f deactivate >/dev/null 2>&1 + fi fi virtualenvwrapper_run_hook "pre_activate" "$env_name" From 03a253b73cc3bcbd20ea38cbb6b0a220d5d49843 Mon Sep 17 00:00:00 2001 From: Zhiming Wang Date: Tue, 7 Feb 2017 17:40:02 -0500 Subject: [PATCH 802/947] virtualenvwrapper.sh: always export VIRTUALENVWRAPPER_HOOK_DIR Previously, if VIRTUALENVWRAPPER_HOOK_DIR is set to a nonempty value but not exported, virtualenvwrapper_initialize would assume it is available in the environment, and that leads to confusing problems like #276 where user_scripts.make_hook attempts to create hooks like '/Users/jacob/venvs/$VIRTUALENVWRAPPER_HOOK_DIR/premkproject'. In this commit, we make sure VIRTUALENVWRAPPER_HOOK_DIR is always exported, so that $VIRTUALENVWRAPPER_HOOK_DIR is always expanded by user_scripts.get_path. --- virtualenvwrapper.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 91b06e2..2460086 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -304,8 +304,9 @@ function virtualenvwrapper_initialize { # Set the location of the hook scripts if [ "$VIRTUALENVWRAPPER_HOOK_DIR" = "" ] then - export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME" + VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME" fi + export VIRTUALENVWRAPPER_HOOK_DIR mkdir -p "$VIRTUALENVWRAPPER_HOOK_DIR" From 764a925a46e087f62823035556a52ffdf5cabe64 Mon Sep 17 00:00:00 2001 From: Christopher Arndt Date: Thu, 16 Mar 2017 16:20:00 +0100 Subject: [PATCH 803/947] Import distutils.sysconfig properly (fixes #167) Signed-off-by: Christopher Arndt --- virtualenvwrapper.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 91b06e2..edb2687 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -244,8 +244,8 @@ function virtualenvwrapper_run_hook { source "$hook_script" elif [ "${1}" = "initialize" ] then - cat - 1>&2 <&2 </dev/null \ | command \tr "\n" " " \ @@ -809,7 +809,7 @@ function virtualenvwrapper_get_python_version { # Prints the path to the site-packages directory for the current environment. function virtualenvwrapper_get_site_packages_dir { - "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/python" -c "import distutils; print(distutils.sysconfig.get_python_lib())" + "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/python" -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())" } # Path management for packages outside of the virtual env. @@ -947,7 +947,7 @@ function cpvirtualenv { typeset src_name="$1" typeset trg_name="$2" typeset src - typeset trg + typeset trg # without a source there is nothing to do if [ "$src_name" = "" ]; then @@ -991,10 +991,10 @@ function cpvirtualenv { echo "Copying $src_name as $trg_name..." ( - [ -n "$ZSH_VERSION" ] && setopt SH_WORD_SPLIT + [ -n "$ZSH_VERSION" ] && setopt SH_WORD_SPLIT virtualenvwrapper_cd "$WORKON_HOME" && - "$VIRTUALENVWRAPPER_VIRTUALENV_CLONE" "$src" "$trg" - [ -d "$trg" ] && + "$VIRTUALENVWRAPPER_VIRTUALENV_CLONE" "$src" "$trg" + [ -d "$trg" ] && virtualenvwrapper_run_hook "pre_cpvirtualenv" "$src" "$trg_name" && virtualenvwrapper_run_hook "pre_mkvirtualenv" "$trg_name" ) From cce429c63920efeb95f75b6dbca95873b029a0c4 Mon Sep 17 00:00:00 2001 From: kk6 Date: Thu, 23 Mar 2017 16:10:40 +0900 Subject: [PATCH 804/947] =?UTF-8?q?Fixes=20Issue=20#291=20wipeenv=20ignore?= =?UTF-8?q?=20setuptools=E2=80=99s=20dependencies.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- virtualenvwrapper.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 91b06e2..2e6610f 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -244,8 +244,8 @@ function virtualenvwrapper_run_hook { source "$hook_script" elif [ "${1}" = "initialize" ] then - cat - 1>&2 <&2 </dev/null \ | command \tr "\n" " " \ @@ -947,7 +947,7 @@ function cpvirtualenv { typeset src_name="$1" typeset trg_name="$2" typeset src - typeset trg + typeset trg # without a source there is nothing to do if [ "$src_name" = "" ]; then @@ -991,10 +991,10 @@ function cpvirtualenv { echo "Copying $src_name as $trg_name..." ( - [ -n "$ZSH_VERSION" ] && setopt SH_WORD_SPLIT + [ -n "$ZSH_VERSION" ] && setopt SH_WORD_SPLIT virtualenvwrapper_cd "$WORKON_HOME" && - "$VIRTUALENVWRAPPER_VIRTUALENV_CLONE" "$src" "$trg" - [ -d "$trg" ] && + "$VIRTUALENVWRAPPER_VIRTUALENV_CLONE" "$src" "$trg" + [ -d "$trg" ] && virtualenvwrapper_run_hook "pre_cpvirtualenv" "$src" "$trg_name" && virtualenvwrapper_run_hook "pre_mkvirtualenv" "$trg_name" ) @@ -1281,7 +1281,7 @@ function wipeenv { virtualenvwrapper_verify_active_environment || return 1 typeset req_file="$(virtualenvwrapper_tempfile "requirements.txt")" - pip freeze | egrep -v '(distribute|wsgiref)' > "$req_file" + pip freeze | egrep -v '(distribute|wsgiref|appdirs|packaging|pyparsing|six)' > "$req_file" if [ -n "$(cat "$req_file")" ] then echo "Uninstalling packages:" From c4b6da9ccf45be396c976257add80e646919f52d Mon Sep 17 00:00:00 2001 From: Erick M'bwana Date: Mon, 3 Apr 2017 13:26:32 +0000 Subject: [PATCH 805/947] command_ref.rst edited online with Bitbucket --- docs/source/command_ref.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 9606e71..9b5af55 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -169,7 +169,7 @@ created elsewhere. Copying virtual environments is not well supported. Each virtualenv has path information hard-coded into it, and there may be cases - where the copy code does not know to update a particular + where the copy code does not know how to update a particular file. **Use with caution.** Syntax:: From 76424df5f4e61d5e8c67403e9fc0fc23f835c169 Mon Sep 17 00:00:00 2001 From: Erick M'bwana Date: Wed, 5 Apr 2017 07:16:20 +0000 Subject: [PATCH 806/947] Update sentence to make it more clear. --- docs/source/command_ref.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 9b5af55..f2e2f33 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -169,7 +169,7 @@ created elsewhere. Copying virtual environments is not well supported. Each virtualenv has path information hard-coded into it, and there may be cases - where the copy code does not know how to update a particular + where the copy code does not know it needs to update a particular file. **Use with caution.** Syntax:: From 06e2c7a79db6837c9a64a1f2d844558749b021eb Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Mon, 4 Sep 2017 10:17:28 -0500 Subject: [PATCH 807/947] Typo fix Signed-off-by: Jason Myers --- docs/source/design.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/design.rst b/docs/source/design.rst index 73d5d73..d5eb387 100644 --- a/docs/source/design.rst +++ b/docs/source/design.rst @@ -58,7 +58,7 @@ How the Shell Runs a Program When a shell receives a command to be executed, either interactively or by parsing a script file, and determines that the command is -implemented in a separate program file, is uses ``fork()`` to create a +implemented in a separate program file, it uses ``fork()`` to create a new process and then inside that process it uses one of the ``exec`` functions to start the specified program. The language that program is written in doesn't make any difference in the decision about whether From f8f1939eab702a49e64f3e1b140ca7f6ee7e9c44 Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Mon, 4 Sep 2017 10:37:55 -0500 Subject: [PATCH 808/947] Adding a note about package managers Signed-off-by: Jason Myers --- docs/source/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index e0cca59..c29ff06 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -39,7 +39,7 @@ First, some initialization steps. Most of this only needs to be done one time. You will want to add the command to ``source /usr/local/bin/virtualenvwrapper.sh`` to your shell startup file, changing the path to virtualenvwrapper.sh depending on where it was -installed by pip. +installed by pip or your package manager. :: From 6b9b7dcaaf7fd3f7a74a199fb8927ca5fdf17440 Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Mon, 4 Sep 2017 10:44:38 -0500 Subject: [PATCH 809/947] First shot at Fixing #263 Signed-off-by: Jason Myers --- virtualenvwrapper.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index e0cbc1e..f4a9101 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -45,26 +45,26 @@ # # Locate the global Python where virtualenvwrapper is installed. -if [ "$VIRTUALENVWRAPPER_PYTHON" = "" ] +if [ "${VIRTUALENVWRAPPER_PYTHON:-}" = "" ] then VIRTUALENVWRAPPER_PYTHON="$(command \which python)" fi # Set the name of the virtualenv app to use. -if [ "$VIRTUALENVWRAPPER_VIRTUALENV" = "" ] +if [ "${VIRTUALENVWRAPPER_VIRTUALENV:-}" = "" ] then VIRTUALENVWRAPPER_VIRTUALENV="virtualenv" fi # Set the name of the virtualenv-clone app to use. -if [ "$VIRTUALENVWRAPPER_VIRTUALENV_CLONE" = "" ] +if [ "${VIRTUALENVWRAPPER_VIRTUALENV_CLONE:-}" = "" ] then VIRTUALENVWRAPPER_VIRTUALENV_CLONE="virtualenv-clone" fi # Define script folder depending on the platorm (Win32/Unix) VIRTUALENVWRAPPER_ENV_BIN_DIR="bin" -if [ "$OS" = "Windows_NT" ] && ([ "$MSYSTEM" = "MINGW32" ] || [ "$MSYSTEM" = "MINGW64" ]) +if [ "${OS:-}" = "Windows_NT" ] && ([ "${MSYSTEM:-}" = "MINGW32" ] || [ "${MSYSTEM:-}" = "MINGW64" ]) then # Only assign this for msys, cygwin use standard Unix paths # and its own python installation @@ -73,7 +73,7 @@ fi # Let the user override the name of the file that holds the project # directory name. -if [ "$VIRTUALENVWRAPPER_PROJECT_FILENAME" = "" ] +if [ "${VIRTUALENVWRAPPER_PROJECT_FILENAME:-}" = "" ] then export VIRTUALENVWRAPPER_PROJECT_FILENAME=".project" fi @@ -83,7 +83,7 @@ fi export VIRTUALENVWRAPPER_WORKON_CD=${VIRTUALENVWRAPPER_WORKON_CD:-1} # Remember where we are running from. -if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ] +if [ -z "${VIRTUALENVWRAPPER_SCRIPT:-}" ] then if [ -n "$BASH" ] then @@ -108,10 +108,10 @@ fi # we are trying to change the state of the current shell, so we use # "builtin" for bash and zsh but "command" under ksh. function virtualenvwrapper_cd { - if [ -n "$BASH" ] + if [ -n "${BASH:-}" ] then builtin \cd "$@" - elif [ -n "$ZSH_VERSION" ] + elif [ -n "${ZSH_VERSION:-}" ] then builtin \cd -q "$@" else From 043d215fc5dbaf572ecf5c66a771d808c30abbd8 Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Mon, 4 Sep 2017 10:49:40 -0500 Subject: [PATCH 810/947] Fixing run_hook and tab_completion Signed-off-by: Jason Myers --- virtualenvwrapper.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index f4a9101..9c0b1ac 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -228,7 +228,7 @@ function virtualenvwrapper_run_hook { ( \ virtualenvwrapper_cd "$WORKON_HOME" && "$VIRTUALENVWRAPPER_PYTHON" -m 'virtualenvwrapper.hook_loader' \ - $HOOK_VERBOSE_OPTION --script "$hook_script" "$@" \ + ${HOOK_VERBOSE_OPTION:-} --script "$hook_script" "$@" \ ) result=$? @@ -260,7 +260,7 @@ EOF # Set up tab completion. (Adapted from Arthur Koziel's version at # http://arthurkoziel.com/2008/10/11/virtualenvwrapper-bash-completion/) function virtualenvwrapper_setup_tab_completion { - if [ -n "$BASH" ] ; then + if [ -n "${BASH:-}" ] ; then _virtualenvs () { local cur="${COMP_WORDS[COMP_CWORD]}" COMPREPLY=( $(compgen -W "`virtualenvwrapper_show_workon_options`" -- ${cur}) ) From 486f1d310545cc7fcd93105aba151dc0cb5b79ce Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Mon, 4 Sep 2017 11:07:05 -0500 Subject: [PATCH 811/947] Adding python 3.6 Signed-off-by: Jason Myers --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index cd69916..8c6ade5 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py26,py33,py34,py35,zsh,ksh,style +envlist = py27,py26,py33,py34,py35,py36,zsh,ksh,style [testenv] install_command = pip install -U {opts} {packages} @@ -49,4 +49,4 @@ basepython=python2.7 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/docs/requirements.txt -commands = python setup.py build_sphinx \ No newline at end of file +commands = python setup.py build_sphinx From f7c3ead68bd1623a8a944667832644ccd517debc Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Mon, 4 Sep 2017 11:09:29 -0500 Subject: [PATCH 812/947] Update supported versions Signed-off-by: Jason Myers --- docs/source/install.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/install.rst b/docs/source/install.rst index b06fc62..2aafa8d 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -76,7 +76,7 @@ can download virtualenvwrapper-powershell_ from PyPI. Python Versions =============== -virtualenvwrapper is tested under Python 2.6-3.4. +virtualenvwrapper is tested under Python 2.7-3.6. .. _install-basic: From 96190923f5b206aa5e693b361b5b95da53b68125 Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Mon, 4 Sep 2017 11:12:14 -0500 Subject: [PATCH 813/947] Fixing Documentation Signed-off-by: Jason Myers --- docs/source/index.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index c29ff06..eabd39d 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -197,10 +197,6 @@ of Python Magazine: `virtualenvwrapper | And Now For Something Completely Different `_. -Rich Leland has created a short `screencast -`__ -showing off the features of virtualenvwrapper. - Manuel Kaufmann has `translated this documentation into Spanish `__. From 2064934c678bdf992545ecc71349bc1b5157efdf Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Mon, 4 Sep 2017 14:24:01 -0500 Subject: [PATCH 814/947] New PBR doesn't like provides_dist Signed-off-by: Jason Myers --- setup.cfg | 4 ---- 1 file changed, 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index d38e298..d955af2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,10 +22,6 @@ keywords = virtualenv home-page = http://virtualenvwrapper.readthedocs.org/ zip_safe = False -provides_dist = - virtualenvwrapper - virtualenvwrapper.user_scripts - virtualenvwrapper.project [files] packages = From a54953cf17fb9639c2408d742d865e0d616daa7b Mon Sep 17 00:00:00 2001 From: Jeff Widman Date: Sat, 16 Sep 2017 05:14:28 +0000 Subject: [PATCH 815/947] Update readme with current test status Looks like the tox setup is already testing python 3.5/3.6 --- README.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.txt b/README.txt index 17dd07c..2d386f6 100644 --- a/README.txt +++ b/README.txt @@ -63,7 +63,7 @@ from this page. Python Versions =============== -virtualenvwrapper is tested under Python 2.6 - 3.4. +virtualenvwrapper is tested under Python 2.6 - 3.6. ======= Support From 3e3103803f809ebca08880907e92fb858f21826a Mon Sep 17 00:00:00 2001 From: Jeff Widman Date: Sat, 16 Sep 2017 05:18:29 +0000 Subject: [PATCH 816/947] Add python 3.6 to Pypi trove classifiers --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index d955af2..11a2646 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,6 +16,7 @@ classifier = Programming Language :: Python :: 3.3 Programming Language :: Python :: 3.4 Programming Language :: Python :: 3.5 + Programming Language :: Python :: 3.6 Intended Audience :: Developers Environment :: Console keywords = From 7e22152b4b7c45ed9d6b1eede58cfd3821484215 Mon Sep 17 00:00:00 2001 From: Jeff Widman Date: Sat, 16 Sep 2017 05:20:43 +0000 Subject: [PATCH 817/947] Update RTD url They now use .io rather than .org. Also, default to HTTPS --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index d955af2..6fc794e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,7 +20,7 @@ classifier = Environment :: Console keywords = virtualenv -home-page = http://virtualenvwrapper.readthedocs.org/ +home-page = https://virtualenvwrapper.readthedocs.io/ zip_safe = False [files] From a88bcec52d4313f4db8c2c6be3b49d36877e07ce Mon Sep 17 00:00:00 2001 From: Jakob Gerhard Martinussen Date: Tue, 24 Oct 2017 20:15:15 +0000 Subject: [PATCH 818/947] Fix formatting error On read the docs this is shown as one single line --- docs/source/scripts.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/scripts.rst b/docs/source/scripts.rst index 4363f8a..99b482e 100644 --- a/docs/source/scripts.rst +++ b/docs/source/scripts.rst @@ -29,6 +29,7 @@ If your :ref:`WORKON_HOME ` is set to ~/.virtualenvs: Edit the file so it contains the following (for a default Django setup): # Automatically set django settings for the virtualenv + echo "export DJANGO_SETTINGS_MODULE=$1.settings" >> "$1/bin/activate" Create a new virtualenv, and you should see DJANGO_SETTINGS_MODULE in your env! From 7d398012579e57f15f54af1e3a5591f94188659b Mon Sep 17 00:00:00 2001 From: Jakob Gerhard Martinussen Date: Tue, 24 Oct 2017 21:17:57 +0000 Subject: [PATCH 819/947] Use code blocks in order to allow easier copy-pasting Currently when you copy these code snippets, quotes are formatted wrongly, resulting in errors. --- docs/source/scripts.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/source/scripts.rst b/docs/source/scripts.rst index 99b482e..30f4863 100644 --- a/docs/source/scripts.rst +++ b/docs/source/scripts.rst @@ -22,14 +22,13 @@ if you work on multiple projects, you want it to be specific to the project you are currently working on. Wouldn't it be nice if it was set based on the active virtualenv? You can achieve this with :ref:`scripts` as follows. -If your :ref:`WORKON_HOME ` is set to ~/.virtualenvs: +If your :ref:`WORKON_HOME ` is set to ~/.virtualenvs:: vim ~/.virtualenvs/premkvirtualenv -Edit the file so it contains the following (for a default Django setup): +Edit the file so it contains the following (for a default Django setup):: # Automatically set django settings for the virtualenv - echo "export DJANGO_SETTINGS_MODULE=$1.settings" >> "$1/bin/activate" Create a new virtualenv, and you should see DJANGO_SETTINGS_MODULE in your env! From 2b9646781f57496435fb93ba57cd2e072411d1b1 Mon Sep 17 00:00:00 2001 From: Harrison Katz Date: Thu, 31 May 2018 10:23:04 -0400 Subject: [PATCH 820/947] Fix bug with workon deactivate typeset -f ; Add test_workon_deactivate_hooks --- tests/test_workon.sh | 39 ++++++++++++++++++++++++++++++++++++--- virtualenvwrapper.sh | 2 +- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/tests/test_workon.sh b/tests/test_workon.sh index 17656bb..1e3aef7 100755 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -25,7 +25,7 @@ setUp () { } tearDown () { - deactivate >/dev/null 2>&1 + deactivate >/dev/null 2>&1 } test_workon () { @@ -50,7 +50,7 @@ test_workon_activate_hooks () { touch "$TMPDIR/catch_output" workon test1 - + output=$(cat "$TMPDIR/catch_output") expected="GLOBAL preactivate ENV preactivate @@ -58,7 +58,7 @@ GLOBAL postactivate ENV postactivate" assertSame "$expected" "$output" - + for t in pre post do rm -f "$WORKON_HOME/test1/bin/${t}activate" @@ -66,6 +66,39 @@ ENV postactivate" done } +test_workon_deactivate_hooks () { + for t in pre post + do + echo "#!/bin/sh" > "$WORKON_HOME/${t}deactivate" + echo "echo GLOBAL ${t}deactivate >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/${t}deactivate" + chmod +x "$WORKON_HOME/${t}deactivate" + + echo "#!/bin/sh" > "$WORKON_HOME/test2/bin/${t}deactivate" + echo "echo ENV ${t}deactivate >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/test1/bin/${t}deactivate" + chmod +x "$WORKON_HOME/test1/bin/${t}deactivate" + done + + rm -f "$TMPDIR/catch_output" + touch "$TMPDIR/catch_output" + + workon test1 + workon test2 + + output=$(cat "$TMPDIR/catch_output") + expected="ENV predeactivate +GLOBAL predeactivate +ENV postdeactivate +GLOBAL postdeactivate" + + assertSame "$expected" "$output" + + for t in pre post + do + rm -f "$WORKON_HOME/test1/bin/${t}deactivate" + rm -f "$WORKON_HOME/${t}deactivate" + done +} + test_virtualenvwrapper_show_workon_options () { mkdir "$WORKON_HOME/not_env" (cd "$WORKON_HOME"; ln -s test1 link_env) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 9c0b1ac..ade8ddd 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -755,7 +755,7 @@ function workon { type deactivate >/dev/null 2>&1 if [ $? -eq 0 ] then - type deactivate | grep 'typeset env_postdeactivate_hook' >/dev/null 2>&1 + typeset -f deactivate | grep 'typeset env_postdeactivate_hook' >/dev/null 2>&1 if [ $? -eq 0 ] then deactivate From f280f0f38fcd4cbcd38a36b94bca1e775615a4b7 Mon Sep 17 00:00:00 2001 From: Joel Cross Date: Wed, 20 Jun 2018 23:07:07 +0000 Subject: [PATCH 821/947] Allow building docs on Python 3 --- docs/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index f089f60..d1e81c2 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -54,7 +54,7 @@ version = subprocess.check_output([ 'sh', '-c', 'cd ../..; python setup.py --version', -]) +]).decode('utf-8') version = version.strip() # The full version, including alpha/beta/rc tags. release = version From 63596865a18093dff7707687a68491aeb5c5e8e0 Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Sat, 3 Nov 2018 22:00:39 -0700 Subject: [PATCH 822/947] Make mkvirtualenv work with interpreters whose paths have spaces --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index ade8ddd..4d000b8 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -461,7 +461,7 @@ function mkvirtualenv { i=$(( $i + 1 )) done - if [ ! -z $interpreter ] + if [ ! -z "$interpreter" ] then out_args=( "--python=$interpreter" ${out_args[@]} ) fi; From 459ce5e138af135bc6c590364ea907416dfbcee0 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Sun, 4 Nov 2018 14:34:37 +0000 Subject: [PATCH 823/947] Merged in techtonik/virtualenvwrapper/techtonik/toxini-edited-online-with-bitbucket-1525341850929 (pull request #69) Drop Python 2.6 support in tox * tox.ini: get dependencies from requirements.txt * Fix tox tests for Python 2.6 They fail because of missing NullHandler (#289) * Python 2.6 support is dropped https://bitbucket.org/virtualenvwrapper/virtualenvwrapper/pull-requests/69/fix-tests-with-python-26/diff#comment-63267802 * tox.ini: drop Python 2.6 support * developers.rst: update supported Python versions Approved-by: Jason Myers --- docs/source/developers.rst | 2 +- tox.ini | 18 ++---------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/docs/source/developers.rst b/docs/source/developers.rst index 259c0c2..83ce8e4 100644 --- a/docs/source/developers.rst +++ b/docs/source/developers.rst @@ -69,7 +69,7 @@ The test suite for virtualenvwrapper uses shunit2_ and tox_. The shunit2 source is included in the ``tests`` directory, but tox must be installed separately (``pip install tox``). -To run the tests under bash, zsh, and ksh for Python 2.4 through 2.7, +To run the tests under bash, zsh, and ksh for Python 2.7 through 3.6, run ``tox`` from the top level directory of the hg repository. To run individual test scripts, use a command like:: diff --git a/tox.ini b/tox.ini index 8c6ade5..ba242cc 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,10 @@ [tox] -envlist = py27,py26,py33,py34,py35,py36,zsh,ksh,style +envlist = py27,py33,py34,py35,py36,zsh,ksh,style [testenv] install_command = pip install -U {opts} {packages} commands = bash ./tests/run_tests {envdir} [] -deps = virtualenv - virtualenv-clone - stevedore +deps = -rrequirements.txt setenv = TOXIC = true SHELL = /bin/bash @@ -19,18 +17,6 @@ whitelist_externals = deps = flake8 commands = flake8 virtualenvwrapper docs/source/conf.py -# Not sure why the basepython setting is needed, but on my system if -# it isn't included then the python version picked up for 2.6 is -# actually 2.7. -# -# IF THIS CAUSES YOU A PROBLEM COMMENT IT OUT BEFORE RUNNING THE TESTS. -# -[testenv:py26] -basepython=python2.6 -setenv = - SHELL = /bin/bash -commands = bash ./tests/run_tests {envdir} [] - [testenv:zsh] basepython=python2.7 setenv = From c5d08eafa6f270495eeafa982323a6a982d3aa71 Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Sat, 9 Feb 2019 11:05:06 -0600 Subject: [PATCH 824/947] Upgrade sphinx, fix docs Signed-off-by: Jason Myers --- README.txt | 6 +++--- docs/requirements.txt | 5 +++-- docs/source/conf.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.txt b/README.txt index 2d386f6..63915dd 100644 --- a/README.txt +++ b/README.txt @@ -45,7 +45,7 @@ Installation ============ See the `project documentation -`__ for +`__ for installation and setup instructions. Supported Shells @@ -71,7 +71,7 @@ Support Join the `virtualenvwrapper Google Group `__ to discuss -issues and features. +issues and features. Report bugs via the `bug tracker on Bitbucket `__. @@ -92,7 +92,7 @@ Change Log The `release history`_ is part of the project documentation. -.. _release history: http://www.doughellmann.com/docs/virtualenvwrapper/history.html +.. _release history: https://virtualenvwrapper.readthedocs.io/en/latest/history.html ======= License diff --git a/docs/requirements.txt b/docs/requirements.txt index 7acfbd9..0fca33e 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,2 +1,3 @@ -sphinxcontrib-bitbucket -sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3 +# sphinxcontrib-bitbucket +# sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3 +sphinx diff --git a/docs/source/conf.py b/docs/source/conf.py index d1e81c2..1a79ec8 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -25,7 +25,7 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ['sphinxcontrib.bitbucket'] +# extensions = ['sphinxcontrib.bitbucket'] bitbucket_project_url = 'https://bitbucket.org/virtualenvwrapper/virtualenvw' \ 'rapper/' From aa2ac7fcbe0d3c97e4bba0a4098d504a89d67d69 Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Sat, 9 Feb 2019 11:40:27 -0600 Subject: [PATCH 825/947] Formatting change Signed-off-by: Jason Myers --- README.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/README.txt b/README.txt index 63915dd..1b7221a 100644 --- a/README.txt +++ b/README.txt @@ -94,6 +94,7 @@ The `release history`_ is part of the project documentation. .. _release history: https://virtualenvwrapper.readthedocs.io/en/latest/history.html + ======= License ======= From b71ddca0837cf193b1e8bb05f3c4e2c937913bb4 Mon Sep 17 00:00:00 2001 From: Lumir Balhar Date: Tue, 19 Feb 2019 14:36:36 +0100 Subject: [PATCH 826/947] Find the highest Python version with installed virtualenvwrapper --- virtualenvwrapper.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index ade8ddd..45b0493 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -45,9 +45,21 @@ # # Locate the global Python where virtualenvwrapper is installed. +# Use the highest Python version if [ "${VIRTUALENVWRAPPER_PYTHON:-}" = "" ] then - VIRTUALENVWRAPPER_PYTHON="$(command \which python)" + for NAME in python3 python2 python + do + PYTHON="$(command \which $NAME 2>&1)" + if ! [ -z $PYTHON ] + then + if $PYTHON -m 'virtualenvwrapper.hook_loader' --help >/dev/null 2>&1 + then + VIRTUALENVWRAPPER_PYTHON=$PYTHON + break + fi + fi + done fi # Set the name of the virtualenv app to use. From 0ea789333df5ded2e275fcfabb41dcdeec4faef6 Mon Sep 17 00:00:00 2001 From: Lumir Balhar Date: Tue, 12 Mar 2019 13:08:41 +0100 Subject: [PATCH 827/947] fixup! Find the highest Python version with installed virtualenvwrapper --- virtualenvwrapper.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 45b0493..e83f666 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -50,16 +50,23 @@ if [ "${VIRTUALENVWRAPPER_PYTHON:-}" = "" ] then for NAME in python3 python2 python do - PYTHON="$(command \which $NAME 2>&1)" - if ! [ -z $PYTHON ] + python_executable="$(which $NAME 2>/dev/null)" + if ! [ -z "$python_executable" ] then - if $PYTHON -m 'virtualenvwrapper.hook_loader' --help >/dev/null 2>&1 + if $python_executable -m 'virtualenvwrapper.hook_loader' --help >/dev/null 2>&1 then - VIRTUALENVWRAPPER_PYTHON=$PYTHON + VIRTUALENVWRAPPER_PYTHON=$python_executable break fi fi done + if [ "${VIRTUALENVWRAPPER_PYTHON:-}" = "" ] + then + echo -e "ERROR: Python with virtualenvwrapper module not found! +Either, install virtualenvwrapper module for standard python2 +or python3 or set VIRTUALENVWRAPPER_PYTHON variable manually." 1>&2 + return 1 + fi fi # Set the name of the virtualenv app to use. From d41b18b918803fd2f3464b29ea7dc922c521691b Mon Sep 17 00:00:00 2001 From: Shailesh Vashishth Date: Sun, 25 Aug 2019 09:29:55 +0000 Subject: [PATCH 828/947] index.rst edited online with Bitbucket --- docs/source/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index eabd39d..29e088d 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -25,7 +25,7 @@ Features 4. Tab completion for commands that take a virtual environment as argument. 5. User-configurable hooks for all operations (see :ref:`scripts`). -6. Plugin system for more creating sharable extensions (see +6. Plugin system for creating more sharable extensions (see :ref:`plugins`). ============ From 426961c10e885cabf5a31eb049845c54e14da2f3 Mon Sep 17 00:00:00 2001 From: Stephan Sokolow Date: Sat, 23 Nov 2019 00:56:43 +0000 Subject: [PATCH 829/947] Improve Zsh prompt tip Closes #332 --- docs/source/tips.rst | 80 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 17 deletions(-) diff --git a/docs/source/tips.rst b/docs/source/tips.rst index c610322..c32bdf9 100644 --- a/docs/source/tips.rst +++ b/docs/source/tips.rst @@ -10,25 +10,71 @@ an email or post a comment on `this blog post `__ and I'll add it here. -zsh Prompt -========== - -From Nat (was blogger.com/profile/16779944428406910187): - -Using zsh, I added some bits to ``$WORKON_HOME/post(de)activate`` to show -the active virtualenv on the right side of my screen instead. - -in ``postactivate``:: - - PS1="$_OLD_VIRTUAL_PS1" - _OLD_RPROMPT="$RPROMPT" - RPROMPT="%{${fg_bold[white]}%}(env: %{${fg[green]}%}`basename \"$VIRTUAL_ENV\"`%{${fg_bold[white]}%})%{${reset_color}%} $RPROMPT" - -and in ``postdeactivate``:: +Enhanced bash/zsh Prompt +======================== + +Via `Stephan Sokolow `_ + +While the virtualenv ``activate`` script does attempt to provide +an indicator in the prompt, it has various shortcomings, and +cannot be customized. + +However, it does also set a shell variable named +``VIRTUAL_ENV`` which can be used as the basis for disabling the +built-in prompt indicator and substituting an improved one, +as a customization to ``.bashrc`` or ``.zshrc``:: + + virtualenv_prompt() { + # If not in a virtualenv, print nothing + [[ "$VIRTUAL_ENV" == "" ]] && return + + # Distinguish between the shell where the virtualenv was activated + # and its children + local venv_name="${VIRTUAL_ENV##*/}" + if typeset -f deactivate >/dev/null; then + echo "[${venv_name}] " + else + echo "<${venv_name}> " + fi + } + + # Display a "we are in a virtualenv" indicator that works in child shells too + VIRTUAL_ENV_DISABLE_PROMPT=1 + PS1='$(virtualenv_prompt)'"$PS1" + +This basic example works in both bash and zsh and has the following +advantages: + +1. It will also display in sub-shells, because it works by having the + shell detect an active virtualenv, rather than by having the ``activate`` + script modify the prompt for just the current shell instance. +2. It will clearly indicate if you're in a subshell, where the + virtualenv will still apply, but the ``deactivate`` command will be + missing. + +However, if you are using zsh, a better example of what the design +is capable of can be constructed by taking advantage of zsh's built-in +support for easily adding color and right-aligned segments to prompts:: + + zsh_virtualenv_prompt() { + # If not in a virtualenv, print nothing + [[ "$VIRTUAL_ENV" == "" ]] && return + + # Distinguish between the shell where the virtualenv was activated + # and its children + local venv_name="${VIRTUAL_ENV##*/}" + if typeset -f deactivate >/dev/null; then + echo "[%F{green}${venv_name}%f] " + else + echo "<%F{green}${venv_name}%f> " + fi + } - RPROMPT="$_OLD_RPROMPT" + setopt PROMPT_SUBST PROMPT_PERCENT -Adjust colors according to your own personal tastes or environment. + # Display a "we are in a virtualenv" indicator that works in child shells too + VIRTUAL_ENV_DISABLE_PROMPT=1 + RPS1='$(zsh_virtualenv_prompt)' Updating cached ``$PATH`` entries ================================= From 9eeeb1bf45987fc5ba334e07095f5e32cb04a9bc Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 9 Feb 2020 09:34:56 -0500 Subject: [PATCH 830/947] improve some of the wording in the readme The project is maintained by more than one person, so replace "I" with "we", etc. Link to the places that we want users to report problems or send pull requests. Signed-off-by: Doug Hellmann --- README.txt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/README.txt b/README.txt index 1b7221a..f64a874 100644 --- a/README.txt +++ b/README.txt @@ -52,13 +52,16 @@ Supported Shells ================ virtualenvwrapper is a set of shell *functions* defined in Bourne -shell compatible syntax. It is tested under ``bash``, ``ksh``, and ``zsh``. -It may work with other shells, so if you find that it does work with a -shell not listed here please let me know. If you can modify it to -work with another shell, without completely rewriting it, send a pull -request through the bitbucket project page. If you write a clone to -work with an incompatible shell, let me know and I will link to it -from this page. +shell compatible syntax. It is tested under ``bash``, ``ksh``, and +``zsh``. It may work with other shells, so if you find that it does +work with a shell not listed here please let us know by opening a +`ticket on bitbucket +`_. +If you can modify it to work with another shell, without completely +rewriting it, send a pull request through the `bitbucket project page +`_. If +you write a clone to work with an incompatible shell, let us know and +we will link to it from this page. Python Versions =============== From 0b9e83541c59d1763cfd82984fd5dd287670aa7b Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 9 Feb 2020 18:33:35 -0500 Subject: [PATCH 831/947] fix link to screencast Link directly to the vimeo page instead of the blog post, which no longer exists. Signed-off-by: Doug Hellmann --- README.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.txt b/README.txt index 1b7221a..ebd09b7 100644 --- a/README.txt +++ b/README.txt @@ -37,8 +37,8 @@ Features 6. Plugin system for more creating sharable extensions. Rich Leland has created a short `screencast -`__ -showing off the features of virtualenvwrapper. +`__ showing off the features of +virtualenvwrapper. ============ Installation From ef7548c63acd8a4cf31421a6406861bf40f179e6 Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Fri, 14 Feb 2020 09:39:40 -0600 Subject: [PATCH 832/947] Updating to support virtualenv 20+ Signed-off-by: Jason Myers --- Makefile | 2 +- docs/source/developers.rst | 2 +- docs/source/index.rst | 38 +++++++++++++++---------------- requirements.txt | 2 +- setup.cfg | 4 ++-- tox.ini | 2 +- virtualenvwrapper.sh | 2 +- virtualenvwrapper/user_scripts.py | 2 +- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 253bab6..10e44a7 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ test: tox test-quick: - tox -e py27 + tox -e py37 develop: python setup.py develop diff --git a/docs/source/developers.rst b/docs/source/developers.rst index 83ce8e4..6e0e560 100644 --- a/docs/source/developers.rst +++ b/docs/source/developers.rst @@ -50,7 +50,7 @@ documentation:: writing output... [100%] index writing additional files... search - copying static files... WARNING: static directory '/Users/dhellmann/Devel/virtualenvwrapper/plugins/docs/sphinx/pkg/static' does not exist + copying static files... WARNING: static directory '/Users/username/Devel/virtualenvwrapper/plugins/docs/sphinx/pkg/static' does not exist done dumping search index... done dumping object inventory... done diff --git a/docs/source/index.rst b/docs/source/index.rst index 29e088d..02a98cd 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -54,10 +54,10 @@ installed by pip or your package manager. .................................................... .................................................... ...............................done. - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/predeactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/postdeactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/preactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/postactivate New python executable in env1/bin/python + virtualenvwrapper.user_scripts Creating /Users/username/Envs/env1/bin/predeactivate + virtualenvwrapper.user_scripts Creating /Users/username/Envs/env1/bin/postdeactivate + virtualenvwrapper.user_scripts Creating /Users/username/Envs/env1/bin/preactivate + virtualenvwrapper.user_scripts Creating /Users/username/Envs/env1/bin/postactivate New python executable in env1/bin/python (env1)$ ls $WORKON_HOME env1 hook.log @@ -72,7 +72,7 @@ Now we can install some software into the environment. Installing collected packages: django Running setup.py install for django changing mode of build/scripts-2.6/django-admin.py from 644 to 755 - changing mode of /Users/dhellmann/Envs/env1/bin/django-admin.py to 755 + changing mode of /Users/username/Envs/env1/bin/django-admin.py to 755 Successfully installed django We can see the new package with ``lssitepackages``:: @@ -91,10 +91,10 @@ Of course we are not limited to a single virtualenv:: .................................................... .................................................... ........... ...............................done. - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/predeactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/postdeactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/preactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/postactivate New python executable in env2/bin/python + virtualenvwrapper.user_scripts Creating /Users/username/Envs/env2/bin/predeactivate + virtualenvwrapper.user_scripts Creating /Users/username/Envs/env2/bin/postdeactivate + virtualenvwrapper.user_scripts Creating /Users/username/Envs/env2/bin/preactivate + virtualenvwrapper.user_scripts Creating /Users/username/Envs/env2/bin/postactivate New python executable in env2/bin/python (env2)$ ls $WORKON_HOME env1 env2 hook.log @@ -102,7 +102,7 @@ Switch between environments with ``workon``:: (env2)$ workon env1 (env1)$ echo $VIRTUAL_ENV - /Users/dhellmann/Envs/env1 + /Users/username/Envs/env1 (env1)$ The ``workon`` command also includes tab completion for the @@ -114,7 +114,7 @@ is activated or deactivated (see :ref:`scripts`). (env1)$ echo 'cd $VIRTUAL_ENV' >> $WORKON_HOME/postactivate (env1)$ workon env2 (env2)$ pwd - /Users/dhellmann/Envs/env2 + /Users/username/Envs/env2 :ref:`scripts-postmkvirtualenv` is run when a new environment is created, letting you automatically install commonly-used tools. @@ -128,10 +128,10 @@ created, letting you automatically install commonly-used tools. .................................................... .................................................... ........... ...............................done. - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/predeactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/postdeactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/preactivate - virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/postactivate + virtualenvwrapper.user_scripts Creating /Users/username/Envs/env3/bin/predeactivate + virtualenvwrapper.user_scripts Creating /Users/username/Envs/env3/bin/postdeactivate + virtualenvwrapper.user_scripts Creating /Users/username/Envs/env3/bin/preactivate + virtualenvwrapper.user_scripts Creating /Users/username/Envs/env3/bin/postactivate Downloading/unpacking sphinx Downloading Sphinx-0.6.5.tar.gz (972Kb): 972Kb downloaded Running setup.py egg_info for package sphinx @@ -152,12 +152,12 @@ created, letting you automatically install commonly-used tools. Running setup.py install for Pygments Running setup.py install for sphinx no previously-included directories found matching 'doc/_build' - Installing sphinx-build script to /Users/dhellmann/Envs/env3/bin - Installing sphinx-quickstart script to /Users/dhellmann/Envs/env3/bin - Installing sphinx-autogen script to /Users/dhellmann/Envs/env3/bin + Installing sphinx-build script to /Users/username/Envs/env3/bin + Installing sphinx-quickstart script to /Users/username/Envs/env3/bin + Installing sphinx-autogen script to /Users/username/Envs/env3/bin Successfully installed docutils Jinja2 Pygments sphinx (env3)$ (venv3)$ which sphinx-build - /Users/dhellmann/Envs/env3/bin/sphinx-build + /Users/username/Envs/env3/bin/sphinx-build Through a combination of the existing functions defined by the core package (see :ref:`command`), third-party plugins (see diff --git a/requirements.txt b/requirements.txt index 8f54551..9bcb2ef 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -virtualenv +virtualenv>=20.0.4 virtualenv-clone stevedore diff --git a/setup.cfg b/setup.cfg index d24d69d..6348038 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,13 +10,13 @@ classifier = License :: OSI Approved :: MIT License Programming Language :: Python Programming Language :: Python :: 2 - Programming Language :: Python :: 2.6 Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 - Programming Language :: Python :: 3.3 Programming Language :: Python :: 3.4 Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 Intended Audience :: Developers Environment :: Console keywords = diff --git a/tox.ini b/tox.ini index ba242cc..3e475e1 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py33,py34,py35,py36,zsh,ksh,style +envlist = py27,py34,py35,py36,py37,py38,zsh,ksh,style [testenv] install_command = pip install -U {opts} {packages} diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index e83f666..aebe9f1 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -82,7 +82,7 @@ then fi # Define script folder depending on the platorm (Win32/Unix) -VIRTUALENVWRAPPER_ENV_BIN_DIR="bin" +VIRTUALENVWRAPPER_ENV_BIN_DIR="usr/local/bin" if [ "${OS:-}" = "Windows_NT" ] && ([ "${MSYSTEM:-}" = "MINGW32" ] || [ "${MSYSTEM:-}" = "MINGW64" ]) then # Only assign this for msys, cygwin use standard Unix paths diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index 8a5eedc..b76fffb 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -23,7 +23,7 @@ script_folder = 'Scripts' else: is_msys = False - script_folder = 'bin' + script_folder = 'usr/local/bin' def _get_msys_shell(): From 9b1e4374d368a6f18f5495cfe11ea78a82509dde Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Fri, 14 Feb 2020 10:07:41 -0600 Subject: [PATCH 833/947] Fixing readme.txt Signed-off-by: Jason Myers --- README.txt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.txt b/README.txt index e08b371..4aea1ed 100644 --- a/README.txt +++ b/README.txt @@ -11,12 +11,7 @@ managing your development workflow, making it easier to work on more than one project at a time without introducing conflicts in their dependencies. -**Warning:** The 4.x release includes some potentially incompatible -changes for extensions from 3.x. The python modules for extensions are -now *always* run with ``PWD=$WORKON_HOME`` (previously the value of -PWD varied depending on the hook). The *shell* portion of any hook -(anything sourced by the user's shell when the hook is run) is still -run in the same place as before. +**Warning:** The 5.x release requires virtualenv 20+ ======== Features From f481be386e527c53bb2cc81ed965b66a93d4e792 Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Sun, 16 Feb 2020 12:41:48 -0600 Subject: [PATCH 834/947] Revert "Merged in 334 (pull request #78)" This reverts commit 3ca9883fdeb543c0ac52e650e028d40a1d2afa74, reversing changes made to ef6b567687191c3613ca3cc3f6cdb783f0721a09. --- Makefile | 2 +- docs/source/developers.rst | 2 +- docs/source/index.rst | 38 +++++++++++++++---------------- requirements.txt | 2 +- setup.cfg | 4 ++-- tox.ini | 2 +- virtualenvwrapper.sh | 2 +- virtualenvwrapper/user_scripts.py | 2 +- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 10e44a7..253bab6 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ test: tox test-quick: - tox -e py37 + tox -e py27 develop: python setup.py develop diff --git a/docs/source/developers.rst b/docs/source/developers.rst index 6e0e560..83ce8e4 100644 --- a/docs/source/developers.rst +++ b/docs/source/developers.rst @@ -50,7 +50,7 @@ documentation:: writing output... [100%] index writing additional files... search - copying static files... WARNING: static directory '/Users/username/Devel/virtualenvwrapper/plugins/docs/sphinx/pkg/static' does not exist + copying static files... WARNING: static directory '/Users/dhellmann/Devel/virtualenvwrapper/plugins/docs/sphinx/pkg/static' does not exist done dumping search index... done dumping object inventory... done diff --git a/docs/source/index.rst b/docs/source/index.rst index 02a98cd..29e088d 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -54,10 +54,10 @@ installed by pip or your package manager. .................................................... .................................................... ...............................done. - virtualenvwrapper.user_scripts Creating /Users/username/Envs/env1/bin/predeactivate - virtualenvwrapper.user_scripts Creating /Users/username/Envs/env1/bin/postdeactivate - virtualenvwrapper.user_scripts Creating /Users/username/Envs/env1/bin/preactivate - virtualenvwrapper.user_scripts Creating /Users/username/Envs/env1/bin/postactivate New python executable in env1/bin/python + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/predeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/postdeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/preactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env1/bin/postactivate New python executable in env1/bin/python (env1)$ ls $WORKON_HOME env1 hook.log @@ -72,7 +72,7 @@ Now we can install some software into the environment. Installing collected packages: django Running setup.py install for django changing mode of build/scripts-2.6/django-admin.py from 644 to 755 - changing mode of /Users/username/Envs/env1/bin/django-admin.py to 755 + changing mode of /Users/dhellmann/Envs/env1/bin/django-admin.py to 755 Successfully installed django We can see the new package with ``lssitepackages``:: @@ -91,10 +91,10 @@ Of course we are not limited to a single virtualenv:: .................................................... .................................................... ........... ...............................done. - virtualenvwrapper.user_scripts Creating /Users/username/Envs/env2/bin/predeactivate - virtualenvwrapper.user_scripts Creating /Users/username/Envs/env2/bin/postdeactivate - virtualenvwrapper.user_scripts Creating /Users/username/Envs/env2/bin/preactivate - virtualenvwrapper.user_scripts Creating /Users/username/Envs/env2/bin/postactivate New python executable in env2/bin/python + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/predeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/postdeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/preactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env2/bin/postactivate New python executable in env2/bin/python (env2)$ ls $WORKON_HOME env1 env2 hook.log @@ -102,7 +102,7 @@ Switch between environments with ``workon``:: (env2)$ workon env1 (env1)$ echo $VIRTUAL_ENV - /Users/username/Envs/env1 + /Users/dhellmann/Envs/env1 (env1)$ The ``workon`` command also includes tab completion for the @@ -114,7 +114,7 @@ is activated or deactivated (see :ref:`scripts`). (env1)$ echo 'cd $VIRTUAL_ENV' >> $WORKON_HOME/postactivate (env1)$ workon env2 (env2)$ pwd - /Users/username/Envs/env2 + /Users/dhellmann/Envs/env2 :ref:`scripts-postmkvirtualenv` is run when a new environment is created, letting you automatically install commonly-used tools. @@ -128,10 +128,10 @@ created, letting you automatically install commonly-used tools. .................................................... .................................................... ........... ...............................done. - virtualenvwrapper.user_scripts Creating /Users/username/Envs/env3/bin/predeactivate - virtualenvwrapper.user_scripts Creating /Users/username/Envs/env3/bin/postdeactivate - virtualenvwrapper.user_scripts Creating /Users/username/Envs/env3/bin/preactivate - virtualenvwrapper.user_scripts Creating /Users/username/Envs/env3/bin/postactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/predeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/postdeactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/preactivate + virtualenvwrapper.user_scripts Creating /Users/dhellmann/Envs/env3/bin/postactivate Downloading/unpacking sphinx Downloading Sphinx-0.6.5.tar.gz (972Kb): 972Kb downloaded Running setup.py egg_info for package sphinx @@ -152,12 +152,12 @@ created, letting you automatically install commonly-used tools. Running setup.py install for Pygments Running setup.py install for sphinx no previously-included directories found matching 'doc/_build' - Installing sphinx-build script to /Users/username/Envs/env3/bin - Installing sphinx-quickstart script to /Users/username/Envs/env3/bin - Installing sphinx-autogen script to /Users/username/Envs/env3/bin + Installing sphinx-build script to /Users/dhellmann/Envs/env3/bin + Installing sphinx-quickstart script to /Users/dhellmann/Envs/env3/bin + Installing sphinx-autogen script to /Users/dhellmann/Envs/env3/bin Successfully installed docutils Jinja2 Pygments sphinx (env3)$ (venv3)$ which sphinx-build - /Users/username/Envs/env3/bin/sphinx-build + /Users/dhellmann/Envs/env3/bin/sphinx-build Through a combination of the existing functions defined by the core package (see :ref:`command`), third-party plugins (see diff --git a/requirements.txt b/requirements.txt index 9bcb2ef..8f54551 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -virtualenv>=20.0.4 +virtualenv virtualenv-clone stevedore diff --git a/setup.cfg b/setup.cfg index 6348038..d24d69d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,13 +10,13 @@ classifier = License :: OSI Approved :: MIT License Programming Language :: Python Programming Language :: Python :: 2 + Programming Language :: Python :: 2.6 Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 + Programming Language :: Python :: 3.3 Programming Language :: Python :: 3.4 Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 Intended Audience :: Developers Environment :: Console keywords = diff --git a/tox.ini b/tox.ini index 3e475e1..ba242cc 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py34,py35,py36,py37,py38,zsh,ksh,style +envlist = py27,py33,py34,py35,py36,zsh,ksh,style [testenv] install_command = pip install -U {opts} {packages} diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index aebe9f1..e83f666 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -82,7 +82,7 @@ then fi # Define script folder depending on the platorm (Win32/Unix) -VIRTUALENVWRAPPER_ENV_BIN_DIR="usr/local/bin" +VIRTUALENVWRAPPER_ENV_BIN_DIR="bin" if [ "${OS:-}" = "Windows_NT" ] && ([ "${MSYSTEM:-}" = "MINGW32" ] || [ "${MSYSTEM:-}" = "MINGW64" ]) then # Only assign this for msys, cygwin use standard Unix paths diff --git a/virtualenvwrapper/user_scripts.py b/virtualenvwrapper/user_scripts.py index b76fffb..8a5eedc 100644 --- a/virtualenvwrapper/user_scripts.py +++ b/virtualenvwrapper/user_scripts.py @@ -23,7 +23,7 @@ script_folder = 'Scripts' else: is_msys = False - script_folder = 'usr/local/bin' + script_folder = 'bin' def _get_msys_shell(): From 1a7bec7500ce2af4648a70b9f301810d4afca9d3 Mon Sep 17 00:00:00 2001 From: Alexander Huynh Date: Mon, 12 Sep 2022 06:54:22 +0000 Subject: [PATCH 835/947] replace deprecated `egrep` with `grep -E` On newer verions of GNU grep, this warning pops up: egrep: warning: egrep is obsolescent; using grep -E Suppress the warning by doing what it asks. See the following for more detail: https://www.phoronix.com/news/GNU-Grep-3.8-Stop-egrep-fgrep --- virtualenvwrapper.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index e83f666..4127a08 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -177,7 +177,7 @@ function virtualenvwrapper_derive_workon_home { # path might contain stuff to expand. # (it might be possible to do this in shell, but I don't know a # cross-shell-safe way of doing it -wolever) - if echo "$workon_home_dir" | (unset GREP_OPTIONS; command \egrep '([\$~]|//)' >/dev/null) + if echo "$workon_home_dir" | (unset GREP_OPTIONS; command \grep -E '([\$~]|//)' >/dev/null) then # This will normalize the path by: # - Removing extra slashes (e.g., when TMPDIR ends in a slash) @@ -599,7 +599,7 @@ function virtualenvwrapper_show_workon_options { | command \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate |/|g" \ | command \tr "/" "\n" \ | command \sed "/^\s*$/d" \ - | (unset GREP_OPTIONS; command \egrep -v '^\*$') 2>/dev/null + | (unset GREP_OPTIONS; command \grep -E -v '^\*$') 2>/dev/null } function _lsvirtualenv_usage { @@ -1306,7 +1306,7 @@ function wipeenv { virtualenvwrapper_verify_active_environment || return 1 typeset req_file="$(virtualenvwrapper_tempfile "requirements.txt")" - pip freeze | egrep -v '(distribute|wsgiref|appdirs|packaging|pyparsing|six)' > "$req_file" + pip freeze | grep -E -v '(distribute|wsgiref|appdirs|packaging|pyparsing|six)' > "$req_file" if [ -n "$(cat "$req_file")" ] then echo "Uninstalling packages:" From 60122f0ff80516458f67872390c29e875cbbe103 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Jan 2023 10:25:07 -0500 Subject: [PATCH 836/947] add github action configuration for test jobs --- .github/workflows/test.yml | 118 +++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ce8761c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,118 @@ +name: Test + +on: + - push + - pull_request + +jobs: + + # Test different python versions with bash on Ubuntu. + ubuntu: + name: Test Ubuntu + runs-on: ubuntu-latest + if: ${{ !startsWith(github.ref, 'refs/tags') }} + + strategy: + fail-fast: false + matrix: + python-version: + - 3.8 + - 3.9 + - "3.10" + - "3.11" + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: python -m pip install tox + + - name: Run tests + run: tox -e py + + # Test the latest python version with zsh on macOS + zsh: + name: Test Zsh + runs-on: macos-latest + if: ${{ !startsWith(github.ref, 'refs/tags') }} + + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + + - name: Install dependencies + run: python -m pip install tox + + - name: Run tests + run: tox -e zsh + + # Test different python versions with bash on macOS + macos: + name: Test macOS + runs-on: macos-latest + if: ${{ !startsWith(github.ref, 'refs/tags') }} + + strategy: + fail-fast: false + matrix: + python-version: + - 3.8 + - 3.9 + - "3.10" + - "3.11" + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: python -m pip install tox + + - name: Run tests + run: tox -e py + + # Run various style checkers + style: + runs-on: ubuntu-latest + if: ${{ !startsWith(github.ref, 'refs/tags') }} + + strategy: + fail-fast: false + tox-environment: + - docs + - style + - pkglint + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v4 + + - name: Install dependencies + run: python -m pip install tox + + - name: Run + run: tox -e ${{ matrix.tox-environment }} From 63285b933fdb7878e39504f356479260448ca66d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Jan 2023 10:37:17 -0500 Subject: [PATCH 837/947] fix linter action config --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ce8761c..05a1838 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -98,10 +98,10 @@ jobs: strategy: fail-fast: false - tox-environment: + matrix: + tox-environment: - docs - style - - pkglint steps: - uses: actions/checkout@v3 From 8b4885f26c618056a0e905349f0cf7c95ed98d4a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Jan 2023 10:39:25 -0500 Subject: [PATCH 838/947] set the version of python to use for linter jobs --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 05a1838..ead0771 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -110,6 +110,8 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 + with: + python-version: "3.11" - name: Install dependencies run: python -m pip install tox From f5b8523040f537545287fdb3eba3c5ae4298b6da Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Jan 2023 10:40:07 -0500 Subject: [PATCH 839/947] do not specify python version for docs env in tox settings --- tox.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/tox.ini b/tox.ini index ba242cc..b20ddae 100644 --- a/tox.ini +++ b/tox.ini @@ -31,7 +31,6 @@ setenv = commands = ksh ./tests/run_tests {envdir} [] [testenv:docs] -basepython=python2.7 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/docs/requirements.txt From ef3d2d12b16409202c9077077228fa2065eefcf8 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Jan 2023 10:41:36 -0500 Subject: [PATCH 840/947] update tox config for tox 4 --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index b20ddae..e375374 100644 --- a/tox.ini +++ b/tox.ini @@ -8,7 +8,7 @@ deps = -rrequirements.txt setenv = TOXIC = true SHELL = /bin/bash -whitelist_externals = +allowlist_externals = bash zsh ksh From 5c78c0d5f8ac4de3198e70b4480c5aeb6d070165 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Jan 2023 10:43:46 -0500 Subject: [PATCH 841/947] set python version for zsh job in ci --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ead0771..4ae527f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -53,6 +53,8 @@ jobs: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 + with: + python-version: "3.11" - name: Install dependencies run: python -m pip install tox From 1f2c153ed979d88f2d56a11ef7f2f35c5e220bd4 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Jan 2023 10:57:46 -0500 Subject: [PATCH 842/947] add pkglint test and fix some warnings --- .github/workflows/test.yml | 1 + setup.cfg | 6 +++--- tox.ini | 10 ++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4ae527f..3d39c3c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -104,6 +104,7 @@ jobs: tox-environment: - docs - style + - pkglint steps: - uses: actions/checkout@v3 diff --git a/setup.cfg b/setup.cfg index d24d69d..c459b66 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,9 +1,9 @@ [metadata] name = virtualenvwrapper author = Doug Hellmann -author-email = doug@doughellmann.com +author_email = doug@doughellmann.com summary = Enhancements to virtualenv -description-file = README.txt +description_file = README.txt license = MIT classifier = Development Status :: 5 - Production/Stable @@ -21,7 +21,7 @@ classifier = Environment :: Console keywords = virtualenv -home-page = https://virtualenvwrapper.readthedocs.io/ +home_page = https://virtualenvwrapper.readthedocs.io/ zip_safe = False [files] diff --git a/tox.ini b/tox.ini index e375374..f8b2751 100644 --- a/tox.ini +++ b/tox.ini @@ -35,3 +35,13 @@ deps = -r{toxinidir}/requirements.txt -r{toxinidir}/docs/requirements.txt commands = python setup.py build_sphinx + +[testenv:pkglint] +deps= + pbr + twine + check-python-versions +commands= + python setup.py sdist + twine check dist/*.tar.gz + check-python-versions --only setup.py,setup.cfg,.github/workflows/test.yml From 0399e4ad20441a8f5848a7bf625c438d4b69399c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Jan 2023 10:33:35 -0500 Subject: [PATCH 843/947] update trove classifiers with more modern python versions fixes #7 --- setup.cfg | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/setup.cfg b/setup.cfg index c459b66..0ec5d5c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,15 +9,12 @@ classifier = Development Status :: 5 - Production/Stable License :: OSI Approved :: MIT License Programming Language :: Python - Programming Language :: Python :: 2 - Programming Language :: Python :: 2.6 - Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 - Programming Language :: Python :: 3.3 - Programming Language :: Python :: 3.4 - Programming Language :: Python :: 3.5 - Programming Language :: Python :: 3.6 - Intended Audience :: Developers + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 +Intended Audience :: Developers Environment :: Console keywords = virtualenv From 9dddc079955cfafabd43c4c2bb3f00afcb5b871c Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Sun, 15 Jan 2023 10:09:00 -0600 Subject: [PATCH 844/947] Updating references to bitbucket Fixes: python-virtualenvwrapper/virtualenvwrapper#9 --- README.es.rst | 2 +- README.ja.rst | 4 ++-- README.txt | 12 ++++++------ docs/source/developers.rst | 4 ++-- docs/source/extensions.rst | 4 ++-- docs/source/index.rst | 4 ++-- docs/source/install.rst | 4 ++-- docs/source/plugins.rst | 2 +- docs/source/projects.rst | 6 +++--- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.es.rst b/README.es.rst index 6147175..15d6764 100644 --- a/README.es.rst +++ b/README.es.rst @@ -80,4 +80,4 @@ USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.. _BitBucket: http://bitbucket.org/dhellmann/virtualenvwrapper/overview/ +.. _github: https://github.com/python-virtualenvwrapper/virtualenvwrapper/ diff --git a/README.ja.rst b/README.ja.rst index 805f0ce..b540423 100644 --- a/README.ja.rst +++ b/README.ja.rst @@ -48,7 +48,7 @@ virtualenvwrapper は Bourne シェル互換の構文で定義された ここに記載されていないシェルで動作することを発見したら私に 教えてください。もしあなたがその他のシェルで動作させるために virtualenvwrapper を完全に書き直すことなく修正できるなら、 -bitbucket のプロジェクトページを通じて pull リクエストを +GitHub のプロジェクトページを通じて pull リクエストを 送ってください。あなたが非互換なシェル上で動作させるクローンを 作成するなら、このページでリンクを張るので私に連絡してください。 @@ -84,7 +84,7 @@ virtualenvwrapper のコアへ新しい機能を追加する前に、 `virtualenvwrapper Google Group `__ に参加してください。 -`BitBucket のバグトラッカー `__ +`github のバグトラッカー `__ でバグを報告してください。 シェルエイリアス diff --git a/README.txt b/README.txt index 4aea1ed..bd42fbe 100644 --- a/README.txt +++ b/README.txt @@ -50,11 +50,11 @@ virtualenvwrapper is a set of shell *functions* defined in Bourne shell compatible syntax. It is tested under ``bash``, ``ksh``, and ``zsh``. It may work with other shells, so if you find that it does work with a shell not listed here please let us know by opening a -`ticket on bitbucket -`_. +`ticket on GitHub +`_. If you can modify it to work with another shell, without completely -rewriting it, send a pull request through the `bitbucket project page -`_. If +rewriting it, send a pull request through the `GitHub project page +`_. If you write a clone to work with an incompatible shell, let us know and we will link to it from this page. @@ -71,8 +71,8 @@ Join the `virtualenvwrapper Google Group `__ to discuss issues and features. -Report bugs via the `bug tracker on Bitbucket -`__. +Report bugs via the `bug tracker on GitHub +`__. Shell Aliases ============= diff --git a/docs/source/developers.rst b/docs/source/developers.rst index 83ce8e4..692d60e 100644 --- a/docs/source/developers.rst +++ b/docs/source/developers.rst @@ -4,8 +4,8 @@ For Developers If you would like to contribute to virtualenvwrapper directly, these instructions should help you get started. Patches, bug reports, and -feature requests are all welcome through the `BitBucket site -`_. Contributions +feature requests are all welcome through the `GitHub site +`_. Contributions in the form of patches or pull requests are easier to integrate and will receive priority attention. diff --git a/docs/source/extensions.rst b/docs/source/extensions.rst index 8b300f3..8814546 100644 --- a/docs/source/extensions.rst +++ b/docs/source/extensions.rst @@ -45,13 +45,13 @@ Templates Below is a list of some of the templates available for use with :ref:`command-mkproject`. -.. _templates-bitbucket: +.. _templates-github: bitbucket --------- The bitbucket_ extension automatically clones a mercurial repository -from the specified bitbucket project. +from the specified Bitbucket project. .. _bitbucket: https://pypi.python.org/pypi/virtualenvwrapper.bitbucket diff --git a/docs/source/index.rst b/docs/source/index.rst index 29e088d..f0fc0e1 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -211,8 +211,8 @@ Join the `virtualenvwrapper Google Group `__ to discuss issues and features. -Report bugs via the `bug tracker on BitBucket -`__. +Report bugs via the `bug tracker on GitHub +`__. Shell Aliases ============= diff --git a/docs/source/install.rst b/docs/source/install.rst index 2aafa8d..2826b79 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -18,11 +18,11 @@ shells on OS X and Linux: It may work with other shells, so if you find that it does work with a shell not listed here please let me know. If you can modify it to work with another shell without completely rewriting it, then send a pull -request through the `bitbucket project page`_. If you write a clone to +request through the `GitHub project page`_. If you write a clone to work with an incompatible shell, let me know and I will link to it from this page. -.. _bitbucket project page: https://bitbucket.org/virtualenvwrapper/virtualenvwrapper/ +.. _github project page: https://GitHub.com/python-virtualenvwrapper/virtualenvwrapper/ Windows Command Prompt ---------------------- diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index a27a406..63e8e0c 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -396,4 +396,4 @@ respectively. .. _Setuptools entry points: https://setuptools.readthedocs.io/en/latest/pkg_resources.html#entry-points -.. _project: https://bitbucket.org/virtualenvwrapper/virtualenvwrapper +.. _project: https://github.com/python-virtualenvwrapper/virtualenvwrapper diff --git a/docs/source/projects.rst b/docs/source/projects.rst index c08ea33..501b61f 100644 --- a/docs/source/projects.rst +++ b/docs/source/projects.rst @@ -23,13 +23,13 @@ A new project directory can be created empty, or populated using one or more :term:`template` plugins. Templates should be specified as arguments to :ref:`command-mkproject`. Multiple values can be provided to apply more than one template. For example, to check out a Mercurial -repository from a project on bitbucket and create a new Django -site, combine the :ref:`templates-bitbucket` and +repository from a project on GitHub and create a new Django +site, combine the :ref:`templates-github` and :ref:`templates-django` templates. :: - $ mkproject -t bitbucket -t django my_site + $ mkproject -t github -t django my_site .. seealso:: From 83eecfb7901e10bdae16f5fc73155b6402942643 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 12 Jan 2023 16:23:00 -0500 Subject: [PATCH 845/947] expand the relative path for envdir to the full path tox is passing a relative directory, but the script wants a full path in some cases. --- tests/run_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run_tests b/tests/run_tests index aa2e55c..82ee36b 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -1,7 +1,7 @@ # -*- mode: shell-script -*- #set -x -envdir="$1" +envdir="$(cd $1 && pwd)" shift scripts="$*" if [ -z "$scripts" ] From 7cd5da4bad0bb65e0a6645aa588d474444ef4b7d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 12 Jan 2023 16:35:20 -0500 Subject: [PATCH 846/947] run all of the tests and accumulate errors --- tests/run_tests | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/run_tests b/tests/run_tests index 82ee36b..8ad74a6 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -44,6 +44,7 @@ unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS # Run the test scripts with a little formatting around them to make it # easier to find where each script output starts. +RC=0 for test_script in $scripts do @@ -66,9 +67,11 @@ do echo SHUNIT_PARENT="$test_script" export SHUNIT_PARENT - $SHELL $test_shell_opts $test_script || exit 1 + if ! $SHELL $test_shell_opts $test_script; then + RC=1 + fi echo done -exit 0 +exit $RC From 5c857be68c5741bfed300a3de983c2c5b01ff8e7 Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Sun, 15 Jan 2023 10:27:19 -0600 Subject: [PATCH 847/947] missed ones --- README.ja.rst | 2 +- docs/source/install.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.ja.rst b/README.ja.rst index b540423..a3931e7 100644 --- a/README.ja.rst +++ b/README.ja.rst @@ -84,7 +84,7 @@ virtualenvwrapper のコアへ新しい機能を追加する前に、 `virtualenvwrapper Google Group `__ に参加してください。 -`github のバグトラッカー `__ +`GitHub のバグトラッカー `__ でバグを報告してください。 シェルエイリアス diff --git a/docs/source/install.rst b/docs/source/install.rst index 2826b79..0769ce7 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -22,7 +22,7 @@ request through the `GitHub project page`_. If you write a clone to work with an incompatible shell, let me know and I will link to it from this page. -.. _github project page: https://GitHub.com/python-virtualenvwrapper/virtualenvwrapper/ +.. _GitHub project page: https://GitHub.com/python-virtualenvwrapper/virtualenvwrapper/ Windows Command Prompt ---------------------- From 599583c3a9a070e4f23e7cd17b775ce9f3544be9 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Jan 2023 11:29:10 -0500 Subject: [PATCH 848/947] add a "fast" environment in tox to exit as soon as any test fails The default in CI is still to run all of the tests. --- docs/source/developers.rst | 5 +++++ tests/run_tests | 6 ++++++ tox.ini | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/docs/source/developers.rst b/docs/source/developers.rst index 83ce8e4..8f13c03 100644 --- a/docs/source/developers.rst +++ b/docs/source/developers.rst @@ -86,6 +86,11 @@ Python:: $ tox -e py27 tests/test_cd.sh +To stop the test suite as soon as any test fails, use the `fast` tox +target:: + + $ tox -e fast + Add new tests by modifying an existing file or creating new script in the ``tests`` directory. diff --git a/tests/run_tests b/tests/run_tests index 8ad74a6..9176386 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -14,6 +14,9 @@ then fi fi +# Override FAIL_FAST to true to exit as soon as any test fails +FAIL_FAST=${FAIL_FAST:-false} + # Force the tox virtualenv to be active. # # Since this script runs from within a separate shell created by tox, @@ -69,6 +72,9 @@ do export SHUNIT_PARENT if ! $SHELL $test_shell_opts $test_script; then RC=1 + if $FAIL_FAST; then + exit $RC + fi fi echo diff --git a/tox.ini b/tox.ini index f8b2751..8b84cb1 100644 --- a/tox.ini +++ b/tox.ini @@ -13,6 +13,12 @@ allowlist_externals = zsh ksh +[testenv:fast] +setenv = + TOXIC = true + SHELL = /bin/bash + FAIL_FAST = true + [testenv:style] deps = flake8 commands = flake8 virtualenvwrapper docs/source/conf.py From d6201d950ad82dad9ea50e12c167dd8a3cd1d290 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 12 Jan 2023 16:23:45 -0500 Subject: [PATCH 849/947] update test runner to use python3 --- tests/run_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run_tests b/tests/run_tests index 9176386..68cb362 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -36,7 +36,7 @@ export HOOK_VERBOSE_OPTION # Force virtualenvwrapper to use the python interpreter in the # tox-created virtualenv. -VIRTUALENVWRAPPER_PYTHON="$envdir/bin/python" +VIRTUALENVWRAPPER_PYTHON="$envdir/bin/python3" export VIRTUALENVWRAPPER_PYTHON # Clear any user settings for the hook directory or log directory From e8b6fd2830cbce413c87c8903ef5d31abb26d371 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Jan 2023 11:19:41 -0500 Subject: [PATCH 850/947] update tox to only use default python version --- docs/source/developers.rst | 12 +++++++----- tox.ini | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/source/developers.rst b/docs/source/developers.rst index 8f13c03..8de06e5 100644 --- a/docs/source/developers.rst +++ b/docs/source/developers.rst @@ -69,22 +69,24 @@ The test suite for virtualenvwrapper uses shunit2_ and tox_. The shunit2 source is included in the ``tests`` directory, but tox must be installed separately (``pip install tox``). -To run the tests under bash, zsh, and ksh for Python 2.7 through 3.6, -run ``tox`` from the top level directory of the hg repository. +To run the tests under bash and zsh for the default Python, +run ``tox`` from the top level directory of the hg repository:: + + $ tox To run individual test scripts, use a command like:: - $ tox tests/test_cd.sh + $ tox -- tests/test_cd.sh To run tests under a single version of Python, specify the appropriate environment when running tox:: - $ tox -e py27 + $ tox -e py311 Combine the two modes to run specific tests with a single version of Python:: - $ tox -e py27 tests/test_cd.sh + $ tox -e py311 -- tests/test_cd.sh To stop the test suite as soon as any test fails, use the `fast` tox target:: diff --git a/tox.ini b/tox.ini index 8b84cb1..4226abd 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py33,py34,py35,py36,zsh,ksh,style +envlist = py,zsh,style [testenv] install_command = pip install -U {opts} {packages} From 655878f7210c43649b9174e6ba76da5160aa1489 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Jan 2023 11:19:59 -0500 Subject: [PATCH 851/947] update tox config to not set basepython for zsh --- tox.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/tox.ini b/tox.ini index 4226abd..ad7c3f6 100644 --- a/tox.ini +++ b/tox.ini @@ -24,7 +24,6 @@ deps = flake8 commands = flake8 virtualenvwrapper docs/source/conf.py [testenv:zsh] -basepython=python2.7 setenv = SHELL = /bin/zsh test_shell_opts = -o shwordsplit From 04a2c3d151fe95c115b603dec6e57d24c4e18e67 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Jan 2023 11:26:12 -0500 Subject: [PATCH 852/947] remove the test for making virtualenvs relocatable The --relocatable flag was removed from virtualenv, so there is no need to test that mode any more. --- tests/test_cp.sh | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tests/test_cp.sh b/tests/test_cp.sh index fc93ec1..d5cdf2c 100755 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -98,17 +98,6 @@ test_virtualenvwrapper_virtualenv_clone_variable () { assertTrue "VIRTUALENVWRAPPER_CLONE did not clone fake file" "[ -f $WORKON_HOME/destination/fake_virtualenv_clone_was_here ]" } -test_source_relocatable () { - mkvirtualenv "source" >/dev/null 2>&1 - (cd tests/testpackage && python setup.py install) >/dev/null 2>&1 - assertTrue "virtualenv --relocatable \"$WORKON_HOME/source\"" - cpvirtualenv "source" "destination" >/dev/null 2>&1 - testscript="$(which testscript.py)" - assertTrue "Environment test script not the same as copy" "[ $WORKON_HOME/destination/bin/testscript.py -ef $testscript ]" - assertTrue virtualenvwrapper_verify_active_environment - assertSame "Wrong virtualenv name" "destination" $(basename "$VIRTUAL_ENV") -} - test_source_does_not_exist () { assertSame "Please provide a valid virtualenv to copy." "$(cpvirtualenv virtualenvthatdoesntexist foo)" } From d9f58eafadebdd713b60c0edc29a9b4f047c799a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Jan 2023 11:33:04 -0500 Subject: [PATCH 853/947] remove tests and features relying on --no-site-packages virtualenv dropped the --no-site-packages option. This PR updates the code and tests to remove features related to that missing option. * remove copy tests for --no-site-packages * update test_mktmpenv_virtualenv_args to not need --no-site-packages * update mkvirtualenv tests to not rely on --no-site-packages * remove toggleglobalsitepackages command related to #8 --- docs/source/command_ref.rst | 30 ------------------ tests/test_cp.sh | 29 ----------------- tests/test_lazy_loaded.sh | 4 --- tests/test_mktmpenv.sh | 6 ++-- tests/test_mkvirtualenv.sh | 29 +++++------------ tests/test_toggleglobalsitepackages.sh | 43 -------------------------- virtualenvwrapper.sh | 16 ---------- 7 files changed, 10 insertions(+), 147 deletions(-) delete mode 100755 tests/test_toggleglobalsitepackages.sh diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index f2e2f33..eadb850 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -465,36 +465,6 @@ for the environment. *Based on a contribution from James Bennett and Jannis Leidel.* -.. _command-toggleglobalsitepackages: - -toggleglobalsitepackages ------------------------- - -Controls whether the active virtualenv will access the packages in the -global Python ``site-packages`` directory. - -Syntax:: - - toggleglobalsitepackages [-q] - -Outputs the new state of the virtualenv. Use the ``-q`` switch to turn off all -output. - -:: - - $ mkvirtualenv env1 - New python executable in env1/bin/python - Installing setuptools............................................. - .................................................................. - .................................................................. - done. - (env1)$ toggleglobalsitepackages - Disabled global site-packages - (env1)$ toggleglobalsitepackages - Enabled global site-packages - (env1)$ toggleglobalsitepackages -q - (env1)$ - ============================ Project Directory Management ============================ diff --git a/tests/test_cp.sh b/tests/test_cp.sh index d5cdf2c..3bd9196 100755 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -137,33 +137,4 @@ GLOBAL postcpvirtualenv" rm -f "$WORKON_HOME/postmkvirtualenv" } -test_no_site_packages () { - # See issue #102 - mkvirtualenv "source" --no-site-packages >/dev/null 2>&1 - cpvirtualenv "source" "destination" >/dev/null 2>&1 - ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" - assertTrue "$ngsp_file does not exist in copied env" "[ -f \"$ngsp_file\" ]" -} - -test_no_site_packages_default_args () { - # See issue #102 - VIRTUALENVWRAPPER_VIRTUALENV_ARGS="--no-site-packages" - # With the argument, verify that they are not copied. - mkvirtualenv "source" >/dev/null 2>&1 - cpvirtualenv "source" "destination" >/dev/null 2>&1 - ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" - assertTrue "$ngsp_file does not exist" "[ -f \"$ngsp_file\" ]" - unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS -} - -test_no_site_packages_default_behavior () { - # See issue #102 - # virtualenv 1.7 changed to make --no-site-packages the default - mkvirtualenv "source" >/dev/null 2>&1 - cpvirtualenv "source" "destination" >/dev/null 2>&1 - ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" - assertTrue "$ngsp_file does not exist in copied env" "[ -f \"$ngsp_file\" ]" -} - . "$test_dir/shunit2" - diff --git a/tests/test_lazy_loaded.sh b/tests/test_lazy_loaded.sh index 46e4f58..9d217c2 100755 --- a/tests/test_lazy_loaded.sh +++ b/tests/test_lazy_loaded.sh @@ -64,10 +64,6 @@ test_lssitepackages_defined_normal() { function_defined_normal lssitepackages } -test_toggleglobalsitepackages_defined_normal() { - function_defined_normal toggleglobalsitepackages -} - test_cpvirtualenv_defined_normal() { function_defined_normal cpvirtualenv } diff --git a/tests/test_mktmpenv.sh b/tests/test_mktmpenv.sh index c8989bc..6a1171d 100755 --- a/tests/test_mktmpenv.sh +++ b/tests/test_mktmpenv.sh @@ -43,9 +43,9 @@ test_mktmpenv_no_cd() { } test_mktmpenv_virtualenv_args() { - mktmpenv --no-site-packages >/dev/null 2>&1 - ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" - assertTrue "$ngsp_file does not exist" "[ -f \"$ngsp_file\" ]" + mktmpenv --without-pip >/dev/null 2>&1 + contents="$(lssitepackages)" + assertFalse "found pip in site-packages: ${contents}" "echo $contents | grep -q pip" } test_deactivate() { diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index bbfd543..3c37dfe 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -104,23 +104,6 @@ test_no_workon_home () { WORKON_HOME="$old_home" } -test_mkvirtualenv_sitepackages () { - # This part of the test is not reliable because - # creating a new virtualenv from inside the - # tox virtualenv inherits the setting from there. -# # Without the option, verify that site-packages are copied. -# mkvirtualenv "with_sp" >/dev/null 2>&1 -# ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" -# assertFalse "$ngsp_file exists" "[ -f \"$ngsp_file\" ]" -# rmvirtualenv "env3" - - # With the argument, verify that they are not copied. - mkvirtualenv --no-site-packages "without_sp" >/dev/null 2>&1 - ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" - assertTrue "$ngsp_file does not exist" "[ -f \"$ngsp_file\" ]" - rmvirtualenv "env4" >/dev/null 2>&1 -} - test_mkvirtualenv_hooks_system_site_packages () { # See issue #189 @@ -143,12 +126,14 @@ GLOBAL postmkvirtualenv" test_mkvirtualenv_args () { # See issue #102 - VIRTUALENVWRAPPER_VIRTUALENV_ARGS="--no-site-packages" + VIRTUALENVWRAPPER_VIRTUALENV_ARGS="--without-pip" # With the argument, verify that they are not copied. - mkvirtualenv "without_sp2" >/dev/null 2>&1 - ngsp_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" - assertTrue "$ngsp_file does not exist" "[ -f \"$ngsp_file\" ]" - rmvirtualenv "env4" >/dev/null 2>&1 + mkvirtualenv "without_pip" >/dev/null 2>&1 + local RC=$? + assertTrue "mkvirtualenv failed" "[ $RC -eq 0 ]" + contents="$(lssitepackages)" + assertFalse "found pip in site-packages: ${contents}" "echo $contents | grep -q pip" + rmvirtualenv "without_pip" >/dev/null 2>&1 unset VIRTUALENVWRAPPER_VIRTUALENV_ARGS } diff --git a/tests/test_toggleglobalsitepackages.sh b/tests/test_toggleglobalsitepackages.sh deleted file mode 100755 index c1d3d82..0000000 --- a/tests/test_toggleglobalsitepackages.sh +++ /dev/null @@ -1,43 +0,0 @@ -# -*- mode: shell-script -*- - -test_dir=$(cd $(dirname $0) && pwd) -source "$test_dir/setup.sh" - -oneTimeSetUp() { - rm -rf "$WORKON_HOME" - mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" -} - -oneTimeTearDown() { - rm -rf "$WORKON_HOME" -} - -setUp () { - echo -} - -tearDown () { - deactivate >/dev/null 2>&1 -} - -test_toggleglobalsitepackages () { - mkvirtualenv --no-site-packages "test1" - ngsp_file=$(dirname "`virtualenvwrapper_get_site_packages_dir`")/no-global-site-packages.txt - assertTrue "$ngsp_file does not exist 1" "[ -f \"$ngsp_file\" ]" - toggleglobalsitepackages -q - assertFalse "$ngsp_file exists" "[ -f \"$ngsp_file\" ]" - toggleglobalsitepackages -q - assertTrue "$ngsp_file does not exist 2" "[ -f \"$ngsp_file\" ]" -} - -test_toggleglobalsitepackages_quiet () { - mkvirtualenv --no-site-packages "test2" - assertEquals "Command output is not correct" "Enabled global site-packages" "`toggleglobalsitepackages`" - assertEquals "Command output is not correct" "Disabled global site-packages" "`toggleglobalsitepackages`" - - assertEquals "Command output is not correct" "" "`toggleglobalsitepackages -q`" - assertEquals "Command output is not correct" "" "`toggleglobalsitepackages -q`" -} - -. "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index edf0313..f80a087 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -948,22 +948,6 @@ function lssitepackages { fi } -# Toggles the currently-active virtualenv between having and not having -# access to the global site-packages. -#:help:toggleglobalsitepackages: turn access to global site-packages on/off -function toggleglobalsitepackages { - virtualenvwrapper_verify_workon_home || return 1 - virtualenvwrapper_verify_active_environment || return 1 - typeset no_global_site_packages_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt" - if [ -f $no_global_site_packages_file ]; then - rm $no_global_site_packages_file - [ "$1" = "-q" ] || echo "Enabled global site-packages" - else - touch $no_global_site_packages_file - [ "$1" = "-q" ] || echo "Disabled global site-packages" - fi -} - #:help:cpvirtualenv: duplicate the named virtualenv to make a new one function cpvirtualenv { virtualenvwrapper_verify_workon_home || return 1 From 1c2e94d5be13f793416017c30ba078e1c1320228 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Jan 2023 11:37:36 -0500 Subject: [PATCH 854/947] update lssitepackages tests to not need easy_install The easy_install package is no longer installed by default, so look for pip instead. --- tests/test_ls.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_ls.sh b/tests/test_ls.sh index 8d26b3a..25ceab2 100755 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -27,8 +27,8 @@ test_get_site_packages_dir () { test_lssitepackages () { mkvirtualenv "lssitepackagestest" >/dev/null 2>&1 - contents="$(lssitepackages)" - assertTrue "did not find easy_install in site-packages" "echo $contents | grep -q easy_install" + contents="$(lssitepackages)" + assertTrue "did not find pip in site-packages: ${contents}" "echo $contents | grep -q pip" deactivate } @@ -36,8 +36,8 @@ test_lssitepackages_space_in_name () { # Only test with leading and internal spaces. Directory names with trailing spaces are legal, # and work with virtualenv on OSX, but error out on Linux. mkvirtualenv " space lssitepackagestest" >/dev/null 2>&1 - contents="$(lssitepackages)" - assertTrue "did not find easy_install in site-packages" "echo $contents | grep -q easy_install" + contents="$(lssitepackages)" + assertTrue "did not find pip in site-packages: ${contents}" "echo $contents | grep -q pip" deactivate } @@ -46,7 +46,7 @@ test_lssitepackages_add2virtualenv () { parent_dir=$(dirname $(pwd)) base_dir=$(basename $(pwd)) add2virtualenv "../$base_dir" - contents="$(lssitepackages)" + contents="$(lssitepackages)" actual=$(echo $contents | grep $base_dir) expected=$(echo $contents) assertSame "$expected" "$actual" From a948d6f66f5705447a98afe3bea89988ceceaf5d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Jan 2023 11:55:49 -0500 Subject: [PATCH 855/947] adjust error message detection in hook tests --- tests/test_run_hook.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_run_hook.sh b/tests/test_run_hook.sh index 2d6983d..e1e8644 100755 --- a/tests/test_run_hook.sh +++ b/tests/test_run_hook.sh @@ -57,7 +57,7 @@ test_virtualenvwrapper_run_hook_permissions() { echo "echo run $@ >> \"$TMPDIR/catch_output\"" >> "$WORKON_HOME/prermvirtualenv" chmod 0444 "$WORKON_HOME/prermvirtualenv" touch "$TMPDIR/catch_output" - error=$(virtualenvwrapper_run_hook "pre_rmvirtualenv" "foo" 2>&1 | grep "could not run" | cut -f2- -d'[') + error=$(virtualenvwrapper_run_hook "pre_rmvirtualenv" "foo" 2>&1 | grep "could not run" | cut -f2- -d'[' | cut -f1 -d:) output=$(cat "$TMPDIR/catch_output") expected="" assertSame "$expected" "$output" From e51c3b5353a71e34654038ce81be4bd819aa0d43 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Jan 2023 12:15:15 -0500 Subject: [PATCH 856/947] skip some tempfile tests on macos --- tests/test_tempfile.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_tempfile.sh b/tests/test_tempfile.sh index 9fb6b79..be1f89d 100755 --- a/tests/test_tempfile.sh +++ b/tests/test_tempfile.sh @@ -21,6 +21,11 @@ setUp () { } test_tempfile () { + if [ "$(uname)" = "Darwin" ]; then + # macOS doesn't seem to allow controlling where mktemp creates + # the output files + return 0 + fi filename=$(virtualenvwrapper_tempfile hook) assertTrue "Filename is empty" "[ ! -z \"$filename\" ]" assertTrue "File doesn't exist" "[ -f \"$filename\" ]" @@ -52,6 +57,11 @@ test_bad_mktemp() { } test_no_such_tmpdir () { + if [ "$(uname)" = "Darwin" ]; then + # macOS doesn't seem to allow controlling where mktemp creates + # the output files + return 0 + fi old_tmpdir="$TMPDIR" export TMPDIR="$TMPDIR/does-not-exist" virtualenvwrapper_run_hook "initialize" >/dev/null 2>&1 @@ -61,6 +71,11 @@ test_no_such_tmpdir () { } test_tmpdir_not_writable () { + if [ "$(uname)" = "Darwin" ]; then + # macOS doesn't seem to allow controlling where mktemp creates + # the output files + return 0 + fi old_tmpdir="$TMPDIR" export TMPDIR="$TMPDIR/cannot-write" mkdir "$TMPDIR" From 6f4511344328fb4122637cfc8c65c05a3183b942 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Jan 2023 12:55:48 -0500 Subject: [PATCH 857/947] fix wipeenv for editable packages Based on https://bitbucket.org/virtualenvwrapper/virtualenvwrapper/pull-requests/81 from Daniel Cordero --- tests/test_wipeenv.sh | 4 ++-- virtualenvwrapper.sh | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/tests/test_wipeenv.sh b/tests/test_wipeenv.sh index 2dbd9cf..9b8895c 100755 --- a/tests/test_wipeenv.sh +++ b/tests/test_wipeenv.sh @@ -32,10 +32,10 @@ test_wipeenv_pip_e () { mkvirtualenv "wipetest" >/dev/null 2>&1 (cd tests/testpackage && pip install -e .) >/dev/null 2>&1 before="$(pip freeze)" - assertTrue "testpackage not installed" "pip freeze | grep testpackage" + assertTrue "testpackage not installed: $before" "pip freeze | grep testpackage" wipeenv >/dev/null 2>&1 after="$(pip freeze)" - assertFalse "testpackage still installed" "pip freeze | grep testpackage" + assertFalse "testpackage still installed: $after" "pip freeze | grep testpackage" } # test_wipeenv_pip_e_url () { diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index f80a087..79def0d 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -1294,9 +1294,28 @@ function wipeenv { if [ -n "$(cat "$req_file")" ] then echo "Uninstalling packages:" - cat "$req_file" echo - pip uninstall -y $(cat "$req_file" | grep -v '^-f' | sed 's/>/=/g' | cut -f1 -d=) + while read line; do + typeset pkg="" + if [[ "$line" =~ ^-f ]]; then + # ignore lines starting -f which pip sometimes + # includes and that do not point to specific + # dependencies + continue + fi + if [[ "$line" =~ ^-e ]]; then + # fix lines pointing to editable packages, which look like: + # -e git+ssh://git@github.com/python-virtualenvwrapper/virtualenvwrapper.git@1dc9e5f52102f0133b804c0c8a6b76c55db908bf#egg=testpackage&subdirectory=tests/testpackage + # and parse out the egg name to pass to pip + pkg=$(echo "$line" | cut -f2 -d' ' | sed -e 's|&subdirectory.*||g' -e 's|.*egg=||g') + else + # Strip version specifiers off of the end of the line + # to keep only the package name. + pkg=$(echo "$line" | sed -e 's/[<>!=].*//g') + fi + echo $pkg + pip uninstall -y "$pkg" + done < "$req_file" else echo "Nothing to remove." fi From c945ffbf7bb0f4aba707386c41f7789c9428b26c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Jan 2023 13:51:42 -0500 Subject: [PATCH 858/947] pass user and home through from tox instead of using id to derive them The id command being used does not work on Linux. --- tests/setup.sh | 5 ----- tox.ini | 3 +++ 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/setup.sh b/tests/setup.sh index a28d360..6e006fb 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -10,8 +10,3 @@ export WORKON_HOME=$(mktemp -d -t "WORKON_HOME.XXXX.$$") export PROJECT_HOME=$(mktemp -d -t "PROJECT_HOME.XXXX.$$") #unset HOOK_VERBOSE_OPTION - -# tox no longer exports these variables by default, so set them -# ourselves to ensure the tests that rely on the values work -export USER=$(id -u -n) -export HOME=$(id -P | cut -f9 -d:) diff --git a/tox.ini b/tox.ini index ad7c3f6..c97b5ef 100644 --- a/tox.ini +++ b/tox.ini @@ -5,6 +5,9 @@ envlist = py,zsh,style install_command = pip install -U {opts} {packages} commands = bash ./tests/run_tests {envdir} [] deps = -rrequirements.txt +pass_env = + HOME + USER setenv = TOXIC = true SHELL = /bin/bash From 83aff096e8a77f9fdfb5809d618a8b4e2fa396ec Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Jan 2023 13:59:34 -0500 Subject: [PATCH 859/947] ci(Mergify): configuration update Signed-off-by: Doug Hellmann --- .mergify.yml | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .mergify.yml diff --git a/.mergify.yml b/.mergify.yml new file mode 100644 index 0000000..740f992 --- /dev/null +++ b/.mergify.yml @@ -0,0 +1,54 @@ +pull_request_rules: + + - name: Add CI label + conditions: + - or: + - "title~=^tox:" + - "title~=^ci:" + - "files~=tox.ini" + - "files~=tests" + actions: + label: + add: + - ci + + - name: Add Mergify label + conditions: + - or: + - "title~=^mergify:" + - "files~=.mergify.yml$" + actions: + label: + add: + - mergify + + - name: Add Documentation label + conditions: + - or: + - "title~=^docs:" + - "files~=docs" + - "files~=.rst$" + actions: + label: + add: + - documentation + + - name: Automatic merge on approval + conditions: + - and: + - "check-success=style (docs)" + - "check-success=style (style)" + - "check-success=style (pkglint)" + - "check-success=Test macOS (3.8)" + - "check-success=Test macOS (3.9)" + - "check-success=Test macOS (3.10)" + - "check-success=Test macOS (3.11)" + - "check-success=Test Ubuntu (3.8)" + - "check-success=Test Ubuntu (3.9)" + - "check-success=Test Ubuntu (3.10)" + - "check-success=Test Ubuntu (3.11)" + - "check-success=Test Zsh" + - "-draft" + actions: + merge: + method: merge From 4d7e7a88d94b5f2ff06a7aeecfa5fe6c4e5a96d2 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 15 Jan 2023 14:11:14 -0500 Subject: [PATCH 860/947] require at least one reviewer to approve PRs --- .mergify.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.mergify.yml b/.mergify.yml index 740f992..4fbb008 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -49,6 +49,7 @@ pull_request_rules: - "check-success=Test Ubuntu (3.11)" - "check-success=Test Zsh" - "-draft" + - "#approved-reviews-by>=1" actions: merge: method: merge From 8ed41e75e59df5670d86d6b53b9817b5ad401e7f Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Sun, 15 Jan 2023 10:09:00 -0600 Subject: [PATCH 861/947] Updating references to bitbucket Fixes: python-virtualenvwrapper/virtualenvwrapper#9 --- README.es.rst | 2 +- README.ja.rst | 4 ++-- README.txt | 12 ++++++------ docs/source/developers.rst | 4 ++-- docs/source/extensions.rst | 4 ++-- docs/source/index.rst | 4 ++-- docs/source/install.rst | 4 ++-- docs/source/plugins.rst | 2 +- docs/source/projects.rst | 6 +++--- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.es.rst b/README.es.rst index 6147175..15d6764 100644 --- a/README.es.rst +++ b/README.es.rst @@ -80,4 +80,4 @@ USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.. _BitBucket: http://bitbucket.org/dhellmann/virtualenvwrapper/overview/ +.. _github: https://github.com/python-virtualenvwrapper/virtualenvwrapper/ diff --git a/README.ja.rst b/README.ja.rst index 805f0ce..b540423 100644 --- a/README.ja.rst +++ b/README.ja.rst @@ -48,7 +48,7 @@ virtualenvwrapper は Bourne シェル互換の構文で定義された ここに記載されていないシェルで動作することを発見したら私に 教えてください。もしあなたがその他のシェルで動作させるために virtualenvwrapper を完全に書き直すことなく修正できるなら、 -bitbucket のプロジェクトページを通じて pull リクエストを +GitHub のプロジェクトページを通じて pull リクエストを 送ってください。あなたが非互換なシェル上で動作させるクローンを 作成するなら、このページでリンクを張るので私に連絡してください。 @@ -84,7 +84,7 @@ virtualenvwrapper のコアへ新しい機能を追加する前に、 `virtualenvwrapper Google Group `__ に参加してください。 -`BitBucket のバグトラッカー `__ +`github のバグトラッカー `__ でバグを報告してください。 シェルエイリアス diff --git a/README.txt b/README.txt index 4aea1ed..bd42fbe 100644 --- a/README.txt +++ b/README.txt @@ -50,11 +50,11 @@ virtualenvwrapper is a set of shell *functions* defined in Bourne shell compatible syntax. It is tested under ``bash``, ``ksh``, and ``zsh``. It may work with other shells, so if you find that it does work with a shell not listed here please let us know by opening a -`ticket on bitbucket -`_. +`ticket on GitHub +`_. If you can modify it to work with another shell, without completely -rewriting it, send a pull request through the `bitbucket project page -`_. If +rewriting it, send a pull request through the `GitHub project page +`_. If you write a clone to work with an incompatible shell, let us know and we will link to it from this page. @@ -71,8 +71,8 @@ Join the `virtualenvwrapper Google Group `__ to discuss issues and features. -Report bugs via the `bug tracker on Bitbucket -`__. +Report bugs via the `bug tracker on GitHub +`__. Shell Aliases ============= diff --git a/docs/source/developers.rst b/docs/source/developers.rst index 8de06e5..01e9e04 100644 --- a/docs/source/developers.rst +++ b/docs/source/developers.rst @@ -4,8 +4,8 @@ For Developers If you would like to contribute to virtualenvwrapper directly, these instructions should help you get started. Patches, bug reports, and -feature requests are all welcome through the `BitBucket site -`_. Contributions +feature requests are all welcome through the `GitHub site +`_. Contributions in the form of patches or pull requests are easier to integrate and will receive priority attention. diff --git a/docs/source/extensions.rst b/docs/source/extensions.rst index 8b300f3..8814546 100644 --- a/docs/source/extensions.rst +++ b/docs/source/extensions.rst @@ -45,13 +45,13 @@ Templates Below is a list of some of the templates available for use with :ref:`command-mkproject`. -.. _templates-bitbucket: +.. _templates-github: bitbucket --------- The bitbucket_ extension automatically clones a mercurial repository -from the specified bitbucket project. +from the specified Bitbucket project. .. _bitbucket: https://pypi.python.org/pypi/virtualenvwrapper.bitbucket diff --git a/docs/source/index.rst b/docs/source/index.rst index 29e088d..f0fc0e1 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -211,8 +211,8 @@ Join the `virtualenvwrapper Google Group `__ to discuss issues and features. -Report bugs via the `bug tracker on BitBucket -`__. +Report bugs via the `bug tracker on GitHub +`__. Shell Aliases ============= diff --git a/docs/source/install.rst b/docs/source/install.rst index 2aafa8d..2826b79 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -18,11 +18,11 @@ shells on OS X and Linux: It may work with other shells, so if you find that it does work with a shell not listed here please let me know. If you can modify it to work with another shell without completely rewriting it, then send a pull -request through the `bitbucket project page`_. If you write a clone to +request through the `GitHub project page`_. If you write a clone to work with an incompatible shell, let me know and I will link to it from this page. -.. _bitbucket project page: https://bitbucket.org/virtualenvwrapper/virtualenvwrapper/ +.. _github project page: https://GitHub.com/python-virtualenvwrapper/virtualenvwrapper/ Windows Command Prompt ---------------------- diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index a27a406..63e8e0c 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -396,4 +396,4 @@ respectively. .. _Setuptools entry points: https://setuptools.readthedocs.io/en/latest/pkg_resources.html#entry-points -.. _project: https://bitbucket.org/virtualenvwrapper/virtualenvwrapper +.. _project: https://github.com/python-virtualenvwrapper/virtualenvwrapper diff --git a/docs/source/projects.rst b/docs/source/projects.rst index c08ea33..501b61f 100644 --- a/docs/source/projects.rst +++ b/docs/source/projects.rst @@ -23,13 +23,13 @@ A new project directory can be created empty, or populated using one or more :term:`template` plugins. Templates should be specified as arguments to :ref:`command-mkproject`. Multiple values can be provided to apply more than one template. For example, to check out a Mercurial -repository from a project on bitbucket and create a new Django -site, combine the :ref:`templates-bitbucket` and +repository from a project on GitHub and create a new Django +site, combine the :ref:`templates-github` and :ref:`templates-django` templates. :: - $ mkproject -t bitbucket -t django my_site + $ mkproject -t github -t django my_site .. seealso:: From c91d69e091b501a06cbe634e310785dcb4aceb51 Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Sun, 15 Jan 2023 10:27:19 -0600 Subject: [PATCH 862/947] missed ones --- README.ja.rst | 2 +- docs/source/install.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.ja.rst b/README.ja.rst index b540423..a3931e7 100644 --- a/README.ja.rst +++ b/README.ja.rst @@ -84,7 +84,7 @@ virtualenvwrapper のコアへ新しい機能を追加する前に、 `virtualenvwrapper Google Group `__ に参加してください。 -`github のバグトラッカー `__ +`GitHub のバグトラッカー `__ でバグを報告してください。 シェルエイリアス diff --git a/docs/source/install.rst b/docs/source/install.rst index 2826b79..0769ce7 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -22,7 +22,7 @@ request through the `GitHub project page`_. If you write a clone to work with an incompatible shell, let me know and I will link to it from this page. -.. _github project page: https://GitHub.com/python-virtualenvwrapper/virtualenvwrapper/ +.. _GitHub project page: https://GitHub.com/python-virtualenvwrapper/virtualenvwrapper/ Windows Command Prompt ---------------------- From 47d3b58aa35b9714d6a64940f9b02dc8ceca270c Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Sun, 15 Jan 2023 16:21:58 -0600 Subject: [PATCH 863/947] Updating template docs based on PR feedback --- docs/source/extensions.rst | 2 +- docs/source/projects.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/extensions.rst b/docs/source/extensions.rst index 8814546..8519d24 100644 --- a/docs/source/extensions.rst +++ b/docs/source/extensions.rst @@ -45,7 +45,7 @@ Templates Below is a list of some of the templates available for use with :ref:`command-mkproject`. -.. _templates-github: +.. _templates-bitbucket: bitbucket --------- diff --git a/docs/source/projects.rst b/docs/source/projects.rst index 501b61f..8cc999d 100644 --- a/docs/source/projects.rst +++ b/docs/source/projects.rst @@ -23,8 +23,8 @@ A new project directory can be created empty, or populated using one or more :term:`template` plugins. Templates should be specified as arguments to :ref:`command-mkproject`. Multiple values can be provided to apply more than one template. For example, to check out a Mercurial -repository from a project on GitHub and create a new Django -site, combine the :ref:`templates-github` and +repository from a project on BitBucket and create a new Django +site, combine the :ref:`templates-bitbucket` and :ref:`templates-django` templates. :: From 344f09ca9696c3b523141fc7719b766f4bd5a908 Mon Sep 17 00:00:00 2001 From: Jason Myers Date: Mon, 16 Jan 2023 16:39:50 -0600 Subject: [PATCH 864/947] Fixing bitbucket in projects Signed-off-by: Jason Myers --- docs/source/projects.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/projects.rst b/docs/source/projects.rst index 8cc999d..d5f6e63 100644 --- a/docs/source/projects.rst +++ b/docs/source/projects.rst @@ -29,7 +29,7 @@ site, combine the :ref:`templates-bitbucket` and :: - $ mkproject -t github -t django my_site + $ mkproject -t bitbucket -t django my_site .. seealso:: From 35b792d88ec4d4ac8bcdfcfd76851c9b4e927bdb Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 21 Jan 2023 09:07:31 -0500 Subject: [PATCH 865/947] docs: update language that implies there is only 1 maintainer --- docs/source/install.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/install.rst b/docs/source/install.rst index 0769ce7..f1b6f46 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -16,10 +16,10 @@ shells on OS X and Linux: * ``zsh`` It may work with other shells, so if you find that it does work with a -shell not listed here please let me know. If you can modify it to +shell not listed here please let us know. If you can modify it to work with another shell without completely rewriting it, then send a pull request through the `GitHub project page`_. If you write a clone to -work with an incompatible shell, let me know and I will link to it +work with an incompatible shell, let us know and we will link to it from this page. .. _GitHub project page: https://GitHub.com/python-virtualenvwrapper/virtualenvwrapper/ From cf90b2ed6f2de56ca33b54d04e0037f12c1dac8a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 21 Jan 2023 09:09:52 -0500 Subject: [PATCH 866/947] docs: clean up trailing whitespace --- docs/source/plugins.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index 63e8e0c..e2fd808 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -80,7 +80,7 @@ techniques. The API is the same for every extension point. Each uses a Python function that takes a single argument, a list of strings passed to the -hook loader on the command line. +hook loader on the command line. :: @@ -106,7 +106,7 @@ user scripts when ``virtualenvwrapper.sh`` is loaded. def initialize(args): for filename, comment in GLOBAL_HOOKS: make_hook(os.path.join('$WORKON_HOME', filename), comment) - return + return .. _plugins-user-env: @@ -156,7 +156,7 @@ shell process. where examining the ``SHELL`` environment variable to generate different syntax for each case is the only way to achieve the desired result. - + Registering Entry Points ------------------------ @@ -200,9 +200,9 @@ application, use the ``-m`` option to the interpreter:: $ python -m virtualenvwrapper.hook_loader -h Usage: virtualenvwrapper.hook_loader [options] [] - + Manage hooks for virtualenvwrapper - + Options: -h, --help show this help message and exit -s, --source Print the shell commands to be run in the current @@ -213,7 +213,7 @@ application, use the ``-m`` option to the interpreter:: -q, --quiet Show less information on the console -n NAMES, --name=NAMES Only run the hook from the named plugin - + To run the extensions for the initialize hook:: $ python -m virtualenvwrapper.hook_loader -v initialize @@ -375,7 +375,7 @@ Plugins that define new operations can also define new extension points. No setup needs to be done to allow the hook loader to find the extensions; documenting the names and adding calls to ``virtualenvwrapper_run_hook`` is sufficient to cause them to be -invoked. +invoked. The hook loader assumes all extension point names start with ``virtualenvwrapper.`` and new plugins will want to use their own From d7365499b3fd442e92200e481c7a3711981ab78e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 21 Jan 2023 09:13:47 -0500 Subject: [PATCH 867/947] drop ksh support Fixes #11 Sem-Ver: api-break --- README.txt | 2 +- docs/source/install.rst | 1 - docs/source/plugins.rst | 2 +- tests/run_tests | 1 - tests/test_dir_stack.sh | 1 - tox.ini | 7 ------- virtualenvwrapper.sh | 10 +++------- 7 files changed, 5 insertions(+), 19 deletions(-) diff --git a/README.txt b/README.txt index bd42fbe..49a0fee 100644 --- a/README.txt +++ b/README.txt @@ -47,7 +47,7 @@ Supported Shells ================ virtualenvwrapper is a set of shell *functions* defined in Bourne -shell compatible syntax. It is tested under ``bash``, ``ksh``, and +shell compatible syntax. It is tested under ``bash`` and ``zsh``. It may work with other shells, so if you find that it does work with a shell not listed here please let us know by opening a `ticket on GitHub diff --git a/docs/source/install.rst b/docs/source/install.rst index f1b6f46..94de69e 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -12,7 +12,6 @@ shell compatible syntax. Its automated tests run under these shells on OS X and Linux: * ``bash`` -* ``ksh`` * ``zsh`` It may work with other shells, so if you find that it does work with a diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index e2fd808..4026837 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -150,7 +150,7 @@ shell process. .. warning:: virtualenvwrapper works under several shells with slightly - different syntax (bash, sh, zsh, ksh). Take this portability into + different syntax (bash, sh, zsh). Take this portability into account when defining source hooks. Sticking to the simplest possible syntax usually avoids problems, but there may be cases where examining the ``SHELL`` environment variable to generate diff --git a/tests/run_tests b/tests/run_tests index 68cb362..a29179b 100755 --- a/tests/run_tests +++ b/tests/run_tests @@ -61,7 +61,6 @@ do echo " SHELL=$SHELL" echo " BASH_VERSION=$BASH_VERSION" echo " ZSH_VERSION=$ZSH_VERSION" - echo " KSH_VERSION=$KSH_VERSION" echo " virtualenv=$(which virtualenv)" echo " test_shell_opts=$test_shell_opts" echo " ZSH=$ZSH_NAME $ZSH_EVAL_CONTEXT" diff --git a/tests/test_dir_stack.sh b/tests/test_dir_stack.sh index f86c9fc..e391754 100755 --- a/tests/test_dir_stack.sh +++ b/tests/test_dir_stack.sh @@ -29,7 +29,6 @@ tearDown() { } test_ticket_101 () { - [ ! -z "$KSH_VERSION" ] && echo "Skipping test under ksh" && return 0 mkvirtualenv some_env deactivate cd "$WORKON_HOME/start_here" diff --git a/tox.ini b/tox.ini index c97b5ef..3549d6a 100644 --- a/tox.ini +++ b/tox.ini @@ -14,7 +14,6 @@ setenv = allowlist_externals = bash zsh - ksh [testenv:fast] setenv = @@ -32,12 +31,6 @@ setenv = test_shell_opts = -o shwordsplit commands = zsh -o shwordsplit ./tests/run_tests {envdir} [] -[testenv:ksh] -basepython=python2.7 -setenv = - SHELL = /bin/ksh -commands = ksh ./tests/run_tests {envdir} [] - [testenv:docs] deps = -r{toxinidir}/requirements.txt diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 79def0d..9ba3e81 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -121,11 +121,9 @@ fi # alias or even a shell function. Under bash and zsh, "builtin" forces # the use of a command that is part of the shell itself instead of an # alias, function, or external command, while "command" does something -# similar but allows external commands. Under ksh "builtin" registers -# a new command from a shared library, but "command" will pick up -# existing builtin commands. We need to use a builtin for cd because -# we are trying to change the state of the current shell, so we use -# "builtin" for bash and zsh but "command" under ksh. +# similar but allows external commands. We need to use a builtin for +# cd because we are trying to change the state of the current shell, +# so we use "builtin". function virtualenvwrapper_cd { if [ -n "${BASH:-}" ] then @@ -133,8 +131,6 @@ function virtualenvwrapper_cd { elif [ -n "${ZSH_VERSION:-}" ] then builtin \cd -q "$@" - else - command \cd "$@" fi } From e63d2c389ed276aa161bb50a27c77af94d96a50c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 21 Jan 2023 09:19:41 -0500 Subject: [PATCH 868/947] remove python2 from startup logic for finding the python interpreter Fixes #22 Sem-Ver: api-break --- virtualenvwrapper.sh | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 79def0d..b8e4a42 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -45,29 +45,21 @@ # # Locate the global Python where virtualenvwrapper is installed. -# Use the highest Python version if [ "${VIRTUALENVWRAPPER_PYTHON:-}" = "" ] then - for NAME in python3 python2 python - do - python_executable="$(which $NAME 2>/dev/null)" - if ! [ -z "$python_executable" ] - then - if $python_executable -m 'virtualenvwrapper.hook_loader' --help >/dev/null 2>&1 - then - VIRTUALENVWRAPPER_PYTHON=$python_executable - break - fi - fi - done - if [ "${VIRTUALENVWRAPPER_PYTHON:-}" = "" ] + _virtualenvwrapper_python_executable="$(which python3 2>/dev/null)" + if [ -n "$_virtualenvwrapper_python_executable" ] && $_virtualenvwrapper_python_executable -m 'virtualenvwrapper.hook_loader' --help >/dev/null 2>&1 then - echo -e "ERROR: Python with virtualenvwrapper module not found! -Either, install virtualenvwrapper module for standard python2 -or python3 or set VIRTUALENVWRAPPER_PYTHON variable manually." 1>&2 - return 1 + VIRTUALENVWRAPPER_PYTHON=$_virtualenvwrapper_python_executable fi fi +if [ "${VIRTUALENVWRAPPER_PYTHON:-}" = "" ] +then + echo -e "ERROR: Python with virtualenvwrapper module not found! +Either, install virtualenvwrapper module for the default python3 interpreter +or set VIRTUALENVWRAPPER_PYTHON to the interpreter to use." 1>&2 + return 1 +fi # Set the name of the virtualenv app to use. if [ "${VIRTUALENVWRAPPER_VIRTUALENV:-}" = "" ] From 838a628e821e7cf5b5c0a0ec2b9cee32f7d1e7b3 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 21 Jan 2023 09:34:00 -0500 Subject: [PATCH 869/947] mergify: add rules to label PRs based on pbr sem-ver data --- .mergify.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.mergify.yml b/.mergify.yml index 4fbb008..6b41ced 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -33,6 +33,24 @@ pull_request_rules: add: - documentation + - name: Add breaking-change label + # https://docs.openstack.org/pbr/latest/user/features.html + conditions: + - "body~=Sem-Ver: api-break" + actions: + label: + add: + - "breaking change" + + - name: Add feature label + # https://docs.openstack.org/pbr/latest/user/features.html + conditions: + - "body~=Sem-Ver: feature" + actions: + label: + add: + - feature + - name: Automatic merge on approval conditions: - and: From ae23b7191c94b4c39556b28e64ff3f22056178db Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 21 Jan 2023 09:41:49 -0500 Subject: [PATCH 870/947] tox: update doc build commands - Run html builder with warnings treated as errors. - Run the linkcheck builder. Fixes #15 --- tox.ini | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index c97b5ef..b629574 100644 --- a/tox.ini +++ b/tox.ini @@ -42,7 +42,9 @@ commands = ksh ./tests/run_tests {envdir} [] deps = -r{toxinidir}/requirements.txt -r{toxinidir}/docs/requirements.txt -commands = python setup.py build_sphinx +commands = + sphinx-build -W -j auto -b html -d docs/build/doctrees docs/source docs/build/html + sphinx-build -W -j auto -b linkcheck -d docs/build/doctrees docs/source docs/build/linkcheck [testenv:pkglint] deps= From e07bbdd93659e0a82635f1b62765350e55a0a338 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 21 Jan 2023 09:42:30 -0500 Subject: [PATCH 871/947] docs: remove broken link from tips list Also clean up trailing whitespace. --- docs/source/tips.rst | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/docs/source/tips.rst b/docs/source/tips.rst index c32bdf9..aec51f5 100644 --- a/docs/source/tips.rst +++ b/docs/source/tips.rst @@ -19,7 +19,7 @@ While the virtualenv ``activate`` script does attempt to provide an indicator in the prompt, it has various shortcomings, and cannot be customized. -However, it does also set a shell variable named +However, it does also set a shell variable named ``VIRTUAL_ENV`` which can be used as the basis for disabling the built-in prompt indicator and substituting an improved one, as a customization to ``.bashrc`` or ``.zshrc``:: @@ -27,7 +27,7 @@ as a customization to ``.bashrc`` or ``.zshrc``:: virtualenv_prompt() { # If not in a virtualenv, print nothing [[ "$VIRTUAL_ENV" == "" ]] && return - + # Distinguish between the shell where the virtualenv was activated # and its children local venv_name="${VIRTUAL_ENV##*/}" @@ -37,7 +37,7 @@ as a customization to ``.bashrc`` or ``.zshrc``:: echo "<${venv_name}> " fi } - + # Display a "we are in a virtualenv" indicator that works in child shells too VIRTUAL_ENV_DISABLE_PROMPT=1 PS1='$(virtualenv_prompt)'"$PS1" @@ -116,10 +116,6 @@ directory each time he runs ``cd``. If it finds a ``.venv`` file, it activates the environment named within. On leaving that directory, the current virtualenv is automatically deactivated. -`Harry Marr `__ -wrote a similar function that works with `git repositories -`__. - Installing Common Tools Automatically in New Environments ========================================================= From 4adb9b3e28c70bf09b8ee81ecd4cae173c030f4a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 21 Jan 2023 09:43:03 -0500 Subject: [PATCH 872/947] packaging: fix indentation of trove classifier for audience --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 0ec5d5c..764868c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -14,7 +14,7 @@ classifier = Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 -Intended Audience :: Developers + Intended Audience :: Developers Environment :: Console keywords = virtualenv From e31583e680274a0670f0352f056517717723f5c8 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 21 Jan 2023 09:49:15 -0500 Subject: [PATCH 873/947] docs: fix or remove broken links --- docs/source/command_ref.rst | 2 +- docs/source/developers.rst | 2 +- docs/source/plugins.rst | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index eadb850..50997e7 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -57,7 +57,7 @@ installed. * :ref:`scripts-postmkvirtualenv` * `requirements file format`_ -.. _requirements file format: https://pip.pypa.io/en/latest/reference/pip_install/#requirements-file-format +.. _requirements file format: https://pip.pypa.io/en/stable/reference/requirements-file-format/ .. _command-mktmpenv: diff --git a/docs/source/developers.rst b/docs/source/developers.rst index 01e9e04..1c6c7d7 100644 --- a/docs/source/developers.rst +++ b/docs/source/developers.rst @@ -98,7 +98,7 @@ the ``tests`` directory. .. _shunit2: https://github.com/kward/shunit2 -.. _tox: https://tox.testrun.org/ +.. _tox: https://tox.wiki/ .. _developer-templates: diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index 63e8e0c..c601dbd 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -186,8 +186,7 @@ used). .. seealso:: - * `namespace packages `__ - * `Extensible Applications and Frameworks `__ + * `namespace packages `__ The Hook Loader --------------- @@ -257,7 +256,7 @@ messages. .. seealso:: * `Standard library documentation for logging `__ - * `PyMOTW for logging `__ + * `PyMOTW for logging `__ .. _plugins-extension-points: From af41484a4709503f6029830b91eb0ec0b4abb2a0 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Sat, 21 Jan 2023 19:24:31 +0100 Subject: [PATCH 874/947] Updated tested Python versions in README. As per the GHA workflow files, only Python 3.8+ are tested. --- README.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.txt b/README.txt index 49a0fee..415130e 100644 --- a/README.txt +++ b/README.txt @@ -61,7 +61,7 @@ we will link to it from this page. Python Versions =============== -virtualenvwrapper is tested under Python 2.6 - 3.6. +virtualenvwrapper is tested under Python 3.8 - 3.11. ======= Support From 4250f111de82d435711febe28977bb38bac27e94 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 28 Jan 2023 09:08:44 -0500 Subject: [PATCH 875/947] add github action for publishing packages Addresses #6 --- .github/workflows/python-publish.yaml | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/python-publish.yaml diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml new file mode 100644 index 0000000..bfeb191 --- /dev/null +++ b/.github/workflows/python-publish.yaml @@ -0,0 +1,40 @@ +# This workflows will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: Upload Python Package + +on: + - push + +jobs: + build-n-publish: + name: Build and publish Python distributions to PyPI and TestPyPI + if: ${{ github.repository_owner == 'python-virtualenvwrapper' }} + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine pbr + - name: Build sdist and wheel + run: | + python setup.py sdist bdist_wheel + - name: Publish distribution to Test PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.test_pypi_password }} + repository_url: https://test.pypi.org/legacy/ + - name: Publish distribution to PyPI + if: startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.pypi_password }} From a761f386a8aee8c395d5478a55c9fbad12f191c4 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 28 Jan 2023 09:29:55 -0500 Subject: [PATCH 876/947] switch to implicit namespaces Remove explicit namespace package handling. See https://peps.python.org/pep-0420/ Fixes #32 --- setup.cfg | 2 -- virtualenvwrapper/__init__.py | 4 ---- 2 files changed, 6 deletions(-) delete mode 100644 virtualenvwrapper/__init__.py diff --git a/setup.cfg b/setup.cfg index 764868c..470d25a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -24,8 +24,6 @@ zip_safe = False [files] packages = virtualenvwrapper -namespace_packages = - virtualenvwrapper scripts = virtualenvwrapper.sh virtualenvwrapper_lazy.sh diff --git a/virtualenvwrapper/__init__.py b/virtualenvwrapper/__init__.py deleted file mode 100644 index 59336ae..0000000 --- a/virtualenvwrapper/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -"""virtualenvwrapper module -""" - -__import__('pkg_resources').declare_namespace(__name__) From 6f105539c2bdfc60148dc5ba4aec10ebbde1a287 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 28 Jan 2023 09:38:57 -0500 Subject: [PATCH 877/947] update pypi publishing action * update publishing action using latest instructions in https://github.com/marketplace/actions/pypi-publish * add debug info * change secret names to match docs * remove test upload (secret are not available in PR jobs, see https://securitylab.github.com/research/github-actions-preventing-pwn-requests/) --- .github/workflows/python-publish.yaml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index bfeb191..75a668f 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -28,13 +28,12 @@ jobs: - name: Build sdist and wheel run: | python setup.py sdist bdist_wheel - - name: Publish distribution to Test PyPI - uses: pypa/gh-action-pypi-publish@master - with: - password: ${{ secrets.test_pypi_password }} - repository_url: https://test.pypi.org/legacy/ - name: Publish distribution to PyPI - if: startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@master + # This condition prevents PRs from being published as part of + # the test job. + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@v1.6.4 with: - password: ${{ secrets.pypi_password }} + password: ${{ secrets.PYPI_API_TOKEN }} + verbose: true + print_hash: true From a22a4e99ba11934225859c4673b328e9d4376f27 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 30 Jan 2023 20:00:30 -0500 Subject: [PATCH 878/947] add a --version option to the hook loader Use the hook loader --version option to report the version of virtualenvwrapper installed when the user runs the `virtualenvwrapper` command. Fixes #42 --- docs/source/command_ref.rst | 4 +++- tests/test_virtualenvwrapper.sh | 12 ++++++++++++ virtualenvwrapper.sh | 11 +++++++++++ virtualenvwrapper/hook_loader.py | 11 +++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/docs/source/command_ref.rst b/docs/source/command_ref.rst index 50997e7..4571703 100644 --- a/docs/source/command_ref.rst +++ b/docs/source/command_ref.rst @@ -591,7 +591,9 @@ Other Commands virtualenvwrapper ----------------- -Print a list of commands and their descriptions as basic help output. +Print a list of commands, their descriptions, and some details about +the version and locations used by virtualenvwrapper as basic help +output. Syntax:: diff --git a/tests/test_virtualenvwrapper.sh b/tests/test_virtualenvwrapper.sh index 529dff1..ecaef8e 100755 --- a/tests/test_virtualenvwrapper.sh +++ b/tests/test_virtualenvwrapper.sh @@ -26,4 +26,16 @@ test_virtualenvwrapper_script_set() { "echo $VIRTUALENVWRAPPER_SCRIPT | grep -q /virtualenvwrapper.sh" } +test_virtualenvwrapper_version() { + source "$test_dir/../virtualenvwrapper.sh" + typeset ver=$(_virtualenvwrapper_version) + assertTrue "version is empty" "[ -n $ver ]" +} + +test_virtualenvwrapper_help_shows_version() { + source "$test_dir/../virtualenvwrapper.sh" + typeset pattern="Version: $(_virtualenvwrapper_version)" + assertTrue "version not in command output" "virtualenvwrapper | grep \"$pattern\"" +} + . "$test_dir/shunit2" diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 7eb4ca7..cf43626 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -1336,8 +1336,13 @@ function allvirtualenv { unset IFS } +function _virtualenvwrapper_version { + "$VIRTUALENVWRAPPER_PYTHON" -m 'virtualenvwrapper.hook_loader' --version +} + #:help:virtualenvwrapper: show this help message function virtualenvwrapper { + typeset version=$(_virtualenvwrapper_version) cat < Date: Sat, 11 Feb 2023 09:43:58 -0500 Subject: [PATCH 879/947] packaging: modernize packaging - Replace pbr with setuptools, setuptools_scm, and build. - Move most of the packaging settings into pyproject.toml. - Update tox settings to reflect packaging changes. - Update documentation build version detection. - Update documentation for entry points now that setup.cfg is removed. Fixes #33 Addresses #34 --- docs/source/conf.py | 8 +--- docs/source/plugins.rst | 23 ++++++----- pyproject.toml | 90 +++++++++++++++++++++++++++++++++++++++++ requirements.txt | 3 -- setup.cfg | 79 ------------------------------------ setup.py | 8 +++- tox.ini | 9 ++--- 7 files changed, 115 insertions(+), 105 deletions(-) create mode 100644 pyproject.toml delete mode 100644 requirements.txt delete mode 100644 setup.cfg diff --git a/docs/source/conf.py b/docs/source/conf.py index 1a79ec8..ab23616 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -13,7 +13,7 @@ # serve to show the default. import datetime -import subprocess +import importlib.metadata # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -51,11 +51,7 @@ # built documents. # # The short X.Y version. -version = subprocess.check_output([ - 'sh', '-c', - 'cd ../..; python setup.py --version', -]).decode('utf-8') -version = version.strip() +version = importlib.metadata.version('virtualenvwrapper') # The full version, including alpha/beta/rc tags. release = version diff --git a/docs/source/plugins.rst b/docs/source/plugins.rst index 6422930..4587355 100644 --- a/docs/source/plugins.rst +++ b/docs/source/plugins.rst @@ -162,25 +162,30 @@ Registering Entry Points The functions defined in the plugin need to be registered as *entry points* in order for virtualenvwrapper's hook loader to find them. -Entry points are configured in the ``setup.py`` (or ``setup.cfg`` when -using pbr) for your package by mapping the entry point name to the -function in the package that implements it. +Entry points are configured in the packaging instructions for your +package by mapping the entry point name to the function in the package +that implements it. -This partial copy of virtualenvwrapper's ``setup.cfg`` illustrates how +This partial copy of virtualenvwrapper's ``pyproject.toml`` illustrates how the ``initialize()`` and ``initialize_source()`` entry points are configured. -.. include:: ../../setup.cfg - :literal: - :start-after: [entry_points] +:: + + [project.entry-points."virtualenvwrapper.initialize"] + user_scripts = "virtualenvwrapper.user_scripts:initialize" + project = "virtualenvwrapper.project:initialize" + + [project.entry-points."virtualenvwrapper.initialize_source"] + user_scripts = "virtualenvwrapper.user_scripts:initialize_source" -The ``entry_points`` section maps the *group names* to lists of entry +Each entry points section maps the *group names* to lists of entry point specifiers. A different group name is defined by virtualenvwrapper for each extension point (see :ref:`plugins-extension-points`). The entry point specifiers are strings with the syntax ``name = -package.module:function``. By convention, the *name* of each entry +"package.module:function"``. By convention, the *name* of each entry point is the plugin name, but that is not required (the names are not used). diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..2233798 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,90 @@ +[build-system] +requires = ["setuptools", "setuptools_scm[toml]>=6.2"] +build-backend = "setuptools.build_meta" + +[project] +authors = [ + {name = "Doug Hellmann", email = "doug@doughellmann.com"}, + {name = "Jason Myers", email = "jason@mailthemyers.com"}, +] + +classifiers = [ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Intended Audience :: Developers", + "Environment :: Console", +] + +name = "virtualenvwrapper" +description = "" +dynamic = ["version"] +keywords = ["virtualenv"] +license = {text = "MIT"} +readme = "README.txt" +requires-python = ">=3.8" + +dependencies = [ + "virtualenv", + "virtualenv-clone", + "stevedore", +] + +# https://github.com/pypa/setuptools_scm/ +[tool.setuptools_scm] + +[project.urls] +homepage = "https://virtualenvwrapper.readthedocs.io/" +repository = "https://github.com/python-virtualenvwrapper/virtualenvwrapper" + +[project.entry-points."virtualenvwrapper.initialize"] +user_scripts = "virtualenvwrapper.user_scripts:initialize" +project = "virtualenvwrapper.project:initialize" + +[project.entry-points."virtualenvwrapper.initialize_source"] +user_scripts = "virtualenvwrapper.user_scripts:initialize_source" + +[project.entry-points."virtualenvwrapper.pre_mkvirtualenv"] +user_scripts = "virtualenvwrapper.user_scripts:pre_mkvirtualenv" + +[project.entry-points."virtualenvwrapper.post_mkvirtualenv_source"] +user_scripts = "virtualenvwrapper.user_scripts:post_mkvirtualenv_source" + +[project.entry-points."virtualenvwrapper.pre_cpvirtualenv"] +user_scripts = "virtualenvwrapper.user_scripts:pre_cpvirtualenv" + +[project.entry-points."virtualenvwrapper.post_cpvirtualenv_source"] +user_scripts = "virtualenvwrapper.user_scripts:post_cpvirtualenv_source" + +[project.entry-points."virtualenvwrapper.pre_rmvirtualenv"] +user_scripts = "virtualenvwrapper.user_scripts:pre_rmvirtualenv" + +[project.entry-points."virtualenvwrapper.post_rmvirtualenv"] +user_scripts = "virtualenvwrapper.user_scripts:post_rmvirtualenv" + +[project.entry-points."virtualenvwrapper.project.pre_mkproject"] +project = "virtualenvwrapper.project:pre_mkproject" + +[project.entry-points."virtualenvwrapper.project.post_mkproject_source"] +project = "virtualenvwrapper.project:post_mkproject_source" + +[project.entry-points."virtualenvwrapper.pre_activate"] +user_scripts = "virtualenvwrapper.user_scripts:pre_activate" + +[project.entry-points."virtualenvwrapper.post_activate_source"] +project = "virtualenvwrapper.project:post_activate_source" +user_scripts = "virtualenvwrapper.user_scripts:post_activate_source" + +[project.entry-points."virtualenvwrapper.pre_deactivate_source"] +user_scripts = "virtualenvwrapper.user_scripts:pre_deactivate_source" + +[project.entry-points."virtualenvwrapper.post_deactivate_source"] +user_scripts = "virtualenvwrapper.user_scripts:post_deactivate_source" + +[project.entry-points."virtualenvwrapper.get_env_details"] +user_scripts = "virtualenvwrapper.user_scripts:get_env_details" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 8f54551..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -virtualenv -virtualenv-clone -stevedore diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 470d25a..0000000 --- a/setup.cfg +++ /dev/null @@ -1,79 +0,0 @@ -[metadata] -name = virtualenvwrapper -author = Doug Hellmann -author_email = doug@doughellmann.com -summary = Enhancements to virtualenv -description_file = README.txt -license = MIT -classifier = - Development Status :: 5 - Production/Stable - License :: OSI Approved :: MIT License - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Intended Audience :: Developers - Environment :: Console -keywords = - virtualenv -home_page = https://virtualenvwrapper.readthedocs.io/ -zip_safe = False - -[files] -packages = - virtualenvwrapper -scripts = - virtualenvwrapper.sh - virtualenvwrapper_lazy.sh - -[global] -zip_safe = False -setup-hooks = - pbr.hooks.setup_hook - -[entry_points] -virtualenvwrapper.initialize = - user_scripts = virtualenvwrapper.user_scripts:initialize - project = virtualenvwrapper.project:initialize -virtualenvwrapper.initialize_source = - user_scripts = virtualenvwrapper.user_scripts:initialize_source -virtualenvwrapper.pre_mkvirtualenv = - user_scripts = virtualenvwrapper.user_scripts:pre_mkvirtualenv -virtualenvwrapper.post_mkvirtualenv_source = - user_scripts = virtualenvwrapper.user_scripts:post_mkvirtualenv_source -virtualenvwrapper.pre_cpvirtualenv = - user_scripts = virtualenvwrapper.user_scripts:pre_cpvirtualenv -virtualenvwrapper.post_cpvirtualenv_source = - user_scripts = virtualenvwrapper.user_scripts:post_cpvirtualenv_source -virtualenvwrapper.pre_rmvirtualenv = - user_scripts = virtualenvwrapper.user_scripts:pre_rmvirtualenv -virtualenvwrapper.post_rmvirtualenv = - user_scripts = virtualenvwrapper.user_scripts:post_rmvirtualenv -virtualenvwrapper.project.pre_mkproject = - project = virtualenvwrapper.project:pre_mkproject -virtualenvwrapper.project.post_mkproject_source = - project = virtualenvwrapper.project:post_mkproject_source -virtualenvwrapper.pre_activate = - user_scripts = virtualenvwrapper.user_scripts:pre_activate -virtualenvwrapper.post_activate_source = - project = virtualenvwrapper.project:post_activate_source - user_scripts = virtualenvwrapper.user_scripts:post_activate_source -virtualenvwrapper.pre_deactivate_source = - user_scripts = virtualenvwrapper.user_scripts:pre_deactivate_source -virtualenvwrapper.post_deactivate_source = - user_scripts = virtualenvwrapper.user_scripts:post_deactivate_source -virtualenvwrapper.get_env_details = - user_scripts = virtualenvwrapper.user_scripts:get_env_details - -[pbr] -warnerrors = true - -[wheel] -universal = true - -[build_sphinx] -source-dir = docs/source -build-dir = docs/build -all_files = 1 diff --git a/setup.py b/setup.py index aa2d8a0..bb5e197 100644 --- a/setup.py +++ b/setup.py @@ -3,6 +3,10 @@ from setuptools import setup setup( - setup_requires=['pbr'], - pbr=True, + # Listing the scripts in pyproject.toml requires them to be python + # entry points for console scripts, but they are shell scripts. + scripts=[ + "virtualenvwrapper.sh", + "virtualenvwrapper_lazy.sh", + ], ) diff --git a/tox.ini b/tox.ini index cb2e757..dff8fbd 100644 --- a/tox.ini +++ b/tox.ini @@ -2,9 +2,7 @@ envlist = py,zsh,style [testenv] -install_command = pip install -U {opts} {packages} commands = bash ./tests/run_tests {envdir} [] -deps = -rrequirements.txt pass_env = HOME USER @@ -33,7 +31,6 @@ commands = zsh -o shwordsplit ./tests/run_tests {envdir} [] [testenv:docs] deps = - -r{toxinidir}/requirements.txt -r{toxinidir}/docs/requirements.txt commands = sphinx-build -W -j auto -b html -d docs/build/doctrees docs/source docs/build/html @@ -41,10 +38,10 @@ commands = [testenv:pkglint] deps= - pbr + build twine check-python-versions commands= - python setup.py sdist + python -m build twine check dist/*.tar.gz - check-python-versions --only setup.py,setup.cfg,.github/workflows/test.yml + check-python-versions --only pyproject.toml,.github/workflows/test.yml From 389179cef6904551350c1a447f2633941d0bad78 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Feb 2023 11:26:06 -0500 Subject: [PATCH 880/947] tests: update tests to use the packaged version of the scripts The tests were always running the local source copy of virtualenvwrapper.sh, which does not ensure we are packaging and installing that file properly. This commit changes the logic for loading the wrappers so when the job is running under tox we always look in the virtualenv's bin directory. --- tests/setup.sh | 16 ++++++++++++++++ tests/test.sh | 2 +- tests/test_add2virtualenv.sh | 2 +- tests/test_allvirtualenv.sh | 2 +- tests/test_cd.sh | 2 +- tests/test_cd_alias.sh | 2 +- tests/test_cd_space_in_name.sh | 2 +- tests/test_cp.sh | 4 ++-- tests/test_cpvirtualenv.sh | 2 +- tests/test_deactivate.sh | 2 +- tests/test_derive_workon_home.sh | 2 +- tests/test_dir_stack.sh | 2 +- tests/test_expandpath.sh | 2 +- tests/test_hook_dir.sh | 2 +- tests/test_log_file.sh | 6 +++--- tests/test_ls.sh | 2 +- tests/test_mktmpenv.sh | 2 +- tests/test_mkvirtualenv.sh | 2 +- tests/test_mkvirtualenv_associate.sh | 2 +- tests/test_mkvirtualenv_install.sh | 2 +- tests/test_mkvirtualenv_requirements.sh | 2 +- tests/test_project.sh | 4 ++-- tests/test_project_activate.sh | 2 +- tests/test_project_cd.sh | 2 +- tests/test_project_mk.sh | 2 +- tests/test_project_templates.sh | 2 +- tests/test_rmvirtualenv.sh | 2 +- tests/test_run_hook.sh | 2 +- tests/test_setvirtualenvproject.sh | 2 +- tests/test_support.sh | 2 +- tests/test_tempfile.sh | 2 +- tests/test_virtualenvwrapper.sh | 2 +- tests/test_wipeenv.sh | 2 +- tests/test_workon.sh | 2 +- tox.ini | 5 +++-- 35 files changed, 56 insertions(+), 39 deletions(-) diff --git a/tests/setup.sh b/tests/setup.sh index 6e006fb..6ecd404 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -10,3 +10,19 @@ export WORKON_HOME=$(mktemp -d -t "WORKON_HOME.XXXX.$$") export PROJECT_HOME=$(mktemp -d -t "PROJECT_HOME.XXXX.$$") #unset HOOK_VERBOSE_OPTION + +SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# This should point to VIRTUAL_ENV/bin when running under tox. +TEST_BIN_DIR=$(dirname $(which python)) + +load_wrappers() { + if [ "$USING_TOX" = "1" ]; then + # Use the version of the scripts installed as part of the + # package. + source "$TEST_BIN_DIR/virtualenvwrapper.sh" + else + echo "USING SOURCE VERSION OF SCRIPT" + source "$SCRIPTDIR/../virtualenvwrapper.sh" + fi +} diff --git a/tests/test.sh b/tests/test.sh index 0bd26e9..2c05920 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -6,7 +6,7 @@ source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers } oneTimeTearDown() { diff --git a/tests/test_add2virtualenv.sh b/tests/test_add2virtualenv.sh index fedba20..e1a0cb3 100755 --- a/tests/test_add2virtualenv.sh +++ b/tests/test_add2virtualenv.sh @@ -6,7 +6,7 @@ source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" >/dev/null 2>&1 + load_wrappers >/dev/null 2>&1 } oneTimeTearDown() { diff --git a/tests/test_allvirtualenv.sh b/tests/test_allvirtualenv.sh index fd7b027..7cc26b9 100755 --- a/tests/test_allvirtualenv.sh +++ b/tests/test_allvirtualenv.sh @@ -6,8 +6,8 @@ source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" + load_wrappers unset VIRTUAL_ENV - source "$test_dir/../virtualenvwrapper.sh" # These three env names must sort the same whether the OS considers leading whitespace or not. # "test" is after " env" and after "env", so the asserts work on OSX and Linux. mkvirtualenv test1 >/dev/null 2>&1 diff --git a/tests/test_cd.sh b/tests/test_cd.sh index a4cada2..1001204 100755 --- a/tests/test_cd.sh +++ b/tests/test_cd.sh @@ -6,8 +6,8 @@ source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" + load_wrappers unset VIRTUAL_ENV - source "$test_dir/../virtualenvwrapper.sh" mkvirtualenv cd-test >/dev/null 2>&1 deactivate } diff --git a/tests/test_cd_alias.sh b/tests/test_cd_alias.sh index 4af8f70..e7ec6ae 100755 --- a/tests/test_cd_alias.sh +++ b/tests/test_cd_alias.sh @@ -6,8 +6,8 @@ source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" + load_wrappers unset VIRTUAL_ENV - source "$test_dir/../virtualenvwrapper.sh" mkvirtualenv cd-test >/dev/null 2>&1 deactivate } diff --git a/tests/test_cd_space_in_name.sh b/tests/test_cd_space_in_name.sh index 157371d..281dcbf 100755 --- a/tests/test_cd_space_in_name.sh +++ b/tests/test_cd_space_in_name.sh @@ -7,8 +7,8 @@ oneTimeSetUp() { export WORKON_HOME="$WORKON_HOME/ this has spaces" rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" + load_wrappers unset VIRTUAL_ENV - source "$test_dir/../virtualenvwrapper.sh" # Only test with leading and internal spaces. Directory names with trailing spaces are legal, # and work with virtualenv on OSX, but error out on Linux. mkvirtualenv " env with space" >/dev/null 2>&1 diff --git a/tests/test_cp.sh b/tests/test_cp.sh index 3bd9196..b1b9b3d 100755 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -6,14 +6,14 @@ source "$test_dir/setup.sh" setUp () { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers rm -f "$TMPDIR/catch_output" echo } tearDown() { if type deactivate >/dev/null 2>&1 - then + then deactivate fi rm -rf "$WORKON_HOME" diff --git a/tests/test_cpvirtualenv.sh b/tests/test_cpvirtualenv.sh index ad7803f..b39fea0 100755 --- a/tests/test_cpvirtualenv.sh +++ b/tests/test_cpvirtualenv.sh @@ -6,7 +6,7 @@ source "$test_dir/setup.sh" setUp () { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers echo } diff --git a/tests/test_deactivate.sh b/tests/test_deactivate.sh index a0afa11..bbc6414 100755 --- a/tests/test_deactivate.sh +++ b/tests/test_deactivate.sh @@ -6,7 +6,7 @@ source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers mkvirtualenv "env1" } diff --git a/tests/test_derive_workon_home.sh b/tests/test_derive_workon_home.sh index 01b22ba..4f5ddd1 100755 --- a/tests/test_derive_workon_home.sh +++ b/tests/test_derive_workon_home.sh @@ -7,7 +7,7 @@ TMP_WORKON_HOME="$WORKON_HOME" oneTimeSetUp() { rm -rf "$TMP_WORKON_HOME" mkdir -p "$TMP_WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers echo $PYTHONPATH } diff --git a/tests/test_dir_stack.sh b/tests/test_dir_stack.sh index e391754..8383866 100755 --- a/tests/test_dir_stack.sh +++ b/tests/test_dir_stack.sh @@ -14,7 +14,7 @@ oneTimeTearDown() { setUp () { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers mkdir "$WORKON_HOME/start_here" mkdir "$WORKON_HOME/on_the_stack" echo diff --git a/tests/test_expandpath.sh b/tests/test_expandpath.sh index 541df56..f96f67d 100755 --- a/tests/test_expandpath.sh +++ b/tests/test_expandpath.sh @@ -5,7 +5,7 @@ source "$test_dir/setup.sh" TMP_WORKON_HOME="$WORKON_HOME" oneTimeSetUp() { - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers echo $PYTHONPATH } diff --git a/tests/test_hook_dir.sh b/tests/test_hook_dir.sh index f83b235..8c86e50 100755 --- a/tests/test_hook_dir.sh +++ b/tests/test_hook_dir.sh @@ -23,7 +23,7 @@ RUN_SCRIPTS="premkvirtualenv prermvirtualenv postrmvirtualenv preactivate get_en test_virtualenvwrapper_initialize() { export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME/hooks" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers for hook in $SOURCE_SCRIPTS do assertTrue "Global $WORKON_HOME/$hook was not created" "[ -f $WORKON_HOME/hooks/$hook ]" diff --git a/tests/test_log_file.sh b/tests/test_log_file.sh index 73f57a6..4bdc317 100755 --- a/tests/test_log_file.sh +++ b/tests/test_log_file.sh @@ -9,13 +9,13 @@ setUp () { test_set_by_user() { export VIRTUALENVWRAPPER_LOG_FILE="$WORKON_HOME/hooks.log" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers assertTrue "Log file was not created" "[ -f $VIRTUALENVWRAPPER_LOG_FILE ]" } test_file_permissions() { export VIRTUALENVWRAPPER_LOG_FILE="$WORKON_HOME/hooks.log" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers perms=$(ls -l "$VIRTUALENVWRAPPER_LOG_FILE" | cut -f1 -d' ') #echo $perms assertTrue "Log file permissions are wrong: $perms" "echo $perms | grep '^-rw-rw'" @@ -25,7 +25,7 @@ test_not_set_by_user() { unset WORKON_HOME unset VIRTUALENVWRAPPER_LOG_FILE unset VIRTUALENVWRAPPER_HOOK_DIR - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers assertSame "" "$VIRTUALENVWRAPPER_LOG_FILE" } diff --git a/tests/test_ls.sh b/tests/test_ls.sh index 25ceab2..18d0008 100755 --- a/tests/test_ls.sh +++ b/tests/test_ls.sh @@ -6,7 +6,7 @@ source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers } oneTimeTearDown() { diff --git a/tests/test_mktmpenv.sh b/tests/test_mktmpenv.sh index 6a1171d..d2a8785 100755 --- a/tests/test_mktmpenv.sh +++ b/tests/test_mktmpenv.sh @@ -7,7 +7,7 @@ source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers } oneTimeTearDown() { diff --git a/tests/test_mkvirtualenv.sh b/tests/test_mkvirtualenv.sh index 3c37dfe..d8ecf11 100755 --- a/tests/test_mkvirtualenv.sh +++ b/tests/test_mkvirtualenv.sh @@ -6,7 +6,7 @@ source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers } oneTimeTearDown() { diff --git a/tests/test_mkvirtualenv_associate.sh b/tests/test_mkvirtualenv_associate.sh index 98526e0..e617f94 100755 --- a/tests/test_mkvirtualenv_associate.sh +++ b/tests/test_mkvirtualenv_associate.sh @@ -6,7 +6,7 @@ source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers } oneTimeTearDown() { diff --git a/tests/test_mkvirtualenv_install.sh b/tests/test_mkvirtualenv_install.sh index 4cebd28..faf1652 100755 --- a/tests/test_mkvirtualenv_install.sh +++ b/tests/test_mkvirtualenv_install.sh @@ -6,7 +6,7 @@ source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers } oneTimeTearDown() { diff --git a/tests/test_mkvirtualenv_requirements.sh b/tests/test_mkvirtualenv_requirements.sh index 84ac5ac..744d4fd 100755 --- a/tests/test_mkvirtualenv_requirements.sh +++ b/tests/test_mkvirtualenv_requirements.sh @@ -6,7 +6,7 @@ source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers } oneTimeTearDown() { diff --git a/tests/test_project.sh b/tests/test_project.sh index f58d5c5..6f2c576 100755 --- a/tests/test_project.sh +++ b/tests/test_project.sh @@ -21,7 +21,7 @@ setUp () { } test_initialize() { - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers for hook in premkproject postmkproject do assertTrue "Global $hook was not created" "[ -f $WORKON_HOME/$hook ]" @@ -32,7 +32,7 @@ test_initialize() { test_initialize_hook_dir() { export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME/hooks" mkdir -p "$VIRTUALENVWRAPPER_HOOK_DIR" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers for hook in premkproject postmkproject do assertTrue "Global $hook was not created" "[ -f $VIRTUALENVWRAPPER_HOOK_DIR/$hook ]" diff --git a/tests/test_project_activate.sh b/tests/test_project_activate.sh index b566568..e4b52b3 100755 --- a/tests/test_project_activate.sh +++ b/tests/test_project_activate.sh @@ -8,7 +8,7 @@ oneTimeSetUp() { mkdir -p "$WORKON_HOME" rm -rf "$PROJECT_HOME" mkdir -p "$PROJECT_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers } # oneTimeTearDown() { diff --git a/tests/test_project_cd.sh b/tests/test_project_cd.sh index 77a2bae..e336139 100755 --- a/tests/test_project_cd.sh +++ b/tests/test_project_cd.sh @@ -8,7 +8,7 @@ oneTimeSetUp() { mkdir -p "$WORKON_HOME" rm -rf "$PROJECT_HOME" mkdir -p "$PROJECT_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers } oneTimeTearDown() { diff --git a/tests/test_project_mk.sh b/tests/test_project_mk.sh index 1e7eb1f..17a9b90 100755 --- a/tests/test_project_mk.sh +++ b/tests/test_project_mk.sh @@ -9,7 +9,7 @@ oneTimeSetUp() { rm -rf "$PROJECT_HOME" mkdir -p "$PROJECT_HOME" export VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME/hooks" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers } oneTimeTearDown() { diff --git a/tests/test_project_templates.sh b/tests/test_project_templates.sh index f75b777..5329cf6 100755 --- a/tests/test_project_templates.sh +++ b/tests/test_project_templates.sh @@ -9,7 +9,7 @@ oneTimeSetUp() { mkdir -p "$WORKON_HOME" rm -rf "$PROJECT_HOME" mkdir -p "$PROJECT_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers } oneTimeTearDown() { diff --git a/tests/test_rmvirtualenv.sh b/tests/test_rmvirtualenv.sh index a1bbe78..9836344 100755 --- a/tests/test_rmvirtualenv.sh +++ b/tests/test_rmvirtualenv.sh @@ -6,7 +6,7 @@ source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers } oneTimeTearDown() { diff --git a/tests/test_run_hook.sh b/tests/test_run_hook.sh index e1e8644..7ea0b9d 100755 --- a/tests/test_run_hook.sh +++ b/tests/test_run_hook.sh @@ -6,7 +6,7 @@ source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers } oneTimeTearDown() { diff --git a/tests/test_setvirtualenvproject.sh b/tests/test_setvirtualenvproject.sh index 766036c..c29dcd3 100755 --- a/tests/test_setvirtualenvproject.sh +++ b/tests/test_setvirtualenvproject.sh @@ -8,7 +8,7 @@ oneTimeSetUp() { mkdir -p "$WORKON_HOME" rm -rf "$PROJECT_HOME" mkdir -p "$PROJECT_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers } oneTimeTearDown() { diff --git a/tests/test_support.sh b/tests/test_support.sh index 20552d7..cf1ac23 100755 --- a/tests/test_support.sh +++ b/tests/test_support.sh @@ -6,7 +6,7 @@ source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers } oneTimeTearDown() { diff --git a/tests/test_tempfile.sh b/tests/test_tempfile.sh index be1f89d..f3c0842 100755 --- a/tests/test_tempfile.sh +++ b/tests/test_tempfile.sh @@ -8,7 +8,7 @@ source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers echo $PYTHONPATH } diff --git a/tests/test_virtualenvwrapper.sh b/tests/test_virtualenvwrapper.sh index 529dff1..d488d20 100755 --- a/tests/test_virtualenvwrapper.sh +++ b/tests/test_virtualenvwrapper.sh @@ -21,7 +21,7 @@ setUp () { } test_virtualenvwrapper_script_set() { - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers assertTrue "VIRTUALENVWRAPPER_SCRIPT is not right: $VIRTUALENVWRAPPER_SCRIPT" \ "echo $VIRTUALENVWRAPPER_SCRIPT | grep -q /virtualenvwrapper.sh" } diff --git a/tests/test_wipeenv.sh b/tests/test_wipeenv.sh index 9b8895c..3eb7b71 100755 --- a/tests/test_wipeenv.sh +++ b/tests/test_wipeenv.sh @@ -6,7 +6,7 @@ source "$test_dir/setup.sh" setUp () { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers echo } diff --git a/tests/test_workon.sh b/tests/test_workon.sh index 1e3aef7..25047f9 100755 --- a/tests/test_workon.sh +++ b/tests/test_workon.sh @@ -6,7 +6,7 @@ source "$test_dir/setup.sh" oneTimeSetUp() { rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers mkvirtualenv "test1" >/dev/null 2>&1 mkvirtualenv "test2" >/dev/null 2>&1 # Only test with leading and internal spaces. Directory names with trailing spaces are legal, diff --git a/tox.ini b/tox.ini index dff8fbd..48b11a7 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,7 @@ pass_env = HOME USER setenv = - TOXIC = true + USING_TOX = 1 SHELL = /bin/bash allowlist_externals = bash @@ -15,7 +15,7 @@ allowlist_externals = [testenv:fast] setenv = - TOXIC = true + USING_TOX = 1 SHELL = /bin/bash FAIL_FAST = true @@ -25,6 +25,7 @@ commands = flake8 virtualenvwrapper docs/source/conf.py [testenv:zsh] setenv = + USING_TOX = 1 SHELL = /bin/zsh test_shell_opts = -o shwordsplit commands = zsh -o shwordsplit ./tests/run_tests {envdir} [] From b636de6febc1672f272f6d286ac0c6c80ece3068 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Feb 2023 11:26:22 -0500 Subject: [PATCH 881/947] docs: switch to manually managed changelog We will want something nicer, but without pbr we don't get this generated content for free so this commit initializes the static content. Addresses #36 --- docs/source/history.rst | 1302 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 1301 insertions(+), 1 deletion(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index 69ed4fe..0d46a23 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -1 +1,1301 @@ -.. include:: ../../ChangeLog +CHANGES +======= + +Unreleased +---------- + +* add a --version option to the hook loader +* modernize packaging + +6.0.0.0a1 +--------- + +* update pypi publishing action +* switch to implicit namespaces +* add github action for publishing packages +* Updated tested Python versions in README +* docs: fix or remove broken links +* packaging: fix indentation of trove classifier for audience +* docs: remove broken link from tips list +* tox: update doc build commands +* mergify: add rules to label PRs based on pbr sem-ver data +* remove python2 from startup logic for finding the python interpreter +* drop ksh support +* docs: clean up trailing whitespace +* docs: update language that implies there is only 1 maintainer +* Fixing bitbucket in projects +* Updating template docs +* missed ones +* Updating references to bitbucket +* require at least one reviewer to approve PRs +* ci(Mergify): configuration update +* pass user and home through from tox instead of using id to derive them +* fix wipeenv for editable packages +* skip some tempfile tests on macos +* adjust error message detection in hook tests +* update lssitepackages tests to not need easy\_install +* remove tests and features relying on --no-site-packages +* remove the test for making virtualenvs relocatable +* update tox config to not set basepython for zsh +* update tox to only use default python version +* update test runner to use python3 +* add a "fast" environment in tox to exit as soon as any test fails +* missed ones +* run all of the tests and accumulate errors +* expand the relative path for envdir to the full path +* Updating references to bitbucket +* update trove classifiers with more modern python versions +* add pkglint test and fix some warnings +* set python version for zsh job in ci +* update tox config for tox 4 +* do not specify python version for docs env in tox settings +* set the version of python to use for linter jobs +* fix linter action config +* add github action configuration for test jobs +* Merged in fix/space\_in\_mkvenv\_project\_path (pull request #50) +* Merged in Stephan-Sokolow/improve-zsh-prompt-tip-closes-332-1574470574700 (pull request #75) +* Merged in master (pull request #72) +* Merged in no-more-egrep-its-deprecated (pull request #84) +* replace deprecated \`egrep\` with \`grep -E\` +* Revert "Merged in 334 (pull request #78)" +* Fixing readme.txt +* Merged in 334 (pull request #78) +* Updating to support virtualenv 20+ +* Merged in readme-updates (pull request #76) +* Merged in fix-screencast-link (pull request #77) +* fix link to screencast +* improve some of the wording in the readme +* Improve Zsh prompt tip +* Merged in Shailesh-Vashishth/indexrst-edited-online-with-bitbucket-1566725355529 (pull request #74) +* index.rst edited online with Bitbucket +* Merged in master (pull request #73) +* fixup! Find the highest Python version with installed virtualenvwrapper +* Find the highest Python version with installed virtualenvwrapper + +4.8.4 +----- + +* Formatting change + +4.8.3 +----- + +* Upgrade sphinx, fix docs +* Merged in ukch/virtualenvwrapper/ukch/allow-building-docs-on-python-3-1529536003674 (pull request #71) +* Merged in techtonik/virtualenvwrapper/techtonik/toxini-edited-online-with-bitbucket-1525341850929 (pull request #69) +* Make mkvirtualenv work with interpreters whose paths have spaces +* Allow building docs on Python 3 +* Merged in hjkatz/virtualenvwrapper/fix/workon\_deactivate\_and\_tests (pull request #70) +* Fix bug with workon deactivate typeset -f ; Add test\_workon\_deactivate\_hooks +* Merged in JakobGM/virtualenvwrapper-1/JakobGM/use-code-blocks-in-order-to-allow-easier-1508879869188 (pull request #66) +* Use code blocks in order to allow easier copy-pasting +* Merged in JakobGM/virtualenvwrapper/JakobGM/fix-formatting-error-on-read-the-docs-t-1508876093482 (pull request #65) +* Fix formatting error + +4.8.2 +----- + +* Merged in jeffwidman/virtualenvwrapper-2/jeffwidman/update-rtd-url-they-now-use-io-rather-t-1505539237232 (pull request #63) +* Merged in jeffwidman/virtualenvwrapper-1/jeffwidman/add-python-36-to-pypi-trove-classifiers-1505539102243 (pull request #62) +* Merged in jeffwidman/virtualenvwrapper/jeffwidman/update-readme-with-current-test-status--1505538852189 (pull request #61) +* Update RTD url +* Add python 3.6 to Pypi trove classifiers +* Update readme with current test status + +4.8.1 +----- + +* New PBR doesn't like provides\_dist + +4.8.0 +----- + +* Merged in fix/263 (pull request #60) +* Merged in fix/296 (pull request #59) +* Fixing Documentation +* Update supported versions +* Adding python 3.6 +* Fixing run\_hook and tab\_completion +* First shot at Fixing #263 +* Adding a note about package managers +* Merged in zmwangx/virtualenvwrapper/always-export-virtualenvwrapper\_hook\_dir (pull request #55) +* Typo fix +* Merged in lendenmc/virtualenvwrapper (pull request #51) +* Merged in SpotlightKid/virtualenvwrapper/bugfix/distutils-sysconfig (pull request #56) +* Merged in dougharris/virtualenvwrapper (pull request #53) +* Merged in kk6/virtualenvwrapper/fix/wipeenv\_ignore\_setuptools\_dependencies (pull request #57) +* Merged in erickmk/virtualenvwrapper/erickmk/command\_refrst-edited-online-with-bitbuc-1491225971803 (pull request #58) +* Update sentence to make it more clear +* command\_ref.rst edited online with Bitbucket +* Fixes Issue #291 wipeenv ignore setuptools’s dependencies +* Import distutils.sysconfig properly (fixes #167) +* virtualenvwrapper.sh: always export VIRTUALENVWRAPPER\_HOOK\_DIR +* Fixed case where alternate deactivate didn't exist +* Makes workon more selective in its search for \`deactivate\` #285 +* Merged in sambrightman/virtualenvwrapper (pull request #52) +* Fix spelling mistake in error message +* Fix .kshrc sourcing error "'&>file' is nonstandard" +* Fixes Issues #248 +* Merged in lonetwin/virtualenvwrapper (pull request #48) + +4.7.2 +----- + +* Baseline testing to python27 +* Fixing naming in tests +* Merged in phd/virtualenvwrapper (pull request #46) +* Ignore \*.pyo byte-code files +* Fix docs: fix URLs whenever possible, change protocol to https +* Add wipeenv and allvirtualenv for lazy loading +* Remove one-time functions from the environment +* Fix the problem with lazy completion for bash +* Last set of docs +* Docs fixes +* Updating to virtualenvwrapper +* Last set of docs +* Docs fixes +* Merged in fix/issue-282-link-to-virtualenvwrapper (pull request #49) +* Updating to virtualenvwrapper +* Unset previously defined cd function rather than redefine it +* Merged in ismailsunni/virtualenvwrapper/ismailsunni/command\_refrst-edited-online-with-bitbuc-1454377958615 (pull request #44) +* command\_ref.rst edited online with Bitbucket Adding -d for remove extra path +* use a ref instead of hard-coded link in new tip +* Merged in kojiromike/virtualenvwrapper/deactivate-on-logout-tip (pull request #43) +* Add Deactivate-on-Logout Tip +* update REAMDE with new bug tracker URL +* more dir fixes for El Capitan +* add testing for python 3.5 +* temporary dir fixes for OS X El Capitan (10.11) +* update to work with tox 2.1.1 +* Merged in jveatch/virtualenvwrapper/fix-py26-logging (pull request #41) +* Pass stream as arg rather than kwarg to avoid py26 conflict. Fixes issue #274. StreamHandler arg was named strm in python 2.6 +* enhance verbose output of hook loader +* Merged in erilem/virtualenvwrapper/user-scheme-installation (pull request #38) +* Change install docs to use --user + +4.7.0 +----- + +* Merged in gnawybol/virtualenvwrapper/support\_MINGW64 (pull request #36) +* Detect MSYS if MSYSTEM is MINGW64 +* Merged in kdeldycke/virtualenvwrapper/kdeldycke/restore-overridden-cd-command-to-its-def-1435073839852 (pull request #34) +* Restore overridden cd command to its default builtin behaviour + +4.6.0 +----- + +* remove some explicit tox environments +* Merged in jessamynsmith/virtualenvwrapper/py34 (pull request #30) +* quiet some of the lsvirtualenv tests +* add test for previous patch +* Merged in robsonpeixoto/virtualenvwrapper/bug/265 (pull request #33) +* Removes empty when list all virtualenvs +* Merged in justinabrahms/virtualenvwrapper/justinabrahms/update-links-and-name-for-venv-post-1431982402822 (pull request #32) +* Update links and name for venv post +* Added testing and updated docs for python 3.4 +* Merged in jessamynsmith/virtualenvwrapper/env\_with\_space (pull request #28) +* Changes as per code review +* Added tests to verify that cpvirtualenv, lsvirtualenv, and mkproject work with spaces in env names +* Made rmvirtualenv work with spaces +* Added tests for leading spaces (trailing spaces don't work in Linux, so don't test them) +* Made lsvirtualenv and allvirtualenv work with spaces in env names +* Made cd command work with space in virtualenv name +* Fixed ordering in asserts for workon tests +* Made workon fully support virtualenvs with spaces in names +* fix default for VIRTUALENVWRAPPER\_WORKON\_CD + +4.5.0 +----- + +* Add -c/-n options to mktmpenv +* update mktmpenv test to assert changed directory +* Add test for creating venv with space in name + +4.4.1 +----- + +* Touch temporary file after a name is created +* document 'workon .' and give attribution +* Support "workon ." +* fix pep8 error +* make cd after workon optional +* fix sphinx build +* Merged in hjwp/virtualenvwrapper (pull request #25) +* Stop mangling the python argument to virtualenv +* ignore -f lines in pip freeze output +* Merged in bittner/virtualenvwrapper (pull request #22) +* hacked attempt to get round MSYS\_HOME environ dependency on windows/git-bash/msys +* Change "distribute" to "setuptools" in docs +* Merged in jessamynsmith/virtualenvwrapper (pull request #23) +* Override tox's desire to install pre-releases +* Reworded the documentation around user scripts vs plugin creation, to make it more clear which one you need. Also added a simple example of user scripts +* do not install distribute in test environments +* Correct spelling of "Bitbucket" +* Update issue tracker URL + +4.3.2 +----- + +* build universal wheels +* Merged in das\_g/virtualenvwrapper/das\_g/removed-gratuitous-preposition-1413208408920 (pull request #19) +* removed gratuitous preposition +* Fix test invocation for zsh +* add -q option to cd for zsh +* make run\_tests use the SHELL var to run test script + +4.3.1 +----- + +* pep8 and test updates for previous commit +* Make postmkproject use VIRTUALENVWRAPPER\_HOOK\_DIR +* Tell tox it is ok to run shells not installed in the virtualenv +* Set VIRTUALENVWRAPPER\_SCRIPT correctly for different shells +* Merged in nishikar/virtualenvwrapper (pull request #14) +* changed phrasing of environment not found message +* Add tests for wipenv with editable packages +* Remove obsolete information about pip environment vars +* Replace manually maintained history with ChangeLog +* Update doc build to fail if there are warnings + +4.3 +--- + +* remove announce.rst; move to blogging repository +* Merged in erikb85/virtualenvwrapper/erikb85/run-user-postactivate-after-changing-dir-1401272364804 (pull request #15) +* Run User Postactivate after changing dirs +* add link to sublimetext extension +* moved environment exists check below active environment check +* added no such environment prompt to rmvirtualenv if it does not exist +* updated pep8 +* clean up script mode changes +* forgotten comment +* trailing whitespace removed +* tabs expanded; mode difference +* changed comments and mode for sourced scripts +* ignore bin, include, lib +* mode constant for sourced-only files +* do not specify a version for pbr +* Merged in mjbrooks/virtualenvwrapper (pull request #12) +* use VIRTUALENVWRAPPER\_ENV\_BIN\_DIR throughout +* Extract basic help text from the script +* Add list of commands as basic help output +* update author email +* clean up comment about zsh behavior in lazy +* Fix syntax error (empty \`if\` block) + +4.2 +--- + +* update docs for 4.2 release +* update history for previous change; fix syntax issue in previous change +* update history +* Do not create hooks for rmproject +* make setvirtualenvproject honor relative paths +* Ensure hook directory exists +* fix indentation in virtualenvwrapper\_lazy.sh +* use valid syntax for creating tmpdir under linux +* stop python 3.2 tests +* stop using distribute for packaging the test templates +* fix merge issue from previous commit +* Fix mkvirtualenv -a relative paths +* minor: tabs to spaces +* Fix zsh crash caused by lazily loading the completions +* Fix hint in error message, when virtualenvwrapper\_run\_hook failed +* changed spelling of proj\_name calculation +* Fix \`which\` with virtualenvwrapper\_lazy.sh +* use virtualenvwrapper\_cd in project plugin +* document new force option in history +* Merged in claymcclure/virtualenvwrapper (pull request #2) +* update history for doc fix from dirn +* Merged in dirn/virtualenvwrapper/dirn/fix-documentation-for-allvirtualenv-the-1375587964876 (pull request #4) +* update history for cd command fix +* consolidate 'ls' tests +* update test to handle change easy\_install +* ignore any egg directories created while packaging +* add tests to make sure we override cd properly +* Merged in isbadawi/virtualenvwrapper (pull request #5) +* Always use virtualenvwrapper\_cd instead of cd +* Fix documentation for allvirtualenv +* Document \`mkproject --force\` usage +* Mention sphinxcontrib-bitbucket requirement +* Merged in mrdbr/virtualenvwrapper (pull request #3) +* add tmp- prefix to temporary envs +* Preserve quoting for allvirtualenv command arguments +* Add \`mkproject --force\` option +* Remove extraneous punctuation + +4.1.1 +----- + +* update history for 4.1.1 +* Merged in mordred/virtualenvwrapper (pull request #1) +* Take advantage of pbr 0.5.19 +* Working on packaging issue with 4.1 release + +4.1 +--- + +* prep for 4.1 release +* fix pep8 issue in user\_scripts.py +* quiet cdproject test +* one more parallel test issue +* use pbr for packaging +* Allow tests to run in parallel +* Fix virtualenv detection with spaces in WORKON\_HOME +* add license file +* Fix problem lsvirtualenv after previous commit +* Add allvirtualenv command +* Ensure that -p and --python options are consistent +* quiet tests +* add test for mkvirtualenv w/ site-packages +* ignore emacs TAGS file +* Provide a way to extend the lazy-loader +* Add wipeenv command +* Update ignore file +* remove trailing whitespace in tox.ini +* Quote paths +* Skip pushd/popd test under ksh +* Run the cdproject test in a subshell +* Show more details when running under zsh +* add doc explaining implementation choices +* add a warning to cpvirtualenv command docs +* fix rst in announcement file +* fix home page url +* add python 3.3 classifier +* Added tag 4.0 for changeset 2ba65a13f804 + +4.0 +--- + +* Prepare for 4.0 release +* Update Python 3 compatibility +* assume setuptools is available during the installation +* update tested-under version lists +* add attribution for previous fix to the history file +* Correct script name in error message +* reorg test runner to remove redundant test runs +* flake8 fixes for setup.py +* Prep 3.7.1 release +* Make --python option to mkvirtualenv not sticky +* Fix project template listing when none installed +* note change in the history file +* better prefix and fix for other help functions +* prevent workon\_help from polluting the global namespace +* Fixed broken screencast link +* Merged in dasevilla/virtualenvwrapper/link-fix (pull request #33) +* Update link to requirements docs +* Added tag 3.7 for changeset 303ff1485acb + +3.7 +--- + +* update version number +* Apply style to sphinx config file +* add link to flake8 in history +* use flake8 instead of pep8 for style checking +* Turn off logging by default +* Add help option to workon +* Add --help option to mkproject +* merge readme filename change +* Merged in jeffbyrnes/virtualenvwrapper (pull request #32) +* merge Add complete-time load to lazy loader +* Merged in upsuper/virtualenvwrapper (pull request #29) +* fix issue with toggleglobalsitepackages tests that was hidden by old test virtualenv +* show which virtualenv is used in tests +* do not check in test output +* Use $\_VIRTUALENVWRAPPER\_API instead of listing functions +* merge exclusion rules for doc build artifacts +* Added tag 3.6.1 for changeset c180ccae77b4 + +3.6.1 +----- + +* prepare 3.6.1 release +* Rename READMEs to be RST +* Added exclusion for docs/en, docs/es, and docs/ja to .hgignore +* Add complete-time load to lazy loader +* Fix link to setvirtualenvproject command +* merge fix for relative python interpreter option to mkvirtualenv +* Replace realpath with a more portable way of converting a relative path to an absolute path +* Fix typo in documentation +* Fix --python switch for virtualenv +* fix markup typo in announcement +* Added tag 3.6 for changeset 002a0ccdcc7a + +3.6 +--- + +* update version number before release, 2 +* update version number before release +* fix pep8 issues with setup.py +* fix pep8 issues with sphinx conf file +* Fix virtualenvwrapper\_show\_workon\_options under zsh with chpwd +* update history for previous change +* Update documentation to point to the real file where add2virtualenv command adds directories to PYTHONPATH +* update the links to the translated versions of the documentation +* change to the default theme for readthedocs.org +* move es and ja versions of docs to their own repositories +* add attribution to history file for previous patch +* fix issue with add2virtualenv and noclobber setting in shell; fixes #137 +* pep8 cleanup +* fix lazy-loader function definitions under zsh; fixes #144 +* use the right virtualenv binary to get help; fixes #148 +* convert hook loader to use stevedore +* fix reference in announcement +* Added tag 3.5 for changeset c93b81815391 + +3.5 +--- + +* bump version number and update announcement text +* fix whitespace and rename a few worker functions to be consistent with the rest +* document previous changes +* Use "command" to avoid aliases or functions that mask common utilities. fixes #119 +* quiet some test operations and check for error codes before continuing +* allow the caller to control which shells are used for tests; unset variables that might be inherited and give the wrong idea about what the current shell is for a test; export SHELL to point to the current shell +* add test for lazy loading via workon; addresses #144 +* update docs with link to virtualenvwrapper-win port; fixes #140 +* clean up cpvirtualenv documentation +* if cpvirtualenv fails to create the target directory, return an error code +* document cpvirtualenv addition +* merged upstream +* Forgot to uncommit the remove workon\_home in teardown +* update README with supported python versions +* Did not mean to commit isitepackages +* Update cpvirtualenv utilizing virtualenv-clone and allowing for external virutalenvs to be added to WORKON\_HOME +* fix xref endpoint used in install.rst +* Added tag 3.4 for changeset 07905d9135ac + +3.4 +--- + +* bump version +* update announcement +* clarify warning on tab completion +* add lazy loader +* move error reporting for bad python interpreter closer to where the error occurs +* Invoke the initialization hooks directly when testing for error with Python +* hide error messages +* fix section heading in announce blog post so the version number does not appear twice +* update announcement file for 3.3 release +* fix the requirement name +* remove old copy of requirements file +* add requirements file to try readthedocs again +* Added tag 3.3 for changeset 45877370548e + +3.3 +--- + +* prepare 3.3 release +* attribution for previous merge +* Merged in agriffis/virtualenvwrapper (pull request #22) +* clean up RST formatting +* attribution for previous merge +* Merged in barberj/vew/fix\_installing\_requirements\_after\_cd (pull request #21) +* Use spaces for indentation consistently instead of mixed spaces/tabs. No functional changes +* Quoting arguments to expandpath to allow for spaces in the arguments +* Update to get fully qualified path of requirments in case a directory change occurs before pip is called +* Clean up the temporary file in the virtualenvwrapper\_run\_hook error returns +* attribution for previous merge +* Merged in agriffis/virtualenvwrapper (pull request #20) +* Fix error handling in virtualenvwrapper\_tempfile; the typeset builtin will return success even if the command-substitution fails, so put them on separate lines +* catch --help option to mkvirtualenv; fixes #136 +* Remove the trap from virtualenvwrapper\_tempfile; the function is called in a command substitution, so the trap fires immediately to remove the file. There are ways to accomplish this, but they're complex and the caller is already explicitly rm'ing the file +* attribution for merging pull request 17 +* merge in hook listing and pep8 fixes +* pep8 changes +* Merged in bwanamarko/virtualenvwrapper (pull request #17) +* print the list of core hooks if no hook name is given in list mode +* attribution for previous merges +* Check that required test shells are available ahead of running tests. This avoids accidentally running tests with /bin/sh (dash) on Debian, which eventually deletes the ~/.virtualenvs directory. (Whoops.) +* Enforce running run\_tests under tox by setting/checking an env var +* another fix for msys users \* using lssitepackages \* keep $site\_packages in quotes in case of spaces +* fix bug for MSYS users - makes several folders, fails on shell startup \* if $WORKON\_HOME not defined, or folder missing, then when mkdir called must \* pass $WORKON\_HOME in double-quotes "$WORKON\_HOME" because there might be \* spaces that will be interpretted separately \* e.g. C:\Documents and Settings\.virtualenv makes 3 folders: \* "C:\Documents", "~/and" & "~/Settings/.virtualenv" +* update shell function virtualenvwrapper\_get\_site\_packages\_dir \* let MSYS users use lssitepackages & cdsitepackages \* replace $VIRTUAL\_ENV/bin with $VIRTUAL\_ENV/$VIRTUALENVWRAPPER\_ENV\_BIN\_DIR +* attribution for documentation work +* reset the default language +* revised the Japanese translation in plugins.rst +* revised the Japanese translation in index.rst +* merged the changes (r369:550) in extensions.rst +* merged the changes (r369:550) for Japanese translation in projects.rst +* merged the changes (r369:550) for Japanese translation in extensions.rst +* merged the changes (r369:550) for Japanese translation in developers.rst +* merged the changes (r369:550) for Japanese translation in tips.rst +* merged the changes (r369:550) for Japanese translation in scripts.rst +* merged the changes (r369:550) for Japanese translation +* merged the changes (r369:550) for Japanese translation +* changed LANGUAGE settings "en" to "ja" +* merged from original +* add attribution to history file for ralphbean's changes +* merge in permission changes from ralphbean +* Bypass the test for missing virtualenv if the user has it installed to the subset of the path needed for the shunit2 framework to function properly. Add a test for having VIRTUALENVWRAPER\_VIRTUALENV set to a program that does not exist +* Removed shebangs from scripts non-executable site-packages files +* Removed execution bit on virtualenvwrapper.sh +* update announcement blog post for 3.2 +* Added tag 3.2 for changeset dccf1a1abf4e + +3.2 +--- + +* bump version number +* Add a link target name for the rmvritualenv command +* Use distutils to get the site-packages directory. Fixes #112 +* more global test header cleanup +* Centralize setup of variables for tests. Change WORKON\_HOME and PROJECT\_HOME for tests to make them unique across runs, allowing simultaneous test runs in different sandboxes +* update history for previous merge +* Merged in ciberglo/virtualenvwrapper (pull request #13) +* add history details about license classification change +* Merged in ralphbean/virtualenvwrapper (pull request #14) +* attribution for previous commit +* Fix typo in documentation reported by Nick Martin +* Changed trove classifiers from BSD to MIT (like the README indicates.) +* add test for removing several environments +* changing rmvirtualenv message: Erasing --> Removing +* support to remove several environments at once +* remove blank spaces +* use typeset instead of local and provide attribution for the original fix +* Make project\_dir local so it doesn't clobber other variables +* Added tag 3.1 for changeset ebbb3ba81687 + +3.1 +--- + +* prepare release 3.1 +* quote the path as we are editing the pth file; fixes #132 +* update history file for previous change +* associate project before enabling the new virtualenv; fixes #122 +* add tags to announce.rst +* add a couple of debugging lines to the generated scripts +* Added tag 3.0.1 for changeset 14cf7e58d321 + +3.0.1 +----- + +* package release 3.0.1; fixes #126 +* Add test files to the sdist package. Addresses #126 +* Remove /usr/bin since apparently there are times when virtualenv is installed there due to vendor packages. Fixes #127 +* Added tag 3.0 for changeset 434b87ebc24a + +3.0 +--- + +* fix version info in trove classifiers, take 2 +* fix version info in trove classifiers +* use the version of python in the current virtualenv to install the template project into the tox virtualenv during the test +* merge in support for python 3.2 +* bump version number, update history, prepare announcement +* remove redundant test +* use the version of python in the virtualenv instead of depending on the PATH +* use packages available for python 3 +* use packages that can be installed under python 3 to test the -i option to mkvirtualenv +* get the output in a way that makes it work properly with grep +* include virtualenv in the test dependencies +* fix shell expression to get the python version +* fix indentation +* py3k compatibility +* py3k compatibility +* py3k compatibility +* Added tag 2.11.1 for changeset 12a1e0b65313 + +2.11.1 +------ + +* update history and version number for bug release +* Skiping re-initialization in subshells breaks tab completion, so go ahead and take the performance hit. Closes #121 +* quiet some tests +* announcement for 2.11 release +* Added tag 2.11 for changeset ff4d492c873c + +2.11 +---- + +* bump version number for release +* add VIRTUALENVWRAPPER\_PROJECT\_FILENAME; resolves issue 120 +* make log files group writable; resolves #62 +* shortcut initialization if it has run before +* Remove support for Python 2.4 and 2.5. Update tests to work with virtualenv 1.7, where --no-site-packages is now the default +* Add note about -a option to history file and clarify its description in the docs a bit +* documentation for -a flag +* test for 'mkvirtualenv -a ' +* add -a project\_path to mkvirtualenv usage summary +* associate a project with a venv at creation +* fix link to Justin Lily's helper post +* Added tag 2.10.1 for changeset 9e10c201a500 + +2.10.1 +------ + +* bump version to 2.10.1; closes #114 +* improve test for mktmpenv with options; addresses #114 +* change mktmpenv to always create an env name for the user; addresses #114 +* update announcement text +* bump version number +* document previous fix in history +* strip spaces from template names; fixes #111 +* fix template listing for python 2.4, which does not support the -m option with namespace packages +* if uuid is not available, use random to generate a name for the new environment +* Use old style string formatting instead of the format method to retain python 2.4 and 2.5 support +* add test to ensure templates are applied correctly +* get the version number from the packaging scripts +* add mktmpenv command from virtualenvwrapper.tmpenv +* add -i option to mkvirtualenv +* more test quieting +* quiet tests and add intermediate check for delete +* fix use of sed in add2virtualenv to be more portable +* quiet test +* Merged in miracle2k/virtualenvwrapper (pull request #6) +* merge in linux changes +* ignore temporary files created by editor +* variable name changes and other cleanup so the script does not bomb under ksh on ubunutu 11.04 +* run each test script in every shell before moving to the next script +* Make add2virtualenv tests work again, add new test code for new features +* Update lssitepackages to work with new pth filename +* Merged upstream +* add link to changelog in readme +* fix version number in history +* update announcement file +* Upgrade instructions +* Clean up help functions. Add documentation for new -r option to mkvirtualenv +* Add -r option to mkvirtualenv to install base requirements after the environment is created. Fix argument processing in mkproject so the correct template names are preserved +* merge virtualenvwrapper.project features into virtualenvwrapper +* convert function definition format so typeset works under ksh +* Merged upstream +* add link to powershell port +* Added tag 2.8 for changeset 279244c0fa41 + +2.8 +--- + +* set version in history and update announcement +* Added tag 2.8 for changeset 7e0abe005937 +* bump version number +* merge in patches from noirbizarre to add support for MSYS environment; clean up doc addition; fix resulting problem is lsvirtualenv +* Identify another --no-site-packages test and add one for cpvirtualenv using the default args variable; addresses #102 +* add test for --no-site-packages flag after cpvirtualenv; addresses #102 +* Escape uses of cd in case it is aliased. addresses #101 +* add a test to verify pushd/popd behavior; addresses #101 +* Set is\_msys to False when not in MSYS shell +* Avoid declaring the 'command\_exists' function for a one shot use +* Replaced all remaining 'bin' occurences by $VIRTUALENVWRAPPER\_ENV\_BIN\_DIR +* Use VIRTUALENVWRAPPER\_VIRTUALENV in cpvirtualenv. fixes #104 +* Merged in sharat87/virtualenvwrapper (pull request #1) +* Update documentation about mktemp +* VIRTUALENVWRAPPER\_VIRTUALENV\_ARGS not working with >1 args on zsh +* User scripts should be called based on new $VIRTUALENVWRAPPER\_ENV\_BIN\_DIR variable +* add some debugging and a test to try to reproduce problem with log directory variable; addresses #95 +* move tab completion initialization; expand support for tab completion in zsh (fixes #97) +* Added support for getopts with fallback on getopt +* Improved variable name: VIRTUALENVWRAPPER\_ENV\_BIN\_DIR instead of script\_folder and is\_msys instead of msys +* Document MSys installation +* Allow Win32 and Unix paths for MSYS\_HOME variable +* Added msys paths support +* update announce file +* Added tag 2.7.1 for changeset b20cf787d8e1 + +2.7.1 +----- + +* bump version number for bug release +* set log dir and hook dir variables after WORKON\_HOME is set; fixes #94 +* link to documentation about installing into user directory +* further installation doc clarification +* add a warning about installing into a virtualenv +* clarify instructions for running tests; fixes #92 +* report an error if there are no test scripts +* Added tag 2.7 for changeset ea378ef00313 + +2.7 +--- + +* update version and draft announcement +* add grep fix to history +* remove -e option from all calls to grep for better portability; fixes #85 +* nicer titles for configuration section +* reorg install docs to separate the customization stuff; add some comments about site-wide installation; fixes #87 +* make it possible to remove a virtualenv while inside it; fixes #83 +* pass VIRTUALENVWRAPPER\_VIRTUALENV\_ARGS when calling VIRTUALENVWRAPPER\_VIRTUALENV; fixes #89; fixes #87 +* add link to vim-virtualenv +* enable tab completion for showvirtualenv; fixes #78 +* clean up test instructions for developers; fixes #75 +* clear configuration variables before running tests +* fix typo in cpvirtualenv; fixes #71 +* Add VIRTUALENVWRAPPER\_LOG\_DIR variable +* Use VIRTUALENVWRAPPER\_HOOK\_DIR to control where the hooks are defined +* doc updates for VIRTUALENVWRAPPER\_VIRTUALENV +* fix tests to work under ksh on ubuntu 10.10 by using alternate syntax for capturing messages sent to stderr +* fix tempdir tests to work on ubuntu 10.10 +* merge pmclanahan's test changes and toggleglobalsitepackages +* Add attribution for recent patches to the history file +* fix tests for changes to virtualenvwrapper\_verify\_workon\_home +* suppress hook loader messages in tests +* change verbosity level when creating hook scripts so the messages can be suppressed in tests +* Added docs for the toggleglobalsitepackages command +* Added "toggleglobalsitepackages" command. Added tests for the new command +* Modified the test runner to reliably use the intended shells +* fix arg handling for lsvirtualenv under zsh - fixes issue #86 +* remove the custom functions from the sphinx config, since rtd does not support them +* trying readthedocs again +* ignore .orig files created by hg +* fix lsvirtualenv to read args in zsh +* remove the download url since I upload packages to pypi now +* translated 2.6.2/2.6.3 history into Japanese +* fixes issue 79 by enclosing WORKON\_HOME in quotes +* merged from original +* Added tag 2.6.3 for changeset 246ce68795ea + +2.6.3 +----- + +* tweak history +* Added tag 2.6.3 for changeset e7582879df06 +* more doc build changes +* add upload target +* Added tag 2.6.2 for changeset 625d85d3136f + +2.6.2 +----- + +* fix doc build for readthedocs.org +* add test for space in WORKON\_HOME to address #79 +* add a test to verify that when virtualenv fails to create an environment the hook scripts are not run. see #76 +* merged a few fixes and updated history +* update history +* merge in japanese translation of documentation, with a few markup fixes; disable spelling extension until there is a python 2.7 installer for it +* add spelling extension +* Added Japanese translation for the documentation Added to make html/website for the Japanese documentation Added the Japanese documentation link in original English index.rst +* restore download url +* Added tag 2.6.1 for changeset 445a58d5a05a + +2.6.1 +----- + +* version 2.6.1 +* fixes issue #73 by changing virtualenvwrapper\_get\_python\_version to only include the major and minor numbers +* add supported version info to readme so it appears on pypi page +* Added tag 2.6 for changeset b0f27c65fa64 + +2.6 +--- + +* bump version to 2.6 and document updates +* avoid specifying text mode when creating hook scripts (fixes #68) +* closes #70 by adding a list of supported shells and python versions to documentation and trove classifiers +* fix #60 by setting install\_requires instead of requires +* change the way we determine the python version +* convert test scripts to use tox instead of home-grown multi-version system in the Makefile +* create the WORKON\_HOME dir if it doesn't exist +* fix platforms definition so upload to pypi will work +* Added tag 2.5.3 for changeset dc74f106d8d2 + +2.5.3 +----- + +* point release before uploading sdist +* Added tag 2.5.2 for changeset f71ffbb996c4 + +2.5.2 +----- + +* Make lsvirtualenv work under zsh using patch from Zach Voase. Fixes #64 +* Added tag 2.5.1 for changeset 2ab678413a29 + +2.5.1 +----- + +* fix workon to list in brief mode +* Added tag 2.5 for changeset 80e2fcda77ac + +2.5 +--- + +* bump version +* add docs for showvirtualenv +* add showvirtualenv and re-implement lsvirtualenv with it +* Added tag 2.4 for changeset a85d80e88996 + +2.4 +--- + +* tweak history file +* Added tag 2.4 for changeset 64f858d461d4 +* add lsvirtualenv command with -l option +* Added tag 2.3 for changeset b9d4591458bb + +2.3 +--- + +* add get\_env\_details hook +* Added tag 2.2.2 for changeset 266a166f80da + +2.2.2 +----- + +* bump version to 2.2.2 +* check exit code of virtualenv before proceeding (fixes #56) +* use single quotes around regex with $ (see #55) +* update history with changes (see #57) +* escape more commands (see #57) +* incorporate patch from fredpalmer to escape grep calls (fixes #57) +* Added tag 2.2.1 for changeset 87d60f20a715 + +2.2.1 +----- + +* fix #50 by escaping rm before calling it +* Added tag 2.2.1 for changeset 66a89d019905 +* bump version to 2.2.1 +* convert path deriving code in startup of script to function so it is easier to test +* escape dollar sign in regex to resolve #53 +* add tests for GREP\_OPTIONS problem (ref #51) +* unset GREP\_OPTIONS before to use grep +* add support and bug tracker link to readme and docs +* ignore missing files in trap cleanup (see #38) +* address #37 with wording change in docs +* update history +* address issue #46 by escaping the calls to which +* Added tag 2.2 for changeset d5c5faecc92d + +2.2 +--- + +* bump version number +* more test refinements +* add trap to remove temporary file, see #38 +* more tempfile fixes +* changes to make the tests run on my linux host +* mention changes to address ticket 35 in history +* addresses ticket 35 by adding debugging instrumentation +* since we always use the same config dir, set it once +* unify sphinx config files +* use the sphinxcontrib.bitbucket extension for links to the issues and changesets in history.rst +* update history with recent changes +* fix tests; clean up contributed changes +* Fixing a bug in the call to mktemp +* Some cleanup after talking with dhellmann +* First pass at speeding things up by making fewer calls into Python. Needs review +* review for text added by Doug about the translation +* show python version in test progress messages +* fix #44 by updating the tests to run with python 2.7b1 +* fix #43 by switching the way the hook loader is run +* Added tag 2.1.1 for changeset 7540fc7d8e63 + +2.1.1 +----- + +* setting up for a release +* fix #42 by quieting the errors/warnings +* fix #41 by using the cached python where the wrappers are installed +* fix formatting of seealso block +* link to Manuel's home page instead of just the translation +* add link back to english docs +* add attribution for Manuel +* add link from english to spanish docs; update history +* shift output directory for html build so the sdist package looks nicer +* merge in spanish translation +* another attempt to address #35 +* added italic to deactivation +* announce translation +* english paragraph removed +* README translated +* first revision +* index revision +* markup fix +* aspell to plugins and fix some paragraphs +* aspell for script +* aspell to install +* aspell to index +* aspell to hooks +* aspell for extensions +* aspell for developers +* aspell for command\_ref +* another paragraph +* almost done for plugins.rst +* continue the translation +* continue the translation of plugins.rst +* remove the option that copy the static files: we don't have file to copy and it generate a WARNING in the sphinx compilation +* markup fixed +* remove translation from the toctree +* scripts.rst tranlated to spanish +* remove old version of translations.rst, we don't need this file anymore +* I don't think that we need to translate the ChangeLog +* extensions.rst translated +* tips.rst translated +* rst markup fixed +* typo fixed on english documentation +* fix the Makefile to generate the website documentation for 'en' and 'es' languages +* reorder the documents files in docs/LANGUAGE folders and modify the rules in the Makefile to build the documentation +* merge from Doug commit. Added the base.html template to make the website documentation +* Makefile modified to build "es" documentation +* put the base template in the repository +* developers.rst translated +* typo fixed +* continue plugins.rst translation +* Fix typo found by humitos +* starting with "Defining an Extension" +* start to translate plugins.rst +* hooks translated +* translations in the index page +* added some translated topics +* added the translation for install.rst +* index.rst translated to spanish +* fixed the right bug :) +* update announcement for 2.1 +* add emacs directive to readme +* Added tag 2.1 for changeset 241df6c36860 + +2.1 +--- + +* bump version +* rotate log file when it grows too big +* do not include website html in sdist +* do not include html docs inside virtualenvwrapper dir to avoid conflicts with other packages using that namespace +* fix mkvirtualenv -h +* doc updates +* add references to new extensions +* add -n and -l options to hook loader +* update docs with examples +* handle empty workon\_home dir properly +* support nondescructive argument to deactivate +* include a date value in the filename +* fix #34 by using python's tempfile module instead of a shell command +* add hooks for cpvirtualenv; make deactivate work better under ksh +* Update docs for mkvirtualenv to fix #30 +* fix #33 with improved installation instructions and a better error message +* use tempfile to create temporary files instead of the process id so the filenames are less predictable +* update contributing info +* add attribution for research work for ksh port +* add support for ksh (fixes #25) +* copy dist file to desktop after building +* Added tag 2.0.2 for changeset 6a51a81454ae + +2.0.2 +----- + +* update version and history +* fix #32 by removing use of 'with' ; add tests for python 2.6 and 2.5 +* sort ignore lines and add build directory +* Added tag 2.0.1 for changeset 91e1124c6831 + +2.0.1 +----- + +* update version and history +* add documentation about temp files +* fix #29 by checking TMPDIR and using a default if no value is found +* save draft of email for announcing new releases on python-announce +* Added tag 2.0 for changeset 54713c4552c2 + +2.0 +--- + +* fix install dir for web docs +* Added tag 2.0 for changeset 485e1999adf0 +* move todo list out of hg repo +* add namespace package declaration +* include more motivational background +* add help to Makefile +* merge 2.0 changes into tip +* status update +* even more doc cleanup +* doc restructuring +* remove rudundant 'source' from cli +* more doc cleanup +* more doc cleanup +* update extension entry point docs +* move make\_hooks functionality into user\_scripts, since they are related +* start overhauling doc content +* test cleanup and enhancement +* add VIRTUALENVWRAPPER\_LAST\_VIRTUAL\_ENV variable for postdeactivate scripts +* use the user's current shell as the default interpreter in the hook script +* quiet hook loader +* minor doc updates and formatting changes +* comment out debug logging +* all existing tests are passing again +* convert more hooks; stop running tests when we see a failure or error +* implement initialize hooks +* start implementing hook loader and a couple of sample hooks +* rename wrapper script +* add register rule +* update installation test +* don't need pavement.py any more +* add rules for updating website +* set version in Makefile before building html +* more tasks +* add test rules +* start moving from paver back to make and distribute +* reorg todo list +* add todo list and design notes for hook scripts +* Added tag 1.27 for changeset d64869519c2e + +1.27 +---- + +* add explicit check for virtualenv in the test +* Added tag 1.27 for changeset 3edf5f224815 +* bump version; pre-release code cleanup +* add note about relocatable side-effect +* undo merge, tests moved to separate files +* touch up tests +* flush formatting prints +* quiet tests +* ignore build files created by tests +* added test that copied virtualenv exists +* resolve conflict on tests dispatch +* added script to setup.py +* add testpackage setup.py +* Added tag 1.26 for changeset 51eef82a39d4 + +1.26 +---- + +* preparing version 1.26 for release +* fix #26 by quieting the error message during init and only showing it when an action is explicitly taken by the user +* remove directories likely to contain a site-wide virtualenv installation and hide the error message because we expect mkvirtualenv to fail +* break up the tests to make it easier to run only part of them +* run all tests on all shells +* Added tag 1.25 for changeset 06229877a640 + +1.25 +---- + +* add cdsitepackages arg handling from William McVey +* Added test for cdsitepackages with argument +* Updated with expanded capability of cdsitepackages to cd to a subdir +* Added tab completion and pathname argument handling to cdsitepackages +* I didn't know about 'sed -i', makes this a lot easier +* When echoing the current list of paths, do not include the 'import' lines +* Test for existance of path file was broken, used the wrong test +* New -d option to 'add2virtualenv' which allows removal of a path previously added +* Make sure that paths added via 'add2virtualenv' always end up being listed \*before\* regularily installed packages in sys.path. This ensures that you can always use the command to replace an installed package with a out-of-virtualenv version +* Added tag 1.24.2 for changeset f31869779141 + +1.24.2 +------ + +* update history and bump version +* update history +* add user-provided tips to the docs +* switch doc theme for packaged docs; add link to Rich Leland's screencast +* Added tag 1.24.1 for changeset 4a8870326d84 + +1.24.1 +------ + +* bump version num before new release +* add license and home page info to top of script +* Added tag 1.24 for changeset b243d023094b + +1.24 +---- + +* bump version and update history +* fix preactivate scripts; warn for existing scripts that need to be executable but are not +* Added tag 1.23 for changeset e55e8a54de7b + +1.23 +---- + +* prep for release +* test both mkvirtualenv hooks +* fix the postmkvirtualenv hook +* Added tag 1.22 for changeset c50385e9c99b + +1.22 +---- + +* bump version +* Added tag 1.22 for changeset eddb2921783c +* automatically create hook scripts +* add mode specification for emacs +* update README instructions +* Added tag 1.21 for changeset 2190584becc7 + +1.21 +---- + +* update version for new release +* Added tag 1.21 for changeset c11ee7913230 +* verify that virtualenv is installed; correct use of python to fix the WORKON\_HOME value; more tests +* improve handling for missing WORKON\_HOME variable or directory; add test for #18 - can't reproduce +* Added tag 1.20 for changeset ed873ac408ff + +1.20 +---- + +* prepare release +* minor code cleanup +* added simple lssitepackages test +* lssitepackages now also shows contents of virtualenv\_path\_extensions.pth, if that file exists +* added a white-line at the end +* added lssitepackages info +* added lssitepackages command +* moved main website source files +* Added tag 1.19 for changeset 8af191bfa3c8 + +1.19 +---- + +* fix for ticket #14: relative paths don't work with add2virtualenv +* incorporate patch from Sascha Brossmann to fix #15 +* Applying my own ridiculous formatting to the README file. Give me 72 characters or give me death! +* Added tag 1.18 for changeset 24190e878fa8 + +1.18 +---- + +* bump version number +* don't forget the destdir info +* add basic developer info to the documentation +* add docs for deactivate to resolve issue #12 +* fix issue #10 by removing warning and using an error at runtime +* Added tag 1.17.1 for changeset 10fbaab7da41 + +1.17.1 +------ + +* update pavement to use sphinxcontrib.paverutils +* Added tag 1.17 for changeset 749030a692a0 + +1.17 +---- + +* add installation test task +* incorporate personal site templates into a build that lets me generate hosted docs +* formatting tweaks +* add feature list; clean up hook list; fix bug in warning message generation +* cannot run package from command line, so just warn on import +* create a simple python package and include the documentation in it so it is installed by default +* clean up and update docs, reduce size of readme, start working on packaging changes +* import documentation contribution from Steve Steiner +* run the tests under zsh as well as explicitly invoking bash +* Added tag 1.16 for changeset 7d9dbc84f25d + +1.16 +---- + +* bump version +* remove todo list +* Redirect all error messages from stdout to stderr Added directory completion for cdvirtualenv +* Allow cdvirtualenv to take an argument which is a directory under the virtualenv root to change into +* Added tag 1.15 for changeset bddfac3c8fde + +1.15 +---- + +* prep release 1.15 +* error handling in mkvirtualenv +* add tests to sdist package +* Added tag 1.14 for changeset 6e54ea32a9d1 + +1.14 +---- + +* use dist\_dir option for sdist command +* Added tag 1.14 for changeset caf3f2a31fdd +* update version # +* Added tag 1.14 for changeset e31542a0d946 +* update change list +* fix virtualenvwrapper\_show\_workon\_options to use find again +* rewrite tests using shutil2 +* experimental version of deactivate wrapper +* Added tag 1.13 for changeset 7c40caf6ce6f + +1.13 +---- + +* add test.sh to manifest +* Added tag 1.13 for changeset 8e73805a97e1 +* fix for issue #5 +* Added tag 1.12 for changeset dda0e4d36a91 + +1.12 +---- + +* fix verification in navigation functions and add tests +* Add a couple of quick-navigation helper functions +* add attribution +* check return code from virtualenvwrapper\_verify\_workon\_home everywhere and return an error code if validation fails +* Update quick setup instructions to make them a little easier to follow and to fix a mistake in the order of some of the steps +* Added tag 1.11 for changeset 511994f15d58 + +1.11 +---- + +* run global postactivatehook before local; move release not to the correct version +* merge ChrisHas35's postactivatehook changes +* start 1.11 with optimization suggestion from ChrisHas35 +* Added tag 1.10 for changeset 274d4576d606 +* add global postactivate hook. related to #3 +* remove unnecssary egrep calls on show\_workon\_options. fixes #4 + +1.10 +---- + +* update change history +* Updated 'workon' to use find, to avoid problems with colorized 'ls' output +* Added tag 1.9 for changeset d8112e52eadc + +1.9 +--- + +* add more hooks based on suggestion from Chris Hasenpflug; add documentation +* Added tag 1.8.1 for changeset 8417344df8ff + +1.8.1 +----- + +* bump version number +* Added tag 1.8.1 for changeset dca76424222e +* fix argument processing in mkvirtualenv +* Added tag 1.8 for changeset ea5f27af83bb + +1.8 +--- + +* Fix for processing the argument list in mkvirtualenv from jorgevargas (#1) +* Added tag 1.7 for changeset 32f2a081d649 + +1.7 +--- + +* Clean up TODO list and svn keywords. Add license section to README +* Added tag 1.7 for changeset 54aa96a1c09f +* Ignore files generated by paver and the build process. Use a fixed version string in the pavement.py file +* update tags +* convert from make to paver 1.0 +* patches to rmvirtualenv to make it work with zsh from Byron Clark +* add note about zsh completion support +* add zsh completion support, courtesy of Ted Leung +* add docs; fix space issues +* remove premature release +* add path management feature contributed by James Bennett +* fix another typo, TEST, then add another useful message when the user tries to remove an active environment +* fix spelling mistake + +1.6.1 +----- + +* bug fix from John Shimek +* Add tab completion based on Arthur Koziel's version at http://arthurkoziel.com/2008/10/11/virtualenvwrapper-bash-completion/ +* fix the download url + +1.3 +--- + +* add setup.py and related pieces, including minimal docs +* usability patches from Alex Satrapa +* notes about what I still need to do +* cleanup +* predeactivate and postactivate hooks +* go ahead and change to the environment after creating it +* look for the workdir script and run it if we find it +* update comments +* add attribution +* keywords + +1.0 +--- + +* first copy +* start new project From 2fe0f73690e6f8f9a91b98e5f9aad6acdfb7b617 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Feb 2023 11:17:06 -0500 Subject: [PATCH 882/947] pkglint: check both package formats --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 48b11a7..ab01679 100644 --- a/tox.ini +++ b/tox.ini @@ -44,5 +44,5 @@ deps= check-python-versions commands= python -m build - twine check dist/*.tar.gz + twine check dist/*.tar.gz dist/*.whl check-python-versions --only pyproject.toml,.github/workflows/test.yml From f0b245f72705e3940bb66f432d3a0b6304c2cbce Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Feb 2023 13:46:08 -0500 Subject: [PATCH 883/947] docs: update requirements for build on rtd - Add importlib_metadata dependency for older python versions, which seems to be what is used on RTD. - Split the docs job out of the other style jobs and pin the version of Python to force the use of the separate library in CI builds of docs. - Update the mergify rules accordingly. --- .github/workflows/test.yml | 27 +++++++++++++++++++++++++++ .mergify.yml | 2 +- docs/requirements.txt | 2 ++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3d39c3c..a075696 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -121,3 +121,30 @@ jobs: - name: Run run: tox -e ${{ matrix.tox-environment }} + + # Test build the docs + docs: + runs-on: ubuntu-latest + if: ${{ !startsWith(github.ref, 'refs/tags') }} + + strategy: + fail-fast: false + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + # Pin this low because RTD doesn't seem to adopt new + # versions quickly and this ensures we don't have a + # dependency problem with importlib.metadata. + python-version: "3.9" + + - name: Install dependencies + run: python -m pip install tox + + - name: Run + run: tox -e docs diff --git a/.mergify.yml b/.mergify.yml index 6b41ced..ad3cb2c 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -54,7 +54,7 @@ pull_request_rules: - name: Automatic merge on approval conditions: - and: - - "check-success=style (docs)" + - "check-success=docs" - "check-success=style (style)" - "check-success=style (pkglint)" - "check-success=Test macOS (3.8)" diff --git a/docs/requirements.txt b/docs/requirements.txt index 0fca33e..1729741 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,3 +1,5 @@ # sphinxcontrib-bitbucket # sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3 sphinx +# We need importlib.metadata, which was added in 3.10. +importlib_metadata;python_version<'3.10' From 5e0d73a324ffda0e75e9a963989ebb68153fdecb Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Feb 2023 14:42:05 -0500 Subject: [PATCH 884/947] pin python version in doc build test RTD uses python 3.7 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a075696..438c5d5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -141,7 +141,7 @@ jobs: # Pin this low because RTD doesn't seem to adopt new # versions quickly and this ensures we don't have a # dependency problem with importlib.metadata. - python-version: "3.9" + python-version: "3.7" - name: Install dependencies run: python -m pip install tox From dbd54a45a7f76fc80df1a3df4af9e663a57aaa34 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Feb 2023 14:44:57 -0500 Subject: [PATCH 885/947] restore python 3.7 support This needs to be enabled for the package lint job to pass. The 3.7 jobs do not have to pass for Mergify to accept the PR. --- .github/workflows/test.yml | 1 + pyproject.toml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 438c5d5..4de60e7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,6 +16,7 @@ jobs: fail-fast: false matrix: python-version: + - 3.7 - 3.8 - 3.9 - "3.10" diff --git a/pyproject.toml b/pyproject.toml index 2233798..716d3e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -27,7 +28,7 @@ dynamic = ["version"] keywords = ["virtualenv"] license = {text = "MIT"} readme = "README.txt" -requires-python = ">=3.8" +requires-python = ">=3.7" dependencies = [ "virtualenv", From 6be4cdac72f136d9a5a928cbd58c2cbc9b634475 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Feb 2023 15:08:54 -0500 Subject: [PATCH 886/947] add virtualenvwrapper.version module Have setuptools_scm write a module with the package version so we don't need to use importlib.metadata to look up the value at runtime. This makes version handling more portable across versions of Python. --- .gitignore | 1 + docs/requirements.txt | 2 -- docs/source/conf.py | 5 +++-- pyproject.toml | 1 + tests/test_virtualenvwrapper.sh | 4 ++-- virtualenvwrapper/hook_loader.py | 8 ++++---- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 606759f..df625c4 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ syntax: re ^web/ .python-version .eggs +/virtualenvwrapper/version.py diff --git a/docs/requirements.txt b/docs/requirements.txt index 1729741..0fca33e 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,5 +1,3 @@ # sphinxcontrib-bitbucket # sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3 sphinx -# We need importlib.metadata, which was added in 3.10. -importlib_metadata;python_version<'3.10' diff --git a/docs/source/conf.py b/docs/source/conf.py index ab23616..6d46571 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -13,7 +13,8 @@ # serve to show the default. import datetime -import importlib.metadata + +import virtualenvwrapper.version # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -51,7 +52,7 @@ # built documents. # # The short X.Y version. -version = importlib.metadata.version('virtualenvwrapper') +version = virtualenvwrapper.version.version # The full version, including alpha/beta/rc tags. release = version diff --git a/pyproject.toml b/pyproject.toml index 716d3e7..1d1176a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,7 @@ dependencies = [ # https://github.com/pypa/setuptools_scm/ [tool.setuptools_scm] +write_to = "virtualenvwrapper/version.py" [project.urls] homepage = "https://virtualenvwrapper.readthedocs.io/" diff --git a/tests/test_virtualenvwrapper.sh b/tests/test_virtualenvwrapper.sh index 15556ec..fe9e689 100755 --- a/tests/test_virtualenvwrapper.sh +++ b/tests/test_virtualenvwrapper.sh @@ -27,13 +27,13 @@ test_virtualenvwrapper_script_set() { } test_virtualenvwrapper_version() { - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers typeset ver=$(_virtualenvwrapper_version) assertTrue "version is empty" "[ -n $ver ]" } test_virtualenvwrapper_help_shows_version() { - source "$test_dir/../virtualenvwrapper.sh" + load_wrappers typeset pattern="Version: $(_virtualenvwrapper_version)" assertTrue "version not in command output" "virtualenvwrapper | grep \"$pattern\"" } diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 6e95e44..449e651 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -13,8 +13,9 @@ import os import sys -from stevedore import ExtensionManager -from stevedore import NamedExtensionManager +from stevedore import ExtensionManager, NamedExtensionManager + +import virtualenvwrapper.version LOG_FORMAT = '%(asctime)s %(levelname)s %(name)s %(message)s' @@ -89,8 +90,7 @@ def main(): options, args = parser.parse_args() if options.version: - import importlib.metadata - print(importlib.metadata.version('virtualenvwrapper')) + print(virtualenvwrapper.version.version) return 0 root_logger = logging.getLogger('virtualenvwrapper') From 8fc971c63078e6e7a2b4bc7b75cdefb04342637a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 11 Feb 2023 15:42:14 -0500 Subject: [PATCH 887/947] doc build take version from git when package not installed --- docs/source/conf.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 6d46571..3d8530e 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,7 +14,15 @@ import datetime -import virtualenvwrapper.version +# Try to import the version from our package, but if that fails +# because of the way the RTD build works fall back to at least using +# the git tag information. +try: + from virtualenvwrapper.version import version +except ImportError: + import subprocess + p = subprocess.run(['git', 'describe'], stdout=subprocess.PIPE) + version = p.stdout.decode('utf-8').strip() # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -52,7 +60,7 @@ # built documents. # # The short X.Y version. -version = virtualenvwrapper.version.version +# version = "SEE IMPORTS ABOVE" # The full version, including alpha/beta/rc tags. release = version From 72acd99b15b25bfc25af7eff9d92cbc16e5a26cf Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 12 Feb 2023 09:39:12 -0500 Subject: [PATCH 888/947] docs: add read the docs configuration file Details from https://docs.readthedocs.io/en/stable/tutorial/index.html and https://mastodon.social/@hynek/109849829588314515 Addresses #49 --- .readthedocs.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .readthedocs.yaml diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..67875cf --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,12 @@ +version: 2 + +build: + os: "ubuntu-20.04" + tools: + python: "3.11" + +python: + # Install our python package before building the docs + install: + - method: pip + path: . From d896fb033447a845b2a764692a9752a316dbab4d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 12 Feb 2023 09:43:58 -0500 Subject: [PATCH 889/947] Revert "doc build take version from git when package not installed" This reverts commit 8fc971c63078e6e7a2b4bc7b75cdefb04342637a. We should not need this now that the rtd.org build is installing our package via pip. --- docs/source/conf.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 3d8530e..6d46571 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,15 +14,7 @@ import datetime -# Try to import the version from our package, but if that fails -# because of the way the RTD build works fall back to at least using -# the git tag information. -try: - from virtualenvwrapper.version import version -except ImportError: - import subprocess - p = subprocess.run(['git', 'describe'], stdout=subprocess.PIPE) - version = p.stdout.decode('utf-8').strip() +import virtualenvwrapper.version # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -60,7 +52,7 @@ # built documents. # # The short X.Y version. -# version = "SEE IMPORTS ABOVE" +version = virtualenvwrapper.version.version # The full version, including alpha/beta/rc tags. release = version From 5e330f400f1bc89b5f2ce63462e5bb3710f548cf Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 12 Feb 2023 09:44:22 -0500 Subject: [PATCH 890/947] Revert "restore python 3.7 support" This reverts commit dbd54a45a7f76fc80df1a3df4af9e663a57aaa34. We no longer need this now that rtd.org is using 3.11. --- .github/workflows/test.yml | 1 - pyproject.toml | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4de60e7..438c5d5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,6 @@ jobs: fail-fast: false matrix: python-version: - - 3.7 - 3.8 - 3.9 - "3.10" diff --git a/pyproject.toml b/pyproject.toml index 1d1176a..0c88714 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,6 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -28,7 +27,7 @@ dynamic = ["version"] keywords = ["virtualenv"] license = {text = "MIT"} readme = "README.txt" -requires-python = ">=3.7" +requires-python = ">=3.8" dependencies = [ "virtualenv", From 2f90581295b625c18d8b8d740c6db53581a17a8c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 12 Feb 2023 09:44:31 -0500 Subject: [PATCH 891/947] Revert "pin python version in doc build test" This reverts commit 5e0d73a324ffda0e75e9a963989ebb68153fdecb. --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 438c5d5..a075696 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -141,7 +141,7 @@ jobs: # Pin this low because RTD doesn't seem to adopt new # versions quickly and this ensures we don't have a # dependency problem with importlib.metadata. - python-version: "3.7" + python-version: "3.9" - name: Install dependencies run: python -m pip install tox From 1b86035e64dc0058d812abd74a74b5d1b81456e8 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 12 Feb 2023 09:45:28 -0500 Subject: [PATCH 892/947] docs: github action to test build should use same version rtd.org --- .github/workflows/test.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a075696..f90f4ed 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -138,10 +138,8 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - # Pin this low because RTD doesn't seem to adopt new - # versions quickly and this ensures we don't have a - # dependency problem with importlib.metadata. - python-version: "3.9" + # Pin this to the same version used on in .readthedocs.yaml + python-version: "3.11" - name: Install dependencies run: python -m pip install tox From 11c201ec9c08b5383f35fedeefa58a7c06a23583 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 12 Feb 2023 09:49:57 -0500 Subject: [PATCH 893/947] mergify: update documentation label rule to include rtd config file --- .mergify.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.mergify.yml b/.mergify.yml index ad3cb2c..c92fa0a 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -28,6 +28,7 @@ pull_request_rules: - "title~=^docs:" - "files~=docs" - "files~=.rst$" + - "files~=.readthedocs.yaml$" actions: label: add: From 78c0a298dc26453cf9eaef9096f119178d58b5bf Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 18 Feb 2023 13:58:58 -0500 Subject: [PATCH 894/947] add dependabot config Add configuration to look for updates to github actions. --- .github/dependabot.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..7a1392c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +# Via https://github.com/nedbat/scriv/blob/main/.github/dependabot.yml +# +# From: +# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/keeping-your-actions-up-to-date-with-dependabot +# Set update schedule for GitHub Actions + +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + # Check for updates to GitHub Actions once a week + interval: "weekly" From 99170ad99ac12db41c2c4929c83f460886df1140 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Mar 2023 20:07:37 +0000 Subject: [PATCH 895/947] Bump pypa/gh-action-pypi-publish from 1.6.4 to 1.7.1 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.6.4 to 1.7.1. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.6.4...v1.7.1) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/python-publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index 75a668f..d80c901 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -32,7 +32,7 @@ jobs: # This condition prevents PRs from being published as part of # the test job. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@v1.6.4 + uses: pypa/gh-action-pypi-publish@v1.7.1 with: password: ${{ secrets.PYPI_API_TOKEN }} verbose: true From 4cef53df5ea707403e72739f44d540a1898bf90b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Mar 2023 20:04:27 +0000 Subject: [PATCH 896/947] Bump pypa/gh-action-pypi-publish from 1.7.1 to 1.8.3 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.7.1 to 1.8.3. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.7.1...v1.8.3) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/python-publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index d80c901..daa6376 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -32,7 +32,7 @@ jobs: # This condition prevents PRs from being published as part of # the test job. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@v1.7.1 + uses: pypa/gh-action-pypi-publish@v1.8.3 with: password: ${{ secrets.PYPI_API_TOKEN }} verbose: true From d7b88d65db6a50ef36f23e324d234a8fad65b512 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 20:02:19 +0000 Subject: [PATCH 897/947] Bump pypa/gh-action-pypi-publish from 1.8.3 to 1.8.5 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.3 to 1.8.5. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.8.3...v1.8.5) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/python-publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index daa6376..232ae8b 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -32,7 +32,7 @@ jobs: # This condition prevents PRs from being published as part of # the test job. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@v1.8.3 + uses: pypa/gh-action-pypi-publish@v1.8.5 with: password: ${{ secrets.PYPI_API_TOKEN }} verbose: true From e33b3296545bf07242ba55781477302258b91c81 Mon Sep 17 00:00:00 2001 From: Neal Joslin Date: Thu, 13 Apr 2023 15:23:37 -0400 Subject: [PATCH 898/947] Changed workon's env switching to use OR not $? --- virtualenvwrapper.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index cf43626..edd9631 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -759,16 +759,14 @@ function workon { # before switching so we use our override function, # if it exists, but make sure it's the deactivate function # we set up - type deactivate >/dev/null 2>&1 - if [ $? -eq 0 ] - then + ! type deactivate >/dev/null 2>&1 || { typeset -f deactivate | grep 'typeset env_postdeactivate_hook' >/dev/null 2>&1 if [ $? -eq 0 ] then deactivate unset -f deactivate >/dev/null 2>&1 fi - fi + } virtualenvwrapper_run_hook "pre_activate" "$env_name" From d78588e4f50f39fbbbb3b322b47a5cbe94f59026 Mon Sep 17 00:00:00 2001 From: Evan Chong <40609285+evantkchong@users.noreply.github.com> Date: Sat, 15 Apr 2023 06:29:31 +0800 Subject: [PATCH 899/947] Update the tested Python versions to match README The following commit https://github.com/python-virtualenvwrapper/virtualenvwrapper/commit/af41484a4709503f6029830b91eb0ec0b4abb2a0 missed out on updating the tested Python versions in the documentation --- docs/source/install.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/install.rst b/docs/source/install.rst index 94de69e..7271cab 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -75,7 +75,7 @@ can download virtualenvwrapper-powershell_ from PyPI. Python Versions =============== -virtualenvwrapper is tested under Python 2.7-3.6. +virtualenvwrapper is tested under Python 3.8 - 3.11. .. _install-basic: From e36060e8348bacc6d01269b42c201beda6bb4df5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 20:01:28 +0000 Subject: [PATCH 900/947] Bump pypa/gh-action-pypi-publish from 1.8.5 to 1.8.6 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.5 to 1.8.6. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.8.5...v1.8.6) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/python-publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index 232ae8b..527d2e5 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -32,7 +32,7 @@ jobs: # This condition prevents PRs from being published as part of # the test job. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@v1.8.5 + uses: pypa/gh-action-pypi-publish@v1.8.6 with: password: ${{ secrets.PYPI_API_TOKEN }} verbose: true From 05ccf752512c74d212f746017f240c692f848983 Mon Sep 17 00:00:00 2001 From: Alfred Wingate Date: Mon, 19 Jun 2023 07:30:22 +0300 Subject: [PATCH 901/947] remove use of distutils * Python 3.11 deprecated distutils and Python 3.12 completely removed it * Removed find_package_data entirely as there was not package data to install Signed-off-by: Alfred Wingate --- tests/testtemplate/setup.py | 103 ------------------------------------ virtualenvwrapper.sh | 2 +- 2 files changed, 1 insertion(+), 104 deletions(-) diff --git a/tests/testtemplate/setup.py b/tests/testtemplate/setup.py index f18835e..6c9b794 100644 --- a/tests/testtemplate/setup.py +++ b/tests/testtemplate/setup.py @@ -5,102 +5,6 @@ from setuptools import setup, find_packages -from distutils.util import convert_path -from fnmatch import fnmatchcase - -import os -import sys - -############################################################################## -# find_package_data is an Ian Bicking creation. - -# Provided as an attribute, so you can append to these instead -# of replicating them: -standard_exclude = ('*.py', '*.pyc', '*~', '.*', '*.bak', '*.swp*') -standard_exclude_directories = ('.*', 'CVS', '_darcs', './build', - './dist', 'EGG-INFO', '*.egg-info') - - -def find_package_data( - where='.', package='', - exclude=standard_exclude, - exclude_directories=standard_exclude_directories, - only_in_packages=True, - show_ignored=False): - """ - Return a dictionary suitable for use in ``package_data`` - in a distutils ``setup.py`` file. - - The dictionary looks like:: - - {'package': [files]} - - Where ``files`` is a list of all the files in that package that - don't match anything in ``exclude``. - - If ``only_in_packages`` is true, then top-level directories that - are not packages won't be included (but directories under packages - will). - - Directories matching any pattern in ``exclude_directories`` will - be ignored; by default directories with leading ``.``, ``CVS``, - and ``_darcs`` will be ignored. - - If ``show_ignored`` is true, then all the files that aren't - included in package data are shown on stderr (for debugging - purposes). - - Note patterns use wildcards, or can be exact paths (including - leading ``./``), and all searching is case-insensitive. - - This function is by Ian Bicking. - """ - - out = {} - stack = [(convert_path(where), '', package, only_in_packages)] - while stack: - where, prefix, package, only_in_packages = stack.pop(0) - for name in os.listdir(where): - fn = os.path.join(where, name) - if os.path.isdir(fn): - bad_name = False - for pattern in exclude_directories: - if (fnmatchcase(name, pattern) - or fn.lower() == pattern.lower()): - bad_name = True - if show_ignored: - print >> sys.stderr, ( - "Directory %s ignored by pattern %s" - % (fn, pattern)) - break - if bad_name: - continue - if os.path.isfile(os.path.join(fn, '__init__.py')): - if not package: - new_package = name - else: - new_package = package + '.' + name - stack.append((fn, '', new_package, False)) - else: - stack.append((fn, prefix + name + '/', package, only_in_packages)) - elif package or not only_in_packages: - # is a file - bad_name = False - for pattern in exclude: - if (fnmatchcase(name, pattern) - or fn.lower() == pattern.lower()): - bad_name = True - if show_ignored: - print >> sys.stderr, ( - "File %s ignored by pattern %s" - % (fn, pattern)) - break - if bad_name: - continue - out.setdefault(package, []).append(prefix+name) - return out -############################################################################## - setup( name=PROJECT, version=VERSION, @@ -130,13 +34,6 @@ def find_package_data( packages=find_packages(), include_package_data=True, - # Scan the input for package information - # to grab any data files (text, images, etc.) - # associated with sub-packages. - package_data=find_package_data('mytemplates', - package='mytemplates', - only_in_packages=False, - ), entry_points={ 'virtualenvwrapper.project.template': [ diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index edd9631..afa5395 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -820,7 +820,7 @@ function virtualenvwrapper_get_python_version { # Prints the path to the site-packages directory for the current environment. function virtualenvwrapper_get_site_packages_dir { - "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/python" -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())" + "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/python" -c "import sysconfig; print(sysconfig.get_path('platlib'))" } # Path management for packages outside of the virtual env. From da927a0d64e039db1bab04f65563db94a7d07fb2 Mon Sep 17 00:00:00 2001 From: Alfred Wingate Date: Mon, 19 Jun 2023 07:34:57 +0300 Subject: [PATCH 902/947] install setuptools for test packages, use pip * setuptools isn't included in ensurepip in Python 3.12 * Use pip install instead of invoking setup.py directly, due to setuptools discouraging it and allowing updates for the tests packages to use PEP517 compliant build system to done seamlessly. Also don't need to invoke pip install -r requirements.txt. * editable_mode=compat is comparable to python setup.py develop. But setuptools doesn't guarantee the longevity of the feature. Removal of support for the legacy method would be a thing consider. Signed-off-by: Alfred Wingate --- tests/test_cp.sh | 2 +- tests/test_project_templates.sh | 2 +- tests/test_wipeenv.sh | 4 ++-- tests/testpackage/requirements.txt | 1 + tests/testtemplate/requirements.txt | 1 + 5 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 tests/testpackage/requirements.txt create mode 100644 tests/testtemplate/requirements.txt diff --git a/tests/test_cp.sh b/tests/test_cp.sh index b1b9b3d..cadd5ea 100755 --- a/tests/test_cp.sh +++ b/tests/test_cp.sh @@ -23,7 +23,7 @@ test_new_env_activated () { mkvirtualenv "source" >/dev/null 2>&1 RC=$? assertEquals "0" "$RC" - (cd tests/testpackage && python setup.py install) >/dev/null 2>&1 + (cd tests/testpackage && pip install .) >/dev/null 2>&1 cpvirtualenv "source" "destination" >/dev/null 2>&1 rmvirtualenv "source" >/dev/null 2>&1 testscript="$(which testscript.py)" diff --git a/tests/test_project_templates.sh b/tests/test_project_templates.sh index 5329cf6..32c7fcf 100755 --- a/tests/test_project_templates.sh +++ b/tests/test_project_templates.sh @@ -4,7 +4,7 @@ test_dir=$(dirname $0) source "$test_dir/setup.sh" oneTimeSetUp() { - (cd "$test_dir/testtemplate" && rm -rf build && "$VIRTUAL_ENV/bin/python" setup.py install) + (cd "$test_dir/testtemplate" && rm -rf build && "$VIRTUAL_ENV/bin/python" -m pip install .) rm -rf "$WORKON_HOME" mkdir -p "$WORKON_HOME" rm -rf "$PROJECT_HOME" diff --git a/tests/test_wipeenv.sh b/tests/test_wipeenv.sh index 3eb7b71..f731580 100755 --- a/tests/test_wipeenv.sh +++ b/tests/test_wipeenv.sh @@ -20,7 +20,7 @@ tearDown() { test_wipeenv () { mkvirtualenv "wipetest" >/dev/null 2>&1 - (cd tests/testpackage && python setup.py install) >/dev/null 2>&1 + (cd tests/testpackage && pip install .) >/dev/null 2>&1 before="$(pip freeze)" assertTrue "testpackage not installed" "pip freeze | grep testpackage" wipeenv >/dev/null 2>&1 @@ -52,7 +52,7 @@ test_wipeenv_pip_e () { test_wipeenv_develop () { mkvirtualenv "wipetest" >/dev/null 2>&1 - (cd tests/testpackage && python setup.py develop) >/dev/null 2>&1 + (cd tests/testpackage && pip install -e . --config-settings editable_mode=compat) >/dev/null 2>&1 before="$(pip freeze)" assertTrue "testpackage not installed" "pip freeze | grep testpackage" wipeenv >/dev/null 2>&1 diff --git a/tests/testpackage/requirements.txt b/tests/testpackage/requirements.txt new file mode 100644 index 0000000..49fe098 --- /dev/null +++ b/tests/testpackage/requirements.txt @@ -0,0 +1 @@ +setuptools diff --git a/tests/testtemplate/requirements.txt b/tests/testtemplate/requirements.txt new file mode 100644 index 0000000..49fe098 --- /dev/null +++ b/tests/testtemplate/requirements.txt @@ -0,0 +1 @@ +setuptools From 73e6f60297fbdcc547c63f438556a205dc145e16 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 19:06:31 +0000 Subject: [PATCH 903/947] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/python-publish.yaml | 2 +- .github/workflows/test.yml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index 527d2e5..e3fa676 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f90f4ed..7d73553 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: - "3.11" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 @@ -47,7 +47,7 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 @@ -78,7 +78,7 @@ jobs: - "3.11" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 @@ -107,7 +107,7 @@ jobs: - pkglint steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 @@ -131,7 +131,7 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 From 8a1a6a50b7c5e31b41684febbafeb6431d25a48f Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Thu, 7 Dec 2023 14:20:55 +0100 Subject: [PATCH 904/947] Fixed broken link in install docs. With setup.py usage deprecated in Python 3.12, the install guide was removed from the docs. Pin link to 3.11 version, pending a fuller modernization. --- docs/source/install.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/install.rst b/docs/source/install.rst index 7271cab..c7429dd 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -103,7 +103,7 @@ or:: An alternative to installing it into the global site-packages is to add it to `your user local directory -`__ +`__ (usually `~/.local`). :: From b8483762736bd3dc9c44a4a031bcde56a99a3452 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Dec 2023 19:12:04 +0000 Subject: [PATCH 905/947] Bump pypa/gh-action-pypi-publish from 1.8.6 to 1.8.11 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.6 to 1.8.11. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.8.6...v1.8.11) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/python-publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index e3fa676..9f54c9e 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -32,7 +32,7 @@ jobs: # This condition prevents PRs from being published as part of # the test job. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@v1.8.6 + uses: pypa/gh-action-pypi-publish@v1.8.11 with: password: ${{ secrets.PYPI_API_TOKEN }} verbose: true From 1f329ee422e22f3b72d1173b13058d5cc83f3a76 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 19:16:06 +0000 Subject: [PATCH 906/947] Bump actions/setup-python from 4 to 5 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/python-publish.yaml | 2 +- .github/workflows/test.yml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index 9f54c9e..3a33b00 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -18,7 +18,7 @@ jobs: with: fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: '3.x' - name: Install dependencies diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7d73553..aa74fe7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,7 @@ jobs: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -52,7 +52,7 @@ jobs: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.11" @@ -83,7 +83,7 @@ jobs: fetch-depth: 0 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -112,7 +112,7 @@ jobs: fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.11" @@ -136,7 +136,7 @@ jobs: fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: # Pin this to the same version used on in .readthedocs.yaml python-version: "3.11" From 8012c54eba7498a6dffa3d654ff7635af39b2f83 Mon Sep 17 00:00:00 2001 From: bendikro Date: Wed, 1 Nov 2023 15:53:08 +0100 Subject: [PATCH 907/947] Fix shell completion on FreeBSD sed on FreeBSD does not support '\s', and gives the error: "sed: 1: "/^\s*$/d": RE error: trailing backslash (\)" Fix by using POSIX bracket expression '[[:space:]]' --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index afa5395..66f0f07 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -586,7 +586,7 @@ function virtualenvwrapper_show_workon_options { | command \tr "\n" " " \ | command \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate |/|g" \ | command \tr "/" "\n" \ - | command \sed "/^\s*$/d" \ + | command \sed "/^[[:space:]]*$/d" \ | (unset GREP_OPTIONS; command \grep -E -v '^\*$') 2>/dev/null } From 2b731ff73f410455b5444496046526781cf515e7 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 21 Dec 2023 10:10:01 -0500 Subject: [PATCH 908/947] add python 3.12 to test matrix --- .github/workflows/test.yml | 1 + .mergify.yml | 1 + pyproject.toml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aa74fe7..fdf092d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,6 +20,7 @@ jobs: - 3.9 - "3.10" - "3.11" + - "3.12" steps: - uses: actions/checkout@v4 diff --git a/.mergify.yml b/.mergify.yml index c92fa0a..4d0825f 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -66,6 +66,7 @@ pull_request_rules: - "check-success=Test Ubuntu (3.9)" - "check-success=Test Ubuntu (3.10)" - "check-success=Test Ubuntu (3.11)" + - "check-success=Test Ubuntu (3.12)" - "check-success=Test Zsh" - "-draft" - "#approved-reviews-by>=1" diff --git a/pyproject.toml b/pyproject.toml index 0c88714..3e56976 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Intended Audience :: Developers", "Environment :: Console", ] From 15062c7fdfa07a3eb6ed2bb324c30e2e0968c4ad Mon Sep 17 00:00:00 2001 From: "Fabian P. Schmidt" Date: Sat, 4 Nov 2023 14:59:26 +0100 Subject: [PATCH 909/947] Improve error message for IOErrors --- virtualenvwrapper/hook_loader.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index 449e651..cb2c865 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -146,14 +146,15 @@ def main(): log.debug('Saving sourcable %s hooks to %s', hook, options.script_filename) options.sourcing = True - output = open(options.script_filename, "w") try: - output.write('# %s\n' % hook) - # output.write('echo %s\n' % hook) - # output.write('set -x\n') - run_hooks(hook + '_source', options, args, output) - finally: - output.close() + with open(options.script_filename, "w") as output: + output.write('# %s\n' % hook) + # output.write('echo %s\n' % hook) + # output.write('set -x\n') + run_hooks(hook + '_source', options, args, output) + except (IOError, OSError) as e: + log.error('Error while writing to %s: \n %s', options.script_filename, e) + sys.exit(1) return 0 From 389610ec663399c084bf1c4f859f239234dbce6f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 21 Dec 2023 10:29:39 -0500 Subject: [PATCH 910/947] fix linter issue --- virtualenvwrapper/hook_loader.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/virtualenvwrapper/hook_loader.py b/virtualenvwrapper/hook_loader.py index cb2c865..7fd5177 100644 --- a/virtualenvwrapper/hook_loader.py +++ b/virtualenvwrapper/hook_loader.py @@ -153,7 +153,8 @@ def main(): # output.write('set -x\n') run_hooks(hook + '_source', options, args, output) except (IOError, OSError) as e: - log.error('Error while writing to %s: \n %s', options.script_filename, e) + log.error('Error while writing to %s: \n %s', + options.script_filename, e) sys.exit(1) return 0 From d4e8f4b54b73e946ebd6272bb205c2664f575be7 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 21 Dec 2023 10:33:51 -0500 Subject: [PATCH 911/947] auto-approve PRs by main contributors --- .mergify.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.mergify.yml b/.mergify.yml index 4d0825f..a11448d 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -69,7 +69,10 @@ pull_request_rules: - "check-success=Test Ubuntu (3.12)" - "check-success=Test Zsh" - "-draft" - - "#approved-reviews-by>=1" + - or: + - "#approved-reviews-by>=1" + - "author=dhellmann" + - "author=jasonamyers" actions: merge: method: merge From dde918adec9816b8431a99680d589e1a152e433b Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 21 Dec 2023 10:34:02 -0500 Subject: [PATCH 912/947] auto-approve PRs from dependabot --- .mergify.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.mergify.yml b/.mergify.yml index a11448d..33f6c75 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -34,6 +34,14 @@ pull_request_rules: add: - documentation + - name: automatic approval for Dependabot pull requests + conditions: + - author=dependabot[bot] + actions: + review: + type: APPROVE + message: Automatically approving dependabot + - name: Add breaking-change label # https://docs.openstack.org/pbr/latest/user/features.html conditions: From 4d514e863b258c3798a8b4af3b1a9f1db9529932 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 21 Dec 2023 10:53:22 -0500 Subject: [PATCH 913/947] label PRs that can be automatically merged --- .mergify.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.mergify.yml b/.mergify.yml index 33f6c75..390f4eb 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -60,6 +60,17 @@ pull_request_rules: add: - feature + - name: Add automatic-merge label + conditions: + - or: + - "author=dhellmann" + - "author=jasonamyers" + - "label!=mergify" + actions: + label: + add: + - automatic-merge + - name: Automatic merge on approval conditions: - and: From 4538ef1b7409006a0d42f5f7d389dc0863b8acc4 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 21 Dec 2023 11:14:49 -0500 Subject: [PATCH 914/947] move linter dependencies to pyproject.toml --- pyproject.toml | 4 ++++ tox.ini | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3e56976..cb55989 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,10 @@ dependencies = [ "stevedore", ] +[project.optional-dependencies] +linter = [ + "flake8", +] # https://github.com/pypa/setuptools_scm/ [tool.setuptools_scm] write_to = "virtualenvwrapper/version.py" diff --git a/tox.ini b/tox.ini index ab01679..8305b6a 100644 --- a/tox.ini +++ b/tox.ini @@ -20,7 +20,7 @@ setenv = FAIL_FAST = true [testenv:style] -deps = flake8 +deps = .[linter] commands = flake8 virtualenvwrapper docs/source/conf.py [testenv:zsh] From 8d01e819aa822b237f23ebbab690e7d2d304ac9e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 21 Dec 2023 11:15:05 -0500 Subject: [PATCH 915/947] move build dependencies to pyproject.toml --- pyproject.toml | 6 ++++++ tox.ini | 5 +---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index cb55989..9da53ba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,12 @@ dependencies = [ linter = [ "flake8", ] +build = [ + "build", + "twine", + "check-python-versions", +] + # https://github.com/pypa/setuptools_scm/ [tool.setuptools_scm] write_to = "virtualenvwrapper/version.py" diff --git a/tox.ini b/tox.ini index 8305b6a..10187c2 100644 --- a/tox.ini +++ b/tox.ini @@ -38,10 +38,7 @@ commands = sphinx-build -W -j auto -b linkcheck -d docs/build/doctrees docs/source docs/build/linkcheck [testenv:pkglint] -deps= - build - twine - check-python-versions +deps=.[build] commands= python -m build twine check dist/*.tar.gz dist/*.whl From 4052c58d66fbc3d1b757e6f80bfad29820aec32d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 21 Dec 2023 11:15:20 -0500 Subject: [PATCH 916/947] fix the way packages are built in the public workflow --- .github/workflows/python-publish.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index 3a33b00..07cd061 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -24,10 +24,10 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine pbr + pip install .[build] - name: Build sdist and wheel run: | - python setup.py sdist bdist_wheel + python -m build - name: Publish distribution to PyPI # This condition prevents PRs from being published as part of # the test job. From 0ef778b1450fd7edd44df0ba680406bf29e1bfd8 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 21 Dec 2023 11:19:45 -0500 Subject: [PATCH 917/947] test python 3.12 on macos --- .github/workflows/test.yml | 1 + .mergify.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fdf092d..74b0237 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -77,6 +77,7 @@ jobs: - 3.9 - "3.10" - "3.11" + - "3.12" steps: - uses: actions/checkout@v4 diff --git a/.mergify.yml b/.mergify.yml index 390f4eb..d898af4 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -81,6 +81,7 @@ pull_request_rules: - "check-success=Test macOS (3.9)" - "check-success=Test macOS (3.10)" - "check-success=Test macOS (3.11)" + - "check-success=Test macOS (3.12)" - "check-success=Test Ubuntu (3.8)" - "check-success=Test Ubuntu (3.9)" - "check-success=Test Ubuntu (3.10)" From 9856c87aff74e6c9b6647faf2ee37f9cb2e31bef Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 21 Dec 2023 12:10:22 -0500 Subject: [PATCH 918/947] update release notes for 6.0.0.0a5 --- docs/source/history.rst | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index 0d46a23..9d3e0cc 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -1,11 +1,18 @@ CHANGES ======= -Unreleased ----------- +6.0.0.0a5 +--------- * add a --version option to the hook loader * modernize packaging +* docs: update requirements for build on rtd +* docs: add read the docs configuration file +* Changed workon's env switching to use OR not $? by @Nealium (pull request #59) +* Fix issues for python 3.12 by @parona-source (pull request #68) +* Fix shell completion on FreeBSD by @bendikro (pull request #86) +* add python 3.12 to test matrix +* Improve error message for IOErrors by @kerel-fs (pull request #81) 6.0.0.0a1 --------- From 54ee48a6d267ffc91da4bc3fd8e88a877a8a7d43 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 27 Dec 2023 12:37:29 -0500 Subject: [PATCH 919/947] update test declaration in readme --- README.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.txt b/README.txt index 415130e..6cd1554 100644 --- a/README.txt +++ b/README.txt @@ -61,7 +61,7 @@ we will link to it from this page. Python Versions =============== -virtualenvwrapper is tested under Python 3.8 - 3.11. +virtualenvwrapper is tested under Python 3.8 - 3.12 on macOS and Linux. ======= Support From d25845365351d63ea3e485dbf9dee0bd30133127 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 27 Jan 2024 14:43:32 -0500 Subject: [PATCH 920/947] source project_dir/.virtualenvwrapper/postactivate during activation --- virtualenvwrapper/project.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/virtualenvwrapper/project.py b/virtualenvwrapper/project.py index 51ec50b..c0f6439 100644 --- a/virtualenvwrapper/project.py +++ b/virtualenvwrapper/project.py @@ -58,4 +58,9 @@ def post_activate_source(args): -a "$VIRTUALENVWRAPPER_PROJECT_CD" = 1 ] && \ virtualenvwrapper_cd \ "$(cat \"$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME\")" +if [ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" ]; then + if [ -f "$(cat \"$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME\")/.virtualenvwrapper/postactivate" ]; then + source "$(cat \"$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME\")/.virtualenvwrapper/postactivate" + fi +fi """ From 427c4665d7de8e0edbf0732fb69f3bf381db5372 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 27 Jan 2024 14:44:36 -0500 Subject: [PATCH 921/947] source project-dir/.virtualenvwrapper/predeactivate when deactivating --- pyproject.toml | 1 + virtualenvwrapper/project.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9da53ba..8223276 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,6 +93,7 @@ project = "virtualenvwrapper.project:post_activate_source" user_scripts = "virtualenvwrapper.user_scripts:post_activate_source" [project.entry-points."virtualenvwrapper.pre_deactivate_source"] +project = "virtualenvwrapper.project:pre_deactivate_source" user_scripts = "virtualenvwrapper.user_scripts:pre_deactivate_source" [project.entry-points."virtualenvwrapper.post_deactivate_source"] diff --git a/virtualenvwrapper/project.py b/virtualenvwrapper/project.py index c0f6439..a255081 100644 --- a/virtualenvwrapper/project.py +++ b/virtualenvwrapper/project.py @@ -8,7 +8,7 @@ import logging import os -from virtualenvwrapper.user_scripts import make_hook, run_global, PERMISSIONS +from virtualenvwrapper.user_scripts import PERMISSIONS, make_hook, run_global log = logging.getLogger(__name__) @@ -64,3 +64,13 @@ def post_activate_source(args): fi fi """ + + +def pre_deactivate_source(args): + return """ +if [ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" ]; then + if [ -f "$(cat \"$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME\")/.virtualenvwrapper/predeactivate" ]; then + source "$(cat \"$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME\")/.virtualenvwrapper/predeactivate" + fi +fi +""" From 6302c43f48b4dd208e5d940b618089ad0ca1d765 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 27 Jan 2024 14:44:56 -0500 Subject: [PATCH 922/947] document project hook directories --- docs/source/projects.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/source/projects.rst b/docs/source/projects.rst index d5f6e63..d8e5c84 100644 --- a/docs/source/projects.rst +++ b/docs/source/projects.rst @@ -31,6 +31,22 @@ site, combine the :ref:`templates-bitbucket` and $ mkproject -t bitbucket -t django my_site +Project Hook Files +================== + +The project directory can include additional hook files for the +`postactivate` and `predeactivate` hooks. Placing hook scripts in the +project hook directory, `.virtualenvwrapper`, allows them to be +checked into version control and shared more easily. + +When the :ref:`scripts-postactivate` hook runs, it looks for +`.virtualenvwrapper/postactivate` within the project directory and if +it is found it sources the file. + +When the :ref:`scripts-predeactivate` hook runs, it looks for +`.virtualenvwrapper/predeactivate` within the project directory and if +it is found it sources the file. + .. seealso:: * :ref:`extensions-templates` From 4fa1041eea7b3dc5a571d866fb620c0b965b23a1 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 27 Jan 2024 14:52:48 -0500 Subject: [PATCH 923/947] add test for project hook scripts --- tests/test_project.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_project.sh b/tests/test_project.sh index 6f2c576..10cb53e 100755 --- a/tests/test_project.sh +++ b/tests/test_project.sh @@ -52,4 +52,24 @@ test_virtualenvwrapper_verify_project_home_missing_dir() { PROJECT_HOME="$old_home" } +test_virtualenvwrapper_postactivate_hook() { + load_wrappers + mkproject "test_project_hook" + mkdir .virtualenvwrapper + echo "export TEST_PROJECT_HOOK_VAR=true" > .virtualenvwrapper/postactivate + echo "unset TEST_PROJECT_HOOK_VAR" > .virtualenvwrapper/predeactivate + deactivate + + # Variable should not be set to start + assertSame "${TEST_PROJECT_HOOK_VAR}" "" + + # Activating the env should set it + workon "test_project_hook" + assertSame "true" "${TEST_PROJECT_HOOK_VAR}" + + # Deactivating should unset it + deactivate + assertSame "" "${TEST_PROJECT_HOOK_VAR}" +} + . "$test_dir/shunit2" From 707921dabd62c7b6cb41e0c05d012e6772a3ad79 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 27 Jan 2024 14:54:20 -0500 Subject: [PATCH 924/947] add release note --- docs/source/history.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/source/history.rst b/docs/source/history.rst index 9d3e0cc..368d8d8 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -1,6 +1,12 @@ CHANGES ======= +Next +---- + +* Look for `./.virtualenvwrapper/postactivate` and + `./.virtualenvwrapper/predeactivate` hook scripts. + 6.0.0.0a5 --------- From e07db6a74af286c8b909d2931f1dea0dd3ad3a80 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 27 Jan 2024 14:58:44 -0500 Subject: [PATCH 925/947] configure linter to allow longer lines --- tox.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tox.ini b/tox.ini index 10187c2..5c4abe9 100644 --- a/tox.ini +++ b/tox.ini @@ -23,6 +23,9 @@ setenv = deps = .[linter] commands = flake8 virtualenvwrapper docs/source/conf.py +[flake8] +max-line-length = 200 + [testenv:zsh] setenv = USING_TOX = 1 From f482fab287b4c7dee1f1beeb5ed5859e56a16096 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 28 Jan 2024 16:21:33 -0500 Subject: [PATCH 926/947] remove link to broken amazon.com page --- docs/source/design.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/source/design.rst b/docs/source/design.rst index d5eb387..c77e704 100644 --- a/docs/source/design.rst +++ b/docs/source/design.rst @@ -163,14 +163,12 @@ what virtualenvwrapper is doing, it's a natural fit. .. seealso:: - * `Advanced Programming in the UNIX Environment`_ by W. Richard + * *Advanced Programming in the UNIX Environment* by W. Richard Stevens & Stephen A. Rago * `Fork (operating system)`_ on Wikipedia * `Environment variable`_ on Wikipedia * `Linux implementation of fork()`_ -.. _Advanced Programming in the UNIX Environment: https://www.amazon.com/gp/product/0321637739/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=0321637739&linkCode=as2&tag=hellflynet-20 - .. _Fork (operating system): https://en.wikipedia.org/wiki/Fork_(operating_system) .. _Environment variable: https://en.wikipedia.org/wiki/Environment_variable From 4bb9bcd3a7cb8695638c2c8c808ce3ff993a3051 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 28 Jan 2024 16:21:50 -0500 Subject: [PATCH 927/947] prepare 6.1.0 release details --- docs/source/history.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/source/history.rst b/docs/source/history.rst index 368d8d8..df6b5cf 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -1,11 +1,12 @@ CHANGES ======= -Next ----- +6.1.0 +----- * Look for `./.virtualenvwrapper/postactivate` and - `./.virtualenvwrapper/predeactivate` hook scripts. + `./.virtualenvwrapper/predeactivate` hook scripts. Same effect as + :ref:`scripts-postactivate` and :ref:`scripts-predeactivate`. 6.0.0.0a5 --------- From b5e0ad9cef8117eb3c62d312e4b3d54e4903db1f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 19:48:27 +0000 Subject: [PATCH 928/947] Bump pypa/gh-action-pypi-publish from 1.8.11 to 1.8.12 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.11 to 1.8.12. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.8.11...v1.8.12) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/python-publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index 07cd061..7d3475b 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -32,7 +32,7 @@ jobs: # This condition prevents PRs from being published as part of # the test job. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@v1.8.11 + uses: pypa/gh-action-pypi-publish@v1.8.12 with: password: ${{ secrets.PYPI_API_TOKEN }} verbose: true From 12367768ed6d4df6e988dff4d016a57e86fa57bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 19:44:15 +0000 Subject: [PATCH 929/947] Bump pypa/gh-action-pypi-publish from 1.8.12 to 1.8.14 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.12 to 1.8.14. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.8.12...v1.8.14) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/python-publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index 7d3475b..e2a6bb2 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -32,7 +32,7 @@ jobs: # This condition prevents PRs from being published as part of # the test job. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@v1.8.12 + uses: pypa/gh-action-pypi-publish@v1.8.14 with: password: ${{ secrets.PYPI_API_TOKEN }} verbose: true From f5592c822958a7acdfc53360435769ce52da027c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 20:00:01 +0000 Subject: [PATCH 930/947] Bump pypa/gh-action-pypi-publish from 1.8.14 to 1.9.0 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.14 to 1.9.0. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.8.14...v1.9.0) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/python-publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index e2a6bb2..759d0be 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -32,7 +32,7 @@ jobs: # This condition prevents PRs from being published as part of # the test job. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@v1.8.14 + uses: pypa/gh-action-pypi-publish@v1.9.0 with: password: ${{ secrets.PYPI_API_TOKEN }} verbose: true From cd45c41cfe8c7e4d643e6cb92bb9b4b454924f9c Mon Sep 17 00:00:00 2001 From: Benjamin Mundt Date: Thu, 11 Jul 2024 12:33:04 -0400 Subject: [PATCH 931/947] make sure virtualenvwrapper_cd always tries to do something, even when it cannot infer the current shell --- virtualenvwrapper.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 66f0f07..4ed4de8 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -117,12 +117,11 @@ fi # cd because we are trying to change the state of the current shell, # so we use "builtin". function virtualenvwrapper_cd { - if [ -n "${BASH:-}" ] - then - builtin \cd "$@" - elif [ -n "${ZSH_VERSION:-}" ] + if [ -n "${ZSH_VERSION:-}" ] then builtin \cd -q "$@" + else + builtin \cd "$@" fi } From 5130800aa08bae35f023d5dcfe1093761b100357 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 19:46:20 +0000 Subject: [PATCH 932/947] Bump pypa/gh-action-pypi-publish from 1.9.0 to 1.10.0 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.9.0 to 1.10.0. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.9.0...v1.10.0) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/python-publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index 759d0be..f5aeddc 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -32,7 +32,7 @@ jobs: # This condition prevents PRs from being published as part of # the test job. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@v1.9.0 + uses: pypa/gh-action-pypi-publish@v1.10.0 with: password: ${{ secrets.PYPI_API_TOKEN }} verbose: true From db4903f0536c5093559c7b8a9847faf82748565f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 19:21:12 +0000 Subject: [PATCH 933/947] Bump pypa/gh-action-pypi-publish from 1.10.0 to 1.10.1 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.10.0 to 1.10.1. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.10.0...v1.10.1) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/python-publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index f5aeddc..a63174e 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -32,7 +32,7 @@ jobs: # This condition prevents PRs from being published as part of # the test job. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@v1.10.0 + uses: pypa/gh-action-pypi-publish@v1.10.1 with: password: ${{ secrets.PYPI_API_TOKEN }} verbose: true From 699d78610695b6bc18fd18f2270b668a221afac4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 19:51:33 +0000 Subject: [PATCH 934/947] Bump pypa/gh-action-pypi-publish from 1.10.1 to 1.10.2 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.10.1 to 1.10.2. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.10.1...v1.10.2) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/python-publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index a63174e..d002043 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -32,7 +32,7 @@ jobs: # This condition prevents PRs from being published as part of # the test job. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@v1.10.1 + uses: pypa/gh-action-pypi-publish@v1.10.2 with: password: ${{ secrets.PYPI_API_TOKEN }} verbose: true From 7f54a54a4919fcddbc2467689f96960515a28957 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 13 Oct 2024 17:11:15 -0400 Subject: [PATCH 935/947] remove hyperlink to msys project page Sourceforge returns 403 during our documentation build if we use a real hyperlink with the link-checker enabled. Replace the hyperlink with inline text to the same URL. --- docs/source/install.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/source/install.rst b/docs/source/install.rst index c7429dd..8b05549 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -54,10 +54,9 @@ or:: export MSYS_HOME=C:\msys\1.0 source /usr/local/bin/virtualenvwrapper.sh -Depending on your MSYS setup, you may need to install the `MSYS mktemp -binary`_ in the ``MSYS_HOME/bin`` folder. - -.. _MSYS mktemp binary: https://sourceforge.net/projects/mingw/files/MSYS/ +Depending on your MSYS setup, you may need to install the MSYS mktemp binary +(``https://sourceforge.net/projects/mingw/files/MSYS/``) in the +``MSYS_HOME/bin`` folder. PowerShell ---------- From f0d683fce3e3938b4366e0c4c921b0a593c08d5e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 19:36:56 +0000 Subject: [PATCH 936/947] Bump pypa/gh-action-pypi-publish from 1.10.2 to 1.10.3 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.10.2 to 1.10.3. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.10.2...v1.10.3) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/python-publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index d002043..d1ef8f5 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -32,7 +32,7 @@ jobs: # This condition prevents PRs from being published as part of # the test job. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@v1.10.2 + uses: pypa/gh-action-pypi-publish@v1.10.3 with: password: ${{ secrets.PYPI_API_TOKEN }} verbose: true From 97b7043f94ff465528e4baa5d981d101d9d8c894 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 13 Oct 2024 17:25:12 -0400 Subject: [PATCH 937/947] move linkcheck out of main doc build Running linkcheck from github actions causes too many issues with rate limiting or bot-protected sites. Disable it. --- tox.ini | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tox.ini b/tox.ini index 5c4abe9..f4ce1b6 100644 --- a/tox.ini +++ b/tox.ini @@ -38,6 +38,11 @@ deps = -r{toxinidir}/docs/requirements.txt commands = sphinx-build -W -j auto -b html -d docs/build/doctrees docs/source docs/build/html + +[testenv:linkcheck] +deps = + -r{toxinidir}/docs/requirements.txt +commands = sphinx-build -W -j auto -b linkcheck -d docs/build/doctrees docs/source docs/build/linkcheck [testenv:pkglint] From 6313fd37a728cca85f6a2320c52dacc5d200b30c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 13 Oct 2024 17:26:03 -0400 Subject: [PATCH 938/947] Revert "remove hyperlink to msys project page" This reverts commit 7f54a54a4919fcddbc2467689f96960515a28957. --- docs/source/install.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/source/install.rst b/docs/source/install.rst index 8b05549..c7429dd 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -54,9 +54,10 @@ or:: export MSYS_HOME=C:\msys\1.0 source /usr/local/bin/virtualenvwrapper.sh -Depending on your MSYS setup, you may need to install the MSYS mktemp binary -(``https://sourceforge.net/projects/mingw/files/MSYS/``) in the -``MSYS_HOME/bin`` folder. +Depending on your MSYS setup, you may need to install the `MSYS mktemp +binary`_ in the ``MSYS_HOME/bin`` folder. + +.. _MSYS mktemp binary: https://sourceforge.net/projects/mingw/files/MSYS/ PowerShell ---------- From a90627ff95f7b6a11bb0aa2969c678ea50ab498f Mon Sep 17 00:00:00 2001 From: LaosLos Date: Sun, 13 Oct 2024 15:39:12 +0200 Subject: [PATCH 939/947] Update mkvirtualenv help to document -p/--python option --- virtualenvwrapper.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 66f0f07..2fc749d 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -391,6 +391,12 @@ function virtualenvwrapper_mkvirtualenv_help { echo echo " Provide a pip requirements file to install a base set of packages" echo " into the new environment." + echo + echo " -p python_interpreter, --python=python_interpreter" + echo + echo " The Python interpreter to use for the new environment." + echo " This can be specified as -p python3.8 or --python=/path/to/python" + echo echo; echo 'virtualenv help:'; echo; From 389ae9b74acdcbefdc44ae1ca7358b240ee312fc Mon Sep 17 00:00:00 2001 From: LaosLos Date: Sun, 13 Oct 2024 16:50:25 +0200 Subject: [PATCH 940/947] Add additional line to mkvirtualenv help --- virtualenvwrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 2fc749d..7527c64 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -375,7 +375,7 @@ function virtualenvwrapper_verify_active_environment { # Help text for mkvirtualenv function virtualenvwrapper_mkvirtualenv_help { - echo "Usage: mkvirtualenv [-a project_path] [-i package] [-r requirements_file] [virtualenv options] env_name" + echo "Usage: mkvirtualenv [-a project_path] [-i package] [-r requirements_file] [-p python_interpreter] [virtualenv options] env_name" echo echo " -a project_path" echo From 6d2f60371e30e29bbe79d4d98a55e71644f16e49 Mon Sep 17 00:00:00 2001 From: LaosLos Date: Sun, 13 Oct 2024 20:17:05 +0200 Subject: [PATCH 941/947] Update broken MSYS link in installation documentation --- docs/source/install.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/install.rst b/docs/source/install.rst index c7429dd..4af1f06 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -57,7 +57,7 @@ or:: Depending on your MSYS setup, you may need to install the `MSYS mktemp binary`_ in the ``MSYS_HOME/bin`` folder. -.. _MSYS mktemp binary: https://sourceforge.net/projects/mingw/files/MSYS/ +.. _MSYS mktemp binary: https://sourceforge.net/projects/mingw/files/MSYS/Extension/mktemp/ PowerShell ---------- From 5f6734aa3e864701b00af6c7e1675db256a0e10c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 19:15:56 +0000 Subject: [PATCH 942/947] Bump pypa/gh-action-pypi-publish from 1.10.3 to 1.11.0 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.10.3 to 1.11.0. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.10.3...v1.11.0) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/python-publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index d1ef8f5..fcdda6e 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -32,7 +32,7 @@ jobs: # This condition prevents PRs from being published as part of # the test job. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@v1.10.3 + uses: pypa/gh-action-pypi-publish@v1.11.0 with: password: ${{ secrets.PYPI_API_TOKEN }} verbose: true From 07b347a3b423ae975cc8eb0b98e736bf509aa1a6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 19:20:34 +0000 Subject: [PATCH 943/947] Bump pypa/gh-action-pypi-publish from 1.11.0 to 1.12.2 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.11.0 to 1.12.2. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.11.0...v1.12.2) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/python-publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index fcdda6e..cf55fbb 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -32,7 +32,7 @@ jobs: # This condition prevents PRs from being published as part of # the test job. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@v1.11.0 + uses: pypa/gh-action-pypi-publish@v1.12.2 with: password: ${{ secrets.PYPI_API_TOKEN }} verbose: true From 8191aea2e6e095906b827323855c90c3b3838fe4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 19:12:33 +0000 Subject: [PATCH 944/947] Bump pypa/gh-action-pypi-publish from 1.12.2 to 1.12.3 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.12.2 to 1.12.3. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.12.2...v1.12.3) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/python-publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index cf55fbb..a9ba732 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -32,7 +32,7 @@ jobs: # This condition prevents PRs from being published as part of # the test job. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@v1.12.2 + uses: pypa/gh-action-pypi-publish@v1.12.3 with: password: ${{ secrets.PYPI_API_TOKEN }} verbose: true From e3d247c37d46ec474979ce43074488246289760c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jan 2025 19:04:20 +0000 Subject: [PATCH 945/947] Bump pypa/gh-action-pypi-publish from 1.12.3 to 1.12.4 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.12.3 to 1.12.4. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.12.3...v1.12.4) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/python-publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index a9ba732..7012340 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -32,7 +32,7 @@ jobs: # This condition prevents PRs from being published as part of # the test job. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@v1.12.3 + uses: pypa/gh-action-pypi-publish@v1.12.4 with: password: ${{ secrets.PYPI_API_TOKEN }} verbose: true From fc044b3a18e755ddcfe442d51d709b270c97e7ff Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Mon, 31 Mar 2025 10:50:28 -0400 Subject: [PATCH 946/947] Explicitly configure readthedocs conf.py path RTD made a change that now requires it: https://about.readthedocs.com/blog/2024/12/deprecate-config-files-without-sphinx-or-mkdocs-config/ --- .readthedocs.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 67875cf..fba7a7d 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,5 +1,8 @@ version: 2 +sphinx: + configuration: docs/source/conf.py + build: os: "ubuntu-20.04" tools: From 23c86d94bac9ed3a2c7af9d13865867b28feb6e2 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Mon, 24 Mar 2025 16:14:45 -0400 Subject: [PATCH 947/947] Set VIRTUALENVWRAPPER_SCRIPT portably - `${.sh.file}` was ksh syntax, but ksh support was dropped in commit d7365499b3fd442e92200e481c7a3711981ab78e - Instead of testing only for certain specific shells (and excluding all others), use `$BASH_SOURCE` if it's set, otherwise fall back to `$0` which should work with more shells (hopefully). Fixes #105 --- virtualenvwrapper.sh | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 4fa589e..26a9452 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -96,14 +96,11 @@ export VIRTUALENVWRAPPER_WORKON_CD=${VIRTUALENVWRAPPER_WORKON_CD:-1} # Remember where we are running from. if [ -z "${VIRTUALENVWRAPPER_SCRIPT:-}" ] then - if [ -n "$BASH" ] + if [ -n "${BASH_SOURCE:-}" ] then export VIRTUALENVWRAPPER_SCRIPT="$BASH_SOURCE" - elif [ -n "$ZSH_VERSION" ] - then - export VIRTUALENVWRAPPER_SCRIPT="$0" else - export VIRTUALENVWRAPPER_SCRIPT="${.sh.file}" + export VIRTUALENVWRAPPER_SCRIPT="$0" fi fi @@ -430,7 +427,7 @@ function mkvirtualenv { i=0 tst="-lt" fi - while [ $i $tst $# ] + while test $i $tst $# do a="${in_args[$i]}" # echo "arg $i : $a" @@ -712,7 +709,7 @@ function workon { tst="-lt" fi typeset cd_after_activate=$VIRTUALENVWRAPPER_WORKON_CD - while [ $i $tst $# ] + while test $i $tst $# do a="${in_args[$i]}" case "$a" in @@ -1111,7 +1108,7 @@ function mkproject { i=0 tst="-lt" fi - while [ $i $tst $# ] + while test $i $tst $# do a="${in_args[$i]}" case "$a" in @@ -1218,7 +1215,7 @@ function mktmpenv { tst="-lt" fi typeset cd_after_activate=$VIRTUALENVWRAPPER_WORKON_CD - while [ $i $tst $# ] + while test $i $tst $# do a="${in_args[$i]}" case "$a" in