Merge pull request #267528 from NickCao/pyscard

python311Packages.pyscard: modernize, stop propagating PCSC/pcsclite …

authored by Guillaume Maudoux and committed by GitHub a2dbeea7 c703e263

+37 -17
+37 -17
pkgs/development/python-modules/pyscard/default.nix
··· 1 1 { lib 2 2 , stdenv 3 - , fetchPypi 3 + , fetchFromGitHub 4 4 , buildPythonPackage 5 + , setuptools 6 + , pkg-config 5 7 , swig 6 8 , pcsclite 7 9 , PCSC 10 + , pytestCheckHook 8 11 }: 9 12 10 13 let ··· 15 18 buildPythonPackage rec { 16 19 version = "2.0.7"; 17 20 pname = "pyscard"; 21 + pyproject = true; 18 22 19 - src = fetchPypi { 20 - inherit pname version; 21 - hash = "sha256-J4BUUl+nX76LEEYNh+3NA6cK2U1oixE0Xkc5mH+Fwb8="; 23 + src = fetchFromGitHub { 24 + owner = "LudovicRousseau"; 25 + repo = "pyscard"; 26 + rev = "refs/tags/${version}"; 27 + hash = "sha256-nkDI1OPQ4SsNhWkg53ZTsG7j0+mvpkJI7dsyaOl1a/8="; 22 28 }; 23 29 24 - postPatch = if withApplePCSC then '' 25 - substituteInPlace smartcard/scard/winscarddll.c \ 26 - --replace "/System/Library/Frameworks/PCSC.framework/PCSC" \ 27 - "${PCSC}/Library/Frameworks/PCSC.framework/PCSC" 28 - '' else '' 29 - substituteInPlace smartcard/scard/winscarddll.c \ 30 - --replace "libpcsclite.so.1" \ 31 - "${lib.getLib pcsclite}/lib/libpcsclite${stdenv.hostPlatform.extensions.sharedLibrary}" 32 - ''; 30 + nativeBuildInputs = [ 31 + setuptools 32 + swig 33 + ] ++ lib.optionals (!withApplePCSC) [ 34 + pkg-config 35 + ]; 33 36 34 - env.NIX_CFLAGS_COMPILE = lib.optionalString (! withApplePCSC) 35 - "-I ${lib.getDev pcsclite}/include/PCSC"; 37 + buildInputs = if withApplePCSC then [ PCSC ] else [ pcsclite ]; 38 + 39 + nativeCheckInputs = [ 40 + pytestCheckHook 41 + ]; 42 + 43 + postPatch = 44 + if withApplePCSC then '' 45 + substituteInPlace smartcard/scard/winscarddll.c \ 46 + --replace "/System/Library/Frameworks/PCSC.framework/PCSC" \ 47 + "${PCSC}/Library/Frameworks/PCSC.framework/PCSC" 48 + '' else '' 49 + substituteInPlace setup.py --replace "pkg-config" "$PKG_CONFIG" 50 + substituteInPlace smartcard/scard/winscarddll.c \ 51 + --replace "libpcsclite.so.1" \ 52 + "${lib.getLib pcsclite}/lib/libpcsclite${stdenv.hostPlatform.extensions.sharedLibrary}" 53 + ''; 36 54 37 - propagatedBuildInputs = if withApplePCSC then [ PCSC ] else [ pcsclite ]; 38 - nativeBuildInputs = [ swig ]; 55 + preCheck = '' 56 + # remove src module, so tests use the installed module instead 57 + rm -r smartcard 58 + ''; 39 59 40 60 meta = with lib; { 41 61 homepage = "https://pyscard.sourceforge.io/";