Commits

Tetsuya Morimoto  committed 253d5e4 Merge

merged from original

  • Participants
  • Parent commits 56db9ce, b0691ce

Comments (0)

Files changed (55)

 syntax: glob
+*~
 *.pyc
 README.html
 build
 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
 .tox
+*.orig
 
 syntax: re
 .DS_Store
 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
+2011-04-13  Doug Hellmann  <dhellmann@racemi.com>
+
+	* 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  <dhellmann@racemi.com>
+
+	* 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  <dhellmann@racemi.com>
 
 	* docs/sphinx/conf.py: Just hard-code the version.
 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
 
 
 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
 ==================
 
 *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
 =======

File announce.rst

+=======================
+ virtualenvwrapper 3.2
+=======================
+
+.. tags:: virtualenvwrapper release python
+
 What is virtualenvwrapper
 =========================
 
 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 3.2
 =================
 
-Version 2.2.1 is a bug-fix release:
+- 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.
 
-- 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.
+Installing
+==========
+
+Visit the virtualenvwrapper_ project page for download links and
+installation instructions.
 
 .. _virtualenv: http://pypi.python.org/pypi/virtualenv
 

File docs/en/command_ref.rst

 
 Syntax::
 
-    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.
 
 ::
 
     mynewenv
     (mynewenv)$ 
 
+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.
+
+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-mktmpenv:
+
+mktmpenv
+--------
+
+Create a new virtualenv in the ``WORKON_HOME`` directory.
+
+Syntax::
+
+    mktmpenv [VIRTUALENV_OPTIONS]
+
+A unique virtualenv 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:
 
 
    * :ref:`scripts-get_env_details`
 
+.. _command-rmvirtualenv:
+
 rmvirtualenv
 ------------
 
 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 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.
+
+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
+

File docs/en/developers.rst

 Running Tests
 =============
 
-The test suite for virtualenvwrapper uses `shunit2
-<http://shunit2.googlecode.com/>`_ and `tox
-<http://codespeak.net/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.
+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
+
+.. _developer-templates:
+
+Creating a New Template
+=======================
+
+virtualenvwrapper.project templates work like `virtualenvwrapper
+plugins
+<http://www.doughellmann.com/docs/virtualenvwrapper/plugins.html>`__.
+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.

File docs/en/extensions.rst

 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
 =============
 
 
 .. _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`.
+
+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
+
+.. _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`

File docs/en/history.rst

 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 <http://www.mingw.org/wiki/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-VIRTUALENVWRAPPER_VIRTUALENV>` variable.
+  - Implement suggestion by Van Lindberg to have
+    :ref:`VIRTUALENVWRAPPER_HOOK_DIR
+    <variable-VIRTUALENVWRAPPER_HOOK_DIR>` and
+    :ref:`VIRTUALENVWRAPPER_LOG_DIR
+    <variable-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.
+    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
 
     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 <variable-VIRTUALENVWRAPPER_VIRTUALENV>`).
 
 2.6.1
 

File docs/en/index.rst

    install
    command_ref
    hooks
+   projects
    tips
    developers
    extensions
 *without* your aliases enabled.  If you can identify the alias causing
 the problem, that will help make virtualenvwrapper more robust.
 
+.. _license:
+
 =======
 License
 =======

File docs/en/install.rst

 ================
 
 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
+<http://www.mingw.org/wiki/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
 
 virtualenvwrapper is tested under Python 2.4 - 2.7.
 
+.. _install-basic:
+
 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::
