git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #65163 from thefloweringash/pyscard-darwin

pyscard: fix darwin build, remove pcsc library mixing

commit1bf5120e0a6b47cf971950818ed8547ef73aa1a2 authorMario Rodas <marsam@users.noreply.github.com> dateMon 2 Sep 2019, 19:23 (7 years ago) parent14c48f759e9e56
2 files changed+48−14
pkgs/development/python-modules/pyscard/default.nix+26−14 pkgs/development/python-modules/pyscard/ignore-macos-bug.patch+22
pkgs/development/python-modules/pyscard/default.nix+26−14
@@ -1,5 +1,13 @@
11{ stdenv, fetchPypi, fetchpatch, buildPythonPackage, swig, pcsclite, PCSC }:
22
3+let
4+ # Package does not support configuring the pcsc library.
5+ withApplePCSC = stdenv.isDarwin;
6+
7+ inherit (stdenv.lib) getLib getDev optionalString optionals;
8+ inherit (stdenv.hostPlatform.extensions) sharedLibrary;
9+in
10+
311buildPythonPackage rec {
412 version = "1.9.8";
513 pname = "pyscard";
@@ -9,24 +17,28 @@ buildPythonPackage rec {
917 sha256 = "15fh00z1an6r5j7hrz3jlq0rb3jygwf3x4jcwsa008bv8vpcg7gm";
1018 };
1119
12− postPatch = ''
13− sed -e 's!"libpcsclite\.so\.1"!"${stdenv.lib.getLib pcsclite}/lib/libpcsclite.so.1"!' \
14− -i smartcard/scard/winscarddll.c
20+ postPatch = if withApplePCSC then ''
21+ substituteInPlace smartcard/scard/winscarddll.c \
22+ --replace "/System/Library/Frameworks/PCSC.framework/PCSC" \
23+ "${PCSC}/Library/Frameworks/PCSC.framework/PCSC"
24+ '' else ''
25+ substituteInPlace smartcard/scard/winscarddll.c \
26+ --replace "libpcsclite.so.1" \
27+ "${getLib pcsclite}/lib/libpcsclite${sharedLibrary}"
1528 '';
1629
17− NIX_CFLAGS_COMPILE = "-isystem ${stdenv.lib.getDev pcsclite}/include/PCSC/";
30+ NIX_CFLAGS_COMPILE = optionalString (! withApplePCSC)
31+ "-I ${getDev pcsclite}/include/PCSC";
1832
19− patches = [
20− # Fixes darwin tests
21− # See: https://github.com/LudovicRousseau/pyscard/issues/77
22− (fetchpatch {
23− url = "https://github.com/LudovicRousseau/pyscard/commit/62e675028086c75656444cc21d563d9f08ebf8e7.patch";
24− sha256 = "1lr55npcpc8j750vf7vaisqyk18d5f00l7nii2lvawg4sssjaaf7";
25− })
26− ];
33+ # The error message differs depending on the macOS host version.
34+ # Since Nix reports a constant host version, but proxies to the
35+ # underlying library, it's not possible to determine the correct
36+ # expected error message. This patch allows both errors to be
37+ # accepted.
38+ # See: https://github.com/LudovicRousseau/pyscard/issues/77
39+ patches = optionals withApplePCSC [ ./ignore-macos-bug.patch ];
2740
28− propagatedBuildInputs = [ pcsclite ];
29− buildInputs = stdenv.lib.optional stdenv.isDarwin PCSC;
41+ propagatedBuildInputs = if withApplePCSC then [ PCSC ] else [ pcsclite ];
3042 nativeBuildInputs = [ swig ];
3143
3244 meta = {
pkgs/development/python-modules/pyscard/ignore-macos-bug.patchnew file+22
@@ -0,0 +1,22 @@
1+diff --git a/test/test_SCardGetErrorMessage.py b/test/test_SCardGetErrorMessage.py
2+old mode 100644
3+new mode 100755
4+index c6fe755..c1217f5
5+--- a/test/test_SCardGetErrorMessage.py
6++++ b/test/test_SCardGetErrorMessage.py
7+@@ -29,12 +29,10 @@ class TestError(unittest.TestCase):
8+ self.assertEqual(res, expected)
9+
10+ res = SCardGetErrorMessage(1)
11++ expected = "Unknown error: 0x00000001"
12+ # macOS bug not yet fixed
13+- if get_platform().startswith('macosx-') and get_platform() < 'macosx-10.13':
14+- expected = "Unkown error: 0x00000001"
15+- else:
16+- expected = "Unknown error: 0x00000001"
17+- self.assertEqual(res, expected)
18++ macos_bug_expected = "Unkown error: 0x00000001"
19++ self.assertIn(res, [expected, macos_bug_expected])
20+
21+
22+ if __name__ == '__main__':