Skip to content

Commit 23f5afc

Browse files
committed
Merge in changes to cdvirtualenv and error messages from wam. Add tests and docs.
1 parent b87f352 commit 23f5afc

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

README

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,32 @@ file does not exist, it will be created first.
114114
Quickly Navigating to a virtualenv
115115
==================================
116116

117-
The functions ``cdsitepackages`` and ``cdvirtualenv`` provide quick shortcuts to quickly
118-
``cd`` into the ``site-packages`` directory of the currently-active virtualenv, and to the
119-
root of the currently-active virtualenv, respectively.
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``.
120143

121144
==========
122145
References
@@ -130,6 +153,11 @@ For more details, refer to the column published in the May 2008 issue of Python
130153
Updates
131154
=======
132155

156+
1.16
157+
158+
- Merged in changes to ``cdvirtualenv`` from wam and added tests and docs.
159+
- Merged in changes to make error messages go to stderr, also provided by wam.
160+
133161
1.15
134162
- Better error handling in mkvirtualenv.
135163
- Remove bogus VIRTUALENV_WRAPPER_BIN variable.

tests/test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ test_cdvirtual() {
3030
pushd "$(pwd)" >/dev/null
3131
cdvirtualenv
3232
assertSame "$VIRTUAL_ENV" "$(pwd)"
33+
cdvirtualenv bin
34+
assertSame "$VIRTUAL_ENV/bin" "$(pwd)"
3335
popd >/dev/null
3436
}
3537

virtualenvwrapper_bashrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ function add2virtualenv () {
276276
function cdsitepackages () {
277277
virtualenvwrapper_verify_active_environment || return 1
278278
pyvers="`python -c 'import sys; print sys.version[:3]'`"
279-
site_packages="$VIRTUAL_ENV/lib/python${pyvers}/site-packages"
280-
cd $site_packages
279+
site_packages="lib/python${pyvers}/site-packages"
280+
cdvirtualenv $site_packages
281281
}
282282

283283
#

0 commit comments

Comments
 (0)