+
+    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`).
+add it to `your user local directory
+<http://docs.python.org/install/index.html#alternate-installation-the-home-scheme>`__
+(usually `~/.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.
-
 .. _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::
+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::
 
     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``).
 
-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
 ===========
 
 5. Run: ``workon``
 6. This time, the ``temp`` environment is included.
 
+Configuration
+=============
+
+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
+------------------------
+
+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.
+
+.. _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_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`
+
+.. _variable-VIRTUALENVWRAPPER_HOOK_DIR:
+
+Location of Hook Scripts
+------------------------
+
+The variable ``VIRTUALENVWRAPPER_HOOK_DIR`` tells virtualenvwrapper
+where the :ref:`user-defined hooks <scripts>` should be placed. The
+default is ``$WORKON_HOME``.
+
+.. seealso::
+
+   * :ref:`scripts`
+
+.. _variable-VIRTUALENVWRAPPER_LOG_DIR:
+
+Location of Hook Logs
+---------------------
+
+The variable ``VIRTUALENVWRAPPER_LOG_DIR`` tells virtualenvwrapper
+where the logs for the hook loader should be written. The default is
+``$WORKON_HOME``.
+
+.. _variable-VIRTUALENVWRAPPER_VIRTUALENV:
+
+.. _variable-VIRTUALENVWRAPPER_VIRTUALENV_ARGS:
+
+.. _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 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
+
+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'
+
 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 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
 ==================
 

File docs/en/projects.rst

+.. _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`
+   * :ref:`variable-PROJECT_HOME`
+   * :ref:`variable-VIRTUALENVWRAPPER_PROJECT_FILENAME`

File docs/en/scripts.rst

 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
+<variable-VIRTUALENVWRAPPER_HOOK_DIR>`. The local scripts should be
+placed in the ``bin`` directory of the virtualenv.
+
 .. _scripts-get_env_details:
 
 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.
   :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.
 
   :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
   :Argument(s): none
   :Sourced/Run: sourced
 
-``$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`` <project_path> flag was used,
+the link to the project directory is set up before this script is sourced.
 
 .. _scripts-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
   :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:
   :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.
 
   :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.
 
 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.
 
   :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.
 
   :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.
+
+.. _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.

File docs/en/tips.rst

 ==================================================
 
 `Justin Lily posted
-<http://justinlilly.com/blog/2009/mar/28/virtualenv-wrapper-helper/>`__
+<http://justinlilly.com/python/virtualenv_wrapper_helper.html>`__
 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,

File docs/sphinx/conf.py

 # serve to show the default.
 
 import sys, os
-
-building_web = int(os.environ.get('BUILDING_WEB', '0'))
+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
 # built documents.
 #
 # The short X.Y version.
-version = '2.6.3'
+version = subprocess.check_output(['sh', '-c', 'cd ../..; python setup.py --version'])
+version = version.strip()
 # The full version, including alpha/beta/rc tags.
 release = version
 

File docs/sphinx/requirements.txt

+sphinxcontrib-bitbucket
 PROJECT = 'virtualenvwrapper'
 
 # Change docs/sphinx/conf.py too!
-VERSION = '2.6.3'
+VERSION = '3.2'
 
 # Bootstrap installation of Distribute
 import distribute_setup
     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',
+                    'License :: OSI Approved :: MIT 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',
+                    'Programming Language :: Python :: 3.2',
                     'Intended Audience :: Developers',
                     'Environment :: Console',
                     ],
 
     provides=['virtualenvwrapper',
               'virtualenvwrapper.user_scripts',
+              'virtualenvwrapper.project',
               ],
     install_requires=['virtualenv'],
 
         #'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',
             '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': [

File tests/run_tests

 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.  
 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.
 export VIRTUALENVWRAPPER_PYTHON="$envdir/bin/python"
 
-if [ -n "${ZSH_VERSION:-}" ]
-then
-    export SHELL=$(which zsh)
-fi
+# 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.
 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
+
+    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"
+        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

File tests/setup.sh

+# 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

File tests/test.sh

 #!/bin/sh
 
-#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"
 setUp () {
     echo
     rm -f "$test_dir/catch_output"
+    unset VIRTUALENVWRAPPER_INITIALIZED
 }
 
 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)
 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
+    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"
+    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"
 }
 
     # 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)
-    assertSame "$expected" "$actual"
-}
-
 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"
-    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 $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

File tests/test_add2virtualenv.sh

 #!/bin/sh
 
-#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"
     mkdir -p "$WORKON_HOME"
