Skip to content

makeOverridablePythonPackage: simplify implementation and make compatible with <pkg>.overrideAttrs#267296

Merged
ShamrockLee merged 3 commits intoNixOS:masterfrom
ShamrockLee:python-overrideattrs-fix
Dec 10, 2025
Merged

makeOverridablePythonPackage: simplify implementation and make compatible with <pkg>.overrideAttrs#267296
ShamrockLee merged 3 commits intoNixOS:masterfrom
ShamrockLee:python-overrideattrs-fix

Conversation

@ShamrockLee
Copy link
Contributor

@ShamrockLee ShamrockLee commented Nov 13, 2023

Description of changes

This patch updates the <pkg>.overrideAttrs inside makeOverridablePythonPackage (the function that adds <pkg>.overridePythonAttrs). If applied, <pkgs>.overridePythonAttrs will work after applying <pkg>.overrideAttrs to override a Python package built with buildPythonPackage or buildPythonApplication.

This patch also adds corresponding test cases to tests.overriding.

Closes #267293.

Initial effort for #271387.

Cc: @FRidh

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added the 6.topic: python Python is a high-level, general-purpose programming language. label Nov 13, 2023
@ShamrockLee ShamrockLee changed the title makeOverridablePythonPackage: fix Python overriding to make <pkg>.overridePythonAttrs work after <pkg>.overrideAttrs python3Packages: fix Python overriding to make <pkg>.overridePythonAttrs work after <pkg>.overrideAttrs Nov 13, 2023
@ShamrockLee ShamrockLee force-pushed the python-overrideattrs-fix branch 2 times, most recently from 205c377 to 2cf1c3c Compare November 13, 2023 21:17
@ShamrockLee ShamrockLee marked this pull request as ready for review November 13, 2023 21:44
@ShamrockLee ShamrockLee requested a review from FRidh as a code owner November 13, 2023 21:44
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Nov 13, 2023
@ShamrockLee ShamrockLee force-pushed the python-overrideattrs-fix branch 2 times, most recently from e16c5f0 to ac74756 Compare November 19, 2023 22:16
@ShamrockLee ShamrockLee force-pushed the python-overrideattrs-fix branch from ac74756 to 971cac5 Compare November 30, 2023 23:12
@ShamrockLee
Copy link
Contributor Author

@ofborg build tests.overriding

@ShamrockLee ShamrockLee force-pushed the python-overrideattrs-fix branch from b2ebd09 to 7928373 Compare December 3, 2023 09:35
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 4, 2024
@ShamrockLee ShamrockLee force-pushed the python-overrideattrs-fix branch from 7928373 to 40ad5e6 Compare August 9, 2024 16:04
@ShamrockLee ShamrockLee requested a review from natsukium as a code owner August 9, 2024 16:04
@ShamrockLee
Copy link
Contributor Author

I rebased the feature branch and resolved the merge conflict.

@SomeoneSerge SomeoneSerge self-requested a review August 10, 2024 00:38
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 10, 2024
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 10, 2024
@ShamrockLee ShamrockLee force-pushed the python-overrideattrs-fix branch from 40ad5e6 to 13aafb0 Compare December 19, 2024 15:35
@nix-owners nix-owners bot requested a review from mweinelt December 19, 2024 15:37
@github-actions github-actions bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Dec 19, 2024
@ShamrockLee ShamrockLee force-pushed the python-overrideattrs-fix branch 3 times, most recently from 01dff07 to c027f25 Compare October 23, 2025 10:42
@ShamrockLee ShamrockLee changed the title python3Packages: fix Python overriding to make <pkg>.overridePythonAttrs work after <pkg>.overrideAttrs makeOverridablePythonPackage: simplify implementation and make compatible with <pkg>.overrideAttrs Oct 23, 2025
@ShamrockLee ShamrockLee force-pushed the python-overrideattrs-fix branch from c027f25 to df82fae Compare December 10, 2025 10:54
@ShamrockLee
Copy link
Contributor Author

Rebase and utilize PR #456848 ("tests.overriding: refactor and allow non-bool expected value").

@ShamrockLee ShamrockLee force-pushed the python-overrideattrs-fix branch 3 times, most recently from e1001d7 to 303cf6f Compare December 10, 2025 11:14
ShamrockLee and others added 2 commits December 10, 2025 19:19
Test with a pseudopackage python-package-stub.

Modularize the transforming function and testing function.
Attach overridePythonAttrs by attribute set update
instead of `stdenv.mkDerivation`'s `passthru`.

Co-authored-by: Matt Sturgeon <[email protected]>
@ShamrockLee ShamrockLee force-pushed the python-overrideattrs-fix branch from 303cf6f to 898832f Compare December 10, 2025 11:21
Make it possible to mix overridePythonAttrs and overrideAttrs, i.e.
((<pkg>.overrideAttrs (_: { foo = "a"; })).overridePythonAttrs (_: { })).foo now works

Co-authored-by: Matt Sturgeon <[email protected]>
@ShamrockLee
Copy link
Contributor Author

I wonder if it's okay to backport this PR, especially after the makeOverridablePythonAttrs refactoring (#267296 (comment)).

It should fix <pkg>.overridePythonAttrs and enable split tests implemented with <pkg>.overrideAttrs due to buildPythonPackage's lack of fixed-point attribute support. PR #469544 is an example of such pattern.

1 similar comment
@ShamrockLee
Copy link
Contributor Author

I wonder if it's okay to backport this PR, especially after the makeOverridablePythonAttrs refactoring (#267296 (comment)).

It should fix <pkg>.overridePythonAttrs and enable split tests implemented with <pkg>.overrideAttrs due to buildPythonPackage's lack of fixed-point attribute support. PR #469544 is an example of such pattern.

Copy link
Contributor

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it's okay to backport this PR

I believe this should be fine to backport. It doesn't do anything too crazy.


Diff LGTM.

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Dec 10, 2025
@ShamrockLee ShamrockLee added this pull request to the merge queue Dec 10, 2025
Merged via the queue into NixOS:master with commit ff13d8c Dec 10, 2025
30 of 33 checks passed
@ShamrockLee ShamrockLee deleted the python-overrideattrs-fix branch December 10, 2025 19:12
@ShamrockLee ShamrockLee added the backport release-25.11 Backport PR automatically label Dec 12, 2025
@nixpkgs-ci
Copy link
Contributor

nixpkgs-ci bot commented Dec 12, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.severity: blocker This is preventing another PR or issue from being completed 6.topic: python Python is a high-level, general-purpose programming language. 8.has: port to stable This PR already has a backport to the stable release. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person. backport release-25.11 Backport PR automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<pkg>.overridePythonAttrs doesn't work together with <pkg>.overrideAttrs

5 participants