From 681973a7c92680cf8acd02bf3b151aeec3424d01 Mon Sep 17 00:00:00 2001 From: "P. R. d. O" Date: Fri, 10 Nov 2023 09:32:26 -0600 Subject: [PATCH] sherlock: 0.14.3 -> unstable-2023-10-06, use buildPythonApplication --- pkgs/tools/security/sherlock/default.nix | 70 ++++++++++++++---------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/pkgs/tools/security/sherlock/default.nix b/pkgs/tools/security/sherlock/default.nix index 05954db51629..e3d6f658aeaf 100644 --- a/pkgs/tools/security/sherlock/default.nix +++ b/pkgs/tools/security/sherlock/default.nix @@ -1,50 +1,61 @@ -{ stdenv, lib, fetchFromGitHub, python3, makeWrapper }: -let - pyenv = python3.withPackages (pp: with pp; [ - beautifulsoup4 - certifi - colorama - lxml - pandas - pysocks - requests - requests-futures - soupsieve - stem - torrequest - ]); -in -stdenv.mkDerivation rec { +{ lib +, fetchFromGitHub +, makeWrapper +, python3 +}: + +python3.pkgs.buildPythonApplication rec { pname = "sherlock"; - version = "0.14.3"; + version = "unstable-2023-10-06"; + format = "other"; src = fetchFromGitHub { owner = "sherlock-project"; repo = pname; - rev = "ab2f6788340903df797d8c336a97fa6e742daf77"; - hash = "sha256-AbWZa33DNrDM0FdjoFSVMnz4Ph7mUiUe/erhI3w7GQQ"; + rev = "7ec56895a37ada47edd6573249c553379254d14a"; + hash = "sha256-bK5yEdh830vgKcsU3gLH7TybLncnX6eRIiYPUiVWM74="; }; nativeBuildInputs = [ makeWrapper ]; - postPatch = '' - substituteInPlace sherlock/sherlock.py \ - --replace "os.path.dirname(__file__)" "\"$out/share\"" - ''; + propagatedBuildInputs = with python3.pkgs; [ + certifi + colorama + pandas + pysocks + requests + requests-futures + stem + torrequest + ]; installPhase = '' runHook preInstall + mkdir -p $out/bin $out/share - cp ./sherlock/*.py $out/bin/ - cp --recursive ./sherlock/resources/ $out/share - makeWrapper ${pyenv.interpreter} $out/bin/sherlock --add-flags "$out/bin/sherlock.py" + cp -R ./sherlock $out/share + runHook postInstall ''; + postFixup = '' + makeWrapper ${python3.interpreter} $out/bin/sherlock \ + --add-flags $out/share/sherlock/sherlock.py \ + --prefix PYTHONPATH : "$PYTHONPATH" + ''; + + checkInputs = with python3.pkgs; [ + exrex + ]; + checkPhase = '' runHook preCheck - cd $srcRoot/sherlock - ${pyenv.interpreter} -m unittest tests.all.SherlockSiteCoverageTests --verbose + + cd $out/share/sherlock + for tests in all test_multiple_usernames; do + ${python3.interpreter} -m unittest tests.$tests --verbose + done + runHook postCheck ''; @@ -52,6 +63,7 @@ stdenv.mkDerivation rec { homepage = "https://sherlock-project.github.io/"; description = "Hunt down social media accounts by username across social networks"; license = licenses.mit; + mainProgram = "sherlock"; maintainers = with maintainers; [ applePrincess ]; }; }