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

Python: buildPythonPackage and overridePythonAttrs should support final: prev: style overrides #258246

Open
RuRo opened this issue Sep 30, 2023 · 2 comments
Labels
0.kind: bug Something is broken

Comments

@RuRo
Copy link
Contributor

RuRo commented Sep 30, 2023

After #119942, mkDerivation supports recursive definition of package attributes with

foo = mkDerivation (final: { });
foo_v2 = foo.overrideAttrs (final: prev: { });

# instead of
foo = mkDerivation rec { };
foo_v2 = foo.overrideAttrs (prev: { });

The buildPythonPackage.overridePythonAttrs functionality originally introduced in #26155 should also support this style of overrides (to avoid the rec antipattern and make the overrides more composable).

pyfoo = buildPythonPackage (final: { });
pyfoo_v2 = pyfoo.overridePythonAttrs (final: prev: { });

# instead of
pyfoo = buildPythonPackage rec { };
pyfoo_v2 = pyfoo.overridePythonAttrs (prev: { });

Also, this probably belongs in #1819.

@RuRo RuRo added the 0.kind: bug Something is broken label Sep 30, 2023
@ShamrockLee
Copy link
Contributor

#234651 addresses this issue with new functions lib.extendMkDerivation and lib.extendMkDerivationModified to defined build helpers with fixed-point arguments based on existing ones. Please take a look!

@uninsane
Copy link
Contributor

for simple packages, a stopgap fix is to use toPythonModule (stdenv.mkDerivation (finalAttrs: { ... })). you'll have to add the appropriate setup hooks to native{Build,Check}Inputs which buildPythonPackage would ordinarily takes care of though.

not the best ergonomics, but if you need it, at least it is possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

3 participants