From 4c3cd1c677f6bc8a28183a75636fba19005ecf7f Mon Sep 17 00:00:00 2001 From: wxt <3264117476@qq.com> Date: Tue, 26 Nov 2024 20:15:10 +0800 Subject: [PATCH] python311Packages.ml-collections: 0.1.1 -> 1.0.0 --- .../python-modules/ml-collections/default.nix | 61 +++++++++---------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/pkgs/development/python-modules/ml-collections/default.nix b/pkgs/development/python-modules/ml-collections/default.nix index 2efd63acb78b..48b044eb27ad 100644 --- a/pkgs/development/python-modules/ml-collections/default.nix +++ b/pkgs/development/python-modules/ml-collections/default.nix @@ -2,58 +2,53 @@ absl-py, buildPythonPackage, contextlib2, - fetchPypi, + fetchFromGitHub, fetchurl, lib, pyyaml, + six, + setuptools, + flit-core, + pytestCheckHook, + pytest-xdist, }: -let - requirements = fetchurl { - url = "https://raw.githubusercontent.com/google/ml_collections/7f749a281c69f9d0b339c05ecb94b80d95029f25/requirements.txt"; - sha256 = "1xb351hiscj4zmajfkql3swpacdp6lmz8iwdvwwdx2zqw9a62zps"; - }; - requirements-test = fetchurl { - url = "https://raw.githubusercontent.com/google/ml_collections/7f749a281c69f9d0b339c05ecb94b80d95029f25/requirements-test.txt"; - sha256 = "0r457k2nrg5jkf093r0x29yf8xwy6l7jxi6al0fh7mmnfrhr9cb1"; - }; -in buildPythonPackage rec { pname = "ml-collections"; - version = "0.1.1"; - format = "setuptools"; + version = "1.0.0"; + pyproject = true; + build-system = [ flit-core ]; - # ml-collections does not have any git release tags. See https://github.com/google/ml_collections/issues/8. - src = fetchPypi { - inherit version; - pname = "ml_collections"; - hash = "sha256-P+/McuxDOqHl0yMHo+R0u7Z/QFvoFOpSohZr/J2+aMw="; + src = fetchFromGitHub { + owner = "google"; + repo = "ml_collections"; + rev = "refs/tags/v${version}"; + hash = "sha256-QUhwkfffjA6gKd6lTmEgnnoUeJOu82mfFPBta9/iebg="; }; - # The pypi source archive does not include requirements.txt or - # requirements-test.txt. See https://github.com/google/ml_collections/issues/7. - postPatch = '' - cp ${requirements} requirements.txt - cp ${requirements-test} requirements-test.txt - ''; - - propagatedBuildInputs = [ + dependencies = [ + six absl-py contextlib2 pyyaml ]; - # The official test suite uses bazel. With pytestCheckHook there are name - # conflicts between files and tests have assumptions that are broken by the - # nix-build environment, eg. re module names and __file__ attributes. - doCheck = false; + nativeCheckInputs = [ + pytestCheckHook + pytest-xdist + ]; + + pytestFlagsArray = [ + "ml_collections/" + "--ignore=ml_collections/config_dict/examples/examples_test.py" # From github workflows + ]; pythonImportsCheck = [ "ml_collections" ]; - meta = with lib; { + meta = { description = "ML Collections is a library of Python collections designed for ML usecases"; homepage = "https://github.com/google/ml_collections"; - license = licenses.asl20; - maintainers = with maintainers; [ samuela ]; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ samuela ]; }; }