1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pcsclite,
6 pkg-config,
7 pytestCheckHook,
8 setuptools,
9 stdenv,
10 swig,
11}:
12
13buildPythonPackage rec {
14 pname = "pyscard";
15 version = "2.2.1";
16 pyproject = true;
17
18 src = fetchFromGitHub {
19 owner = "LudovicRousseau";
20 repo = "pyscard";
21 tag = version;
22 hash = "sha256-RXCz6Npb/MrykHxtUsYlghCPeTwjDC6s9258iLA7OKs=";
23 };
24
25 build-system = [ setuptools ];
26
27 nativeBuildInputs = [ swig ] ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ pkg-config ];
28
29 buildInputs = lib.optionals (!stdenv.hostPlatform.isDarwin) [ pcsclite ];
30
31 nativeCheckInputs = [ pytestCheckHook ];
32
33 postPatch =
34 ''
35 substituteInPlace pyproject.toml \
36 --replace-fail 'requires = ["setuptools","swig"]' 'requires = ["setuptools"]'
37 ''
38 + lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
39 substituteInPlace setup.py --replace-fail "pkg-config" "$PKG_CONFIG"
40 substituteInPlace src/smartcard/scard/winscarddll.c \
41 --replace-fail "libpcsclite.so.1" \
42 "${lib.getLib pcsclite}/lib/libpcsclite${stdenv.hostPlatform.extensions.sharedLibrary}"
43 '';
44
45 meta = {
46 description = "Smartcard library for python";
47 homepage = "https://pyscard.sourceforge.io/";
48 changelog = "https://github.com/LudovicRousseau/pyscard/releases/tag/${version}";
49 license = lib.licenses.lgpl21Plus;
50 maintainers = with lib.maintainers; [ layus ];
51 };
52}