-
-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use the virtual environment to generate the sdist #507
Comments
I can confirm this. Tahoe-LAFS is python2-only. We recently changed the tahoe-lafs Our We don't want to tell users that they must switch to a py2-based tox first (if they knew how to build a py2 virtualenv and install tox into it, they would know enough to just install tahoe into that virtualenv and run Our workaround is to change the tahoe (for reference, the tahoe bug is at https://tahoe-lafs.org/trac/tahoe-lafs/ticket/2876) |
The previous blanket prohibition on py3 for any invocation of setup.py was breaking our recommended "just run 'tox'" test process on e.g. Ubuntu-16.04 LTS "xenial", which ships with a /usr/bin/tox that is based on py3. This tox runs "setup.py sdist" to build a tahoe tarball, then uses its py2 virtualenv's "pip" to install it (into the py2 virtualenv). Forbidding even "setup.py sdist" from running under py3 was causing tox to fail unless it was a py2-based tox. This new approach only enforces the py2 check if setup.py was invoked as "setup.py install" (which users might do), or "setup.py egg_info" (which pip will do before it does anything else). I experimented with doing the check inside an EggInfo or "build_py" subcommand, but the EggInfo class is invoked internally during an sdist. And we need pip3's egg_info to fail, because if it succeeds, it will proceed to run egg_info on our dependencies (like zfec, whose setup.py contains old-style py2-only 'print "foo"' statements, which causes a syntax error, which is the confusing thing we were trying to head off by providing a clean+instructional error message early). This is a workaround for an upstream Tox bug (see tox-dev/tox#507) that should get fixed (to make tox run `setup.py sdist` with the virtualenv's python, rather than tox's python). However since debian/ubuntu don't generally backport non-security bugfixes to existing releases, a new Tox won't actually help our problem on any of today's operating systems (it'll be 6-12 months before anyone is helped by a Tox fix). So even though we'd ideally prefer to fix this upstream and not here, I think practically speaking we need this workaround anyways. closes ticket:2876
The previous blanket prohibition on py3 for any invocation of setup.py was breaking our recommended "just run 'tox'" test process on e.g. Ubuntu-16.04 LTS "xenial", which ships with a /usr/bin/tox that is based on py3. This tox runs "setup.py sdist" to build a tahoe tarball, then uses its py2 virtualenv's "pip" to install it (into the py2 virtualenv). Forbidding even "setup.py sdist" from running under py3 was causing tox to fail unless it was a py2-based tox. This new approach only enforces the py2 check if setup.py was invoked as "setup.py install" (which users might do), or "setup.py egg_info" (which pip will do before it does anything else). I experimented with doing the check inside an EggInfo or "build_py" subcommand, but the EggInfo class is invoked internally during an sdist. And we need pip3's egg_info to fail, because if it succeeds, it will proceed to run egg_info on our dependencies (like zfec, whose setup.py contains old-style py2-only 'print "foo"' statements, which causes a syntax error, which is the confusing thing we were trying to head off by providing a clean+instructional error message early). This is a workaround for an upstream Tox bug (see tox-dev/tox#507) that should get fixed (to make tox run `setup.py sdist` with the virtualenv's python, rather than tox's python). However since debian/ubuntu don't generally backport non-security bugfixes to existing releases, a new Tox won't actually help our problem on any of today's operating systems (it'll be 6-12 months before anyone is helped by a Tox fix). So even though we'd ideally prefer to fix this upstream and not here, I think practically speaking we need this workaround anyways. closes ticket:2876
The previous blanket prohibition on py3 for any invocation of setup.py was breaking our recommended "just run 'tox'" test process on e.g. Ubuntu-16.04 LTS "xenial", which ships with a /usr/bin/tox that is based on py3. This tox runs "setup.py sdist" to build a tahoe tarball, then uses its py2 virtualenv's "pip" to install it (into the py2 virtualenv). Forbidding even "setup.py sdist" from running under py3 was causing tox to fail unless it was a py2-based tox. This new approach only enforces the py2 check if setup.py was invoked as "setup.py install" (which users might do), or "setup.py egg_info" (which pip will do before it does anything else). I experimented with doing the check inside an EggInfo or "build_py" subcommand, but the EggInfo class is invoked internally during an sdist. And we need pip3's egg_info to fail, because if it succeeds, it will proceed to run egg_info on our dependencies (like zfec, whose setup.py contains old-style py2-only 'print "foo"' statements, which causes a syntax error, which is the confusing thing we were trying to head off by providing a clean+instructional error message early). This is a workaround for an upstream Tox bug (see tox-dev/tox#507) that should get fixed (to make tox run `setup.py sdist` with the virtualenv's python, rather than tox's python). However since debian/ubuntu don't generally backport non-security bugfixes to existing releases, a new Tox won't actually help our problem on any of today's operating systems (it'll be 6-12 months before anyone is helped by a Tox fix). So even though we'd ideally prefer to fix this upstream and not here, I think practically speaking we need this workaround anyways. closes ticket:2876
This allows a python3-based tox (as is common on modern debian/ubuntu systems) to test our py2-only package. The first thing Tox does is to build a wheel to install into the target virtualenv (which is a py2-based venv, for tahoe). But Tox bug (tox-dev/tox#507) in which this wheel is built with the same python that Tox is using, instead of the python from the target environment. Our setup.py would see sys.version_info with py3 and launch a crowbar into the works. With python_requires=, pip is smart enough to know that it's ok to build wheels with the wrong python, but "pip install" still throws a sensible error message: ``` (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 ``` Closes ticket:2876
And set environment variables that defined in |
So the solution could be to regenerate the package creation for each and every environment. |
I think we only should build the package under test once, but the Python building that package needs to fullfill the needs of the Maybe we need to introduce a venv that is only there to build the package in cases where this is necessary? So as a default, package is built by the interpreter that tox is installed in, but if you need another interpreter you can ask for it as a global config option? |
The Travis OS-X worker has a very old setuptools-18.5 in /System. This is too old to understand several important setup.py keys like `python_requires`, and crashes when tryung to run the first invocation of tox (`tox -e codechecks`). I think tox is using the system python (with which `tox` was invoked) to run `setup.py egg_info` (to learn the dependencies), which gets the old system-installed setuptools. Ideally it'd use the python from the newly-created virtualenv, which would use whatever version of setuptools was bundled with the `virtualenv` package (probably newer, given that `virtualenv` itself should have been installed a moment earlier as a dependency of `tox`. I consider this a bug in Tox (tox-dev/tox#507), but the workaround is to configure Travis to install the most recent `setuptools` along with `tox`. refs tahoe-lafs#470
@dstufft this now is resolved with pep 517 implementation released with 3.3..0 |
Currently it appears that tox uses the system Python when creating the sdist (specifically,
/usr/bin/python
if that's where tox is installed). This means that if you're trying to use a setuptools feature that is newer than what your system provides in yoursetup.py
, then you're bound by what your current environment provides (which is often times fairly old). I think it would be a great idea if tox re-used one of the virtual environments it's creating to build the sdist (honestly it could be any of them) which would give more control over what version of setuptools is being used.Additionally, I think this would also affect someone trying to use tox with a package whose
setup.py
only runs on Python 3.For reference, here is the output I'm seeing that suggests this is what is happening:
The text was updated successfully, but these errors were encountered: