Skip to content
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

pythonPackages.toPythonModule: also support overridePythonAttrs. #95687

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FRidh
Copy link
Member

@FRidh FRidh commented Aug 17, 2020

The overridePythonAttrs method is for overriding buildPython*
builders. Packages that use toPythonModule directly are typically
bindings build not using buildPython*.

This commit allows also those packages to be overridden with
overridePythonAttrs, insteading actually invoking overrideAttrs.

The motivation for this is to offer a common user interface for users of
the Python packages set. This way they only need to know about
overridePythonAttrs when overriding the builder, and override when
overriding the callPackage call.

Related RFC NixOS/rfcs#67.

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@FRidh FRidh requested a review from jonringer as a code owner August 17, 2020 12:29
The `overridePythonAttrs` method is for overriding `buildPython*`
builders. Packages that use `toPythonModule` directly are typically
bindings build not using `buildPython*`.

This commit allows also those packages to be overridden with
`overridePythonAttrs`, insteading actually invoking `overrideAttrs`.

The motivation for this is to offer a common user interface for users of
the Python packages set. This way they only need to know about
`overridePythonAttrs` when overriding the builder, and `override` when
overriding the `callPackage` call.

Related RFC NixOS/rfcs#67.
@FRidh FRidh requested a review from infinisil August 17, 2020 12:34
@ofborg ofborg bot added 6.topic: python 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Aug 17, 2020
Copy link
Contributor

@drewrisinger drewrisinger left a comment

Choose a reason for hiding this comment

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

Sounds good/reasonable to me.

  • Diff LGTM
  • Commits LGTM
  • Build: no build attempted

Copy link
Contributor

@jonringer jonringer left a comment

Choose a reason for hiding this comment

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

diff LGTM

});
}) // {
overridePythonAttrs = drv.overrideAttrs;
};
Copy link
Member

Choose a reason for hiding this comment

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

Problems:

  • This is not composable: You can't overridePythonAttrs twice
  • overrideAttrs doesn't support non-functions, so .overridePythonAttrs {} fails, leading to inconsistent behavior with the overridePythonAttrs that makeOverridablePythonPackage defines.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see. Any suggestion how this can be resolved by adding the override option after the original function (stdenv.mkDerivation) has already been called? This here also seems a case where NixOS/rfcs#3 would be helpful.

Copy link
Member

Choose a reason for hiding this comment

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

Usually this is done by calling the original function again, but I think this get really messy with multiple ways to override things. Maybe look at the implementation of makeOverridable

@stale
Copy link

stale bot commented Feb 14, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Feb 14, 2021
@wegank wegank added the 12.approvals: 2 This PR was reviewed and approved by two reputable people label Sep 7, 2023
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Sep 7, 2023
@wegank wegank added 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 2.status: merge conflict This PR has merge conflicts with the target branch labels Mar 19, 2024
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 20, 2024
@wegank wegank marked this pull request as draft March 20, 2024 22:57
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: python 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux 12.approvals: 2 This PR was reviewed and approved by two reputable people
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants