From b71ad92137d9487af9374e59c0c9d2068b6c0465 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Tue, 27 Dec 2022 20:01:20 +0100 Subject: [PATCH] python3Packages.hydra-core: unpin antlr4-python3-runtime --- .../python-modules/hydra-core/antlr4.patch | 13 +++++++++++++ .../python-modules/hydra-core/default.nix | 17 +++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 pkgs/development/python-modules/hydra-core/antlr4.patch diff --git a/pkgs/development/python-modules/hydra-core/antlr4.patch b/pkgs/development/python-modules/hydra-core/antlr4.patch new file mode 100644 index 000000000000..958e128998d1 --- /dev/null +++ b/pkgs/development/python-modules/hydra-core/antlr4.patch @@ -0,0 +1,13 @@ +diff --git a/build_helpers/build_helpers.py b/build_helpers/build_helpers.py +index 7159d22615..73db312bbe 100644 +--- a/build_helpers/build_helpers.py ++++ b/build_helpers/build_helpers.py +@@ -185,7 +185,7 @@ class ANTLRCommand(Command): # type: ignore + command = [ + "java", + "-jar", +- join(root_dir, "bin/antlr-4.9.3-complete.jar"), ++ "@antlr_jar@", + "-Dlanguage=Python3", + "-o", + join(project_root, "hydra/grammar/gen/"), diff --git a/pkgs/development/python-modules/hydra-core/default.nix b/pkgs/development/python-modules/hydra-core/default.nix index 4cd6e1b60253..644c16cb52a7 100644 --- a/pkgs/development/python-modules/hydra-core/default.nix +++ b/pkgs/development/python-modules/hydra-core/default.nix @@ -1,5 +1,6 @@ { stdenv , lib +, antlr4 , antlr4-python3-runtime , buildPythonPackage , fetchFromGitHub @@ -8,6 +9,7 @@ , omegaconf , pytestCheckHook , pythonOlder +, substituteAll }: buildPythonPackage rec { @@ -24,6 +26,21 @@ buildPythonPackage rec { hash = "sha256-4FOh1Jr+LM8ffh/xcAqMqKudKbXb2DZdxU+czq2xwxs="; }; + patches = [ + (substituteAll { + src = ./antlr4.patch; + antlr_jar = "${antlr4.out}/share/java/antlr-${antlr4.version}-complete.jar"; + }) + ]; + + postPatch = '' + # We substitute the path to the jar with the one from our antlr4 + # package, so this file becomes unused + rm -v build_helpers/bin/antlr*-complete.jar + + sed -i 's/antlr4-python3-runtime==.*/antlr4-python3-runtime/' requirements/requirements.txt + ''; + nativeBuildInputs = [ jre_headless ];