nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 fetchPypi,
4 fetchFromGitHub,
5 buildPythonPackage,
6 setuptools,
7 absl-py,
8 nltk,
9 numpy,
10 six,
11 pytestCheckHook,
12}:
13let
14 testdata = fetchFromGitHub {
15 owner = "google-research";
16 repo = "google-research";
17 sparseCheckout = [ "rouge/testdata" ];
18 rev = "1d4d2f1aa6f2883a790d2ae46a6ee8ab150d8f31";
19 hash = "sha256-ojqk6U2caS7Xz4iGUC9aQVHrKb2QNvMlPuQAL/jJat0=";
20 };
21in
22buildPythonPackage rec {
23 pname = "rouge-score";
24 version = "0.1.2";
25 pyproject = true;
26
27 src = fetchPypi {
28 pname = "rouge_score";
29 inherit version;
30 extension = "tar.gz";
31 hash = "sha256-x9TaJoPmjJq/ATXvkV1jpGZDZm+EjlWKG59+rRf/DwQ=";
32 };
33
34 # the tar file from pypi doesn't come with the test data
35 postPatch = ''
36 substituteInPlace rouge_score/test_util.py \
37 --replace-fail \
38 'os.path.join(os.path.dirname(__file__), "testdata")' \
39 '"${testdata}/rouge/testdata/"'
40 '';
41
42 build-system = [ setuptools ];
43
44 dependencies = [
45 absl-py
46 nltk
47 numpy
48 six
49 ];
50
51 nativeCheckInputs = [ pytestCheckHook ];
52
53 disabledTests = [
54 # https://github.com/google-research/google-research/issues/1203
55 "testRougeLSumSentenceSplitting"
56 # tries to download external tokenizers via nltk
57 "testRougeLsumLarge"
58 ];
59
60 pythonImportsCheck = [ "rouge_score" ];
61
62 meta = {
63 description = "Python ROUGE Implementation";
64 homepage = "https://github.com/google-research/google-research/tree/master/rouge";
65 license = lib.licenses.asl20;
66 maintainers = with lib.maintainers; [ nviets ];
67 };
68}