Skip to main content

Port of Doug Hellmann's virtualenvwrapper to Windows batch scripts

Project description

virtualenvwrapper-win
=====================

This is a port of Doug Hellmann's `virtualenvwrapper <http://www.doughellmann.com/projects/virtualenvwrapper/>`_
to Windows batch scripts. The idea behind virtualenvwrapper is to ease usage of
Ian Bicking's `virtualenv <http://pypi.python.org/pypi/virtualenv>`_, a tool
for creating isolated Python virtual environments, each with their own libraries
and site-packages.

These scripts should work on any version of Windows (Windows XP, Windows Vista, Windows 7).

However, they only work in the **regular command prompt**. They **will not work in Powershell.** There are other virtualenvwrapper projects out there for Powershell.


Installation
------------
**For Windows only**

Installed scripts are placed in ``%PYTHONHOME%\Scripts``.

To install, run the following in an elevated command prompt::

pip install virtualenvwrapper-win
pyassoc

or download the source and run the following in an elevated command prompt::

python setup.py install
pyassoc

**Optional**: Add an environment variable WORKON_HOME to specify the path to store environments. By default, this is ``%USERPROFILE%\Envs``.

**Note**: ``pyassoc``
Note that the batch script ``pyassoc`` requires an elevated command prompt or that UAC is disabled. This script associates .py files with ``python.bat``, a simple batch file that calls the right ``python.exe`` based on whether you have an active virtualenv. This allows you to call python scripts from the command line and have the right python interpreter invoked. Take a look at the source -- it's incredibly simple but the best way I've found to handle conditional association of a file extension.

Main Commands
-------------
``mkvirtualenv <name>``
Create a new virtualenv environment named *<name>*. The environment will
be created in WORKON_HOME.

``lsvirtualenv``
List all of the enviornments stored in WORKON_HOME.

``rmvirtualenv <name>``
Remove the environment *<name>*. Uses ``folder_delete.bat``.

``workon [<name>]``
If *<name>* is specified, activate the environment named *<name>* (change
the working virtualenv to *<name>*). If a project directory has been defined,
we will change into it.
If no argument is specified, list the available environments.

``deactivate``
Deactivate the working virtualenv and switch back to the default system
Python.

``add2virtualenv <full_path>``
If a virtualenv environment is active, appends *<full_path>* to
``virtualenv_path_extensions.pth`` inside the environment's site-packages,
which effectively adds *<full_path>* to the environment's PYTHONPATH.
If a virtualenv environment is not active, appends *<full_path>* to
``virtualenv_path_extensions.pth`` inside the default Python's
site-packages.

Convenience Commands
--------------------
``cdproject``
If a virtualenv environment is active and a projectdir has been defined,
change the current working directory to active virtualenv's project directory.
``cd-`` will return you to the last directory you were in before calling
``cdproject``.

``cdsitepackages``
If a virtualenv environment is active, change the current working
directory to the active virtualenv's site-packages directory. If
a virtualenv environment is not active, change the current working
directory to the default Python's site-packages directory. ``cd-``
will return you to the last directory you were in before calling
``cdsitepackages``.

``cdvirtualenv``
If a virtualenv environment is active, change the current working
directory to the active virtualenv base directory. If a virtualenv
environment is not active, change the current working directory to
the base directory of the default Python. ``cd-`` will return you
to the last directory you were in before calling ``cdvirtualenv``.

``lssitepackages``
If a virtualenv environment is active, list that environment's
site-packages. If a virtualenv environment is not active, list the
default Python's site-packages. Output includes a basic listing of
the site-packages directory, the contents of easy-install.pth,
and the contents of virtualenv_path_extensions.pth (used by
``add2virtualenv``).

``setprojectdir <full_path>``
If a virtualenv environment is active, define *<full_path>* as project
directory containing the source code. This allows the use of ``cdproject``
to change the working directory. In addition, the directory will be
added to the environment using ``add2virtualenv``.

``toggleglobalsitepackages``
If a virtualenv environment is active, toggle between having the
global site-packages in the PYTHONPATH or just the virtualenv's
site-packages.

``whereis <file>``
A batch file used in many of the scripts above. Returns directory locations
of `file` and `file` with any executable extensions. So you can call
``whereis python`` to find all executables starting with ``python`` or
``whereis python.exe`` for an exact match.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

virtualenvwrapper-win-1.0.8.zip (15.0 kB view details)

Uploaded Source

File details

Details for the file virtualenvwrapper-win-1.0.8.zip.

File metadata

File hashes

Hashes for virtualenvwrapper-win-1.0.8.zip
Algorithm Hash digest
SHA256 a8727a32c31df9137c75c5093f515eae02514badded87cb16e87c9373a575671
MD5 5a7d11528bf739bd86fbc067ba82602a
BLAKE2b-256 787f3989fc44fb52526e21fc06a5c88924288f26031928213066674bff1fd747

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page