From 0923f344c91920cb619eff2a60d549f1f39204ae Mon Sep 17 00:00:00 2001 From: Matias Lopez Date: Thu, 28 Nov 2019 13:10:55 -0500 Subject: [PATCH] test: direct python invocation & simpler pyenv Reorder Travis builds by OS. Replace `pyenv global` calls with properly set `PATH` and `PYENV_VERSION` env vars. Does not assume python modules are in the `PATH` so all python modules are prefixed with `python -m`. PR-URL: https://github.com/nodejs/node-gyp/pull/1979 Reviewed-By: Christian Clauss Reviewed-By: Rod Vagg --- .travis.yml | 64 ++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/.travis.yml b/.travis.yml index 998669cdc3..22f7bc12fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,30 +12,6 @@ jobs: - name: "Python 2.7 on Linux" env: NODE_GYP_FORCE_PYTHON=python2 python: 2.7 - - name: "Python 2.7 on macOS" - os: osx - osx_image: xcode11.2 - language: shell # 'language: python' is not yet supported on macOS - env: NODE_GYP_FORCE_PYTHON=python2 - before_install: - - pyenv install 2.7 - - pyenv global 2.7 - - name: "Node.js 6 & Python 2.7 on Windows" - os: windows - language: node_js - node_js: 6 # node - env: >- - PATH=/c/Python27:/c/Python27/Scripts:$PATH - NODE_GYP_FORCE_PYTHON=/c/Python27/python.exe - before_install: choco install python2 - - name: "Node.js 12 & Python 2.7 on Windows" - os: windows - language: node_js - node_js: 12 # node - env: >- - PATH=/c/Python27:/c/Python27/Scripts:$PATH - NODE_GYP_FORCE_PYTHON=/c/Python27/python.exe - before_install: choco install python2 - name: "Node.js 6 & Python 3.8 on Linux" python: 3.8 @@ -66,11 +42,36 @@ jobs: env: NODE_GYP_FORCE_PYTHON=python3 before_install: nvm install 12 - - name: "Python 3.7 on macOS" + - name: "Python 2.7 on macOS" os: osx osx_image: xcode11.2 language: shell # 'language: python' is not yet supported on macOS - env: NODE_GYP_FORCE_PYTHON=python3 + env: NODE_GYP_FORCE_PYTHON=python2 PATH=$HOME/.pyenv/shims:$PATH PYENV_VERSION=2.7.17 + before_install: pyenv install $PYENV_VERSION + - name: "Python 3.8 on macOS" + os: osx + osx_image: xcode11.2 + language: shell # 'language: python' is not yet supported on macOS + env: NODE_GYP_FORCE_PYTHON=python3 PATH=$HOME/.pyenv/shims:$PATH PYENV_VERSION=3.8.0 + before_install: pyenv install $PYENV_VERSION + + - name: "Node.js 6 & Python 2.7 on Windows" + os: windows + language: node_js + node_js: 6 # node + env: >- + PATH=/c/Python27:/c/Python27/Scripts:$PATH + NODE_GYP_FORCE_PYTHON=/c/Python27/python.exe + before_install: choco install python2 + - name: "Node.js 12 & Python 2.7 on Windows" + os: windows + language: node_js + node_js: 12 # node + env: >- + PATH=/c/Python27:/c/Python27/Scripts:$PATH + NODE_GYP_FORCE_PYTHON=/c/Python27/python.exe + before_install: choco install python2 + - name: "Node.js 12 & Python 3.7 on Windows" os: windows language: node_js @@ -89,20 +90,19 @@ jobs: before_install: choco install python install: - #- pip install -r requirements.txt - - pip install --upgrade flake8 pytest==4.6.6 # pytest 5 no longer supports legacy Python + - python -m pip install --upgrade flake8 pytest==4.6.6 # pytest 5 no longer supports legacy Python before_script: - - flake8 --version + - python -m flake8 --version # stop the build if there are Python syntax errors or undefined names - - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + - python -m flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. Two space indentation is OK. The GitHub editor is 127 chars wide - - flake8 . --count --exit-zero --ignore=E111,E114,W503 --max-complexity=10 --max-line-length=127 --statistics + - python -m flake8 . --count --exit-zero --ignore=E111,E114,W503 --max-complexity=10 --max-line-length=127 --statistics - npm install - npm list script: - node -e 'require("npmlog").level="verbose"; require("./lib/find-python")(null,()=>{})' - npm test - - GYP_MSVS_VERSION=2015 GYP_MSVS_OVERRIDE_PATH="C:\\Dummy" pytest + - GYP_MSVS_VERSION=2015 GYP_MSVS_OVERRIDE_PATH="C:\\Dummy" python -m pytest notifications: on_success: change on_failure: change # `always` will be the setting once code changes slow down