# Controlling minted cache filenames (.pygtex)

I have two nearly-identical documents with slightly different settings (one with 11pt font, and the other with 10pt), say book10.tex and book11.tex. They import a code snippet with minted using \inputminted.

I'm trying to reuse the minted cache from the first book to the others, unfortunately, it seems that the cache filenames are different. After compiling both books with xelatex:

xelatex --shell-escape book10.tex && xelatex --shell-escape book11.tex


I seem to have two .pygtex files, with the first part of the hash being identical, but the second part is different:

\$ ls
FCA5498F9EAF9E235804E47AA988230D31F590DAF3C4999269D16864F0C9105B.pygtex
FCA5498F9EAF9E235804E47AA988230D796938E665113EC976EFD1EDB1C66E95.pygtex
...


Their contents are identical, but the file names are different.

According to a footnote in the documentation, "cache files are named using an MD5 hash of highlighting settings and highlighted text". I can understand the "highlighted text" part, but what are the highlighting settings, and why do they hash differently?

My MWE is:

hello.hs

module Main where

main :: IO ()
main = putStrLn "Hello world!


book10.tex and book11.tex (simplified)

\documentclass{article}
\usepackage[cachedir=_mycache]{minted}

\begin{document}
\inputminted{octave}{hello.hs}

\end{document}


Question: Can I override the produced filenames? I want to keep the hash of the contents, ignoring the settings hash.

N.B. The solution using \finalizecache doesn't work for my situation, because some files use a macro that imports snippets in a different language instead.

I found a solution! I took a closer look at the minted.sty file, and noticed that the jobname was considered as a part of the hash. So I now specify the same -jobname value to xelatex and it seemed to work!
I asked this question on the minted github, and the answer I got suggests doing something similar, specifying \minted@jobname in the .tex file directly.