Closed mcepl closed 4 years ago
OK, a correction: no idea why, but when I build both python2 and python3 version (in separate build directories), it is enough to have just:
%pytest -k 'not (network or parallel or test_provision_missing or test_provision_interrupt_child or test_workdir_gets_resolved)'
to have tests pass.
That command disables those tests so now the test suite passes. This probably is a test suite only bug, I'm not expecting runtime effect.
@mcepl is this something we can reproduce in docker / etc. -- that would make it easier for us to debug
I was able to get the tox testsuite passing inside the opensuse/tumbleweed image, maybe this'll help you debug your build?
(venv) e0bcf2a8404a:/tox # tox -e py37
.package create: /tox/.tox/.package
.package installdeps: setuptools >= 40.0.4, setuptools_scm >= 2.0.0, <4, wheel >= 0.29.0
py37 create: /tox/.tox/py37
py37 installdeps: pip == 19.1.1
py37 inst: /tox/.tox/.tmp/package/1/tox-3.12.2.dev1+g5a2b535.tar.gz
py37 installed: apipkg==1.5,atomicwrites==1.3.0,attrs==19.1.0,coverage==4.5.3,execnet==1.6.0,filelock==3.0.12,flaky==3.5.3,freezegun==0.3.11,more-itertools==7.0.0,pathlib2==2.3.3,pluggy==0.11.0,psutil==5.6.2,py==1.8.0,pytest==4.5.0,pytest-cov==2.7.1,pytest-forked==1.0.2,pytest-mock==1.10.4,pytest-randomly==1.2.3,pytest-xdist==1.28.0,python-dateutil==2.8.0,six==1.12.0,toml==0.10.0,tox==3.12.2.dev1+g5a2b535,virtualenv==16.6.0,wcwidth==0.1.7
py37 run-test-pre: PYTHONHASHSEED='3213873936'
py37 run-test: commands[0] | pytest --cov /tox/.tox/py37/lib/python3.7/site-packages/tox --cov-config /tox/tox.ini --junitxml /tox/.tox/junit.py37.xml -n=auto .
============================= test session starts ==============================
platform linux -- Python 3.7.2, pytest-4.5.0, py-1.8.0, pluggy-0.11.0
cachedir: .tox/py37/.pytest_cache
Using --randomly-seed=1558656965
tox comes from: '/tox/.tox/py37/lib/python3.7/site-packages/tox/__init__.py'
rootdir: /tox, inifile: tox.ini
plugins: xdist-1.28.0, randomly-1.2.3, mock-1.10.4, forked-1.0.2, cov-2.7.1, flaky-3.5.3
gw0 [536] / gw1 [536] / gw2 [536] / gw3 [536] / gw4 [536]
.........................................s.............................. [ 13%]
........................................................................ [ 26%]
........................................................................ [ 40%]
........................................................................ [ 53%]
........................................................................ [ 67%]
.......................................................s.....s.......... [ 80%]
........................................................................ [ 94%]
.ss............................. [100%]
=============================== warnings summary ===============================
.tox/py37/lib/python3.7/site-packages/pathlib2/__init__.py:15
.tox/py37/lib/python3.7/site-packages/pathlib2/__init__.py:15
.tox/py37/lib/python3.7/site-packages/pathlib2/__init__.py:15
.tox/py37/lib/python3.7/site-packages/pathlib2/__init__.py:15
.tox/py37/lib/python3.7/site-packages/pathlib2/__init__.py:15
/tox/.tox/py37/lib/python3.7/site-packages/pathlib2/__init__.py:15: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
from collections import Sequence
-- Docs: https://docs.pytest.org/en/latest/warnings.html
----------------- generated xml file: /tox/.tox/junit.py37.xml -----------------
----------- coverage: platform linux, python 3.7.2-final-0 -----------
Name Stmts Miss Branch BrPart Cover Missing
----------------------------------------------------------------------------------------
src/tox/__main__.py 1 1 0 0 0% 1
src/tox/_pytestplugin.py 341 29 102 13 89% 30, 32, 60, 87-94, 116, 127, 130-135, 169-170, 183, 216, 279, 297, 331-334, 29->30, 31->32, 59->60, 86->87, 115->116, 126->127, 128->130, 182->183, 194->exit, 213->216, 238->251, 294->297, 478->475
src/tox/_quickstart.py 122 19 57 7 83% 76, 83, 91, 99, 116-128, 132-134, 275-277, 75->76, 82->83, 90->91, 98->99, 114->116, 176->186, 178->177
src/tox/action.py 176 41 64 5 75% 117, 133, 151, 159-174, 179-189, 193-205, 242-244, 116->117, 131->133, 150->151, 239->242, 245->249
src/tox/cli.py 7 7 0 0 0% 1-11
src/tox/config/__init__.py 993 15 371 19 98% 366, 850, 914, 1011, 1068, 1233, 1240, 1362, 1583-1584, 1595, 1603, 1660, 1674, 1709, 214->222, 365->366, 582->595, 849->850, 883->885, 913->914, 1007->1011, 1044->1048, 1067->1068, 1172->1168, 1232->1233, 1236->1240, 1361->1362, 1594->1595, 1602->1603, 1617->1627, 1659->1660, 1673->1674, 1690->1709
src/tox/config/parallel.py 35 7 6 0 83% 17-22, 26-27
src/tox/exception.py 40 1 10 0 94% 88
src/tox/helper/build_isolated.py 9 9 2 0 0% 1-12
src/tox/helper/build_requires.py 10 10 2 0 0% 1-13
src/tox/interpreters/__init__.py 94 10 12 3 88% 49-51, 64-65, 76, 78, 81-82, 122, 75->76, 77->78, 121->122
src/tox/interpreters/py_spec.py 49 9 16 6 77% 22, 28-29, 33, 35, 37, 39, 41, 43, 32->33, 34->35, 36->37, 38->39, 40->41, 42->43
src/tox/interpreters/unix.py 13 1 4 1 88% 20, 19->20
src/tox/interpreters/via_path.py 45 5 18 3 87% 49, 65-66, 70-71, 25->18, 39->49, 62->70
src/tox/interpreters/windows/__init__.py 32 32 18 0 0% 1-51
src/tox/interpreters/windows/pep514.py 112 112 42 0 0% 2-161
src/tox/package/__init__.py 53 4 16 2 91% 24-25, 49-50, 23->24, 45->53
src/tox/package/builder/isolated.py 66 1 27 2 97% 30, 27->29, 29->30
src/tox/package/local.py 49 2 18 2 94% 44, 58, 43->44, 57->58
src/tox/package/view.py 27 3 10 2 86% 36-37, 39, 32->38, 38->39
src/tox/reporter.py 111 8 18 4 89% 29, 31, 81, 86-90, 28->29, 30->31, 48->50, 80->81
src/tox/session/__init__.py 220 4 82 8 96% 73, 75, 149, 264, 72->73, 148->149, 230->228, 237->exit, 245->247, 263->264, 273->248, 279->281
src/tox/session/commands/provision.py 17 0 2 1 95% 23->exit
src/tox/session/commands/run/parallel.py 99 20 34 1 78% 72, 108-121, 128-139, 71->72
src/tox/session/commands/run/sequential.py 51 6 20 1 90% 30-32, 63-64, 72, 71->72
src/tox/util/graph.py 48 0 40 1 99% 65->exit
src/tox/util/lock.py 30 2 2 0 94% 37-38
src/tox/util/spinner.py 127 13 44 8 88% 16-19, 133-137, 144-148, 15->16, 24->32, 55->exit, 93->97, 132->133, 138->exit, 143->144, 149->exit
src/tox/util/stdlib.py 31 19 4 1 37% 9-14, 25-45, 21->25
src/tox/venv.py 453 18 187 16 93% 102, 163, 183, 222-223, 256, 437, 513, 538, 565, 597-599, 604, 670, 699-703, 101->102, 177->180, 180->183, 221->222, 225->224, 226->225, 330->328, 436->437, 510->513, 535->499, 564->565, 596->597, 603->604, 669->670, 681->693, 698->699
----------------------------------------------------------------------------------------
TOTAL 3738 408 1292 106 88%
23 files skipped due to complete coverage.
=========================== short test summary info ============================
SKIPPED [1] tests/unit/test_z_cmdline.py:675: Platform doesnt support alwayscopy
SKIPPED [1] tests/unit/interpreters/windows/test_windows.py:4: non posix test
SKIPPED [1] tests/integration/test_jython_env_create.py:5: needs jython and dev cut of virtualenv
SKIPPED [1] tests/unit/interpreters/windows/test_pep514.py:17: non posix test
SKIPPED [1] tests/unit/interpreters/windows/test_pep514.py:10: non posix test
============= 531 passed, 5 skipped, 5 warnings in 119.14 seconds ==============
___________________________________ summary ____________________________________
py37: commands succeeded
congratulations :)
Here's the commands I ran, I filtered out all the unnecessary ones:
(venv) e0bcf2a8404a:/tox # history
6 2019-05-24 00:10:45 zypper install git python3
12 2019-05-24 00:13:04 git clone https://github.com/tox-dev/tox
13 2019-05-24 00:13:11 zypper install curl
14 2019-05-24 00:13:25 curl https://asottile.github.io/get-virtualenv.py | python3 - venv
15 2019-05-24 00:13:31 cd tox/
16 2019-05-24 00:13:34 . ../venv/bin/activate
17 2019-05-24 00:13:36 pip install -e .
19 2019-05-24 00:14:10 zypper install gcc
24 2019-05-24 00:15:29 zypper install python3-devel
27 2019-05-24 00:15:45 tox -e py37
28 2019-05-24 00:18:54 history
This won't work, because openSUSE build system (as every build system on every Linux distro I know about) has no network connection inside of the system. So, pip install -e .
is out of question (I have to explicitly list of build requirements, which will be installed from openSUSE packages).
Nevertheless, I tried to run tests tox
to get closer to your scenario, and it didn't work, because apparently tox cannot be persuaded to stop bother with downloading packages from PyPI. With this script (and PYTHONPATH
in passenv
, notice there are no messages about overriding it):
export PYTHONDONTWRITEBYTECODE=1
export PATH=%{buildroot}%{_bindir}:$PATH
%{python_expand export PYTHONPATH=%{buildroot}%{$python_sitelib}:%{$python_sitelib}
tox-%{$python_bin_suffix} --sitepackages -e py%{$python_version_nodots}
}
I get this failed tests:
[ 4s] + export PYTHONPATH=/home/abuild/rpmbuild/BUILDROOT/python-tox-3.12.1-0.x86_64/usr/l
ib/python2.7/site-packages:/usr/lib/python2.7/site-packages
[ 4s] + PYTHONPATH=/home/abuild/rpmbuild/BUILDROOT/python-tox-3.12.1-0.x86_64/usr/lib/pyth
on2.7/site-packages:/usr/lib/python2.7/site-packages
[ 4s] + tox-2.7 --sitepackages -e py27
[ 5s] .package create: /home/abuild/rpmbuild/BUILD/tox-3.12.1/.tox/.package
[ 6s] .package installdeps: setuptools >= 40.0.4, setuptools_scm >= 2.0.0, <4, wheel >= 0.
29.0
[ 7s] py27 create: /home/abuild/rpmbuild/BUILD/tox-3.12.1/.tox/py27
[ 8s] py27 installdeps: pip == 19.1.1
[ 8s] py27 inst: /home/abuild/rpmbuild/BUILD/tox-3.12.1/.tox/.tmp/package/1/tox-3.12.1.tar
.gz
[ 16s] ERROR: invocation failed (exit code 1), logfile: /home/abuild/rpmbuild/BUILD/tox-3.1
2.1/.tox/py27/log/py27-2.log
[ 16s] ================================== log start ===================================
[ 16s] DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please
upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pi
p will drop support for Python 2.7.
[ 16s] Processing ./.tox/.tmp/package/1/tox-3.12.1.tar.gz
[ 16s] Installing build dependencies: started
[ 16s] Installing build dependencies: finished with status 'error'
[ 16s] ERROR: Complete output from command /home/abuild/rpmbuild/BUILD/tox-3.12.1/.tox/py
27/bin/python /usr/lib/python2.7/site-packages/pip install --ignore-installed --no-user --pre
fix /tmp/pip-build-env-q36Kic/overlay --no-warn-script-location --no-binary :none: --only-bin
ary :none: -i https://pypi.org/simple -- 'setuptools >= 40.0.4' 'setuptools_scm >= 2.0.0, <4'
'wheel >= 0.29.0':
[ 16s] DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Pleas
e upgrade your Python as Python 2.7 won't be maintained after that date. A future version of
pip will drop support for Python 2.7.
[ 16s] Collecting setuptools>=40.0.4
[ 16s] WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status
=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.Verif
iedHTTPSConnection object at 0x7f902fa20290>: Failed to establish a new connection: [Errno -3
] Temporary failure in name resolution',)': /simple/setuptools/
[ 16s] WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status
=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.Verif
iedHTTPSConnection object at 0x7f902fa202d0>: Failed to establish a new connection: [Errno -3
] Temporary failure in name resolution',)': /simple/setuptools/
[ 16s] WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status
=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.Verif
iedHTTPSConnection object at 0x7f902fa20210>: Failed to establish a new connection: [Errno -3
] Temporary failure in name resolution',)': /simple/setuptools/
[ 16s] WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status
=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.Verif
iedHTTPSConnection object at 0x7f902fa20dd0>: Failed to establish a new connection: [Errno -3
] Temporary failure in name resolution',)': /simple/setuptools/
[ 16s] WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status
=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.Verif
iedHTTPSConnection object at 0x7f902fa200d0>: Failed to establish a new connection: [Errno -3
] Temporary failure in name resolution',)': /simple/setuptools/
[ 16s] ERROR: Could not find a version that satisfies the requirement setuptools>=40.0.
4 (from versions: none)
[ 16s] ERROR: No matching distribution found for setuptools>=40.0.4
[ 16s] ----------------------------------------
[ 16s] ERROR: Command "/home/abuild/rpmbuild/BUILD/tox-3.12.1/.tox/py27/bin/python /usr/lib
/python2.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env
-q36Kic/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://
pypi.org/simple -- 'setuptools >= 40.0.4' 'setuptools_scm >= 2.0.0, <4' 'wheel >= 0.29.0'" fa
iled with error code 1 in None
[ 16s]
[ 16s] =================================== log end ====================================
[ 16s] ___________________________________ summary ____________________________________
[ 16s] ERROR: py27: InvocationError for command /home/abuild/rpmbuild/BUILD/tox-3.12.1/.t
ox/py27/bin/python -m pip install --exists-action w '/home/abuild/rpmbuild/BUILD/tox-3.12.1/.
tox/.tmp/package/1/tox-3.12.1.tar.gz[testing]' (exited with code 1)
You can see from the full build log that python2-pip-19.1.1+git.1557777841.63878672-27.1
has been installed.
you can probably prebuild any wheels that it needs and set PIP_FIND_LINKS
and PIP_NO_INDEX
and TOX_TESTENV_PASSENV
to make those variables pass through. This can make pip install work.
debian seems to have a successful build of tox, maybe look into how they packaged it?
you can probably prebuild any wheels that it needs and set
PIP_FIND_LINKS
andPIP_NO_INDEX
andTOX_TESTENV_PASSENV
to make those variables pass through. This can make pip install work.debian seems to have a successful build of tox, maybe look into how they packaged it?
And where do you take your idea that they actually run any tests? Quoting from https://salsa.debian.org/python-team/applications/tox/blob/master/debian/rules:
# The tests are not runnable during package build because many invoke the tox
# command line. It's too much work to make the test suite run partially here
# because upstream always changes the mix.
The difference is that I am just an idiot who hasn't given up yet.
GitLabtox packaging
Fedora is actually not doing much better than me (from https://src.fedoraproject.org/rpms/python-tox/blob/master/f/python-tox.spec):
mkdir .path
ln -s %{__python3} .path/python
ln -s /usr/bin/easy_install-%{python3_version} .path/easy_install
ln -s /usr/bin/pytest-%{python3_version} .path/pytest
ln -s /usr/bin/pip3 .path/pip
export PATH=$(pwd)/.path:%{buildroot}%{_bindir}:$PATH
export PYTHONPATH=%{buildroot}%{python3_sitelib}
export TOXENV=py%{python3_version_nodots}
export TOX_TESTENV_PASSENV="PATH TOX_TESTENV_PASSENV"
# TODO figure out why PEP517/518 tests and test_tox_parallel_build_safe won't pass
pytest-3 -n auto -k "not test_verbose_isolated_build and not test_tox_parallel_build_safe and not test_dist_exists_version_change"
rm -rf .path
Of course, neither of them use tox
command itself.
apologies, I was only trying to help :(
apologies, I was only trying to help :(
Me too, I am just unhappy with what feels to me like a bit patronising and very self-assured tone I get from many comments in this project. We (Linux packagers) are not only unplesant bugs, who need to be swept away. We try to help as well.
apologies, I was only trying to help :(
Me too, I am just unhappy with what feels to me like a bit patronising and very self-assured tone I get from many comments in this project.
tone is pretty difficult through text -- I usually just assume that the person on the other end is trying their best to help especially if they're doing the work for free. I'm sorry if we came across that way
My suggestion is to create a tox plugin that automatically replaces pip with opensuse packages and virtual environments. I can help getting starting with this though I do lack knowledge of opensuse from within.
got the tests passing without network, maybe you can adapt this strategy to your packaging:
FROM opensuse/tumbleweed
RUN : \
&& zypper --non-interactive install \
gcc \
git \
python3-devel \
python3-virtualenv \
&& :
COPY . /code
ENV PATH=/venv/bin:$PATH
RUN virtualenv /venv -ppython3 && pip install -e /code
RUN : \
&& mkdir /dists \
&& pip wheel -w /dists/ \
# tox itself and its test deps
/code[testing] \
# needed by tests
flit poetry \
# needed to build the virtualenv and install tox
pip==19.1.1 wheel setuptools-scm \
&& pip wheel -w /dists/ \
# tests with specific, duplicated dependencies
setuptools==40.6.3 'setuptools-scm<3' tox==3.7.0 \
# and one more
&& pip wheel -w /dists/ tox==3.12 \
&& :
ENV \
PIP_NO_INDEX=1 \
PIP_FIND_LINKS=file:///dists/ \
TOX_TESTENV_PASSENV='PIP_NO_INDEX PIP_FIND_LINKS'
WORKDIR /code
$ docker build -t tox . && docker run --rm --net=none tox tox -e py37
...
============= 531 passed, 5 skipped, 2 warnings in 414.45 seconds ==============
___________________________________ summary ____________________________________
py37: commands succeeded
congratulations :)
got the tests passing without network, maybe you can adapt this strategy to your packaging:
Thank you very much, I will test it this upcoming week.
@mcepl Did you manage to test the Docker config?
May this issue be closed?
@mcepl Did you manage to test the Docker config?
May this issue be closed?
@jugmac00 I have still a couple of questions:
cp . /code
… what is $PWD
at that moment, what I actually copy to that subdirectory?python3 -mvenv
, right? That pip wheel -w /dist/ pip wheel
still needs a network connection, doesn’t it?
This is basically reopening of #1188 which was closed without any good reason (what effect has use of
setup.py build
on tests? That would be a bug in itself, wouldn't it?). Anyway, I have rewritten our packaging scripts to use onlypip
and of course I was able to fully reproduce the original problem. Complete full build log and specifically error message is:Error message
``` [ 62s] =================================== FAILURES =================================== [ 62s] ____________________________ test_provision_missing ____________________________ [ 62s] [ 62s] initproj =