user202729/tex-fast-recompile

Use TEXINPUTS instead of copying files to temporary output directory when --temp-output-dir is on

Closed this issue · 2 comments

Mentioned in #7.

Actually the copy forward seems redundant, just copy back is enough???

Will dump some code here just in case

		env=dict(os.environ)

		# https://stackoverflow.com/questions/19023238/why-python-uppercases-all-environment-variables-in-windows
		texinputs: list[str]=[]
		if env.get("TEXINPUTS"):  # exist and nonempty
			texinputs=env["TEXINPUTS"].split(os.pathsep)

		if os.pathsep in str(self.output_directory):
			print(f"Warning: Output directory {self.output_directory} contains invalid character {os.pathsep}")
			# fallback: copy files from real output_directory to temp_output_directory
			# currently sub-aux files are not copied, see https://github.com/user202729/tex-fast-recompile/issues/7
			for extension in ['aux', 'bcf', 'fls', 'idx', 'ind', 'lof', 'lot', 'out', 'toc', 'blg', 'ilg', 'xdv']:
				try:
					shutil.copyfile(
						self.output_directory / (self.jobname + '.' + extension),
						self._temp_output_dir_path / (self.jobname + '.' + extension),
						)
				except FileNotFoundError:
					pass

		else:
			#texinputs.insert(0, str(self.output_directory))
			pass

		env["TEXINPUTS"]=os.pathsep.join(texinputs)

Never mind, issue only happen with nonstandard output_directory.

Implemented in 1f75da7.