{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  setuptools,
  wheel,
  requests,
}:

buildPythonPackage rec {
  pname = "stashapp-tools";
  version = "0.2.59";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "stg-annon";
    repo = "stashapp-tools";
    rev = "v${version}";
    hash = "sha256-1IkFQrdfEAVldr6QHcPkYuKUutc4uvRPTpHyz0gp768=";
    fetchSubmodules = true;
  };

  build-system = [
    setuptools
    wheel
  ];

  postPatch = ''
    substituteInPlace setup.py \
      --replace 'version="main"' 'version="${version}"'
  '';

  dependencies = [
    requests
  ];

  pythonImportsCheck = [
    "stashapi"
  ];

  meta = {
    description = "Tools to interface with stashapps API";
    homepage = "https://github.com/stg-annon/stashapp-tools";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ ];
  };
}
