summary refs log tree commit diff
path: root/pkgs/development/python-modules/pyscard/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/python-modules/pyscard/default.nix')
-rw-r--r--pkgs/development/python-modules/pyscard/default.nix68
1 files changed, 43 insertions, 25 deletions
diff --git a/pkgs/development/python-modules/pyscard/default.nix b/pkgs/development/python-modules/pyscard/default.nix
index 106fa03a082..6e7a1ec29cb 100644
--- a/pkgs/development/python-modules/pyscard/default.nix
+++ b/pkgs/development/python-modules/pyscard/default.nix
@@ -1,4 +1,14 @@
-{ lib, stdenv, fetchpatch, fetchPypi, buildPythonPackage, swig, pcsclite, PCSC }:
+{ lib
+, stdenv
+, fetchFromGitHub
+, buildPythonPackage
+, setuptools
+, pkg-config
+, swig
+, pcsclite
+, PCSC
+, pytestCheckHook
+}:
 
 let
   # Package does not support configuring the pcsc library.
@@ -6,38 +16,46 @@ let
 in
 
 buildPythonPackage rec {
-  version = "2.0.2";
+  version = "2.0.7";
   pname = "pyscard";
+  pyproject = true;
 
-  src = fetchPypi {
-    inherit pname version;
-    sha256 = "05de0579c42b4eb433903aa2fb327d4821ebac262434b6584da18ed72053fd9e";
+  src = fetchFromGitHub {
+    owner = "LudovicRousseau";
+    repo = "pyscard";
+    rev = "refs/tags/${version}";
+    hash = "sha256-nkDI1OPQ4SsNhWkg53ZTsG7j0+mvpkJI7dsyaOl1a/8=";
   };
 
-  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";
-    })
+  nativeBuildInputs = [
+    setuptools
+    swig
+  ] ++ lib.optionals (!withApplePCSC) [
+    pkg-config
   ];
 
-  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" \
-                "${lib.getLib pcsclite}/lib/libpcsclite${stdenv.hostPlatform.extensions.sharedLibrary}"
-  '';
+  buildInputs = if withApplePCSC then [ PCSC ] else [ pcsclite ];
+
+  nativeCheckInputs = [
+    pytestCheckHook
+  ];
 
-  env.NIX_CFLAGS_COMPILE = lib.optionalString (! withApplePCSC)
-    "-I ${lib.getDev pcsclite}/include/PCSC";
+  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}"
+    '';
 
-  propagatedBuildInputs = if withApplePCSC then [ PCSC ] else [ pcsclite ];
-  nativeBuildInputs = [ swig ];
+  preCheck = ''
+    # remove src module, so tests use the installed module instead
+    rm -r smartcard
+  '';
 
   meta = with lib; {
     homepage = "https://pyscard.sourceforge.io/";