File tree Expand file tree Collapse file tree 3 files changed +32
-8
lines changed
Expand file tree Collapse file tree 3 files changed +32
-8
lines changed Original file line number Diff line number Diff line change 55virtualenvwrapper adds several hook points you can use to change your
66settings, shell environment, or other configuration values when
77creating, deleting, or moving between environments. These hooks are
8- exposed in two ways:
8+ exposed in two ways. :ref: `scripts ` allows a user to perform generic actions
9+ for every virtualenv in your environment, including customization of
10+ virtualenv creation. :ref: `plugins ` makes it possible to share common
11+ behaviors between systems and developers.
912
1013.. toctree ::
1114 :maxdepth: 1
Original file line number Diff line number Diff line change @@ -12,6 +12,13 @@ virtualenvwrapper continues the tradition of encouraging a craftsman
1212to modify their tools to work the way they want, rather than the other
1313way around.
1414
15+ There are two ways to attach your code so that virtualenvwrapper will
16+ run it: End-users can use shell scripts or other programs for personal
17+ customization, e.g. automatically performing an action on every new
18+ virtualenv (see :ref: `scripts `). Extensions can also be
19+ implemented in Python by using Distribute _ *entry points *, making it
20+ possible to share common behaviors between systems and developers.
21+
1522Use the hooks provided to eliminate repetitive manual operations and
1623streamline your development workflow. For example, set up the
1724:ref: `plugins-pre_activate ` and :ref: `plugins-post_activate ` hooks to
@@ -25,12 +32,6 @@ install basic requirements into each new development environment,
2532initialize a source code control repository, or otherwise set up a new
2633project.
2734
28- There are two ways to attach your code so that virtualenvwrapper will
29- run it: End-users can use shell scripts or other programs for personal
30- customization (see :ref: `scripts `). Extensions can also be
31- implemented in Python by using Distribute _ *entry points *, making it
32- possible to share common behaviors between systems and developers.
33-
3435Defining an Extension
3536=====================
3637
Original file line number Diff line number Diff line change @@ -10,9 +10,29 @@ the appropriate trigger time.
1010
1111The global scripts applied to all environments should be placed in the
1212directory named by :ref: `VIRTUALENVWRAPPER_HOOK_DIR
13- <variable-VIRTUALENVWRAPPER_HOOK_DIR>`. The local scripts should be
13+ <variable-VIRTUALENVWRAPPER_HOOK_DIR>`, which by default will be equal
14+ to :ref: `WORKON_HOME <variable-WORKON_HOME >`. The local scripts should be
1415placed in the ``bin `` directory of the virtualenv.
1516
17+ Example Usage
18+ ===============
19+
20+ As a Django developer, you likely want DJANGO_SETTINGS_MODULE to be set, and
21+ if you work on multiple projects, you want it to be specific to the project
22+ you are currently working on. Wouldn't it be nice if it was set based on the
23+ active virtualenv? You can achieve this with :ref: `scripts ` as follows.
24+
25+ If your :ref: `WORKON_HOME <variable-WORKON_HOME >` is set to ~/.virtualenvs:
26+
27+ vim ~/.virtualenvs/premkvirtualenv
28+
29+ Edit the file so it contains the following (for a default Django setup):
30+
31+ # Automatically set django settings for the virtualenv
32+ echo "export DJANGO_SETTINGS_MODULE=$1.settings" >> "$1/bin/activate"
33+
34+ Create a new virtualenv, and you should see DJANGO_SETTINGS_MODULE in your env!
35+
1636.. _scripts-get_env_details :
1737
1838get_env_details
You can’t perform that action at this time.
0 commit comments