Skip to content

toPythonModule discards the effect of buildPython* disabled attribute #376404

@ShamrockLee

Description

@ShamrockLee

Description

As a consequence of lib.extendDerivation's incorrect handling of overrideAttrs (#288148), toPythonApplication would discard the erroring behaviour imposed by the disabled attribute of Python packages, making Python applications with incompatible Python interpreters pass the evaluation silently.

Example and Reproduction

The vcard package is a living example in Nixpkgs. It is disabled for Python >= 3.12, where python currently defaults to CPython 3.12 (on x86_64-linux). python3Packages.vcard fails to evaluate with error messages showing the incompatibility, while pkgs.vcard pass the evaluation.

nix-repl> pkgs.python3Packages.vcard
error:
       … while evaluating the attribute 'drvPath'
         at /home/shamrock/Projects/NixOS/nixpkgs_losslesscut/lib/customisation.nix:418:7:
          417|     // {
          418|       drvPath =
             |       ^
          419|         assert condition;

       … in the condition of the assert statement
         at /home/shamrock/Projects/NixOS/nixpkgs_losslesscut/lib/customisation.nix:419:9:
          418|       drvPath =
          419|         assert condition;
             |         ^
          420|         drv.drvPath;

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: vcard-0.16.1 not supported for interpreter python3.12

nix-repl> pkgs.vcard                  
«derivation /nix/store/2azz11nd41vvih0iyz2vl693zc0f9xpv-python3.12-vcard-0.16.1.drv»

nix-repl> pkgs.python3Packages.toPythonApplication pkgs.vcard
«derivation /nix/store/2azz11nd41vvih0iyz2vl693zc0f9xpv-python3.12-vcard-0.16.1.drv»

Potential solution and workaround

While a long-term solution could be what #376228 proposes, we could monkey-patch the disabling functionality of buildPython* to make it respect overrideAttrs and address this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken6.topic: pythonPython is a high-level, general-purpose programming language.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions