<commit_before>{ stdenv, pythonPackages, fetchFromGitHub }:

with pythonPackages; buildPythonApplication rec {
  version = "3.0";
  name = "buku-${version}";

  src = fetchFromGitHub {
    owner = "jarun";
    repo = "buku";
    rev = "v${version}";
    sha256 = "1a33x3197vi5s8rq5fvhy021jdlsc8ww8zc4kysss6r9mvdlk7ax";
  };

  nativeBuildInputs = [
    pytestcov
    pytest-catchlog
    hypothesis
    pytest
  ];

  propagatedBuildInputs = [
    cryptography
    beautifulsoup4
    requests
    urllib3
  ];

  preCheck = ''
    # Fixes two tests for wrong encoding
    export PYTHONIOENCODING=utf-8

    # Should be upstream, see https://github.com/jarun/Buku/pull/167
    substituteInPlace setup.py \<commit_msg>buku: added not to remove line on next version<commit_after>{ stdenv, pythonPackages, fetchFromGitHub }:

with pythonPackages; buildPythonApplication rec {
  version = "3.0"; # When updating to 3.1, make sure to remove the marked line in preCheck
  name = "buku-${version}";

  src = fetchFromGitHub {
    owner = "jarun";
    repo = "buku";
    rev = "v${version}";
    sha256 = "1a33x3197vi5s8rq5fvhy021jdlsc8ww8zc4kysss6r9mvdlk7ax";
  };

  nativeBuildInputs = [
    pytestcov
    pytest-catchlog
    hypothesis
    pytest
  ];

  propagatedBuildInputs = [
    cryptography
    beautifulsoup4
    requests
    urllib3
  ];

  preCheck = ''
    # Fixes two tests for wrong encoding
    export PYTHONIOENCODING=utf-8

    ### Remove this for 3.1 ###
    # See https://github.com/jarun/Buku/pull/167 (merged)
    substituteInPlace setup.py \
{'fraction_non_alphanumeric': 0.10154241645244216, 'fraction_numerical': 0.04113110539845758, 'mean_word_length': 3.1742627345844503, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6874194', 'n_tokens_mistral': 601, 'n_tokens_neox': 565, 'n_words': 119}