depot/third_party/nixpkgs/pkgs/development/python-modules/pyscard/default.nix
Default email 587713944a Project import generated by Copybara.
GitOrigin-RevId: 6143fc5eeb9c4f00163267708e26191d1e918932
2024-04-21 17:54:59 +02:00

66 lines
1.5 KiB
Nix

{ lib
, stdenv
, fetchFromGitHub
, buildPythonPackage
, setuptools
, pkg-config
, swig
, pcsclite
, PCSC
, pytestCheckHook
}:
let
# Package does not support configuring the pcsc library.
withApplePCSC = stdenv.isDarwin;
in
buildPythonPackage rec {
version = "2.0.9";
pname = "pyscard";
pyproject = true;
src = fetchFromGitHub {
owner = "LudovicRousseau";
repo = "pyscard";
rev = "refs/tags/${version}";
hash = "sha256-DO4Ea+mlrWPpOLI8Eki+03UnsOXEhN2PAl0+gdN5sTo=";
};
nativeBuildInputs = [
setuptools
swig
] ++ lib.optionals (!withApplePCSC) [
pkg-config
];
buildInputs = if withApplePCSC then [ PCSC ] else [ pcsclite ];
nativeCheckInputs = [
pytestCheckHook
];
postPatch =
if withApplePCSC then ''
substituteInPlace smartcard/scard/winscarddll.c \
--replace "/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 "libpcsclite.so.1" \
"${lib.getLib pcsclite}/lib/libpcsclite${stdenv.hostPlatform.extensions.sharedLibrary}"
'';
preCheck = ''
# remove src module, so tests use the installed module instead
rm -r smartcard
'';
meta = with lib; {
homepage = "https://pyscard.sourceforge.io/";
description = "Smartcard library for python";
license = licenses.lgpl21;
maintainers = with maintainers; [ layus ];
};
}