2024-05-15 15:35:15 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
buildPythonPackage,
|
|
|
|
fetchFromGitHub,
|
|
|
|
PCSC,
|
|
|
|
pcsclite,
|
|
|
|
pkg-config,
|
|
|
|
pytestCheckHook,
|
|
|
|
setuptools,
|
|
|
|
stdenv,
|
|
|
|
swig,
|
2023-11-16 04:20:00 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
# Package does not support configuring the pcsc library.
|
2024-09-26 11:04:55 +00:00
|
|
|
withApplePCSC = stdenv.hostPlatform.isDarwin;
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "pyscard";
|
2024-05-15 15:35:15 +00:00
|
|
|
version = "2.0.9";
|
2023-11-16 04:20:00 +00:00
|
|
|
pyproject = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "LudovicRousseau";
|
|
|
|
repo = "pyscard";
|
|
|
|
rev = "refs/tags/${version}";
|
2024-04-21 15:54:59 +00:00
|
|
|
hash = "sha256-DO4Ea+mlrWPpOLI8Eki+03UnsOXEhN2PAl0+gdN5sTo=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
build-system = [ setuptools ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ swig ] ++ lib.optionals (!withApplePCSC) [ pkg-config ];
|
2021-12-06 16:07:01 +00:00
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
buildInputs = if withApplePCSC then [ PCSC ] else [ pcsclite ];
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
nativeCheckInputs = [ pytestCheckHook ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
postPatch =
|
2024-05-15 15:35:15 +00:00
|
|
|
if withApplePCSC then
|
|
|
|
''
|
|
|
|
substituteInPlace smartcard/scard/winscarddll.c \
|
|
|
|
--replace-fail "/System/Library/Frameworks/PCSC.framework/PCSC" \
|
|
|
|
"${PCSC}/Library/Frameworks/PCSC.framework/PCSC"
|
|
|
|
''
|
|
|
|
else
|
|
|
|
''
|
|
|
|
substituteInPlace setup.py --replace "pkg-config" "$PKG_CONFIG"
|
|
|
|
substituteInPlace smartcard/scard/winscarddll.c \
|
|
|
|
--replace-fail "libpcsclite.so.1" \
|
|
|
|
"${lib.getLib pcsclite}/lib/libpcsclite${stdenv.hostPlatform.extensions.sharedLibrary}"
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
preCheck = ''
|
|
|
|
# remove src module, so tests use the installed module instead
|
|
|
|
rm -r smartcard
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
disabledTests = [
|
|
|
|
# AssertionError
|
|
|
|
"test_hresult"
|
|
|
|
"test_low_level"
|
|
|
|
];
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Smartcard library for python";
|
2024-05-15 15:35:15 +00:00
|
|
|
homepage = "https://pyscard.sourceforge.io/";
|
|
|
|
changelog = "https://github.com/LudovicRousseau/pyscard/releases/tag/${version}";
|
|
|
|
license = licenses.lgpl21Plus;
|
2021-02-05 17:12:51 +00:00
|
|
|
maintainers = with maintainers; [ layus ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|