Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 20.09 2.0 kB view raw
1{ stdenv, fetchPypi, fetchpatch, buildPythonPackage, swig, pcsclite, PCSC }: 2 3let 4 # Package does not support configuring the pcsc library. 5 withApplePCSC = stdenv.isDarwin; 6 7 inherit (stdenv.lib) getLib getDev optionalString optionals; 8 inherit (stdenv.hostPlatform.extensions) sharedLibrary; 9in 10 11buildPythonPackage rec { 12 version = "1.9.9"; 13 pname = "pyscard"; 14 15 src = fetchPypi { 16 inherit pname version; 17 sha256 = "082cjkbxadaz2jb4rbhr0mkrirzlqyqhcf3r823qb0q1k50ybgg6"; 18 }; 19 20 postPatch = if withApplePCSC then '' 21 substituteInPlace smartcard/scard/winscarddll.c \ 22 --replace "/System/Library/Frameworks/PCSC.framework/PCSC" \ 23 "${PCSC}/Library/Frameworks/PCSC.framework/PCSC" 24 '' else '' 25 substituteInPlace smartcard/scard/winscarddll.c \ 26 --replace "libpcsclite.so.1" \ 27 "${getLib pcsclite}/lib/libpcsclite${sharedLibrary}" 28 ''; 29 30 NIX_CFLAGS_COMPILE = optionalString (! withApplePCSC) 31 "-I ${getDev pcsclite}/include/PCSC"; 32 33 # The error message differs depending on the macOS host version. 34 # Since Nix reports a constant host version, but proxies to the 35 # underlying library, it's not possible to determine the correct 36 # expected error message. This patch allows both errors to be 37 # accepted. 38 # See: https://github.com/LudovicRousseau/pyscard/issues/77 39 # Building with python from nix on macOS version 10.13 or 40 # greater still causes this issue to occur. 41 patches = optionals withApplePCSC [ 42 (fetchpatch { 43 url = "https://github.com/LudovicRousseau/pyscard/commit/945e9c4cd4036155691f6ce9706a84283206f2ef.patch"; 44 sha256 = "19n8w1wzn85zywr6xf04d8nfg7sgzjyvxp1ccp3rgfr4mcc36plc"; 45 }) 46 ]; 47 48 propagatedBuildInputs = if withApplePCSC then [ PCSC ] else [ pcsclite ]; 49 nativeBuildInputs = [ swig ]; 50 51 meta = { 52 homepage = "https://pyscard.sourceforge.io/"; 53 description = "Smartcard library for python"; 54 license = stdenv.lib.licenses.lgpl21; 55 maintainers = with stdenv.lib.maintainers; [ layus ]; 56 }; 57}