Merge pull request #65163 from thefloweringash/pyscard-darwin
pyscard: fix darwin build, remove pcsc library mixing
This commit is contained in:
commit
1bf5120e0a
2 changed files with 48 additions and 14 deletions
|
@ -1,5 +1,13 @@
|
|||
{ stdenv, fetchPypi, fetchpatch, buildPythonPackage, swig, pcsclite, PCSC }:
|
||||
|
||||
let
|
||||
# Package does not support configuring the pcsc library.
|
||||
withApplePCSC = stdenv.isDarwin;
|
||||
|
||||
inherit (stdenv.lib) getLib getDev optionalString optionals;
|
||||
inherit (stdenv.hostPlatform.extensions) sharedLibrary;
|
||||
in
|
||||
|
||||
buildPythonPackage rec {
|
||||
version = "1.9.8";
|
||||
pname = "pyscard";
|
||||
|
@ -9,24 +17,28 @@ buildPythonPackage rec {
|
|||
sha256 = "15fh00z1an6r5j7hrz3jlq0rb3jygwf3x4jcwsa008bv8vpcg7gm";
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
sed -e 's!"libpcsclite\.so\.1"!"${stdenv.lib.getLib pcsclite}/lib/libpcsclite.so.1"!' \
|
||||
-i smartcard/scard/winscarddll.c
|
||||
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" \
|
||||
"${getLib pcsclite}/lib/libpcsclite${sharedLibrary}"
|
||||
'';
|
||||
|
||||
NIX_CFLAGS_COMPILE = "-isystem ${stdenv.lib.getDev pcsclite}/include/PCSC/";
|
||||
NIX_CFLAGS_COMPILE = optionalString (! withApplePCSC)
|
||||
"-I ${getDev pcsclite}/include/PCSC";
|
||||
|
||||
patches = [
|
||||
# Fixes darwin tests
|
||||
# See: https://github.com/LudovicRousseau/pyscard/issues/77
|
||||
(fetchpatch {
|
||||
url = "https://github.com/LudovicRousseau/pyscard/commit/62e675028086c75656444cc21d563d9f08ebf8e7.patch";
|
||||
sha256 = "1lr55npcpc8j750vf7vaisqyk18d5f00l7nii2lvawg4sssjaaf7";
|
||||
})
|
||||
];
|
||||
# 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
|
||||
patches = optionals withApplePCSC [ ./ignore-macos-bug.patch ];
|
||||
|
||||
propagatedBuildInputs = [ pcsclite ];
|
||||
buildInputs = stdenv.lib.optional stdenv.isDarwin PCSC;
|
||||
propagatedBuildInputs = if withApplePCSC then [ PCSC ] else [ pcsclite ];
|
||||
nativeBuildInputs = [ swig ];
|
||||
|
||||
meta = {
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
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__':
|
Loading…
Reference in a new issue