aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2016-04-27 15:20:25 -0700
committerGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2016-04-27 15:20:25 -0700
commite0183305d19fc72034449f2dd5c0bb6dfe5b9a34 (patch)
treeb36159379ced94b4ecf30f17828817effbfd251b
parentcec42984a0374465de9b2626f16b0efa960a66d0 (diff)
parentee9de2faeed5c7505ee4a34227a97485abd7d5dc (diff)
Merge pull request #6286 from jtattermusch/runtests_python3_support
Add --compiler python3.4 option to run_tests.py (enable running test using python3)
-rwxr-xr-xtools/dockerfile/grpc_interop_python/build_interop.sh6
-rwxr-xr-xtools/run_tests/build_python.sh12
-rwxr-xr-xtools/run_tests/run_python.sh6
-rwxr-xr-xtools/run_tests/run_tests.py34
-rw-r--r--tox.ini2
5 files changed, 27 insertions, 33 deletions
diff --git a/tools/dockerfile/grpc_interop_python/build_interop.sh b/tools/dockerfile/grpc_interop_python/build_interop.sh
index 6454a4f5e2..f29c59da8e 100755
--- a/tools/dockerfile/grpc_interop_python/build_interop.sh
+++ b/tools/dockerfile/grpc_interop_python/build_interop.sh
@@ -39,8 +39,4 @@ cp -r /var/local/jenkins/service_account $HOME || true
cd /var/local/git/grpc
-make
-
-# build Python interop client and server
-CONFIG=opt ./tools/run_tests/build_python.sh
-
+tools/run_tests/run_tests.py -l python -c opt --build_only
diff --git a/tools/run_tests/build_python.sh b/tools/run_tests/build_python.sh
index 30d121007f..594c20b14c 100755
--- a/tools/run_tests/build_python.sh
+++ b/tools/run_tests/build_python.sh
@@ -33,6 +33,8 @@ set -ex
# change to grpc repo root
cd $(dirname $0)/../..
+TOX_PYTHON_ENV="$1"
+
ROOT=`pwd`
export LD_LIBRARY_PATH=$ROOT/libs/$CONFIG
export DYLD_LIBRARY_PATH=$ROOT/libs/$CONFIG
@@ -47,9 +49,9 @@ then
export GRPC_PYTHON_ENABLE_CYTHON_TRACING=1
fi
-tox --notest
+tox -e ${TOX_PYTHON_ENV} --notest
-$ROOT/.tox/py27/bin/python $ROOT/setup.py build
-$ROOT/.tox/py27/bin/python $ROOT/setup.py build_py
-$ROOT/.tox/py27/bin/python $ROOT/setup.py build_ext --inplace
-$ROOT/.tox/py27/bin/python $ROOT/setup.py gather --test
+$ROOT/.tox/${TOX_PYTHON_ENV}/bin/python $ROOT/setup.py build
+$ROOT/.tox/${TOX_PYTHON_ENV}/bin/python $ROOT/setup.py build_py
+$ROOT/.tox/${TOX_PYTHON_ENV}/bin/python $ROOT/setup.py build_ext --inplace
+$ROOT/.tox/${TOX_PYTHON_ENV}/bin/python $ROOT/setup.py gather --test
diff --git a/tools/run_tests/run_python.sh b/tools/run_tests/run_python.sh
index a93ef2576d..7a3ce6b821 100755
--- a/tools/run_tests/run_python.sh
+++ b/tools/run_tests/run_python.sh
@@ -33,6 +33,8 @@ set -ex
# change to grpc repo root
cd $(dirname $0)/../..
+TOX_PYTHON_ENV="$1"
+
ROOT=`pwd`
export LD_LIBRARY_PATH=$ROOT/libs/$CONFIG
export DYLD_LIBRARY_PATH=$ROOT/libs/$CONFIG
@@ -45,9 +47,9 @@ export GRPC_PYTHON_USE_PRECOMPILED_BINARIES=0
if [ "$CONFIG" = "gcov" ]
then
export GRPC_PYTHON_ENABLE_CYTHON_TRACING=1
- tox
+ tox -e ${TOX_PYTHON_ENV}
else
- $ROOT/.tox/py27/bin/python $ROOT/setup.py test_lite
+ $ROOT/.tox/${TOX_PYTHON_ENV}/bin/python $ROOT/setup.py test_lite
fi
mkdir -p $ROOT/reports
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index 4b9898539d..dea481ef90 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -356,25 +356,20 @@ class PhpLanguage(object):
class PythonLanguage(object):
- def __init__(self):
- self._build_python_versions = ['2.7']
- self._has_python_versions = []
-
def configure(self, config, args):
self.config = config
self.args = args
- _check_compiler(self.args.compiler, ['default'])
+ self._tox_env = self._get_tox_env(self.args.compiler)
def test_specs(self):
# load list of known test suites
with open('src/python/grpcio/tests/tests.json') as tests_json_file:
tests_json = json.load(tests_json_file)
environment = dict(_FORCE_ENVIRON_FOR_WRAPPERS)
- environment['PYVER'] = '2.7'
environment['PYTHONPATH'] = os.path.abspath('src/python/gens')
if self.config.build_config != 'gcov':
return [self.config.job_spec(
- ['tools/run_tests/run_python.sh'],
+ ['tools/run_tests/run_python.sh', self._tox_env],
None,
environ=dict(environment.items() +
[('GRPC_PYTHON_TESTRUNNER_FILTER', suite_name)]),
@@ -399,18 +394,7 @@ class PythonLanguage(object):
return []
def build_steps(self):
- commands = []
- for python_version in self._build_python_versions:
- try:
- with open(os.devnull, 'w') as output:
- subprocess.check_call(['which', 'python' + python_version],
- stdout=output, stderr=output)
- commands.append(['tools/run_tests/build_python.sh', python_version])
- self._has_python_versions.append(python_version)
- except:
- jobset.message('WARNING', 'Missing Python ' + python_version,
- do_newline=True)
- return commands
+ return [['tools/run_tests/build_python.sh', self._tox_env]]
def post_tests_steps(self):
return []
@@ -421,6 +405,15 @@ class PythonLanguage(object):
def dockerfile_dir(self):
return 'tools/dockerfile/test/python_jessie_%s' % _docker_arch_suffix(self.args.arch)
+ def _get_tox_env(self, compiler):
+ """Returns name of tox environment based on selected compiler."""
+ if compiler == 'python2.7' or compiler == 'default':
+ return 'py27'
+ elif compiler == 'python3.4':
+ return 'py34'
+ else:
+ raise Exception('Compiler %s not supported.' % compiler)
+
def __str__(self):
return 'python'
@@ -808,7 +801,8 @@ argp.add_argument('--compiler',
choices=['default',
'gcc4.4', 'gcc4.9', 'gcc5.3',
'clang3.4', 'clang3.6',
- 'vs2010', 'vs2013', 'vs2015'],
+ 'vs2010', 'vs2013', 'vs2015',
+ 'python2.7', 'python3.4'],
default='default',
help='Selects compiler to use. Allowed values depend on the platform and language.')
argp.add_argument('--build_only',
diff --git a/tox.ini b/tox.ini
index a655935219..66b74a32db 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,7 +1,7 @@
# GRPC Python tox (test environment) settings
[tox]
skipsdist = true
-envlist = py27
+envlist = py27,py34
[testenv]
setenv =