Commit 1d3c3d4f authored by Yureka's avatar Yureka Committed by Alyssa Ross
Browse files

python: simplify ABI name detection

parent 56c1aa5d
Loading
Loading
Loading
Loading
+15 −18
Original line number Diff line number Diff line
@@ -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<extension>, 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 ""