File tree Expand file tree Collapse file tree 5 files changed +34
-3
lines changed Expand file tree Collapse file tree 5 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,16 @@ cdsitepackages
8484
8585Because the exact path to the site-packages directory in the virtualenv depends on the
8686version of Python, ``cdsitepackages `` is provided as a shortcut for ``cdvirtualenv
87- lib/python${pyvers}/site-packages ``.
87+ lib/python${pyvers}/site-packages ``. An optional argument is also allowed, to specify
88+ a directory hierarchy within the ``site-packages `` directory to change into.
89+
90+ ::
91+ $ workon pymotw
92+ $ echo $VIRTUAL_ENV
93+ /Users/dhellmann/.virtualenvs/pymotw
94+ $ cdsitepackages PyMOTW/bisect/
95+ $ pwd
96+ /Users/dhellmann/.virtualenvs/pymotw/lib/python2.6/site-packages/PyMOTW/bisect
8897
8998===============
9099Path Management
Original file line number Diff line number Diff line change 22Release History
33===============
44
5+ 1.25
6+
7+ - Merged in changes to cdsitepackages from William McVey. It now
8+ takes an argument and supports tab-completion for directories
9+ within site-packages.
10+
5111.24.2
612
713 - Add user provided :ref: `tips-and-tricks ` section.
Original file line number Diff line number Diff line change 2727
2828# What project are we building?
2929PROJECT = 'virtualenvwrapper'
30- VERSION = '1.24.2 '
30+ VERSION = '1.25 '
3131os .environ ['VERSION' ] = VERSION
3232
3333# Read the long description to give to setup
Original file line number Diff line number Diff line change @@ -82,6 +82,16 @@ test_cdsitepackages () {
8282 popd > /dev/null
8383}
8484
85+ test_cdsitepackages_with_arg () {
86+ pushd " $( pwd) " > /dev/null
87+ pyvers=$( python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.)
88+ sitepackage_subdir=" $VIRTUAL_ENV /lib/python${pyvers} /site-packages/subdir"
89+ mkdir -p " ${sitepackage_subdir} "
90+ cdsitepackages subdir
91+ assertSame " $sitepackage_subdir " " $( pwd) "
92+ popd > /dev/null
93+ }
94+
8595test_mkvirtualenv_activates () {
8696 mkvirtualenv " env2"
8797 assertTrue virtualenvwrapper_verify_active_environment
Original file line number Diff line number Diff line change @@ -316,7 +316,13 @@ if [ -n "$BASH" ] ; then
316316 # COMPREPLY=( $(compgen -d -- "${VIRTUAL_ENV}/${cur}" | sed -e "s@${VIRTUAL_ENV}/@@" ) )
317317 COMPREPLY=( $( cdvirtualenv && compgen -d -- " ${cur} " ) )
318318 }
319+ _cdsitepackages_complete ()
320+ {
321+ local cur=" $2 "
322+ COMPREPLY=( $( cdsitepackages && compgen -d -- " ${cur} " ) )
323+ }
319324 complete -o nospace -F _cdvirtualenv_complete -S/ cdvirtualenv
325+ complete -o nospace -F _cdsitepackages_complete -S/ cdsitepackages
320326 complete -o default -o nospace -F _virtualenvs workon
321327 complete -o default -o nospace -F _virtualenvs rmvirtualenv
322328elif [ -n " $ZSH_VERSION " ] ; then
@@ -388,7 +394,7 @@ function add2virtualenv () {
388394function cdsitepackages () {
389395 virtualenvwrapper_verify_active_environment || return 1
390396 site_packages=" ` virtualenvwrapper_get_site_packages_dir` "
391- cd " $site_packages "
397+ cd " $site_packages " / $1
392398}
393399
394400# Does a ``cd`` to the root of the currently-active virtualenv.
You can’t perform that action at this time.
0 commit comments