Python `packageOverrides` not overriding as expected

I’m trying to get a Python package to build, and I’m getting failures because of a Python package version dependency. I’d expected using python3.override {packageOverrides=...;} to allow replacing the offending package with one of the right version in the resultant environment, but I’m still getting version mismatch errors.

I’ve created a relatively minimal stand-alone demo of the problem at https://github.com/me-and/nix-python-problems, which is a trivial Python package plus Nix packaging scripts. The Python package demands setuptools v75, but the Nix packaging is pinned to NixOS 24.05, which has setuptools v69.5.1. package.nix uses packageOverrides to pick up v75.1.0 of setuptools, but the build still fails:

$ nix-build
this derivation will be built:
  /nix/store/s7w68cf7370l7bfm2zzhavdy5c9yabf5-funniest-0.1.drv
building '/nix/store/s7w68cf7370l7bfm2zzhavdy5c9yabf5-funniest-0.1.drv'...
...
Successfully built funniest-0.1-py3-none-any.whl
Finished creating a wheel...
Finished executing pypaBuildPhase
Running phase: pythonRuntimeDepsCheckHook
Executing pythonRuntimeDepsCheck
Checking runtime dependencies for funniest-0.1-py3-none-any.whl
  - setuptools>75.0.0 not satisfied by version 69.5.1.post0
error: builder for '/nix/store/s7w68cf7370l7bfm2zzhavdy5c9yabf5-funniest-0.1.drv' failed with exit code 1;

I know I can use things like relaxPythonDeps to just ignore the dependency problems, and indeed that’s what I’ve done for the real problem I’m dealing with. Nonetheless, I’d expected python3.override {packageOverrides = ...;} to produce a Python environment with the overriden packages, but that doesn’t seem to work. What am I missing?

diff --git a/package.nix b/package.nix
index 9171635..44554ad 100644
--- a/package.nix
+++ b/package.nix
@@ -5,10 +5,11 @@
     # Taken from the NixOS 24.11 branch.
     setuptools = prev.setuptools.overridePythonAttrs (prev: {
       version = "75.1.0";
-      src = prev.src.overrideAttrs {
+      src = prev.src.override {
         rev = "refs/tags/v75.1.0";
         hash = "sha256-ZvhXfusayUHHFXl7ZBksFhxTi1p+Va6qAwq7Fo7Tg/s=";
       };
+      patches = [];
     });
   };
1 Like

…utterly obvious now it’s been pointed out to me. Thank you so much!