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 5
5
virtualenvwrapper adds several hook points you can use to change your
6
6
settings, shell environment, or other configuration values when
7
7
creating, 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.
9
12
10
13
.. toctree ::
11
14
:maxdepth: 1
Original file line number Diff line number Diff line change @@ -12,6 +12,13 @@ virtualenvwrapper continues the tradition of encouraging a craftsman
12
12
to modify their tools to work the way they want, rather than the other
13
13
way around.
14
14
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
+
15
22
Use the hooks provided to eliminate repetitive manual operations and
16
23
streamline your development workflow. For example, set up the
17
24
:ref: `plugins-pre_activate ` and :ref: `plugins-post_activate ` hooks to
@@ -25,12 +32,6 @@ install basic requirements into each new development environment,
25
32
initialize a source code control repository, or otherwise set up a new
26
33
project.
27
34
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
-
34
35
Defining an Extension
35
36
=====================
36
37
Original file line number Diff line number Diff line change @@ -10,9 +10,29 @@ the appropriate trigger time.
10
10
11
11
The global scripts applied to all environments should be placed in the
12
12
directory 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
14
15
placed in the ``bin `` directory of the virtualenv.
15
16
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
+
16
36
.. _scripts-get_env_details :
17
37
18
38
get_env_details
You can’t perform that action at this time.
0 commit comments