Skip to content

python3Packages.pythonMetadataCheckHook: add pythonMetadataCheckName escape-hatch - #546295

Closed
pbsds wants to merge 3 commits into
NixOS:stagingfrom
pbsds:tmp-feat-python-metadata-package-name-1785155688
Closed

pbsds wants to merge 3 commits into
NixOS:stagingfrom
pbsds:tmp-feat-python-metadata-package-name-1785155688

Conversation

@pbsds

@pbsds pbsds commented Jul 27, 2026 •

Copy link
Copy Markdown
Member
  • python3Packages.pythonMetadataCheckHook: add pythonMetadataCheckName escape-hatch
  • python3Packages.pythonMetadataCheckHook: avoid leaking internal variables
  • python3Packages.pythonMetadataCheckHook: fix typo

Sometimes there are valid reasons to not have a match between pname and the resulting package.
This adds pythonMetadataCheckName as a way to set the package name that pythonMetadataCheckHook checks instead of relying on pname.

Reasons one might want to have a mismatch between pname and the package name:

  • to handle pypi and package name mismatches
  • e.g. *-cuda or *-rocm pname variants
  • to help spot debug, test and intermediate builds that should not get propagated (i.e. gradio.sans-reverse-dependencies)

This was tested on pytest.

Things done

@nixpkgs-ci
nixpkgs-ci Bot requested a review from mweinelt July 27, 2026 12:54
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. 6.topic: python Python is a high-level, general-purpose programming language. labels Jul 27, 2026
@Sigmanificient
Sigmanificient requested a review from dotlambda July 27, 2026 13:02
@dotlambda

Copy link
Copy Markdown
Member
  • to handle pypi and package name mismatches

Explain. The package name should always match the name on PyPI.

  • e.g. *-cuda or *-rocm pname variants

That's not a good idea in the Python package set and should be handled via .override. I don't see a need to change the pname.

  • to help spot debug, test and intermediate builds that should not get propagated (i.e. gradio.sans-reverse-dependencies)

What's wrong with dontCheckPythonMetadata there?

@pbsds

pbsds commented Jul 27, 2026

Copy link
Copy Markdown
Member Author
  • to handle pypi and package name mismatches

Explain. The package name should always match the name on PyPI.

TIL

  • e.g. *-cuda or *-rocm pname variants

That's not a good idea in the Python package set and should be handled via .override. I don't see a need to change the pname.

First few examples I found with grep:

pname = "paddlepaddle" + lib.optionalString cudaSupport "-gpu";

pname = "tensorflow" + lib.optionalString cudaSupport "-gpu";

This idea is not limited to cuda or rocm, but can be about any kind of variant the maintainer want to be able to tell apart by pname and not just input hash.
It is not very common in python3Packages however.

  • to help spot debug, test and intermediate builds that should not get propagated (i.e. gradio.sans-reverse-dependencies)

What's wrong with dontCheckPythonMetadata there?

Increased roundstrip times during testing, I prefer things fail early.


If pname == pyproject.toml::project.name is indeed an invariant you want to enforce for python3Packages then consider closing this.

@dotlambda

dotlambda commented Jul 27, 2026 •

Copy link
Copy Markdown
Member

If pname == pyproject.toml::project.name is indeed an invariant you want to enforce for python3Packages then consider closing this.

The docs say that they should be the same, and so should the attribute name.
But I definitely want to keep the commit making variables local.

This idea is not limited to cuda or rocm, but can be about any kind of variant the maintainer want to be able to tell apart by pname and not just input hash.

Right but is there a good reason to do so for python3Packages, where you always need to choose your variant inside overrideScope?

@pbsds

pbsds commented Jul 27, 2026 •

Copy link
Copy Markdown
Member Author

Right but is there a good reason to do so for python3Packages, where you always need to choose your variant inside overrideScope?

I dislike attributes like pytorchWithCuda. But often i check when i apply a change in config or with an override whether it actually worked, by for example inspecting the updated pname. IMO a mismatch between the pname and attrname is not a big deal

But I definitely want to keep the commit making variables local.

alternative here

@dotlambda

Copy link
Copy Markdown
Member

One reason I'm reluctant to add this is that people will use this rather fixing the pname.

@pbsds
pbsds marked this pull request as draft July 27, 2026 14:59
@dotlambda

Copy link
Copy Markdown
Member

If you like some variant having a different pname you can set $pname in preCheck or disable the hook entirely for that variant.

@pbsds

pbsds commented Jul 27, 2026

Copy link
Copy Markdown
Member Author

If you like some variant having a different pname you can set $pname in preCheck or [...]

I think we both agree that such a hack should not pass review 😆
Let's drop this 👍

@pbsds pbsds closed this Jul 27, 2026
@brianmcgillion brianmcgillion mentioned this pull request Aug 4, 2026
5 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: python Python is a high-level, general-purpose programming language. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants