2021-02-05 17:12:51 +00:00
|
|
|
{ lib, stdenv, fetchPypi, buildPythonPackage, swig, pcsclite, PCSC }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
# Package does not support configuring the pcsc library.
|
|
|
|
withApplePCSC = stdenv.isDarwin;
|
|
|
|
in
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
2021-06-28 23:13:55 +00:00
|
|
|
version = "2.0.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "pyscard";
|
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2021-06-28 23:13:55 +00:00
|
|
|
sha256 = "2ba5ed0db0ed3c98e95f9e34016aa3a57de1bc42dd9030b77a546036ee7e46d8";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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" \
|
2021-02-05 17:12:51 +00:00
|
|
|
"${lib.getLib pcsclite}/lib/libpcsclite${stdenv.hostPlatform.extensions.sharedLibrary}"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
NIX_CFLAGS_COMPILE = lib.optionalString (! withApplePCSC)
|
|
|
|
"-I ${lib.getDev pcsclite}/include/PCSC";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
propagatedBuildInputs = if withApplePCSC then [ PCSC ] else [ pcsclite ];
|
|
|
|
nativeBuildInputs = [ swig ];
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://pyscard.sourceforge.io/";
|
|
|
|
description = "Smartcard library for python";
|
2021-02-05 17:12:51 +00:00
|
|
|
license = licenses.lgpl21;
|
|
|
|
maintainers = with maintainers; [ layus ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|