Commits

Doug Hellmann committed 0622987 Merge

add cdsitepackages arg handling from William McVey

Comments (0)

Files changed (5)

docsource/command_ref.rst

 
 Because the exact path to the site-packages directory in the virtualenv depends on the
 version of Python, ``cdsitepackages`` is provided as a shortcut for ``cdvirtualenv
-lib/python${pyvers}/site-packages``.
+lib/python${pyvers}/site-packages``. An optional argument is also allowed, to specify 
+a directory hierarchy within the ``site-packages`` directory to change into.
+
+::
+  $ workon pymotw
+  $ echo $VIRTUAL_ENV
+  /Users/dhellmann/.virtualenvs/pymotw
+  $ cdsitepackages PyMOTW/bisect/
+  $ pwd
+  /Users/dhellmann/.virtualenvs/pymotw/lib/python2.6/site-packages/PyMOTW/bisect
 
 ===============
 Path Management

docsource/history.rst

 Release History
 ===============
 
+1.25
+
+  - Merged in changes to cdsitepackages from William McVey.  It now
+    takes an argument and supports tab-completion for directories
+    within site-packages.
+
 1.24.2
 
   - Add user provided :ref:`tips-and-tricks` section.
 
 # What project are we building?
 PROJECT = 'virtualenvwrapper'
-VERSION = '1.24.2'
+VERSION = '1.25'
 os.environ['VERSION'] = VERSION
 
 # Read the long description to give to setup
     popd >/dev/null
 }
 
+test_cdsitepackages_with_arg () {
+    pushd "$(pwd)" >/dev/null
+    pyvers=$(python -V 2>&1 | cut -f2 -d' ' | cut -f1-2 -d.)
+    sitepackage_subdir="$VIRTUAL_ENV/lib/python${pyvers}/site-packages/subdir"
+    mkdir -p "${sitepackage_subdir}"
+    cdsitepackages subdir
+    assertSame "$sitepackage_subdir" "$(pwd)"
+    popd >/dev/null
+}
+
 test_mkvirtualenv_activates () {
     mkvirtualenv "env2"
     assertTrue virtualenvwrapper_verify_active_environment

virtualenvwrapper_bashrc

         # COMPREPLY=( $(compgen -d -- "${VIRTUAL_ENV}/${cur}" | sed -e "s@${VIRTUAL_ENV}/@@" ) )
         COMPREPLY=( $(cdvirtualenv && compgen -d -- "${cur}" ) )
     }
+    _cdsitepackages_complete ()
+    {
+        local cur="$2"
+        COMPREPLY=( $(cdsitepackages && compgen -d -- "${cur}" ) )
+    }
     complete -o nospace -F _cdvirtualenv_complete -S/ cdvirtualenv
+    complete -o nospace -F _cdsitepackages_complete -S/ cdsitepackages
     complete -o default -o nospace -F _virtualenvs workon
     complete -o default -o nospace -F _virtualenvs rmvirtualenv
 elif [ -n "$ZSH_VERSION" ] ; then
 function cdsitepackages () {
     virtualenvwrapper_verify_active_environment || return 1
     site_packages="`virtualenvwrapper_get_site_packages_dir`"
-    cd "$site_packages"
+    cd "$site_packages"/$1
 }
 
 # Does a ``cd`` to the root of the currently-active virtualenv.