# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
#
# SPDX-License-Identifier: Apache-2.0

{ pkgs, ... }:
with pkgs;
with pkgs.python3Packages;
buildPythonPackage rec {
  pname = "python-emv";
  version = "1.0.9";

  src = fetchFromGitHub {
    owner = "russss";
    repo = "python-emv";
    rev = "v${version}";
    hash = "sha256:1ldibcy1wgnaimf8ri79lg8im1mhfqajrigfflvizw0hb0ivh8al";
  };

  checkInputs = [ pytestCheckHook unittest2 ];
  propagatedBuildInputs = [
    enum-compat
    click
    pyscard
    pycountry
    terminaltables
  ];

  # argparse is part of the standardlib
  prePatch = ''
    substituteInPlace setup.py --replace '"argparse",' ""
  '';

  meta = with lib; {
    homepage = "https://github.com/russss/python-emv";
    description = "A Python implementation of the EMV smartcard protocol, used for chip-and-PIN payments";
    license = licenses.mit;
    maintainers = with maintainers; [ lukegb ];
  };
}