Let the latexmkrc PythonTeX cus_dep use the configured interpreter - #78
Open
dbosk wants to merge 1 commit into
Open
Let the latexmkrc PythonTeX cus_dep use the configured interpreter#78dbosk wants to merge 1 commit into
dbosk wants to merge 1 commit into
Conversation
The cus_dep hardcoded its PythonTeX invocation, so a project that points PythonTeX at a virtualenv interpreter -- the usual case when the document executes the very package it documents -- was ignored whenever latexmk drove the build, since latexmk reaches PythonTeX through the cus_dep rather than through tex.mk's rule. 53e54b0 had aligned the cus_dep with tex.mk's default invocation, but copying a default is not the same as sharing a configuration point: the two paths still diverge the moment anyone overrides it. The failure is silent and remote from its cause. LaTeX succeeds, latexmk reports the cus_dep as run, and the only symptom is a Python traceback about a missing module several build stages later. So export PYTHONTEX and PYTHONTEXFLAGS from tex.mk -- the environment is the only channel that reaches a latexmkrc, which Perl reads in a separate process -- and have the cus_dep read them back, keeping the literal defaults as Perl fallbacks so a hand-run latexmk with no make in the picture behaves as before. Unset is distinguished from empty so a project can deliberately pass no flags. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QiBv9BVhRKCyYJJNDhiowW
This was referenced Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
latexmkrc's PythonTeX custom dependency hardcoded its own invocation, so a project that points PythonTeX at a different interpreter was silently ignored whenever latexmk drove the build — latexmk reaches PythonTeX through the cus_dep, not throughtex.mk's rule.This bites exactly the projects that need PythonTeX most: those whose document executes the package it documents, and so must run under a virtualenv interpreter that can import it. Setting
PYTHONTEXFLAGS= --interpreter "python:poetry run python3"in the project's makefile had no effect on the latexmk path.
53e54b0had already aligned the cus_dep withtex.mk's default invocation, which fixed portability. But copying a default is not the same as sharing a configuration point — the two paths still diverge the moment anyone overrides it.The failure is silent and remote from its cause: LaTeX succeeds, latexmk reports the cus_dep as run, and the only symptom is a Python traceback about a missing module several build stages later.
Change
Made in
tex.mk.nw;tex.mkandlatexmkrcare regenerated.tex.mknowexportsPYTHONTEXandPYTHONTEXFLAGS. A latexmkrc is Perl read by a separate process, so it cannot see make's variables — the environment is the one channel that crosses that boundary.%ENV, keeping the literal defaults as Perl fallbacks so a hand-runlatexmk(no make, empty environment) behaves exactly as before.//rather than||for the flags, so a project can deliberately pass no flags without silently getting the defaults back.The
sub pythontexbody moved into its own<<run PythonTeX with the configured interpreter>>chunk, with prose explaining the departure from the CTAN original.Verification
Against
dbosk/ladok3, whose doc build setsPYTHONTEXFLAGS= --interpreter "python:poetry run python3":ModuleNotFoundError: No module named 'ladok3'0 error(s), 0 warning(s), 58 outputsmake -C doc allperl -c latexmkrcpasses, and both tangled outputs were diffed against freshnotangleruns.Note
make latexmkrcin this repo does not tangle — the includedtex.mk'slatexmkrc:symlink target overrides theMakefiletangle rule, which is #76. I tangled by hand withnotangle -R"[[latexmkrc]]" tex.mk.nw | cpif latexmkrc.🤖 Generated with Claude Code
https://claude.ai/code/session_01QiBv9BVhRKCyYJJNDhiowW