Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Make behaviour clear when some garbage files are in src directory #41

Open
hmgaudecker opened this issue Apr 24, 2022 · 1 comment
Labels
good first issue Good for newcomers

Comments

@hmgaudecker
Copy link

Just came across this while grading assignments, had run into it before myself:

We used \verb|pytask-latex| to compile our document -- a nice feature is that the \LaTeX\ garbage files are stored in the \verb|bld| folder, not the source folder. During the process of writing the report, however, we used source code editors (see above) which compile the document as well right in the \verb|src| folder. At this point, we noted an interesting complication: when the garbage files in the \verb|src| folder are not removed but the ones in the \verb|bld| folder are removed, then, \verb|pytask-latex| fails to compile the document in the \verb|bld| folder. It took us some experiments to figure out this behaviour but we suppose that, in this case, \verb|pytask-latex| at the first run of \verb|latexmk| thinks the garbage files in the \verb|src| folder are the relevant ones and therefore imports wrong ``settings.'' When both garbage file locations are cleaned or both of them are not cleaned, then all works well. Importantly, for unpacking the project it does not matter since we don't include the \verb|src| garbage files in the repository.

This happens easily if one has separate src/bld directories and (accidentally) tries to compile the document in the src folder. Very hard to understand what is happening then.

Not sure what should happen. In any case, first thing to do would be to check whether

  • src/bld are separate
  • and whether there are files in src that are side-effects of the compilation.

If true, possibilities I can think of:

  • Raise an explicit error (maybe with interactive option / command line suggestion to remove the files?)
  • Somehow ignore the files with side-effects in src (stash them like pre-commit does?)

Difficult thing might be to predict exactly which files will be there.

@tobiasraabe
Copy link
Member

tobiasraabe commented Apr 28, 2022

Hi, thanks for the report! This is indeed a weird problem.

It would be possible to check for the existence of auxiliary files when src and bld are separate folders and then raise an error. We would also need the names of these auxiliary files which cause these side-effects or just roll with the common ones.

The implementation could be simple. Just add the checks for certain file names here

@hookimpl
def pytask_execute_task_setup(task):
"""Check that latexmk is found on the PATH if a LaTeX task should be executed."""
if has_mark(task, "latex"):
if shutil.which("latexmk") is None:
raise RuntimeError(
"latexmk is needed to compile LaTeX documents, but it is not found on "
"your PATH."
)

I did not find an option for latexmk for example to ignore files and stashing does only work for tracked files.

@tobiasraabe tobiasraabe added the good first issue Good for newcomers label May 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants