NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.23k stars 13.5k forks source link

`pythonRelaxDepsHook` doesn't work for `pyproject.toml` constraints? #327941

Open doronbehar opened 1 month ago

doronbehar commented 1 month ago

Is this intentional? A common anti pattern in Nixpkgs is stuff like this:

    substituteInPlace pyproject.toml \
      --replace-fail "numpy >=2.0.0rc1" "numpy"

Also the docs don't mention the fact that it is actually working on the METADATA file and not setup.{py,cfg} or any other creative way that dependencies can be specified.

doronbehar commented 1 month ago

cc @mweinelt per https://github.com/NixOS/nixpkgs/commit/58ca0215997f192f00ad7bff9607503fedcb7f0c .

mweinelt commented 1 month ago

The pythonRelaxDepsHook has no effect on build time dependencies, such as those specified in build-system. If a package requires incompatible build time dependencies, they should be removed in postPatch through substituteInPlace or similar.

This is a limitation of modifying the metadata of the resulting wheel, where we can only account for runtime dependencies.

doronbehar commented 1 month ago

The pythonRelaxDepsHook has no effect on build time dependencies, such as those specified in build-system. If a package requires incompatible build time dependencies, they should be removed in postPatch through substituteInPlace or similar.

This is a limitation of modifying the metadata of the resulting wheel, where we can only account for runtime dependencies.

I read that part, I just thought that it is not trivial to figure out (if you are not a Python developer) that pyproject.toml may also specify build time dependencies, and hence pythonRelaxDepsHook won't help with those dependencies.

I was also thinking of perhaps extending it's behavior to also edit pyproject.toml in a more Nixy way, or to create a new hook just for pyproject.toml...