Doug Hellmann avatar Doug Hellmann committed aa44825 Merge

merge in support for python 3.2

Comments (0)

Files changed (14)

-==========================
- virtualenvwrapper 2.11.1
-==========================
+========================
+ virtualenvwrapper 3.0
+========================
 
 What is virtualenvwrapper
 =========================
 making it easier to work on more than one project at a time without
 introducing conflicts in their dependencies.
 
-What's New in 2.11.1
-====================
+What's New in 3.0
+=================
 
-- Fixes a bug with tab completion in sub-shell environments such as
-  screen and tmux introduced in 2.11.
+- Add Python 3 support, thanks in large part to the efforts of Daniel
+  Kraus. Tested under Python 2.6, 2.7, and 3.2.
 
 Installing
 ==========

docs/en/history.rst

 Release History
 ===============
 
+3.0
+
+  - Add Python 3 support, thanks in large part to the efforts of
+    Daniel Kraus (:bbuser:`dakra`). Tested under Python 2.6, 2.7, and
+    3.2.
+
 2.11.1
 
   - Remove the initialization shortcut because it breaks tab
 PROJECT = 'virtualenvwrapper'
 
 # Change docs/sphinx/conf.py too!
-VERSION = '2.11.1'
+VERSION = '3.0'
 
 # Bootstrap installation of Distribute
 import distribute_setup
 
     for test_shell in bash ksh zsh
     do
-	test_shell_opts=
-	if [ $test_shell = "zsh" ]; then
+        test_shell_opts=
+        if [ $test_shell = "zsh" ]; then
             test_shell_opts="-o shwordsplit"
-	fi
-	export test_shell=$(which $test_shell)
+        fi
+        export test_shell=$(which $test_shell)
 
         echo
         echo '********************************************************************************'
     unset GREP_OPTIONS
 }
 
-test_get_python_version() {
-    expected=$(python -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d.)
-    actual=$(virtualenvwrapper_get_python_version)
-    assertSame "$expected" "$actual"
-}
-
 test_python_interpreter_set_incorrectly() {
     return_to="$(pwd)"
     cd "$WORKON_HOME"

tests/test_add2virtualenv.sh

     assertTrue "No path insert code in $(cat $path_file)" "grep -q sys.__egginsert $path_file"
     # Check the path we inserted is actually at the top
     expected="$full_path"
-    actual=$($WORKON_HOME/pathtest/bin/python -c "import sys; print sys.path[1]")
+    actual=$($WORKON_HOME/pathtest/bin/python -c "import sys; sys.stdout.write(sys.path[1]+'\n')")
     assertSame "$expected" "$actual"
     # Make sure the temporary file created
     # during the edit was removed

tests/test_mkvirtualenv.sh

     export WORKON_HOME="$WORKON_HOME/not_there"
     mkvirtualenv should_be_created >"$old_home/output" 2>&1
     output=$(cat "$old_home/output")
-    assertTrue "Did not see expected message" "echo $output | grep 'does not exist'"
+    assertTrue "Did not see expected message in \"$output\"" "cat \"$old_home/output\" | grep 'does not exist'"
     assertTrue "Did not create environment" "[ -d \"$WORKON_HOME/should_be_created\" ]"
     WORKON_HOME="$old_home"
 }

tests/test_mkvirtualenv_install.sh

 }
 
 test_single_package () {
-    mkvirtualenv -i commandlineapp "env4" >/dev/null 2>&1
+    mkvirtualenv -i IPy "env4"
     installed=$(pip freeze)
-    assertTrue "CommandLineApp not found in $installed" "echo $installed | grep CommandLineApp"
+    assertTrue "IPy not found in $installed" "pip freeze | grep IPy"
 }
 
 test_multiple_packages () {
-    mkvirtualenv -i commandlineapp -i csvcat "env4" >/dev/null 2>&1
+    mkvirtualenv -i IPy -i WebTest "env5"
     installed=$(pip freeze)
-    assertTrue "CommandLineApp not found in $installed" "echo $installed | grep CommandLineApp"
-    assertTrue "csvcat not found in $installed" "echo $installed | grep csvcat"
+    assertTrue "IPy not found in $installed" "pip freeze | grep IPy"
+    assertTrue "WebTest not found in $installed" "pip freeze | grep WebTest"
 }
 
 . "$test_dir/shunit2"

