1{ stdenv
2, lib
3, antlr4
4, antlr4-python3-runtime
5, buildPythonPackage
6, fetchFromGitHub
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 ];
36
37 postPatch = ''
38 # We substitute the path to the jar with the one from our antlr4
39 # package, so this file becomes unused
40 rm -v build_helpers/bin/antlr*-complete.jar
41
42 sed -i 's/antlr4-python3-runtime==.*/antlr4-python3-runtime/' requirements/requirements.txt
43 '';
44
45 nativeBuildInputs = [
46 jre_headless
47 ];
48
49 propagatedBuildInputs = [
50 antlr4-python3-runtime
51 omegaconf
52 packaging
53 ] ++ lib.optionals (pythonOlder "3.9") [
54 importlib-resources
55 ];
56
57 nativeCheckInputs = [
58 pytestCheckHook
59 ];
60
61 # Test environment setup broken under Nix for a few tests:
62 disabledTests = [
63 "test_bash_completion_with_dot_in_path"
64 "test_install_uninstall"
65 "test_config_search_path"
66 ];
67
68 disabledTestPaths = [
69 "tests/test_hydra.py"
70 ];
71
72 pythonImportsCheck = [
73 "hydra"
74 # See https://github.com/NixOS/nixpkgs/issues/208843
75 "hydra.version"
76 ];
77
78 meta = with lib; {
79 broken = stdenv.isDarwin;
80 description = "A framework for configuring complex applications";
81 homepage = "https://hydra.cc";
82 license = licenses.mit;
83 maintainers = with maintainers; [ bcdarwin ];
84 };
85}