1{ lib
2, antlr4
3, antlr4-python3-runtime
4, buildPythonPackage
5, fetchFromGitHub
6, fetchpatch
7, importlib-resources
8, jre_headless
9, omegaconf
10, packaging
11, pytestCheckHook
12, pythonOlder
13, substituteAll
14}:
15
16buildPythonPackage rec {
17 pname = "hydra-core";
18 version = "1.3.2";
19 format = "setuptools";
20
21 disabled = pythonOlder "3.6";
22
23 src = fetchFromGitHub {
24 owner = "facebookresearch";
25 repo = "hydra";
26 rev = "refs/tags/v${version}";
27 hash = "sha256-kD4BStnstr5hwyAOxdpPzLAJ9MZqU/CPiHkaD2HnUPI=";
28 };
29
30 patches = [
31 (substituteAll {
32 src = ./antlr4.patch;
33 antlr_jar = "${antlr4.out}/share/java/antlr-${antlr4.version}-complete.jar";
34 })
35 # https://github.com/facebookresearch/hydra/pull/2731
36 (fetchpatch {
37 name = "setuptools-67.5.0-test-compatibility.patch";
38 url = "https://github.com/facebookresearch/hydra/commit/25873841ed8159ab25a0c652781c75cc4a9d6e08.patch";
39 hash = "sha256-oUfHlJP653o3RDtknfb8HaaF4fpebdR/OcbKHzJFK/Q=";
40 })
41 ];
42
43 postPatch = ''
44 # We substitute the path to the jar with the one from our antlr4
45 # package, so this file becomes unused
46 rm -v build_helpers/bin/antlr*-complete.jar
47
48 sed -i 's/antlr4-python3-runtime==.*/antlr4-python3-runtime/' requirements/requirements.txt
49 '';
50
51 nativeBuildInputs = [
52 jre_headless
53 ];
54
55 propagatedBuildInputs = [
56 antlr4-python3-runtime
57 omegaconf
58 packaging
59 ] ++ lib.optionals (pythonOlder "3.9") [
60 importlib-resources
61 ];
62
63 nativeCheckInputs = [
64 pytestCheckHook
65 ];
66
67 # Test environment setup broken under Nix for a few tests:
68 disabledTests = [
69 "test_bash_completion_with_dot_in_path"
70 "test_install_uninstall"
71 "test_config_search_path"
72 ];
73
74 disabledTestPaths = [
75 "tests/test_hydra.py"
76 ];
77
78 pythonImportsCheck = [
79 "hydra"
80 # See https://github.com/NixOS/nixpkgs/issues/208843
81 "hydra.version"
82 ];
83
84 meta = with lib; {
85 description = "A framework for configuring complex applications";
86 homepage = "https://hydra.cc";
87 license = licenses.mit;
88 maintainers = with maintainers; [ bcdarwin ];
89 };
90}