PEP517’s definition of “frontend” and “backend” is unclear to me.
PEP 517 – A build-system independent format for source trees, section ‘‘Terminology and Goals’’, says:
A build frontend is a tool that users might run that takes arbitrary source trees or source distributions and builds wheels from them. The actual building is done by each source tree’s build backend. In a command like
pip wheel some-directory/
, pip is acting as a build frontend.
This says that the frontend is a) what users run, and b) builds wheels. But it says that the backend is what builds wheels. This is confusing. That thing which builds wheels — is it the frontend or the backend?
PEP517’s example confuses me more.
In a command like
pip wheel some-directory/
, pip is acting as a build frontend.
Well, the user invokes pip
from the shell, so that makes it a front-end. But doesn’t pip also make the wheel? Doesn’t that make it a back-end as well? And, am I correct in understanding that pip does not consult pyproject.toml
, so it really predates the PEP517 division of build into frontend and backend? If so, that seems to make pip
a poor example.
PEP517 defines a key build-backend
for the pyproject.toml
file. Its value is “a string naming a Python object that will be used to perform the build”… That implies to me that the object which performs the build is the build-backend, so therefore the frontend must be the object which does not perform the build.
It seems to me that what PEP517 might be trying to say is,
A build is the action of building a wheel or sdist from an arbitrary source trees or source distribution. A build frontend is a tool that users might run to invoke a build. The build backend is a library called by the build frontend, and which actually performs the build action. The build frontend consults the
pyproject.toml
file to identify the build backend, and invokes it. The build backend consultspyproject.toml
and perhaps other configuration files in the source tree and/or parameters passed from the frontend to guide how it performs the build.
Do I understand that correctly?
And, what tools are good examples which clearly show the distinction between build frontends or build backends, in the PEP517 sense?
Background: this question arises because I used my understanding of PEP517 to pose a question in StackOverflow, How to build pex or shiv package from pyproject-compliant project? A contributor there suggested that I misunderstood what PEP517 means by frontend and backend, and that maybe I could clear up my misunderstandings on this forum.