{
  lib,
  buildPythonApplication,
  fetchFromGitHub,
  setuptools,
  flatbencode,
  coverage,
  flake8,
  isort,
  mypy,
  pytest,
  pytest-cov,
  pytest-httpserver,
  pytest-mock,
  pytest-xdist,
  ruff,
  tox,
}:

buildPythonApplication rec {
  pname = "torf";
  version = "4.3.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "rndusr";
    repo = "torf";
    rev = "v${version}";
    hash = "sha256-vJapB4Tbn3tLLUIH9LemU9kTqG7TsByiotkWM52lsno=";
  };

  build-system = [
    setuptools
  ];

  dependencies = [
    flatbencode
  ];

  optional-dependencies = {
    dev = [
      coverage
      flake8
      isort
      mypy
      pytest
      pytest-cov
      pytest-httpserver
      pytest-mock
      pytest-xdist
      ruff
      tox
    ];
  };

  pythonImportsCheck = [
    "torf"
  ];

  meta = {
    description = "Python module to create, parse and edit torrent files and magnet links";
    homepage = "https://github.com/rndusr/torf";
    changelog = "https://github.com/rndusr/torf/blob/${src.rev}/CHANGELOG";
    license = lib.licenses.gpl3Only;
    maintainers = with lib.maintainers; [ ];
    mainProgram = "torf";
  };
}
