Doug Hellmann avatar Doug Hellmann committed 4a90bde

fixes issue #73 by changing virtualenvwrapper_get_python_version to only include the major and minor numbers

Comments (0)

Files changed (5)

+2010-12-27  Doug Hellmann  <dhellmann@racemi.com>
+
+	* virtualenvwrapper.sh (virtualenvwrapper_get_python_version):
+	Only include the major and minor numbers, not the patch level.
+
 2010-12-26  Doug Hellmann  <dhellmann@racemi.com>
 
 	* virtualenvwrapper/user_scripts.py (make_hook): Do not specify

docs/en/history.rst

 Release History
 ===============
 
+2.6.1
+
+  - Fixed virtualenvwrapper_get_python_version (:bbissue:`73`).
+
 2.6
 
   - Fixed a problem with hook script line endings under Cygwin
     rm -f "$test_dir/catch_output"
 }
 
+test_get_site_packages_dir () {
+    mkvirtualenv "lssitepackagestest"
+    d=$(virtualenvwrapper_get_site_packages_dir)
+    echo "site-packages in $d"
+    assertTrue "site-packages dir $d does not exist" "[ -d $d ]"
+    deactivate
+}
+
 test_lssitepackages () {
     mkvirtualenv "lssitepackagestest"
     contents="$(lssitepackages)"    
-    assertTrue "No easy-install.pth in $contents" "echo $contents | grep easy-install.pth"
+    actual=$(echo $contents | grep easy-install.pth)
+    expected=$(echo $contents)
+    assertSame "$expected" "$actual"
+    deactivate
 }
 
 test_lssitepackages_add2virtualenv () {
     base_dir=$(basename $(pwd))
     add2virtualenv "../$base_dir"
     contents="$(lssitepackages)"    
-    assertTrue "No $base_dir in $contents" "echo $contents | grep $base_dir"
+    actual=$(echo $contents | grep $base_dir)
+    expected=$(echo $contents)
+    assertSame "$expected" "$actual"
+    deactivate
 }
 
 test_no_workon_home () {
     WORKON_HOME="$old_home"
 }
 
-test_get_site_packages_dir () {
-    d=$(virtualenvwrapper_get_site_packages_dir)
-    assertTrue "[ -d $d ]"
-}
-
 
 . "$test_dir/shunit2"

tests/test_support.sh

     rm -rf "$WORKON_HOME"
     mkdir -p "$WORKON_HOME"
     source "$test_dir/../virtualenvwrapper.sh"
-    mkvirtualenv testing
 }
 
 oneTimeTearDown() {
 }
 
 test_get_python_version () {
-    expected="$($VIRTUAL_ENV/bin/python -V 2>&1 | cut -f2 -d' ')"
+    expected="$(python -c 'import sys; print ".".join([str(p) for p in sys.version_info[:2]])')"
     echo "Expecting: $expected"
     vers=$(virtualenvwrapper_get_python_version)
     echo "Got      : $vers"

virtualenvwrapper.sh

     # Uses the Python from the virtualenv because we're trying to
     # determine the version installed there so we can build
     # up the path to the site-packages directory.
-    python -V 2>&1 | cut -f2 -d' '
+    python -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d.
 }
 
 # Prints the path to the site-packages directory for the current environment.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.