From d72e0b4c0f5cecc0f48e6bb46d84615e467fd9c4 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Mon, 19 Dec 2022 14:49:02 -0500 Subject: [PATCH] fix: patch `nbconvert` installed source when installed from wheel --- overrides/default.nix | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/overrides/default.nix b/overrides/default.nix index e59d61a..a315db2 100644 --- a/overrides/default.nix +++ b/overrides/default.nix @@ -2732,29 +2732,37 @@ lib.composeManyExtensions [ buildInputs = (old.buildInputs or [ ]) ++ [ self.Babel ]; }); - nbconvert = super.nbconvert.overridePythonAttrs (old: { - postPatch = lib.optionalString (!old.src.isWheel) ( - lib.optionalString (lib.versionAtLeast self.nbconvert.version "6.5.0") '' + nbconvert = + let + patchExporters = lib.optionalString (lib.versionAtLeast self.nbconvert.version "6.5.0") '' substituteInPlace \ ./nbconvert/exporters/templateexporter.py \ --replace \ 'root_dirs.extend(jupyter_path())' \ 'root_dirs.extend(jupyter_path() + [os.path.join("@out@", "share", "jupyter")])' \ --subst-var out - '' + lib.optionalString (lib.versionAtLeast self.nbconvert.version "7.0") '' - substituteInPlace \ - ./hatch_build.py \ - --replace \ - 'if self.target_name not in ["wheel", "sdist"]:' \ - 'if True:' - '' - ); - }); + ''; + in + super.nbconvert.overridePythonAttrs (old: { + postPatch = lib.optionalString (!old.src.isWheel) ( + patchExporters + lib.optionalString (lib.versionAtLeast self.nbconvert.version "7.0") '' + substituteInPlace \ + ./hatch_build.py \ + --replace \ + 'if self.target_name not in ["wheel", "sdist"]:' \ + 'if True:' + '' + ); + postInstall = lib.optionalString old.src.isWheel '' + pushd $out/${self.python.sitePackages} + ${patchExporters} + popd + ''; + }); mkdocs = super.mkdocs.overridePythonAttrs (old: { propagatedBuildInputs = old.propagatedBuildInputs or [ ] ++ [ self.babel ]; }); } ) - ]