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.
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
@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 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants