tox: Add support for PEP-517
Currently tox does not yet appear have support for the buildsystem.requires key of pyproject.toml as defined in PEP-518.
PIP has implemented this: https://github.com/pypa/pip/pull/4144 (will be part of PIP 10.0) and it would be nice if tox could also add support for installing packages defined using that key, instead of having to use the broken setup_requires key of ./setup.py.
Example of a pyproject.toml file that creates a setuptools 34+ environment:
[build-system]
requires = ["setuptools >= 34", "wheel"]
Example of a pyproject.toml file that creates an environment for building flit packages:
[build-system]
requires = ["flit"]
(Note that this kind of setup is pretty useless without support for PEP-517.)
Approximate step by step algorithm for supporting both PEP-517 and “legacy” ./setup.py deployments (based on PEP-518 & how PIP choose to implement it):
- If
skipsdistin thetoxsection oftox.iniistrue, do nothing - Create a new
virtualenvto host thesdistgeneration environment - If a file named
pyproject.tomlexists in thetoxinidir:- Parse the
pyproject.tomlas TOML file (using the python toml library for instance) - Search for the
build-system.requireskey and treat each entry in the array as anPEP-508dependency specification - If the key was missing or not an array, report an informative error message and exit
- Install each found build dependency into the
virtualenv
- Parse the
- Otherwise install
setuptoolsandwheelinto thevirtualenv - Execute
./setup.py sdistwithin thevirtualenvto generate thesdistused for the subsequent testing steps
(The build environment may be reused between subsequent testing sessions, as long as the list of requirements doesn’t change.)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 27 (15 by maintainers)
Commits related to this issue
- PEP-517 source distribution support (#954) create a ``.package`` virtual environment to perform build operations inside Resolves #573 and #820. — committed to tox-dev/tox by gaborbernat 6 years ago
- Scheduled weekly dependency update for week 38 (#25) ### Update [tox](https://pypi.org/project/tox) from **3.2.1** to **3.4.0**. <details> <summary>Changelog</summary> ###... — committed to DmytroLitvinov/kuna by pyup-bot 6 years ago
- Update tox to 3.4.0 (#380) This PR updates [tox](https://pypi.org/project/tox) from **3.1.2** to **3.4.0**. <details> <summary>Changelog</summary> ### 3.4.0 ``` --------... — committed to guykisel/inline-plz by pyup-bot 6 years ago
There’s also a pep517 module providing an API for tools to go from a source tree to an sdist/wheel using the PEP 517 interface. I wrote that in the hope that it would make it easier for pip to add support for that interface.
Drawing from the experience implementing this in toxn (and with pip 10 coming out with PEP-518 support too), I’ll add support for this in the next month, drawing up and during the PyCon sprint.
@warsaw no support at the moment, however I plan to add it at some point 👍
Hi @takluyver, thanks for pointing that out. It will be best to have a close eye on the developments in pip and follow their lead then whatever they will use for parsing toml.
TOML libraries: I had a brief look at the code of each a few months back, and at the time I felt more confident in pytoml than in toml. Consequently, pytoml is the one which is vendored into pip, and which will become a dependency of flit once PEP 517 is finalised.
The developer of pytoml did not express great enthusiasm for ongoing maintenance, IIRC. But if it’s used in pip, there’s an incentive for other people to take over the maintenance if it becomes necessary.
@obestwalter: Only insofar as that they respect the tool namespace collision avoidance rules of PEP-518:
So one could probably make up an interesting legal case about whether that already entailes “using” PEP-518 or not 😉.