-
-
Notifications
You must be signed in to change notification settings - Fork 451
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
Automatically add build-system.requires to nativeBuildInputs #568
Comments
I just ran into this while trying to add |
I read some code a bit, and added some traces. It seems in general, there's all tooling in place to parse However, it seems I don't quite understand the bigger picture yet, why this only applies to @adisbladis, any idea? |
I'm able to workaround this by manually bringing in a flit-core, via the poetry2nix.mkPoetryApplication {
projectDir = ./.;
python = python310;
overrides = poetry2nix.overrides.withDefaults (self: super: {
# …
# workaround https://github.com/nix-community/poetry2nix/issues/568
structlog = super.structlog.overridePythonAttrs (old: {
buildInputs = old.buildInputs or [ ] ++ [ python310.pkgs.flit-core ];
});
});
} So it seems this indeed just a matter of not automatically bringing in the build system packages for dependencies. |
Yes, I'm using this workaround as well. I've also seen that the build system dependencies are hard coded for now for a subset of packages. It would be nice to parse the |
Yeah, but the tooling should be there to just derive this from |
The root cause of this issue is upstream python-poetry/poetry#2789. |
Since poetry does not write the build-system.requires to the lockfile, poetry2nix can't really get that information indeed. |
Huuh. Can we link to the upstream issue somewhere in the poetry2nix docs, and provide some guidance on how we seem to be using the overrides mechanism to manually keep track of these dependencies? |
Maybe could we include https://github.com/DavHau/pypi-deps-db and fetch the desired build system from there? Just like mach-nix does. |
The upstream issue python-poetry/poetry#2789 was fixed, but the fix uses ephemeral build environments, and the information needed to reconstruct them is not recorded in the lock file. Perhaps another upstream issue should be opened explaining why it should be recorded? |
I think upstream understands why it's important, but not how to implement it, due to a technical limitation they explained in python-poetry/poetry#5401 (comment). Just keep that in mind, but in any case I agree to open a new issue and talk with upstream to see what solution could we get to. If solved upstream, it'd have obvious benefits upstream too, so I think they'll be open to it if there's a way to do it. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/why-is-it-so-hard-to-use-a-python-package/19200/11 |
I suggest doing the pinning of the build systems here in Note though you will probably need to resolve them together, to ensure they can cooperate when needed. I think it is rare this is going to cause issues, but you don't know. This could be done with poetry itself. |
Poetry does not lock down information about the build system used to build dependencies. As such poetry2nix cannot automatically figure out build inputs. nix-community/poetry2nix#568 This documents how to help poetry2nix out with figuring out buildinputs.
* Document ModuleNotFoundError Poetry does not lock down information about the build system used to build dependencies. As such poetry2nix cannot automatically figure out build inputs. nix-community/poetry2nix#568 This documents how to help poetry2nix out with figuring out buildinputs. * Use path syntax for including the overrides.nix * Use generic placeholder
|
Looks like python-poetry/poetry#7975 was merged which may potentially fix this? Has anyone tried overriding poetry with a git version to see if this fixes things? |
This example with If anyone would like this issue to progress, we need another new reproducible example that makes sense. |
This [tool.poetry]
name = "test"
version = "0.0.0"
description = ""
authors = []
[tool.poetry.dependencies]
python = "3.10"
urllib3 = "2.0.4"
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api" |
@brendon-boldt I think your problem was resolved by 33db1f3, but that version of poetry2nix is not yet in nixpkgs. I tried your pyproject.toml with the latest poetry2nix flake, and urllib3 was installed correctly. See https://github.com/dmytrokyrychuk/nix-urllib3-test |
I think that the PyPI cmake package is an example of this: pyproject.toml:
flake.nix:
Error:
|
IMO that makes sense, and it is best to figure out a way that does not rely on poetry changing its behavior. It seems to me that most packages use only a very limited set of packages for E.g. { ... }:
let
# from nixpkgs
pythonPackages = ...;
pyprojectToml = ...;
depToDrv = {
# For example
"poetry-core" = pythonPackages.poetry-core;
};
buildRequires = map (dep: ) pyprojectToml.build-system.requires;
in
# add `buildRequires` to the Python build |
That would be IFD, so not possible. |
If I understand the issue correctly, However, Poetry does not put build-time dependencies of the transitive (build- or run-time) dependencies into PyPI exposes the hash of the source through an HTTP API, which is how Poetry puts a hash of the source of every dependency in the Maybe we should frame our request to Poetry as "please provide a |
If the reason it would be slow for Poetry to add
That’s already there as the “As with all configurations described here, this is a user specific configuration. This means that this is not taken into consideration when a lockfile is generated or dependencies are resolved. This is applied only when selecting which distribution for dependency should be installed into a Poetry managed environment.” |
Are there any Python package managers that make a better lockfile? Does PDM do any better? |
Apparently, it is quite feasible to roll your own by using the Poetry solver as a library. See here how That wouldn't be an ideal situation, due to the maintenance burden. But it might be a solution. |
How about a |
A good thing about poetry2nix was the ability to plug it on any poetry repository, including those which we don't have write permissions. Requiring a file specific to poetry2nix in the source code repos would make poetr2nix much less useful. |
I didn't say you need to put that file in the source repository... Since that lock file is only relevant for poetry2nix (and only if you build from sources, not from wheels), then it makes sense that it resides in the same repo as the instructions to build with nix. Example: { poetry2nix, python310, fetchgitArgs }:
poetry2nix.mkPoetryApplication rec {
python = python310;
pyproject = src + "/pyproject.toml";
poetrylock = src + "/poetry.lock";
poetry2nixlock = ./poetry2nix.lock;
src = builtins.fetchgit fetchgitArgs;
} |
EDIT: original title was "flit_core backend missing"
Describe the issue
In
entrypoints-0.4
the backend isflit_core.buildapi
which is specified in requires in build-system.https://github.com/takluyver/entrypoints/blob/ebdf2d8edc9921427ea07688851999796093c240/pyproject.toml#L2-L3
Trying to build
entrypoints
in a poetry2nix mkPoetryEnv fails on build withAdditional context
Entering nix shell I can check that flit_core is not available (not in pip list)
It's weird because it seems to me that poetry2nix reads the backend fields
poetry2nix/lib.nix
Line 161 in 69cc39a
default.nix
/shell.nix
/flake.nix
pyproject.toml
`poetry.lock`
The text was updated successfully, but these errors were encountered: