Commits

Doug Hellmann committed 085120a

change the way we determine the python version

Comments (0)

Files changed (4)

+2010-12-26  Doug Hellmann  <dhellmann@racemi.com>
+
+	* virtualenvwrapper.sh (virtualenvwrapper_get_python_version): Use
+	python's -V option and cut to get the version instead of a python
+	one-liner.
+
 2010-12-24  Doug Hellmann  <dhellmann@racemi.com>
 
 	* virtualenvwrapper.sh (cpvirtualenv): Ensure that both pre hooks
     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

+#!/bin/sh
+
+#set -x
+
+test_dir=$(cd $(dirname $0) && pwd)
+
+export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')"
+
+oneTimeSetUp() {
+    rm -rf "$WORKON_HOME"
+    mkdir -p "$WORKON_HOME"
+    source "$test_dir/../virtualenvwrapper.sh"
+    mkvirtualenv testing
+}
+
+oneTimeTearDown() {
+    rm -rf "$WORKON_HOME"
+}
+
+setUp () {
+    echo
+    rm -f "$test_dir/catch_output"
+}
+
+test_get_python_version () {
+    expected="$($VIRTUAL_ENV/bin/python -V 2>&1 | cut -f2 -d' ')"
+    echo "Expecting: $expected"
+    vers=$(virtualenvwrapper_get_python_version)
+    echo "Got      : $vers"
+    assertSame "$expected" "$vers"
+}
+
+
+. "$test_dir/shunit2"

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 -c 'import sys; print ".".join(str(p) for p in sys.version_info[:2])'
+    python -V 2>&1 | cut -f2 -d' '
 }
 
 # Prints the path to the site-packages directory for the current environment.