pythonPackages.pyscard: Fix build on Darwin

The previously provided patch is still necessary,
as nix python reports an old version of macOS
that has the bug, when in fact modern macOS
does not have the misspelling.

The patch has been upstreamed, so we take it
to fix 1.9.9 in anticipation of the next release.
This commit is contained in:
Kevin Griffin 2020-06-28 19:57:30 +09:00 committed by Jon
parent 51a36a4075
commit 44fd570d73
2 changed files with 16 additions and 23 deletions

View file

@ -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 ];

View file

@ -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__':