Skip to content

Commit 085120a

Browse files
committed
change the way we determine the python version
1 parent 25ab840 commit 085120a

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2010-12-26 Doug Hellmann <[email protected]>
2+
3+
* virtualenvwrapper.sh (virtualenvwrapper_get_python_version): Use
4+
python's -V option and cut to get the version instead of a python
5+
one-liner.
6+
17
2010-12-24 Doug Hellmann <[email protected]>
28

39
* virtualenvwrapper.sh (cpvirtualenv): Ensure that both pre hooks

tests/test_ls.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,10 @@ test_no_workon_home () {
4444
WORKON_HOME="$old_home"
4545
}
4646

47+
test_get_site_packages_dir () {
48+
d=$(virtualenvwrapper_get_site_packages_dir)
49+
assertTrue "[ -d $d ]"
50+
}
51+
4752

4853
. "$test_dir/shunit2"

tests/test_support.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
3+
#set -x
4+
5+
test_dir=$(cd $(dirname $0) && pwd)
6+
7+
export WORKON_HOME="$(echo ${TMPDIR:-/tmp}/WORKON_HOME | sed 's|//|/|g')"
8+
9+
oneTimeSetUp() {
10+
rm -rf "$WORKON_HOME"
11+
mkdir -p "$WORKON_HOME"
12+
source "$test_dir/../virtualenvwrapper.sh"
13+
mkvirtualenv testing
14+
}
15+
16+
oneTimeTearDown() {
17+
rm -rf "$WORKON_HOME"
18+
}
19+
20+
setUp () {
21+
echo
22+
rm -f "$test_dir/catch_output"
23+
}
24+
25+
test_get_python_version () {
26+
expected="$($VIRTUAL_ENV/bin/python -V 2>&1 | cut -f2 -d' ')"
27+
echo "Expecting: $expected"
28+
vers=$(virtualenvwrapper_get_python_version)
29+
echo "Got : $vers"
30+
assertSame "$expected" "$vers"
31+
}
32+
33+
34+
. "$test_dir/shunit2"

virtualenvwrapper.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ virtualenvwrapper_get_python_version () {
407407
# Uses the Python from the virtualenv because we're trying to
408408
# determine the version installed there so we can build
409409
# up the path to the site-packages directory.
410-
python -c 'import sys; print ".".join(str(p) for p in sys.version_info[:2])'
410+
python -V 2>&1 | cut -f2 -d' '
411411
}
412412

413413
# Prints the path to the site-packages directory for the current environment.

0 commit comments

Comments
 (0)