Skip to content

Commit ee36386

Browse files
committed
Fix pdf docbuild failure if destination file exists
The destination of shutil.move must be the filename and not a directory to take advantage of move-overwrite filesystem semantic. Fixes #40854
1 parent 28b7af0 commit ee36386

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/sage_docbuild/builders.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,10 @@ def pdf(self):
291291
# Move generated PDFs
292292
for pdf in tex_dir.glob("*.pdf"):
293293
try:
294-
shutil.move(str(pdf), pdf_dir)
294+
dst_pdf = os.path.join(pdf_dir, os.path.basename(pdf))
295+
shutil.move(str(pdf), dst_pdf)
295296
except Exception as e:
296-
logger.error(f"Failed moving {pdf} to {pdf_dir}: {e}")
297+
logger.error(f"Failed moving {pdf} to {dst_pdf}: {e}")
297298
raise
298299

299300
logger.info(f"Build finished. The built documents can be found in {pdf_dir}.")

0 commit comments

Comments
 (0)