diff --git a/pkgs/development/interpreters/python/cpython/default.nix b/pkgs/development/interpreters/python/cpython/default.nix index 6778dc460e05..4e60b15ba4cb 100644 --- a/pkgs/development/interpreters/python/cpython/default.nix +++ b/pkgs/development/interpreters/python/cpython/default.nix @@ -195,25 +195,22 @@ let if parsed.cpu.significantByte.name == "littleEndian" then "arm" else "armeb" else if isx86_32 then "i386" else parsed.cpu.name; - # Python doesn't distinguish musl and glibc and always prefixes with "gnu" - gnuAbiName = replaceStrings [ "musl" ] [ "gnu" ] parsed.abi.name; - pythonAbiName = - # python's build doesn't support every gnu, and doesn't - # differentiate between musl and glibc, so we list those supported in - # here: + + pythonAbiName = let + # python's build doesn't match the nixpkgs abi in some cases. # https://github.com/python/cpython/blob/e488e300f5c01289c10906c2e53a8e43d6de32d8/configure.ac#L724 - # Note: this is an approximation, as it doesn't take into account the CPU - # family, or the nixpkgs abi naming conventions. - if elem gnuAbiName [ - "gnux32" - "gnueabihf" - "gnueabi" - "gnuabin32" - "gnuabi64" - "gnuspe" - ] - then gnuAbiName - else "gnu"; + nixpkgsPythonAbiMappings = { + "gnuabielfv2" = "gnu"; + "muslabielfv2" = "musl"; + }; + pythonAbi = nixpkgsPythonAbiMappings.${parsed.abi.name} or parsed.abi.name; + in + # Python <3.11 doesn't distinguish musl and glibc and always prefixes with "gnu" + if lib.versionOlder version "3.11" then + replaceStrings [ "musl" ] [ "gnu" ] pythonAbi + else + pythonAbi; + multiarch = if isDarwin then "darwin" else if isWindows then ""