tests/test_mkvirtualenv_requirements.sh

 }
 
 test_requirements_file () {
-    echo "commandlineapp" > "$test_dir/requirements.txt"
+    echo "IPy" > "$test_dir/requirements.txt"
     mkvirtualenv -r "$test_dir/requirements.txt" "env3" >/dev/null 2>&1
     installed=$(pip freeze)
-    assertTrue "CommandLineApp not found in $installed" "echo $installed | grep CommandLineApp"
+    assertTrue "IPy not found in $installed" "pip freeze | grep IPy"
 }
 
 . "$test_dir/shunit2"

tests/test_support.sh

 }
 
 test_get_python_version () {
-    expected="$(python -c 'import sys; print ".".join([str(p) for p in sys.version_info[:2]])')"
+    expected="$($VIRTUAL_ENV/bin/python -c 'import sys; sys.stdout.write("%s.%s\n" % sys.version_info[:2])')"
     echo "Expecting: $expected"
     vers=$(virtualenvwrapper_get_python_version)
     echo "Got      : $vers"
 [tox]
-envlist = py27,py26
+envlist = py27,py26,py32
 
 [testenv]
 commands = bash ./tests/run_tests {envdir} []
+deps = virtualenv
 
 # Not sure why this is needed, but on my system if it isn't included then
 # the python version picked up for 2.6 is actually 2.7.
 # IF THIS CAUSES YOU A PROBLEM COMMENT IT OUT BEFORE RUNNING THE TESTS.
-#[testenv:py26]
+[testenv:py26]
 #basepython=/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
+basepython=python2.6

virtualenvwrapper.sh

         # - Removing extra slashes (e.g., when TMPDIR ends in a slash)
         # - Expanding variables (e.g., $foo)
         # - Converting ~s to complete paths (e.g., ~/ to /home/brian/ and ~arthur to /home/arthur)
-        workon_home_dir=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os; print os.path.expandvars(os.path.expanduser(\"$workon_home_dir\"))")
+        workon_home_dir=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.expandvars(os.path.expanduser(\"$workon_home_dir\"))+'\n')")
     fi
 
     echo "$workon_home_dir"
 
 # Prints the Python version string for the current interpreter.
 function virtualenvwrapper_get_python_version {
-    # 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' ' | cut -f-2 -d.
+    # Uses the Python from the virtualenv rather than
+    # VIRTUALENVWRAPPER_PYTHON because we're trying to determine the
+    # version installed there so we can build up the path to the
+    # site-packages directory.
+    "$VIRTUAL_ENV/bin/python" -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d.
 }
 
 # Prints the path to the site-packages directory for the current environment.
 
     for pydir in "$@"
     do
-        absolute_path=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os; print os.path.abspath(\"$pydir\")")
+        absolute_path=$("$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.abspath(\"$pydir\")+'\n')")
         if [ "$absolute_path" != "$pydir" ]
         then
             echo "Warning: Converting \"$pydir\" to \"$absolute_path\"" 1>&2
     typeset RC
 
     # Generate a unique temporary name
-    tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import uuid; print uuid.uuid4()' 2>/dev/null)
+    tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import uuid,sys; sys.stdout.write(uuid.uuid4()+"\n")' 2>/dev/null)
     if [ -z "$tmpenvname" ]
     then
         # This python does not support uuid
-        tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import random; print hex(random.getrandbits(64))[2:-1]' 2>/dev/null)
+        tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import random,sys; sys.stdout.write(hex(random.getrandbits(64))[2:-1]+"\n")' 2>/dev/null)
     fi
 
     # Create the environment

virtualenvwrapper/hook_loader.py

             continue
         plugin = ep.load()
         if options.listing:
-            print '  %-10s -- %s' % (ep.name, inspect.getdoc(plugin) or '')
+            sys.stdout.write('  %-10s -- %s\n' % (ep.name, inspect.getdoc(plugin) or ''))
             continue
         if options.sourcing:
             # Show the shell commands so they can

virtualenvwrapper/user_scripts.py

         log.debug('running %s', str(cmd))
         try:
             return_code = subprocess.call(cmd)
-        except OSError, msg:
+        except OSError:
+            _,  msg, _ = sys.exc_info()
             log.error('could not run "%s": %s', script_path, str(msg))
         #log.debug('Returned %s', return_code)
     return
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.