mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-10-30 08:00:59 +00:00
texlivePackages.minted: fix compatibility with Python 3.14
Co-authored-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com> Assisted-by: Claude Code (Claude Opus 5.5)
This commit is contained in:
committed by
Dmitry Kalinkin
parent
46f7867226
commit
37b294db23
@@ -421,6 +421,26 @@ rec {
|
||||
l3build install --full --texmfhome "$out"
|
||||
'';
|
||||
|
||||
# verify that minted can highlight code via latexminted
|
||||
minted = mkTeXTest {
|
||||
name = "minted";
|
||||
format = "pdflatex";
|
||||
texLive = texliveSmall.withPackages (ps: [ ps.minted ]);
|
||||
text = ''
|
||||
\documentclass{article}
|
||||
\usepackage{minted}
|
||||
\begin{document}
|
||||
\begin{minted}{python}
|
||||
def fib(n):
|
||||
a, b = 0, 1
|
||||
for _ in range(n):
|
||||
a, b = b, a + b
|
||||
return a
|
||||
\end{minted}
|
||||
\end{document}
|
||||
'';
|
||||
};
|
||||
|
||||
# verify that the restricted mode gets enabled when
|
||||
# needed (detected by checking if it disallows --gscmd)
|
||||
repstopdf =
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchpatch,
|
||||
fetchpatch2,
|
||||
fetchurl,
|
||||
runCommand,
|
||||
writeShellScript,
|
||||
@@ -47,6 +47,7 @@
|
||||
luajit,
|
||||
texinfo,
|
||||
# for bin.nix
|
||||
fetchpatch,
|
||||
gnum4,
|
||||
jdk_headless,
|
||||
perlPackages,
|
||||
@@ -102,7 +103,7 @@ let
|
||||
inherit
|
||||
stdenv
|
||||
lib
|
||||
fetchpatch
|
||||
fetchpatch2
|
||||
bin
|
||||
tlpdb
|
||||
tlpdbxz
|
||||
@@ -128,6 +129,7 @@ let
|
||||
zip
|
||||
luajit
|
||||
texinfo
|
||||
unzip
|
||||
;
|
||||
};
|
||||
in
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
stdenv,
|
||||
fetchpatch,
|
||||
fetchpatch2,
|
||||
lib,
|
||||
tlpdb,
|
||||
bin,
|
||||
@@ -27,6 +27,7 @@
|
||||
zip,
|
||||
luajit,
|
||||
texinfo,
|
||||
unzip,
|
||||
}:
|
||||
oldTlpdb:
|
||||
let
|
||||
@@ -470,9 +471,31 @@ lib.recursiveUpdate orig rec {
|
||||
'';
|
||||
|
||||
# find files in script directory, not in binary directory
|
||||
minted.postFixup = ''
|
||||
substituteInPlace "$out"/bin/latexminted --replace-fail "__file__" "\"$scriptsFolder/latexminted.py\""
|
||||
'';
|
||||
# fix compatibility with Python 3.14 by loading a patched copy of the latexminted package
|
||||
# (the patch is applied here rather than in postUnpack, since repacking the wheel inside the
|
||||
# fixed-output tex container would make its hash depend on the zip/zlib implementation)
|
||||
minted.extraNativeBuildInputs = [ unzip ];
|
||||
minted.postFixup =
|
||||
let
|
||||
patch = fetchpatch2 {
|
||||
name = "minted-python314-compat.patch";
|
||||
url = "https://github.com/gpoore/minted/commit/2a7b3a48e47b834bbc4a616679a0ef9710896a16.diff";
|
||||
hash = "sha256-JcaQjSDqBQFsWLNRaOSNxCvPNa2HktfuzjsMKAWUPl8=";
|
||||
includes = [ "python/latexminted/cmdline.py" ];
|
||||
};
|
||||
in
|
||||
''
|
||||
substituteInPlace "$out"/bin/latexminted --replace-fail "__file__" "\"$scriptsFolder/latexminted.py\""
|
||||
|
||||
latexmintedLib="$out"/share/minted/python
|
||||
mkdir -p "$latexmintedLib"
|
||||
unzip -q "$scriptsFolder"/latexminted-0.6.0-py3-none-any.whl 'latexminted/*' -d "$latexmintedLib"
|
||||
sed -i 's/\r$//' "$latexmintedLib"/latexminted/cmdline.py
|
||||
patch -p2 -d "$latexmintedLib" -i "${patch}"
|
||||
substituteInPlace "$out"/bin/latexminted \
|
||||
--replace-fail "from latexminted.cmdline import main" \
|
||||
"sys.path.insert(0, '$latexmintedLib')"$'\n'"from latexminted.cmdline import main"
|
||||
'';
|
||||
|
||||
# find files in source container, fix incompatibilities with snobol4
|
||||
texaccents.postFixup = ''
|
||||
|
||||
Reference in New Issue
Block a user