1{ absl-py
2, buildPythonPackage
3, contextlib2
4, fetchPypi
5, fetchurl
6, lib
7, pyyaml
8}:
9
10let
11 requirements = fetchurl {
12 url = "https://raw.githubusercontent.com/google/ml_collections/7f749a281c69f9d0b339c05ecb94b80d95029f25/requirements.txt";
13 sha256 = "1xb351hiscj4zmajfkql3swpacdp6lmz8iwdvwwdx2zqw9a62zps";
14 };
15 requirements-test = fetchurl {
16 url = "https://raw.githubusercontent.com/google/ml_collections/7f749a281c69f9d0b339c05ecb94b80d95029f25/requirements-test.txt";
17 sha256 = "0r457k2nrg5jkf093r0x29yf8xwy6l7jxi6al0fh7mmnfrhr9cb1";
18 };
19in
20buildPythonPackage rec {
21 pname = "ml-collections";
22 version = "0.1.0";
23
24 # ml-collections does not have any git release tags. See https://github.com/google/ml_collections/issues/8.
25 src = fetchPypi {
26 inherit version;
27 pname = "ml_collections";
28 sha256 = "0g6gxfz8g6fh1sghys869ylxgpda9hq7ylc8jw05608l3k6pz8ar";
29 };
30
31 # The pypi source archive does not include requirements.txt or
32 # requirements-test.txt. See https://github.com/google/ml_collections/issues/7.
33 postPatch = ''
34 cp ${requirements} requirements.txt
35 cp ${requirements-test} requirements-test.txt
36 '';
37
38 propagatedBuildInputs = [ absl-py contextlib2 pyyaml ];
39
40 # The official test suite uses bazel. With pytestCheckHook there are name
41 # conflicts between files and tests have assumptions that are broken by the
42 # nix-build environment, eg. re module names and __file__ attributes.
43 doCheck = false;
44
45 pythonImportsCheck = [ "ml_collections" ];
46
47 meta = with lib; {
48 description = "ML Collections is a library of Python collections designed for ML usecases.";
49 homepage = "https://github.com/google/ml_collections";
50 license = licenses.asl20;
51 maintainers = with maintainers; [ samuela ];
52 };
53}