2021-12-06 16:07:01 +00:00
|
|
|
{ lib, stdenv, fetchpatch, 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-10-09 14:59:57 +00:00
|
|
|
version = "2.0.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "pyscard";
|
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2021-10-09 14:59:57 +00:00
|
|
|
sha256 = "05de0579c42b4eb433903aa2fb327d4821ebac262434b6584da18ed72053fd9e";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
patches = [
|
|
|
|
# present in master - remove after 2.0.2
|
|
|
|
(fetchpatch {
|
|
|
|
name = "darwin-typo-test-fix.patch";
|
|
|
|
url = "https://github.com/LudovicRousseau/pyscard/commit/ce842fcc76fd61b8b6948d0b07306d82ad1ec12a.patch";
|
|
|
|
sha256 = "0wsaj87wp9d2vnfzwncfxp2w95m0zhr7zpkmg5jccn06z52ihis3";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
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
|
|
|
};
|
|
|
|
}
|