summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormete0r <mete0r@sarangbang.or.kr>2013-08-14 02:32:35 +0900
committermete0r <mete0r@sarangbang.or.kr>2013-08-14 02:32:35 +0900
commitf049cf538c82c7cb38f1699173aa1216a42c9ba4 (patch)
tree9ddd94682192429b6fc73252c6f7a1d8c4beaa8f
parent6ed5c19668de42a6968b64ce69928f8224f53310 (diff)
downloadtox-f049cf538c82c7cb38f1699173aa1216a42c9ba4.tar.gz
use inlined virtualenv-1.9.1 and pip<1.4 for CPython 2.5 / Jython 2.5
Since virtualenv 1.10 and pip 1.4 has dropped python 2.5 support, use inlined virtualenv-1.9.1 and Pip<1.4 for CPython 2.5 / Jython 2.5
-rw-r--r--tests/test_venv.py6
-rw-r--r--tox/_venv.py38
2 files changed, 40 insertions, 4 deletions
diff --git a/tests/test_venv.py b/tests/test_venv.py
index badc3b8..2b72b06 100644
--- a/tests/test_venv.py
+++ b/tests/test_venv.py
@@ -4,6 +4,7 @@ import pytest
import os, sys
from tox._venv import VirtualEnv, CreationConfig, getdigest
from tox._venv import find_executable
+from tox._venv import _getinterpreterversion
#def test_global_virtualenv(capfd):
# v = VirtualEnv()
@@ -80,6 +81,11 @@ def test_getsupportedinterpreter(monkeypatch, newconfig, mocksession):
py.test.raises(tox.exception.InterpreterNotFound,
venv.getsupportedinterpreter)
+def test_getinterpreterversion():
+ from distutils.sysconfig import get_python_version
+ version = _getinterpreterversion(sys.executable)
+ assert version == get_python_version()
+
def test_create(monkeypatch, mocksession, newconfig):
config = newconfig([], """
[testenv:py123]
diff --git a/tox/_venv.py b/tox/_venv.py
index 0c87319..ad4e1c0 100644
--- a/tox/_venv.py
+++ b/tox/_venv.py
@@ -1,5 +1,7 @@
from __future__ import with_statement
import sys, os, re
+import textwrap
+import subprocess
import py
import tox
from tox._config import DepConfig
@@ -180,10 +182,15 @@ class VirtualEnv(object):
if action is None:
action = self.session.newaction(self, "create")
config_interpreter = self.getsupportedinterpreter()
- f, path, _ = py.std.imp.find_module("virtualenv")
- f.close()
- venvscript = path.rstrip("co")
- #venvscript = py.path.local(tox.__file__).dirpath("virtualenv.py")
+ config_interpreter_version = _getinterpreterversion(config_interpreter)
+ use_venv191 = config_interpreter_version < '2.6'
+ use_pip13 = config_interpreter_version < '2.6'
+ if not use_venv191:
+ f, path, _ = py.std.imp.find_module("virtualenv")
+ f.close()
+ venvscript = path.rstrip("co")
+ else:
+ venvscript = py.path.local(tox.__file__).dirpath("virtualenv-1.9.1.py")
args = [config_interpreter, venvscript]
if self.envconfig.distribute:
args.append("--distribute")
@@ -204,6 +211,12 @@ class VirtualEnv(object):
args.append(self.path.basename)
self._pcall(args, venv=False, action=action, cwd=basepath)
self.just_created = True
+ if use_pip13:
+ indexserver = self.envconfig.config.indexserver['default']
+ action = self.session.newaction(self, "pip_downgrade")
+ action.setactivity('pip-downgrade', 'pip<1.4')
+ argv = ["easy_install"] + self._commoninstallopts(indexserver) + ['pip<1.4']
+ self._pcall(argv, cwd=self.envconfig.envlogdir, action=action)
def finish(self):
self._getliveconfig().writeconfig(self.path_config)
@@ -366,6 +379,23 @@ class VirtualEnv(object):
self.session.report.verbosity2("setting PATH=%s" % os.environ["PATH"])
return oldPATH
+def _getinterpreterversion(executable):
+ print_python_version = textwrap.dedent("""
+ from distutils.sysconfig import get_python_version
+ print(get_python_version())
+ """)
+ proc = subprocess.Popen([str(executable), '-c', print_python_version],
+ stdout=subprocess.PIPE)
+ odata, edata = proc.communicate()
+ if proc.returncode:
+ raise tox.exception.UnsupportedInterpreter(
+ "Error getting python version from %s" % executable)
+ if sys.version_info[0] == 3:
+ string = str
+ else:
+ string = lambda x, encoding: str(x)
+ return string(odata, 'ascii').strip()
+
def getdigest(path):
path = py.path.local(path)
if not path.check(file=1):