From 0618873a41e68684cfcf92702a320e194b5c78f8 Mon Sep 17 00:00:00 2001 From: Kwankyu Lee Date: Thu, 31 Mar 2022 23:04:02 +0900 Subject: [PATCH] Ensure symlink points to an existing directory --- src/sage_docbuild/ext/multidocs.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/sage_docbuild/ext/multidocs.py b/src/sage_docbuild/ext/multidocs.py index 124ed26a376..e8c0c25c2bb 100644 --- a/src/sage_docbuild/ext/multidocs.py +++ b/src/sage_docbuild/ext/multidocs.py @@ -227,7 +227,7 @@ def citation_dir(app: Sphinx) -> Path: if dirs[0] == '/': dirs.pop(0) tail = dirs[1:] - citedir = (sage_doc / "inventory").joinpath(*tail) + citedir = (sage_doc / "inventory").joinpath(*tail) else: citedir = outdir / "inventory" os.makedirs(citedir, exist_ok=True) @@ -304,6 +304,10 @@ def copy_static_files(self): shutil.rmtree(static_dir) except OSError: os.unlink(static_dir) + # This ensures that the symlink we are creating points to an + # existing directory. See trac #33608. + os.makedirs(os.path.join(app.builder.outdir, master_static_dir), + exist_ok=True) os.symlink(master_static_dir, static_dir) app.builder.copy_static_files = link_static_files @@ -314,10 +318,9 @@ def copy_static_files(self): app.emit('env-check-consistency', app.env) - def setup(app: Sphinx): app.add_config_value('multidocs_is_master', True, True) app.add_config_value('multidocs_subdoc_list', [], True) app.add_config_value('multidoc_first_pass', 0, False) # 1 = deactivate the loading of the inventory app.connect('builder-inited', init_subdoc) - return {'parallel_read_safe': True} + return {'parallel_read_safe': True}