You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README
+2-195Lines changed: 2 additions & 195 deletions
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
virtualenvwrapper
3
3
#################
4
4
5
+
virtualenvwrapper is a set of extensions to Ian Bicking's `virtualenv <http://pypi.python.org/pypi/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.
6
+
5
7
===========
6
8
Quick Setup
7
9
===========
@@ -19,128 +21,6 @@ Quick Setup
19
21
7. Run: ``workon``
20
22
8. This time, the ``temp`` environment is included.
21
23
22
-
23
-
===============
24
-
Path Management
25
-
===============
26
-
27
-
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``.
28
-
29
-
1. Check out the source for a big project, such as Django.
30
-
2. Run: ``add2virtualenv path_to_source``.
31
-
3. Run: ``add2virtualenv``.
32
-
4. A usage message and list of current "extra" paths is printed.
33
-
34
-
============
35
-
Hook Scripts
36
-
============
37
-
38
-
virtualenvwrapper adds several hook points you can use to change your settings when creating,
39
-
deleting, or moving between environments. They are either *sourced* (allowing them to modify
40
-
your shell environment) or run as an external program at the appropriate trigger time.
41
-
42
-
$VIRTUAL_ENV/bin/postactivate
43
-
=============================
44
-
45
-
The ``postactivate`` script is sourced after the new environment is enabled. ``$VIRTUAL_ENV``
46
-
refers to the new environment at the time the script runs.
47
-
48
-
This example script for the PyMOTW environment changes the current working directory and the
49
-
PATH variable to refer to the source tree containing the PyMOTW source.
50
-
51
-
::
52
-
53
-
pymotw_root=/Users/dhellmann/Documents/PyMOTW
54
-
cd $pymotw_root
55
-
PATH=$pymotw_root/bin:$PATH
56
-
57
-
$VIRTUAL_ENV/bin/predeactivate
58
-
==============================
59
-
60
-
The ``predeactivate`` script is source before the current environment is deactivated, and can
61
-
be used to disable or clear settings in your environment. ``$VIRTUAL_ENV`` refers to the old
62
-
environment at the time the script runs.
63
-
64
-
$WORKON_HOME/postactivate
65
-
=============================
66
-
67
-
The global ``postactivate`` script is sourced after the new environment is enabled and the new
68
-
environment's postactivate is sourced (if it exists). ``$VIRTUAL_ENV`` refers to the new
69
-
environment at the time the script runs.
70
-
71
-
This example script adds a space between the virtual environment name and your old PS1 by making
The ``premkvirtualenv`` script is run as an external program after the virtual environment is
82
-
created but before the current environment is switched to point to the new env. The current
83
-
working directory for the script is ``$WORKON_HOME`` and the name of the new environment is
84
-
passed as an argument to the script.
85
-
86
-
$WORKON_HOME/postmkvirtualenv
87
-
=============================
88
-
89
-
The ``postmkvirtualenv`` script is sourced after the new environment is created and
90
-
activated.
91
-
92
-
$WORKON_HOME/prermvirtualenv
93
-
============================
94
-
95
-
The ``prermvirtualenv`` script is run as an external program before the environment is
96
-
removed. The full path to the environment directory is passed as an argument to the script.
97
-
98
-
$WORKON_HOME/postrmvirtualenv
99
-
=============================
100
-
101
-
The ``postrmvirtualenv`` script is run as an external program after the environment is
102
-
removed. The full path to the environment directory is passed as an argument to the script.
103
-
104
-
===============
105
-
Path Management
106
-
===============
107
-
108
-
The function ``add2virtualenv`` adds the specified directories to the Python path for the
109
-
active virtualenv. The directory names passed as argument are added to a path file named
110
-
``virtualenv_path_extensions.pth`` inside the virtualenv's site-packages directory. If this
111
-
file does not exist, it will be created first.
112
-
113
-
==================================
114
-
Quickly Navigating to a virtualenv
115
-
==================================
116
-
117
-
There are two functions to provide shortcuts to navigate into the the currently-active
118
-
virtualenv.
119
-
120
-
cdvirtualenv
121
-
============
122
-
123
-
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.
124
-
125
-
::
126
-
127
-
$ workon pymotw
128
-
$ echo $VIRTUAL_ENV
129
-
/Users/dhellmann/.virtualenvs/pymotw
130
-
$ cdvirtualenv
131
-
$ pwd
132
-
/Users/dhellmann/.virtualenvs/pymotw
133
-
$ cdvirtualenv bin
134
-
$ pwd
135
-
/Users/dhellmann/.virtualenvs/pymotw/bin
136
-
137
-
cdsitepackages
138
-
==============
139
-
140
-
Because the exact path to the site-packages directory in the virtualenv depends on the
141
-
version of Python, ``cdsitepackages`` is provided as a shortcut for ``cdvirtualenv
142
-
lib/python${pyvers}/site-packages``.
143
-
144
24
==========
145
25
References
146
26
==========
@@ -149,79 +29,6 @@ For more details, refer to the column published in the May 2008 issue of Python
149
29
`virtualenvwrapper | And Now For Something Completely Different
Originally contributed Thursday, May 28, 2009 by Steve Steiner ([email protected])
3
3
4
-
==================
4
+
#################
5
5
Command Reference
6
-
==================
6
+
#################
7
7
8
8
All of the commands below are to be used on the Terminal command line.
9
9
10
-
add2virtualenv
11
-
--------------
12
-
13
-
add2virtualenv directory1 directory2 ...
14
-
15
-
Path management for packages outside of the virtual env.
16
-
Based on a contribution from James Bennett and Jannis Leidel.
17
-
18
-
19
-
Adds the specified directories to the Python path for the currently-active
20
-
virtualenv.
21
-
22
-
This will be done by placing the directory names in a path file
23
-
named "virtualenv_path_extensions.pth" inside the virtualenv's site-packages
24
-
directory; if this file does not exist, it will be created first.
10
+
=====================
11
+
Managing Environments
12
+
=====================
25
13
26
14
mkvirtualenv
27
15
------------
28
16
29
17
Create a new environment, in the WORKON_HOME.
30
18
31
-
Usage: mkvirtualenv [options] ENVNAME
19
+
Syntax::
20
+
21
+
mkvirtualenv [options] ENVNAME
32
22
33
23
(where the options are passed directly to virtualenv)
34
24
35
25
rmvirtualenv
36
26
------------
27
+
37
28
Remove an environment, in the WORKON_HOME.
38
29
39
-
Usage: rmvirtualenv ENVNAME
30
+
Syntax::
31
+
32
+
rmvirtualenv ENVNAME
40
33
41
34
workon
42
-
# List or change working virtual environments
43
-
#
44
-
# Usage: workon [environment_name]
45
-
#
35
+
------
36
+
37
+
List or change working virtual environments
38
+
39
+
Syntax::
40
+
41
+
workon [environment_name]
42
+
43
+
If no ``environment_name`` is given the list of available environments is printed to stdout.
44
+
45
+
==================================
46
+
Quickly Navigating to a virtualenv
47
+
==================================
48
+
49
+
There are two functions to provide shortcuts to navigate into the the currently-active
50
+
virtualenv.
51
+
52
+
cdvirtualenv
53
+
------------
54
+
55
+
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.
56
+
57
+
::
58
+
59
+
$ workon pymotw
60
+
$ echo $VIRTUAL_ENV
61
+
/Users/dhellmann/.virtualenvs/pymotw
62
+
$ cdvirtualenv
63
+
$ pwd
64
+
/Users/dhellmann/.virtualenvs/pymotw
65
+
$ cdvirtualenv bin
66
+
$ pwd
67
+
/Users/dhellmann/.virtualenvs/pymotw/bin
68
+
69
+
cdsitepackages
70
+
--------------
71
+
72
+
Because the exact path to the site-packages directory in the virtualenv depends on the
73
+
version of Python, ``cdsitepackages`` is provided as a shortcut for ``cdvirtualenv
74
+
lib/python${pyvers}/site-packages``.
75
+
76
+
===============
77
+
Path Management
78
+
===============
79
+
80
+
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``.
81
+
82
+
1. Check out the source for a big project, such as Django.
83
+
2. Run: ``add2virtualenv path_to_source``.
84
+
3. Run: ``add2virtualenv``.
85
+
4. A usage message and list of current "extra" paths is printed.
86
+
87
+
add2virtualenv
88
+
--------------
89
+
90
+
Adds the specified directories to the Python path for the currently-active
91
+
virtualenv.
92
+
93
+
Syntax::
94
+
95
+
add2virtualenv directory1 directory2 ...
96
+
97
+
Path management for packages outside of the virtual env.
98
+
Based on a contribution from James Bennett and Jannis Leidel.
99
+
100
+
This will be done by placing the directory names in a path file
101
+
named ``virtualenv_path_extensions.pth`` inside the virtualenv's site-packages
102
+
directory; if this file does not exist, it will be created first.
0 commit comments