Fix tox python3 overrides

We want to default to running all tox environments under python 3, so
set the basepython value in each environment.

We do not want to specify a minor version number, because we do not
want to have to update the file every time we upgrade python.

We do not want to set the override once in testenv, because that
breaks the more specific versions used in default environments like
py35 and py36.

To install horizon, check python3 version and set target directory
in postinstall script on package.json.

Change-Id: Iadf07f630bfc5d8f8d0c2a57e108c0f05aca899d
Co-Authored-By: Shu Muto <shu.mutow@gmail.com>
This commit is contained in:
huang.zhiping 2018-06-10 01:25:36 +08:00 committed by Shu Muto
parent 29f1efd42e
commit 7a9eabf7be
3 changed files with 17 additions and 11 deletions

View File

@ -21,7 +21,7 @@
"phantomjs-prebuilt": "2.1.x" "phantomjs-prebuilt": "2.1.x"
}, },
"scripts": { "scripts": {
"postinstall": "if [ ! -d .tox ] || [ ! -d .tox/karma ]; then tox -ekarma --notest; python3.5 -m pip install -U -t ./.tox/karma/lib/python3.5/site-packages/ ../horizon; fi", "postinstall": "if [ ! -d .tox ] || [ ! -d .tox/karma ]; then tox -ekarma --notest; python3 -m pip install -U -t ./.tox/karma/lib/`python3 -V|tr -d ' '|tr 'P' 'p'|cut -c -9`/site-packages/ ../horizon; fi",
"test": "karma start zun_ui/karma.conf.js --single-run", "test": "karma start zun_ui/karma.conf.js --single-run",
"lint": "eslint --no-color zun_ui/static", "lint": "eslint --no-color zun_ui/static",
"lintq": "eslint --quiet zun_ui/static" "lintq": "eslint --quiet zun_ui/static"

18
tox.ini
View File

@ -26,10 +26,11 @@ commands =
pip install -e ../horizon pip install -e ../horizon
[testenv:venv] [testenv:venv]
basepython = python3
commands = {posargs} commands = {posargs}
[testenv:pep8] [testenv:pep8]
basepython = python3.5 basepython = python3
commands = flake8 {posargs} commands = flake8 {posargs}
[flake8] [flake8]
@ -37,6 +38,7 @@ exclude = .venv,.git,.tox,dist,*egg,build,node_modules
max-complexity = 20 max-complexity = 20
[testenv:cover] [testenv:cover]
basepython = python3
commands = python setup.py test --coverage --testr-args='{posargs}' commands = python setup.py test --coverage --testr-args='{posargs}'
# NOTE(shu-mutow): On CI infra, horizon will be installed # NOTE(shu-mutow): On CI infra, horizon will be installed
@ -71,7 +73,7 @@ commands =
{[testenv]commands} {[testenv]commands}
[testenv:eslint] [testenv:eslint]
basepython = python3.5 basepython = python3
whitelist_externals = whitelist_externals =
npm npm
commands = commands =
@ -79,10 +81,10 @@ commands =
npm run lint npm run lint
# NOTE(shu-mutow): The "postinstall" script on package.json will install horizon # NOTE(shu-mutow): The "postinstall" script on package.json will install horizon
# from master branch into py35 environment for testing javascripts. # from master branch into python3.x environment for testing javascripts.
# Horizon from master is needed to be cloned into ../horizon on both local and CI. # Horizon from master is needed to be cloned into ../horizon on both local and CI.
[testenv:karma] [testenv:karma]
basepython = python3.5 basepython = python3
whitelist_externals = whitelist_externals =
{[testenv:eslint]whitelist_externals} {[testenv:eslint]whitelist_externals}
commands = commands =
@ -90,14 +92,14 @@ commands =
npm run test npm run test
[testenv:karma-local] [testenv:karma-local]
basepython = python3.5 basepython = python3
whitelist_externals = whitelist_externals =
{[testenv:eslint]whitelist_externals} {[testenv:eslint]whitelist_externals}
commands = commands =
{[testenv:karma]commands} {[testenv:karma]commands}
[testenv:docs] [testenv:docs]
basepython = python3.5 basepython = python3
deps = deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}
-r{toxinidir}/doc/requirements.txt -r{toxinidir}/doc/requirements.txt
@ -105,7 +107,7 @@ commands=
sphinx-build -W -b html doc/source doc/build/html sphinx-build -W -b html doc/source doc/build/html
[testenv:docs-local] [testenv:docs-local]
basepython = python3.5 basepython = python3
deps = deps =
{[testenv:docs]deps} {[testenv:docs]deps}
commands= commands=
@ -113,7 +115,7 @@ commands=
{[testenv:docs]commands} {[testenv:docs]commands}
[testenv:releasenotes] [testenv:releasenotes]
basepython = python3.5 basepython = python3
deps = deps =
{[testenv:docs]deps} {[testenv:docs]deps}
commands = commands =

View File

@ -16,14 +16,18 @@
var fs = require('fs'); var fs = require('fs');
var path = require('path'); var path = require('path');
var child_process = require("child_process");
module.exports = function (config) { module.exports = function (config) {
// This tox venv is setup in the post-install npm step // This tox venv is setup in the post-install npm step
var toxPath = '../.tox/karma/lib/python3.5/site-packages/'; var pythonVersion = "python3.";
var stdout = child_process.execFileSync("python3", ["--version"]);
pythonVersion += stdout.toString().split(".")[1];
var toxPath = '../.tox/karma/lib/' + pythonVersion + '/site-packages/';
console.log("Karma will check on directory: ", toxPath);
process.env.PHANTOMJS_BIN = 'node_modules/phantomjs-prebuilt/bin/phantomjs'; process.env.PHANTOMJS_BIN = 'node_modules/phantomjs-prebuilt/bin/phantomjs';
config.set({ config.set({
preprocessors: { preprocessors: {
// Used to collect templates for preprocessing. // Used to collect templates for preprocessing.