Merge pull request #309007 from fabaff/pyscard-fix
python312Packages.pyscard: refactor
This commit is contained in:
@@ -1,58 +1,59 @@
|
||||
{ lib
|
||||
, buildPythonPackage
|
||||
, fetchFromGitHub
|
||||
, click
|
||||
, pyscard
|
||||
, pycountry
|
||||
, terminaltables
|
||||
, pytestCheckHook
|
||||
, pythonOlder
|
||||
{
|
||||
lib,
|
||||
buildPythonPackage,
|
||||
fetchFromGitHub,
|
||||
click,
|
||||
pyscard,
|
||||
pycountry,
|
||||
terminaltables,
|
||||
pytestCheckHook,
|
||||
setuptools,
|
||||
pythonOlder,
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "emv";
|
||||
version = "1.0.14";
|
||||
format = "setuptools";
|
||||
pyproject = true;
|
||||
|
||||
disabled = pythonOlder "3.4";
|
||||
disabled = pythonOlder "3.7";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "russss";
|
||||
repo = "python-emv";
|
||||
rev = "v${version}";
|
||||
rev = "refs/tags/v${version}";
|
||||
hash = "sha256-MnaeQZ0rA3i0CoUA6HgJQpwk5yo4rm9e+pc5XzRd1eg=";
|
||||
};
|
||||
|
||||
propagatedBuildInputs = [
|
||||
postPatch = ''
|
||||
substituteInPlace setup.py \
|
||||
--replace-fail '"enum-compat==0.0.3",' "" \
|
||||
--replace-fail '"argparse==1.4.0",' "" \
|
||||
--replace-fail "click==7.1.2" "click" \
|
||||
--replace-fail "pyscard==2.0.0" "pyscard" \
|
||||
--replace-fail "pycountry==20.7.3" "pycountry" \
|
||||
--replace-fail "terminaltables==3.1.0" "terminaltables"
|
||||
'';
|
||||
|
||||
build-system = [ setuptools ];
|
||||
|
||||
dependencies = [
|
||||
click
|
||||
pyscard
|
||||
pycountry
|
||||
terminaltables
|
||||
];
|
||||
|
||||
nativeCheckInputs = [
|
||||
pytestCheckHook
|
||||
];
|
||||
nativeCheckInputs = [ pytestCheckHook ];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace setup.py \
|
||||
--replace '"enum-compat==0.0.3",' "" \
|
||||
--replace '"argparse==1.4.0",' "" \
|
||||
--replace "click==7.1.2" "click" \
|
||||
--replace "pyscard==2.0.0" "pyscard" \
|
||||
--replace "pycountry==20.7.3" "pycountry" \
|
||||
--replace "terminaltables==3.1.0" "terminaltables"
|
||||
'';
|
||||
|
||||
pythonImportsCheck = [
|
||||
"emv"
|
||||
];
|
||||
pythonImportsCheck = [ "emv" ];
|
||||
|
||||
meta = with lib; {
|
||||
description = "Implementation of the EMV chip-and-pin smartcard protocol";
|
||||
mainProgram = "emvtool";
|
||||
homepage = "https://github.com/russss/python-emv";
|
||||
changelog = "https://github.com/russss/python-emv/releases/tag/v${version}";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ lukegb ];
|
||||
mainProgram = "emvtool";
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
{ lib
|
||||
, stdenv
|
||||
, fetchFromGitHub
|
||||
, buildPythonPackage
|
||||
, setuptools
|
||||
, pkg-config
|
||||
, swig
|
||||
, pcsclite
|
||||
, PCSC
|
||||
, pytestCheckHook
|
||||
{
|
||||
lib,
|
||||
buildPythonPackage,
|
||||
fetchFromGitHub,
|
||||
PCSC,
|
||||
pcsclite,
|
||||
pkg-config,
|
||||
pytestCheckHook,
|
||||
setuptools,
|
||||
stdenv,
|
||||
swig,
|
||||
}:
|
||||
|
||||
let
|
||||
@@ -16,8 +17,8 @@ let
|
||||
in
|
||||
|
||||
buildPythonPackage rec {
|
||||
version = "2.0.9";
|
||||
pname = "pyscard";
|
||||
version = "2.0.9";
|
||||
pyproject = true;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
@@ -27,40 +28,45 @@ buildPythonPackage rec {
|
||||
hash = "sha256-DO4Ea+mlrWPpOLI8Eki+03UnsOXEhN2PAl0+gdN5sTo=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
setuptools
|
||||
swig
|
||||
] ++ lib.optionals (!withApplePCSC) [
|
||||
pkg-config
|
||||
];
|
||||
build-system = [ setuptools ];
|
||||
|
||||
nativeBuildInputs = [ swig ] ++ lib.optionals (!withApplePCSC) [ pkg-config ];
|
||||
|
||||
buildInputs = if withApplePCSC then [ PCSC ] else [ pcsclite ];
|
||||
|
||||
nativeCheckInputs = [
|
||||
pytestCheckHook
|
||||
];
|
||||
nativeCheckInputs = [ pytestCheckHook ];
|
||||
|
||||
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}"
|
||||
'';
|
||||
if withApplePCSC then
|
||||
''
|
||||
substituteInPlace smartcard/scard/winscarddll.c \
|
||||
--replace-fail "/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-fail "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
|
||||
'';
|
||||
|
||||
disabledTests = [
|
||||
# AssertionError
|
||||
"test_hresult"
|
||||
"test_low_level"
|
||||
];
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://pyscard.sourceforge.io/";
|
||||
description = "Smartcard library for python";
|
||||
license = licenses.lgpl21;
|
||||
homepage = "https://pyscard.sourceforge.io/";
|
||||
changelog = "https://github.com/LudovicRousseau/pyscard/releases/tag/${version}";
|
||||
license = licenses.lgpl21Plus;
|
||||
maintainers = with maintainers; [ layus ];
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user