diff options
author | Guillaume Maudoux <layus.on@gmail.com> | 2023-11-15 10:58:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-15 10:58:27 +0100 |
commit | a2dbeea75f2ac054084c9100235157f034fc74dc (patch) | |
tree | 0258a3e46cdc8b9e6b13641f88f4905a03c2151b /pkgs/development | |
parent | c703e26314ddfe078069dea90dde4bdf6114c771 (diff) | |
parent | 03db50d77b9a78d8696448428503738183a19da3 (diff) |
Merge pull request #267528 from NickCao/pyscard
python311Packages.pyscard: modernize, stop propagating PCSC/pcsclite …
Diffstat (limited to 'pkgs/development')
-rw-r--r-- | pkgs/development/python-modules/pyscard/default.nix | 54 |
1 files changed, 37 insertions, 17 deletions
diff --git a/pkgs/development/python-modules/pyscard/default.nix b/pkgs/development/python-modules/pyscard/default.nix index cfa2f64c38b3d..6e7a1ec29cbed 100644 --- a/pkgs/development/python-modules/pyscard/default.nix +++ b/pkgs/development/python-modules/pyscard/default.nix @@ -1,10 +1,13 @@ { lib , stdenv -, fetchPypi +, fetchFromGitHub , buildPythonPackage +, setuptools +, pkg-config , swig , pcsclite , PCSC +, pytestCheckHook }: let @@ -15,27 +18,44 @@ in buildPythonPackage rec { version = "2.0.7"; pname = "pyscard"; + pyproject = true; - src = fetchPypi { - inherit pname version; - hash = "sha256-J4BUUl+nX76LEEYNh+3NA6cK2U1oixE0Xkc5mH+Fwb8="; + src = fetchFromGitHub { + owner = "LudovicRousseau"; + repo = "pyscard"; + rev = "refs/tags/${version}"; + hash = "sha256-nkDI1OPQ4SsNhWkg53ZTsG7j0+mvpkJI7dsyaOl1a/8="; }; - 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}" - ''; + nativeBuildInputs = [ + setuptools + swig + ] ++ lib.optionals (!withApplePCSC) [ + pkg-config + ]; + + buildInputs = if withApplePCSC then [ PCSC ] else [ pcsclite ]; - env.NIX_CFLAGS_COMPILE = lib.optionalString (! withApplePCSC) - "-I ${lib.getDev pcsclite}/include/PCSC"; + nativeCheckInputs = [ + pytestCheckHook + ]; - propagatedBuildInputs = if withApplePCSC then [ PCSC ] else [ pcsclite ]; - nativeBuildInputs = [ swig ]; + 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}" + ''; + + preCheck = '' + # remove src module, so tests use the installed module instead + rm -r smartcard + ''; meta = with lib; { homepage = "https://pyscard.sourceforge.io/"; |