nixpkgs/pkgs/development/python-modules/pyscard/default.nix

40 lines
1.2 KiB
Nix
Raw Normal View History

{ lib, stdenv, fetchPypi, buildPythonPackage, swig, pcsclite, PCSC }:
let
# Package does not support configuring the pcsc library.
withApplePCSC = stdenv.isDarwin;
in
buildPythonPackage rec {
2020-11-08 10:41:06 +00:00
version = "2.0.0";
pname = "pyscard";
src = fetchPypi {
inherit pname version;
2020-11-08 10:41:06 +00:00
sha256 = "0yap0p8mp6dx58n3nina6ryhc2cysaj75sq98wf3qybf33cxjr5k";
};
postPatch = if withApplePCSC then ''
substituteInPlace smartcard/scard/winscarddll.c \
--replace "/System/Library/Frameworks/PCSC.framework/PCSC" \
"${PCSC}/Library/Frameworks/PCSC.framework/PCSC"
'' else ''
substituteInPlace smartcard/scard/winscarddll.c \
--replace "libpcsclite.so.1" \
"${lib.getLib pcsclite}/lib/libpcsclite${stdenv.hostPlatform.extensions.sharedLibrary}"
2017-01-19 14:20:54 +00:00
'';
NIX_CFLAGS_COMPILE = lib.optionalString (! withApplePCSC)
"-I ${lib.getDev pcsclite}/include/PCSC";
propagatedBuildInputs = if withApplePCSC then [ PCSC ] else [ pcsclite ];
nativeBuildInputs = [ swig ];
meta = with lib; {
homepage = "https://pyscard.sourceforge.io/";
description = "Smartcard library for python";
license = licenses.lgpl21;
maintainers = with maintainers; [ layus ];
};
}