tox won't run on ubuntu xenial: python3 #2876
Labels
No Label
0.2.0
0.3.0
0.4.0
0.5.0
0.5.1
0.6.0
0.6.1
0.7.0
0.8.0
0.9.0
1.0.0
1.1.0
1.10.0
1.10.1
1.10.2
1.10a2
1.11.0
1.12.0
1.12.1
1.13.0
1.14.0
1.15.0
1.15.1
1.2.0
1.3.0
1.4.1
1.5.0
1.6.0
1.6.1
1.7.0
1.7.1
1.7β
1.8.0
1.8.1
1.8.2
1.8.3
1.8β
1.9.0
1.9.0-s3branch
1.9.0a1
1.9.0a2
1.9.0b1
1.9.1
1.9.2
1.9.2a1
LeastAuthority.com automation
blocker
cannot reproduce
cloud-branch
code
code-dirnodes
code-encoding
code-frontend
code-frontend-cli
code-frontend-ftp-sftp
code-frontend-magic-folder
code-frontend-web
code-mutable
code-network
code-nodeadmin
code-peerselection
code-storage
contrib
critical
defect
dev-infrastructure
documentation
duplicate
enhancement
fixed
invalid
major
minor
n/a
normal
operational
packaging
somebody else's problem
supercritical
task
trivial
unknown
was already fixed
website
wontfix
worksforme
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Reference: tahoe-lafs/trac-2024-07-25#2876
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
We recently landed a change to our
setup.py
, to bail with a clear error message if you try to run it under python3 (since tahoe only supports python2). Unfortunately, thetox
provided in Ubuntu-16.04 "xenial" (the most recent LTS release) is a python3 executable, and when it runssetup.py
to build a .zip package, it fails:As a result, our xenial buildbot is failing, and folks using xenial can't test tahoe.
I'm a bit surprised that tox is using it's native python3 to build a package, even though the
-e py27
should cause it to use python2 to actually run the tests. Is there some way to tell tox which python to use for packaging purposes?Looking at the
tox
source code, intox/session.py
(around line 412, inSession._makesdist()
), there's a hard-coded use ofsys.executable
to run the sdist command:which suggests to me that a py3-based tox just can't run a py2-requiring setup.py.
I suppose we could change our setup.py check to tolerate an
sdist
command, but reject all others. Or we could soften it to a warning.I think we ought to allow our published "just run
tox
" test procedure to work on the current ubuntu LTS (or any other distribution that has python2.7 available, even iftox
or the system defaultpython
are py3).BTW setting
basepython=python2.7
intox.ini
didn't fix it.Also, it looks like travis didn't catch this when it was a pull request because travis runs everything in a py2 virtualenv, whereas our xenial buildbot tries harder to mimic a real user following our build instructions (using
/usr/bin/tox
).Many of our buildbot boxes appear to be using native
tox
. But several are using a buildbot-specific installation: Centos7, Fedora2.4, and !Debian/Jesse all havetool-versions
logs that show something like~/.local/bin/tox
being used (quite possibly installed specifically to overcome problems like this one). So those builders might be masking problems that would affect users who follow our instructions and just runtox
.Another approach would be to change the unconditional not-py3 check to instead only run in the "build" subcommand, or "build_py". Would that accomplish the same goals as the original issue? We're looking to raise an error as early as possible, for folks who mistakenly use py3 to try to install Tahoe. So we need to make sure that
pip3 install tahoe-lafs
fails in a good way.Ah, part of the issue is py3-incompatible syntax in tahoe's setup.py itself, or (worse) in those of the dependencies. When I do a
pip install .
inside a py3 virtualenv (sopip
is reallypip3
), the first exception I get is a syntax error in zfec's setup.py, which contains an old-styleprint "something"
statement.Tahoe's setup.py is first called as
setup.py egg-info
, then if this succeeds, pip(3) starts doing the same for its dependencies. To deliver a useful error message early, we needegg-info
to throw.When
tox
runs, the first thing it does is to runsdist
. Only later, inside the new (py2) virtualenv, does it runegg_info
. So maybe changing theegg_info
command to check the version, but making sure thatsdist
is py3-tolerant, would allow tox3 to work and still retain the useful error when pip3 is used by mistake.But.. the
sdist
command invokesegg-info
internally. Rats.Ah, so I think the simplest solution is to have our setup.py look at
sys.argv
, and apply the py2-only check iff setup.py was invoked assetup.py egg_info
orsetup.py install
. A pip install will do the former, and users may do the latter directly.PR in https://github.com/tahoe-lafs/tahoe-lafs/pull/422
At yesterday's devchat, exarkun pointed out that this is really a Tox bug (it ought to use the virtualenv python for the sdist step, not whatever python tox itself is using). So:
Meanwhile, we can monkeypatch something to let our CI continue to work until that Tox bug gets fixed. And we should probably find a way to make a zfec release with a py3-tolerant setup.py (which means changing the
print "foo"
into aprint("foo")
)The upstream Tox bug is https://github.com/tox-dev/tox/issues/507 , and I've added a note about how it affects us.
Note: xenial (and other platforms) are unlikely to backport a newer Tox, so even if/when this gets fixed upstream, we'll still have the problem that Tahoe can't run tests on current py3-based systems. So I'm going to argue for landing PR 422 (or something similar) anyways.
A quick workaround is to create a py2 virtualenv, activate it, and install tox:
The narrow-focussed monkeypatch could be:
Some other ideas that exarkun had in today's devchat:
tox.py
script to the tahoe source tree, which would:tox
entrypoint (by askingpkg_resources
, probably, or maybe just hard-coding the currentfrom tox import cmdline
).py
file of the same name to tahoe's top-level directoryIf we did the
tox.py
thing, we could put a note in the "how to run tests" doc that said "on many systems you can just runtox
, but if you see this complain about py3, then you'll need to runpython2 tox.py
instead". The error message that our setup.py raises (when run under py3) would be a good place for these instructions too.I saw a presentation at PyBay this last weekend, by one of the Jupyter developers, about their transition from py2+py3 to py3-only. He encouraged everyone to add a
python_requires=
argument to theirsetup()
call, which adds metadata that specifies which versions of python the package/distribution is compatible with. For their needs, they made sure to publish a version that claimed both 2 and 3 before their switchover. Later, when a newer version was marked as py3-only, py2-based sites which had installed the old version will correctly refuse to upgrade to the newer one. He mentioned that older versions of pip and setuptools do not pay attention to thepython_requires=
field, and they had some workaround and monitoring to keep track of how many installs were affected.So another approach for us would be to mark our
setup()
withpython_requires=
, then remove the manual py3-crowbar from our setup.py. I'll do some testing: my hope is that apip install
will see the metadata and give a useful error (and pip will own that error, not us), but when tox3 doessetup.py wheel
, it won't complain.If that works, I'll cancel PR-422 and replace it with one that uses
python_requires=
.In 04fc0e4/trunk:
(ve36) ~/stuff/tahoe/tahoe$ pip install .
Processing /home/warner/stuff/tahoe/tahoe
tahoe-lafs requires Python '<3.0' but the running Python is 3.6.1