1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 setuptools,
8
9 # patches
10 replaceVars,
11 antlr4,
12 fetchpatch,
13
14 # nativeBuildInputs
15 jre_headless,
16
17 # dependencies
18 antlr4-python3-runtime,
19 omegaconf,
20 packaging,
21
22 # tests
23 pytest8_3CheckHook,
24 pythonAtLeast,
25}:
26
27buildPythonPackage rec {
28 pname = "hydra-core";
29 version = "1.3.2";
30 pyproject = true;
31
32 src = fetchFromGitHub {
33 owner = "facebookresearch";
34 repo = "hydra";
35 tag = "v${version}";
36 hash = "sha256-kD4BStnstr5hwyAOxdpPzLAJ9MZqU/CPiHkaD2HnUPI=";
37 };
38
39 patches = [
40 (replaceVars ./antlr4.patch {
41 antlr_jar = "${antlr4.out}/share/java/antlr-${antlr4.version}-complete.jar";
42 })
43 # https://github.com/facebookresearch/hydra/pull/2731
44 (fetchpatch {
45 name = "setuptools-67.5.0-test-compatibility.patch";
46 url = "https://github.com/facebookresearch/hydra/commit/25873841ed8159ab25a0c652781c75cc4a9d6e08.patch";
47 hash = "sha256-oUfHlJP653o3RDtknfb8HaaF4fpebdR/OcbKHzJFK/Q=";
48 })
49 ];
50
51 postPatch = ''
52 # We substitute the path to the jar with the one from our antlr4
53 # package, so this file becomes unused
54 rm -v build_helpers/bin/antlr*-complete.jar
55 '';
56
57 build-system = [
58 setuptools
59 ];
60
61 nativeBuildInputs = [ jre_headless ];
62
63 pythonRelaxDeps = [
64 "antlr4-python3-runtime"
65 ];
66
67 dependencies = [
68 antlr4-python3-runtime
69 omegaconf
70 packaging
71 ];
72
73 nativeCheckInputs = [ pytest8_3CheckHook ];
74
75 pytestFlags = [
76 "-Wignore::UserWarning"
77 ];
78
79 # Test environment setup broken under Nix for a few tests:
80 disabledTests = [
81 "test_bash_completion_with_dot_in_path"
82 "test_install_uninstall"
83 "test_config_search_path"
84 # does not raise UserWarning
85 "test_initialize_compat_version_base"
86 ]
87 ++ lib.optionals (pythonAtLeast "3.13") [
88 # AssertionError: Regex pattern did not match
89 "test_failure"
90 ];
91
92 disabledTestPaths = [ "tests/test_hydra.py" ];
93
94 pythonImportsCheck = [
95 "hydra"
96 # See https://github.com/NixOS/nixpkgs/issues/208843
97 "hydra.version"
98 ];
99
100 meta = {
101 description = "Framework for configuring complex applications";
102 homepage = "https://hydra.cc";
103 changelog = "https://github.com/facebookresearch/hydra/blob/v${version}/NEWS.md";
104 license = lib.licenses.mit;
105 maintainers = with lib.maintainers; [ bcdarwin ];
106 };
107}