-    source "$test_dir/../virtualenvwrapper.sh"
+    source "$test_dir/../virtualenvwrapper.sh" >/dev/null 2>&1
 }
 
 oneTimeTearDown() {
 }
 
 test_add2virtualenv () {
-    mkvirtualenv "pathtest"
-    add2virtualenv "/full/path"
+    mkvirtualenv "pathtest" >/dev/null 2>&1
+    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"
-    cd -
+    # 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/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"
+    mkvirtualenv "pathtest_relative" >/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"
+    path_file="./_virtualenv_path_extensions.pth"
+    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_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_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"
+    # 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"

File tests/test_cd.sh

 #!/bin/sh
 
-#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"
 }
 
 tearDown () {
-    deactivate
+    deactivate >/dev/null 2>&1
 }
 
 test_cdvirtual() {
 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"
 }
 
 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"
 }
 

File tests/test_cp.sh

 #!/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
+source "$test_dir/setup.sh"
 
 setUp () {
     rm -rf "$WORKON_HOME"
     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
     rm -f "$WORKON_HOME/postmkvirtualenv"
 }
 
+test_no_site_packages () {
+    # See issue #102
+    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_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"
 

File tests/test_deactivate.sh

 #!/bin/sh
 
-#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"

File tests/test_derive_workon_home.sh

 #!/bin/sh
 
-#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() {

File tests/test_dir_stack.sh

+#!/bin/sh
+
+test_dir=$(cd $(dirname $0) && pwd)
+source "$test_dir/setup.sh"
+
+oneTimeSetUp() {
+    test_begin_dir=$(pwd)
+}
+
+oneTimeTearDown() {
+    cd "$test_begin_dir"
+}
+
+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 some_env >/dev/null 2>&1
+    #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"

File tests/test_hook_dir.sh

+#!/bin/sh
+
+test_dir=$(cd $(dirname $0) && pwd)
+source "$test_dir/setup.sh"
+
+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"

File tests/test_log_dir.sh

+#!/bin/sh
+
+test_dir=$(cd $(dirname $0) && pwd)
+source "$test_dir/setup.sh"
+
+setUp () {
+    echo
+}
+
+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_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
+    unset VIRTUALENVWRAPPER_HOOK_DIR
+    source "$test_dir/../virtualenvwrapper.sh"
+    assertSame "$WORKON_HOME" "$VIRTUALENVWRAPPER_LOG_DIR"
+}
+
+. "$test_dir/shunit2"

File tests/test_ls.sh

 #!/bin/sh
 
-#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"
 }
 
 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 ]"
 }
 
 test_lssitepackages () {
-    mkvirtualenv "lssitepackagestest"
+    mkvirtualenv "lssitepackagestest" >/dev/null 2>&1
     contents="$(lssitepackages)"    
     actual=$(echo $contents | grep easy-install.pth)
     expected=$(echo $contents)
 }
 
 test_lssitepackages_add2virtualenv () {
-    mkvirtualenv "lssitepackagestest"
+    mkvirtualenv "lssitepackagestest" >/dev/null 2>&1
     parent_dir=$(dirname $(pwd))
     base_dir=$(basename $(pwd))
     add2virtualenv "../$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`
+    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"
 }

File tests/test_mktmpenv.sh

+#!/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.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() {
+    mktmpenv name-given-by-user >/dev/null 2>&1
+    RC=$?
+    assertTrue "Error was not detected" "[ $RC -ne 0 ]"
+}
+
+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\" ]"
+}
+
+test_deactivate() {
+    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/$env_name\" ]"
+}
+
+. "$test_dir/shunit2"

File tests/test_mkvirtualenv.sh

 #!/bin/sh
 
-#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"
 }
 
 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
 }
 
 test_activates () {
-    mkvirtualenv "env2"
+    mkvirtualenv "env2" >/dev/null 2>&1
     assertTrue virtualenvwrapper_verify_active_environment
     assertSame "env2" $(basename "$VIRTUAL_ENV")
 }
     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
 }
 
 test_no_virtualenv () {
+	# Find "which" before we change the path
+	which=$(which which)