1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build
7 setuptools,
8
9 # runtime
10 looseversion,
11 packaging,
12 typing-extensions,
13
14 # tests
15 pytest-timeout,
16 pytestCheckHook,
17}:
18
19buildPythonPackage rec {
20 pname = "lightning-utilities";
21 version = "0.14.3";
22 pyproject = true;
23
24 src = fetchFromGitHub {
25 owner = "Lightning-AI";
26 repo = "utilities";
27 tag = "v${version}";
28 hash = "sha256-MI2dhcxYZJw+EMO05m+W/yE5UlNBB2AHltb0XDamxMc=";
29 };
30
31 postPatch = ''
32 substituteInPlace src/lightning_utilities/install/requirements.py \
33 --replace-fail "from distutils.version import LooseVersion" "from looseversion import LooseVersion"
34 '';
35
36 build-system = [ setuptools ];
37
38 dependencies = [
39 looseversion
40 packaging
41 typing-extensions
42 ];
43
44 pythonImportsCheck = [ "lightning_utilities" ];
45
46 nativeCheckInputs = [
47 pytest-timeout
48 pytestCheckHook
49 ];
50
51 disabledTests = [
52 # DocTestFailure
53 "lightning_utilities.core.imports.RequirementCache"
54
55 # NameError: name 'operator' is not defined. Did you forget to import 'operator'
56 "lightning_utilities.core.imports.compare_version"
57
58 # importlib.metadata.PackageNotFoundError: No package metadata was found for pytorch-lightning==1.8.0
59 "lightning_utilities.core.imports.get_dependency_min_version_spec"
60
61 # weird doctests fail on imports, but providing the dependency
62 # fails another test
63 "lightning_utilities.core.imports.ModuleAvailableCache"
64 ];
65
66 disabledTestPaths = [
67 "docs"
68 # doctests that expect docs.txt in the wrong location
69 "src/lightning_utilities/install/requirements.py"
70 ];
71
72 meta = {
73 changelog = "https://github.com/Lightning-AI/utilities/releases/tag/v${version}";
74 description = "Common Python utilities and GitHub Actions in Lightning Ecosystem";
75 homepage = "https://github.com/Lightning-AI/utilities";
76 license = lib.licenses.asl20;
77 maintainers = with lib.maintainers; [ GaetanLepage ];
78 };
79}