diff --git a/pkgs/development/python-modules/pyscard/default.nix b/pkgs/development/python-modules/pyscard/default.nix index 4bda0b3c65c..d563a62a46b 100644 --- a/pkgs/development/python-modules/pyscard/default.nix +++ b/pkgs/development/python-modules/pyscard/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchPypi, buildPythonPackage, swig, pcsclite, PCSC }: +{ stdenv, fetchPypi, fetchpatch, buildPythonPackage, swig, pcsclite, PCSC }: let # Package does not support configuring the pcsc library. @@ -30,6 +30,21 @@ buildPythonPackage rec { NIX_CFLAGS_COMPILE = optionalString (! withApplePCSC) "-I ${getDev pcsclite}/include/PCSC"; + # The error message differs depending on the macOS host version. + # Since Nix reports a constant host version, but proxies to the + # underlying library, it's not possible to determine the correct + # expected error message. This patch allows both errors to be + # accepted. + # See: https://github.com/LudovicRousseau/pyscard/issues/77 + # Building with python from nix on macOS version 10.13 or + # greater still causes this issue to occur. + patches = optionals withApplePCSC [ + (fetchpatch { + url = "https://github.com/LudovicRousseau/pyscard/commit/945e9c4cd4036155691f6ce9706a84283206f2ef.patch"; + sha256 = "19n8w1wzn85zywr6xf04d8nfg7sgzjyvxp1ccp3rgfr4mcc36plc"; + }) + ]; + propagatedBuildInputs = if withApplePCSC then [ PCSC ] else [ pcsclite ]; nativeBuildInputs = [ swig ]; diff --git a/pkgs/development/python-modules/pyscard/ignore-macos-bug.patch b/pkgs/development/python-modules/pyscard/ignore-macos-bug.patch deleted file mode 100644 index 62b20477c9f..00000000000 --- a/pkgs/development/python-modules/pyscard/ignore-macos-bug.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/test/test_SCardGetErrorMessage.py b/test/test_SCardGetErrorMessage.py -old mode 100644 -new mode 100755 -index c6fe755..c1217f5 ---- a/test/test_SCardGetErrorMessage.py -+++ b/test/test_SCardGetErrorMessage.py -@@ -29,12 +29,10 @@ class TestError(unittest.TestCase): - self.assertEqual(res, expected) - - res = SCardGetErrorMessage(1) -+ expected = "Unknown error: 0x00000001" - # macOS bug not yet fixed -- if get_platform().startswith('macosx-') and get_platform() < 'macosx-10.13': -- expected = "Unkown error: 0x00000001" -- else: -- expected = "Unknown error: 0x00000001" -- self.assertEqual(res, expected) -+ macos_bug_expected = "Unkown error: 0x00000001" -+ self.assertIn(res, [expected, macos_bug_expected]) - - - if __name__ == '__main__':