pytest-dev / pytest

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
https://pytest.org
MIT License
12.11k stars 2.68k forks source link

Travis CI currently broken on some Python 3.5 environments #2779

Closed nicoddemus closed 7 years ago

nicoddemus commented 7 years ago

Affects all py35-* environments, py35 works fine. So every tox environment which sets basepython = python3.5.

Example failure:

ERROR: Error creating virtualenv. Note that some special characters (e.g. ':' and unicode symbols) in paths are not supported by virtualenv. Error details: InvocationError('Failed to get version_info for python3.5: b"pyenv: python3.5: command not found\\n\\nThe `python3.5\' command exists in these Python versions:\\n  3.5\\n  3.5.3\\n\\n"',)

Extracting the string literal from the message:

pyenv: python3.5: command not found

The `python3.5' command exists in these Python versions:
  3.5
  3.5.3

Which is the same error reported in travis-ci/travis-ci#8363.

Already tried this workaround but it failed with an strange problem:

$ pyenv global system 3.5
install
2.56s$ pip install --upgrade --pre tox
Collecting tox
  Downloading tox-2.8.2-py2.py3-none-any.whl (49kB)
    100% |████████████████████████████████| 51kB 5.5MB/s 
Collecting virtualenv>=1.11.2; python_version != "3.2" (from tox)
  Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB)
    100% |████████████████████████████████| 1.8MB 898kB/s 
Collecting pluggy<1.0,>=0.3.0 (from tox)
  Downloading pluggy-0.5.2.tar.gz
Requirement already up-to-date: py>=1.4.17 in /home/travis/virtualenv/python3.6.2/lib/python3.6/site-packages (from tox)
Building wheels for collected packages: pluggy
  Running setup.py bdist_wheel for pluggy ... done
  Stored in directory: /home/travis/.cache/pip/wheels/22/b2/db/618ae8dcba2994fb9ebce70ec1c1ab4923df89a77edac7e901
Successfully built pluggy
Installing collected packages: virtualenv, pluggy, tox
Successfully installed pluggy-0.5.2 tox-2.8.2 virtualenv-15.1.0
14.06s$ tox --recreate
GLOB sdist-make: /home/travis/build/nicoddemus/pytest/setup.py
py34 create: /home/travis/build/nicoddemus/pytest/.tox/py34
py34 installdeps: hypothesis>=3.5.2, nose, mock, requests
py34 inst: /home/travis/build/nicoddemus/pytest/.tox/dist/pytest-0.1.dev289+g072f256.zip
py34 installed: certifi==2017.7.27.1,chardet==3.0.4,hypothesis==3.27.0,idna==2.6,mock==2.0.0,nose==1.3.7,pbr==3.1.1,py==1.4.34,pytest==0.1.dev289+g072f256,requests==2.18.4,six==1.10.0,urllib3==1.22
py34 runtests: PYTHONHASHSEED='3527525262'
py34 runtests: commands[0] | pytest --lsof -rfsxX testing
ERROR: /home/travis/build/nicoddemus/pytest/tox.ini:194: requires pytest-2.0, actual pytest-0.1.dev289+g072f256'
ERROR: InvocationError: '/home/travis/build/nicoddemus/pytest/.tox/py34/bin/pytest --lsof -rfsxX testing'
obestwalter commented 7 years ago

The error is produced by https://github.com/tox-dev/tox/pull/556 which is supposed to give more meaningful error messages fixing https://github.com/tox-dev/tox/issues/121 - looks like here it covers the actual problem in a different way. Seems hard to report a sensible error from there.

Just to make sure that this is not a tox regression: could you try this with tox 2.7?

nicoddemus commented 7 years ago

Hmmm strange, it fails with:

ERROR: /home/travis/build/nicoddemus/pytest/tox.ini:194: requires pytest-2.0, actual pytest-0.1.dev289+g072f256'
ERROR: InvocationError: '/home/travis/build/nicoddemus/pytest/.tox/py34/bin/pytest --lsof -rfsxX testing'

For some reason the pytest development version is showing up as 0.1.dev289+g072f256...

nicoddemus commented 7 years ago

I don't think it is related to tox, this build run a few days ago with tox-2.8.1 just fine.

Also from the logs in the description of travis-ci/travis-ci#8363, they are using the system's tox so it was not a new tox release which caused the problem.

obestwalter commented 7 years ago

O.k. thanks - just wanted to be sure, as that error message is 2.8+

The-Compiler commented 7 years ago

FWIW I had some similar issue with qutebrowser, and specifying python: 3.5 fixed it. However, looks like pytest is already doing that...

RonnyPfannschmidt commented 7 years ago

@nicoddemus i suspect this is related to having collected enough commits since the last tag, that travis no longer includes a tag in the recent history

without tag, the git describe is wrong

bittner commented 7 years ago

This problem seems to be related to pyenv. It is mentioned in https://github.com/pyenv/pyenv-virtualenv/issues/202.

@gangefors points out a solution in their comment, which may help. Though I guess Travis should fix this.

nicoddemus commented 7 years ago

Thanks @bittner. Python 3.5 was being used in a few secondary test environments and those were failing, so we got around this by testing those secondary environments with Python 3.6 instead

nicoddemus commented 7 years ago

Fixed by #2785

ssbarnea commented 7 years ago

@nicoddemus I think we need to reopen this bug, see https://travis-ci.org/pypa/virtualenv/jobs/283366066

I read it clear: it defines python3.6 as needed, but the installed version does not install python3.6 command so tox fails, translating to a total failure.

I bet that over 95% of Python projects are using tox, and we cannot blame tox for not finding the CLI.

nicoddemus commented 7 years ago

@ssbarnea I'm not sure:

Setting environment variables from .travis.yml
$ export TOXENV=python3.6

This should be TOXENV=py36 no?

bittner commented 7 years ago

See https://github.com/travis-ci/travis-ci/issues/4990#issuecomment-334388582 and https://github.com/travis-ci/travis-ci/issues/8363#issuecomment-332666189 for related follow-ups.

The fix we applied in the behave-django project for that looks like this:

python: 3.6
...
before_install:
  # work around https://github.com/travis-ci/travis-ci/issues/8363
  - pyenv global system 3.5
...

Hope that helps. This is clearly a Travis image issue. They have to set up pyenv correctly.

ysolovyov commented 7 years ago

this still does not help, i have pyenv global system 3.5 then pip3 install --user artifactory and then i got ImportError: No module named 'artifactory' in travis logs when trying to run my script with python3. image set up as

- os: linux
    dist: trusty
    python: 3.5
bittner commented 7 years ago

@ysolovyov Does this reflect a problem re "Travis CI currently broken on some Python 3.5 environments"? I'm not sure. (What if you simply use pip for installing? What if you omit the --user option?)

bittner commented 6 years ago

For everyone landing here and looking for a solution to the Python/Travis issue:

I recommend switching to tox-travis and the native Travis build matrix capabilities. That does away with all the ugly workarounds.

See django-apptemplates for an implementation example (with an extensive build matrix and build stages).