fix: patch nbconvert installed source when installed from wheel

This commit is contained in:
Phillip Cloud 2022-12-19 14:49:02 -05:00
parent cefd25bc6a
commit d72e0b4c0f
No known key found for this signature in database
GPG key ID: D908212070FD785E

View file

@ -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 ];
});
}
)
]