-
Notifications
You must be signed in to change notification settings - Fork 548
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
Support building from sdist
in a build action
#2410
Comments
|
I think they're quite different if I read this issue. I think this issue title is misleading, but you can confirm what you mean. 😊 1103 is for package publishers. It's for teams who want to use bazel as a build backend to build a wheel or sdist. Similar to how meson, poetry, flit are build backends. I read this is issue as an enabler for package consumers. Basically a mechanism that is an improvement to patching. I read this issue as a way to prepare a "build environment" for difficult packages and being able to run with "--no-build-isolation" so that sdist (packages without wheels) can be more easily imported into the Bazel build. |
Ah yes, you are correct here. |
I think we should then consider removing PEP 621 from the title. pyproject.toml is only a standard for storing metadata. |
I would like to restrict us looking only at sdists that comply with PEP621. We will need to somehow get the dependencies for the sdist in the loading phase and then building of the sdist in the build phase can happen correctly. Doing this for sdists that do not comply with PEP621 might be trickier. WDYT? |
My 2c: I love the intention of making "sdist" handling better. Even isolating them into the naughty corner, makes things better for users, because it highlights what is going on when there are failing builds. If you are applying those constraints to the implementation, then it's still unrelated to PEP-621. PEP-621 is purely about storing metadata in pyproject.toml. If you want to limit the implementation to only supporting the dependencies in the But overall, I think that explicitly not supporting legacy setuptools based builds makes sense. Modern setuptools builds do provide a Features that I think I'd like to see from an "sdist" building facility:
|
OK, I think I see what you mean here, I'll remove the PEP621 from the title.
I was thinking about how we could support users injecting the env into the build process and I think we could implement this environment specification by creating a toolchain for building sdists.
The toolchains that would be building sdists maybe could be defined/wired by the |
sdist
in a build actionsdist
in a build action
Using toolchains for the pieces that handle an sdist is a good idea, +1 to that.
Alternatively each builder is its own rule with its own toolchain type. Perhaps there some common toolchain types to carry common backends can reuse. I think we can know which builder to use at repo-phase, right? Since we can look in the sdist's toml file to figure that out. Then codegen e.g. Using transition, it would have to be something like A variation would be to have a toolchain type per backend, and an attribute specifies with toolchain type to lookup. So there'd be pip_toolchain_type, build_toolchain_type, uv_toolchain_type, etc, all of which are optional. Not sure if I really like this idea.
How would this be possible? I guess if the user is registering the toolchains, yeah, that could work. Ideally, it'd be nice if somehow the sdist metadata (pyproject.toml etc) could be processed during the repo phase to generate dependency labels. Once we have labels (of any type), we can then try to get them bound to things.
Yeah, this makes sense. It is those pip.parse() generated pieces that eventually cause those sdists to bulid. Are the sdist build dependencies a separate dependency closure from the pip.parse requirements input? If so, then we'd need someway for pip.parse to take a "sdist_build_requirements.txt" type of thing. |
I like your idea to have a variation per backend. The toolchain types then could be defined in And I think I like your idea of having a rule per builder type. There probably will be a way to easily reuse most of the plumbing across the sdist building rules for each separate backend.
My thinking is that the toolchain definition itself could be something like:
|
We can chat at next maintainers meeting, but I’m not actually sure you need a toolchain per build backend. The way that a PEP517 client/frontend works is by installing the build dependencies declared in build-system.requires and invoking the module declared in build-system.backend. Then hooks are called to invoke the backend. See https://github.com/pypa/pyproject-hooks The issue with that is that often it’s not enough. Often sdists require additional dependencies to build and config settings provided in READMEs. |
Support building from
sdist
as a build action instead ofrepository_rule
.Things needed:
repository
rule that would not do any building withpip
.pyproject.toml
so that thedeps
field is populated at the repository time.pip
toolchain or something similar for building packages. Maybe we should have atoolchain
for each build backend in the https://peps.python.org/pep-0621/Initial thoughts:
sdist_archive
rule, which would download a givensdist
by URL and then would parsepyproject.toml
. If thepyproject.toml
is not found or it is dynamic and requires Python to correctly infer the dependencies, we may need to fail at least in the first iteration.At the moment I don't have time to work on this myself, but writing it down so that an issue for PEP621 based sdist building exists. Feel free to add thoughts here on possible design.
The text was updated successfully, but these errors were encountered: