Answering this question gives some information on what is happening "under the hood" in latexmk for a non-trivial case.
Context: Pythontex allows a .tex document to run calculations in Python and then typeset the results. The basic workflow with pythontex is (a) Compile the .tex document with use of the pythontex package. (b) Run the pythontex program to read files generated in step (a) that specify the calculations. (c) Compile the .tex document again to use the results from step (b).
Configuration of latexmk to use pythontex: The code needed is in the pythontex-latexmkrc file in the latexmk distribution. This sets up a "rule" for using the pythontex program. Its primary input file is file of extension pytxcode generated in the *latex compilation of the tex document. Its primary output file has an extension pytxmcr, and is read by the the next compilation of the document. The rule uses a Perl subroutine to run the pythontex program with appropriate arguments, and then determine the dependencies: what files are read, and what files are written beyond the primary input and output?
Functioning: On a first compilation of the .tex file by *latex, the pythontex package writes a warning to the .log file that the pytxmcr file that it needs doesn't exist. Latexmk sees that warning and sees that the missing file can be made by the pythontex rule. So it links that rule into its rule network. The rule gets run, and generates the missing file. So latexmk recompiles the .tex file, and the missing files are read. After that information on what is read and written by the pythontex package appears in the fls file, which gives the main dependency information.
What went wrong with lualatex: Latexmk (v. 4.80) ran lualatex, but didn't run pythontex or do the second run of lualatex. In the output, it states what it is doing and gives important information about what it found
Latexmk: Getting log file 'aux_dir/manualLatexMavenPlugin.log'
Latexmk: Examining 'aux_dir/manualLatexMavenPlugin.fls'
Latexmk: Examining 'aux_dir/manualLatexMavenPlugin.log'
Latexmk: Missing input file 'pythontex-files/manualLatexMavenPlugin/manualLatexMavenPlugin.pytxmcr.Run PythonTeX to create it' (or dependence on it) from following:
No file pythontex-files-manualLatexMavenPlugin/manualLatexMavenPlugin.pytxmcr.Run PythonTeX to create it.
Notice the exact placement single quotes in the line about the missing input file. Latexmk is reporting that it thinks that the log file tells it that there is a missing file. But the extension of the file is not the expected one with extension .pytxmcr but one with the very long extension .pytxmcr.Run PythonTeX to create it (!). Looking at the log file shows that latexmk has concatenated two neighboring lines together. The first line has length 78 bytes, and latexmk has assumed that the pair of lines is a single long line wrapped to keep it within the length limit on lines in log files.
Why there is a problem only with lualatex: Unlike pdflatex and xelatex, lualatex is quite sloppy in its line wrapping, and latexmk allows for the sloppiness. Unfortunately this has caused a bug where latexmk thinks a line has been wrapped but in reality wasn't, and it wasn't programmed into the current version to deal with this. The use of pythontex accentuates the problem because the filenames it deals with are rather long.
Work-arounds: (a) Change the name of the .tex filename to be slightly longer or shorter. (b) With the TeXLive distribution, set the environment variable max_print_line to a large value, e.g., 10000, to stop significant line wrapping. (c) Run pythontex manually once, then latexmk with the -g option. After that latexmk will work, because it now picks up dependency information from the .fls file.
Next version: The next version (probably 4.81) of latexmk will have a fix for this problem, which is more general than just with pythontex.
max_print_lineto a large number, say 10000. Then the issue of latexmk being confused by wrapped v. unwrapped lines in the log file won't arise. – John Collins Apr 20 '23 at 20:18%extra_rule_spec). I've added a comment about this in the file. What I haven't decided is what the appropriate public interface is: the variable itself or a subroutine. – John Collins Apr 20 '23 at 20:24$extra_rule_spec{'pythontex'} ...in your latexmkrc file saying how to do this. Only on a later run of lualatex, does the .fls file contain an INPUT line for the .pytxmcr file. – John Collins Apr 21 '23 at 14:14