Duplicated package after replacing python

Hi,

I experience a duplicated package error, when building pygogo with custom python. toml package is duplicated. What could cause the problem? I can reproduce the issue with other packages (e.g. pygit2) and interpreter versions (3.9.6).

I suspect it is related somehow to libimport, because it depends on toml. Bytecode non determinism? I noticed a patch for that is applied only for old python versions.

pythonCatchConflictsPhase
Found duplicated packages in closure for dependency ‘toml’:
toml 0.10.2 (/nix/store/rxkbpax8krb083hmpkl570qgk4m948hv-python3.9-toml-0.10.2/lib/python3.9/site-packages)
toml 0.10.2 (/nix/store/gmv2cfzs5i4ssnk016rhy44dn9j8mh2k-python3.9-toml-0.10.2/lib/python3.9/site-packages)

{ pkgs ? import <nixpkgs> {} }:

let
  myPatchedPython = (pkgs.python39.overrideAttrs (old:  {
    src = pkgs.fetchFromGitHub {
      owner = "python";
      repo = "cpython";
      rev = "0a7dcbdb13f1f2ab6e76e1cff47e80fb263f5da0"; # 3.9.5                                                               
      sha256 = "0fw1bdphhahr4syahd6ii732ryfpxzlbpxjc3r81bi05yvhybd3q";
    };

    preBuild=''                                                                                                               
      export LIBFFI_INCLUDEDIR=${pkgs.libffi.dev}/include                                                                     
      export SDKROOT="/Library/Developer/CommandLineTools/SDKs/MacOSX10.12.sdk"                                               
    '';

    commonPreHook = ''                                                                                                        
      export LIBFFI_INCLUDEDIR=${pkgs.libffi.dev}/include                                                                     
      export SDKROOT="/Library/Developer/CommandLineTools/SDKs/MacOSX10.12.sdk";                                              
    '';

    LIBFFI_INCLUDEDIR="${pkgs.libffi.dev}/include";
    CFLAGS="-iwithprefix ${pkgs.libffi.dev}/include";

    buildInputs = old.buildInputs ++ [
      pkgs.libffi
      pkgs.tcl-8_6
      pkgs.tk-8_6
      pkgs.darwin.apple_sdk.frameworks.Tcl
    ];
    doCheck = false;
    LDFLAGS = " -L${pkgs.tcl-8_6}/lib -L${pkgs.tk-8_6}/lib " + old.LDFLAGS;
  }));

  # replace python in packages                                                                                                
  pa-py-pkgs = myPatchedPython.override { self = myPatchedPython; };

in pa-py-pkgs.pkgs.pygogo

This is a bug in the Python packages set. Overriding does not work correctly. Native build inputs such as hooks are still using the old Python interpreter.

In the future, please report the Nixpkgs revision you’re using, it makes it a lot easier to reproduce the issue. I tested with nixos-unstable at 439b1605227b8adb1357b55ce8529d541abbe9eb.