Commit dcdd4792 authored by Niklas Korz's avatar Niklas Korz
Browse files

python3Packages.primp: drop

parent 16828490
Loading
Loading
Loading
Loading
+0 −132
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,
  rustPlatform,
  pytest,
  runCommand,
  boringssl,
  libiconv,
  gcc-unwrapped,
  python,
  fetchpatch,
}:

let
  boringsslPatched = boringssl.overrideAttrs (oa: {
    # boringssl source obtained from https://github.com/0x676e67/boring2/tree/1a0f1cd24e728aac100df68027c820f858199224/boring-sys/deps
    src = fetchFromGitHub {
      owner = "google";
      repo = "boringssl";
      rev = "44b3df6f03d85c901767250329c571db405122d5";
      hash = "sha256-REELo7X9aFy2OHjubYLO1UQXLTgekD4QFd2vyFthIrg=";
    };
    modRoot = "./src";
    patches = [
      # A patch required to build boringssl compatible with `boring-sys2`.
      # See https://github.com/0x676e67/boring2/blob/refs/tags/v4.15.11/boring-sys/build/main.rs#L486-L489
      (fetchpatch {
        name = "boringssl-44b3df6f03d85c901767250329c571db405122d5.patch";
        url = "https://raw.githubusercontent.com/0x676e67/boring2/refs/tags/v4.15.11/boring-sys/patches/boringssl-44b3df6f03d85c901767250329c571db405122d5.patch";
        hash = "sha256-JRRATcCXo0HBQTzgCAuLpxC3NEGrTw1cEmC0VHOgO2M=";
      })
    ];

    # Remove bazel specific build file to make way for build directory
    # This is a problem on Darwin because of case-insensitive filesystem
    preBuild =
      (lib.optionalString stdenv.hostPlatform.isDarwin ''
        rm ../BUILD
      '')
      + oa.preBuild;

    env.NIX_CFLAGS_COMPILE =
      oa.env.NIX_CFLAGS_COMPILE
      + " "
      + toString (
        lib.optionals stdenv.cc.isClang [
          "-Wno-error=reorder-ctor"
        ]
        ++ lib.optionals stdenv.cc.isGNU [
          "-Wno-error=reorder"
          "-Wno-error=ignored-attributes"
        ]
      );

    vendorHash = "sha256-06MkjXl0DKFzIH/H+uT9kXsQdPq7qdZh2dlLW/YhJuk=";

    installPhase = ''
      runHook preInstall

      mkdir -p $bin/bin $dev $out/lib

      install -Dm755 tool/bssl -t $bin/bin
      install -Dm644 ssl/libssl.a -t $out/lib
      install -Dm644 crypto/libcrypto.a -t $out/lib
      install -Dm644 decrepit/libdecrepit.a -t $out/lib

      cp -r ../include $dev

      runHook postInstall
    '';
  });
  # boring-sys expects the static libraries in build/ instead of lib/
  boringssl-wrapper = runCommand "boringssl-wrapper" { } ''
    mkdir $out
    ln -s ${boringsslPatched.out}/lib $out/build
    ln -s ${boringsslPatched.dev}/include $out/include
  '';
in
buildPythonPackage rec {
  pname = "primp";
  version = "0.15.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "deedy5";
    repo = "primp";
    tag = "v${version}";
    hash = "sha256-13o0Ni0dvZaoKgYy2cFQhebwKAJGm5Z2s+gVAddxYxU=";
  };

  cargoDeps = rustPlatform.fetchCargoVendor {
    inherit pname version src;
    hash = "sha256-UBpf9f3wJgbizHERsm83cuKHiMixj/8JX/IGvteySIo=";
  };

  nativeBuildInputs = [
    rustPlatform.bindgenHook
    rustPlatform.cargoSetupHook
    rustPlatform.maturinBuildHook
  ];

  # TODO: Can we improve this?
  postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
    patchelf --add-rpath ${lib.getLib gcc-unwrapped.lib} --add-needed libstdc++.so.6 $out/${python.sitePackages}/primp/primp.abi3.so
  '';

  buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
    libiconv
  ];

  env.BORING_BSSL_PATH = boringssl-wrapper;
  env.BORING_BSSL_ASSUME_PATCHED = true;

  optional-dependencies = {
    dev = [ pytest ];
  };

  # Test use network
  doCheck = false;

  pythonImportsCheck = [ "primp" ];

  meta = {
    changelog = "https://github.com/deedy5/primp/releases/tag/${version}";
    description = "Python Requests IMPersonate, the fastest Python HTTP client that can impersonate web browsers";
    homepage = "https://github.com/deedy5/primp";
    license = lib.licenses.mit;
    maintainers = [ ];
  };
}
+1 −0
Original line number Diff line number Diff line
@@ -542,6 +542,7 @@ mapAliases {
  powerlineMemSegment = powerline-mem-segment; # added 2021-10-08
  prayer-times-calculator = prayer-times-calculator-offline; # added 2024-08-11
  premailer = throw "premailer was removed, as it is not compatible with lxml>4.9.4.";
  primp = throw "primp was removed as it required a very outdated version of boringssl"; # added 2025-10-20
  privacyidea-ldap-proxy = throw "privacyidea-ldap-proxy has been removed from nixpkgs"; # added 2023-10-31
  proboscis = throw "proboscis has been removed since it has not been maintained for 11 years"; # added 2024-05-20
  prometheus_client = prometheus-client; # added 2021-06-10
+0 −2
Original line number Diff line number Diff line
@@ -12166,8 +12166,6 @@ self: super: with self; {
  primer3 = callPackage ../development/python-modules/primer3 { };
  primp = callPackage ../development/python-modules/primp { };
  print-color = callPackage ../development/python-modules/print-color { };
  priority = callPackage ../development/python-modules/priority { };