doc: external_content: fix for Unix
Path.rename() uses os.rename() internally. Per the Python docs: The operation may fail on some Unix flavors if src and dst are on different filesystems. Since 'src_adjusted' is in a temporary directory, on my flavor of Unix, that's in /tmp, which is indeed on a different filesystem than 'dst', a destination in the doc build directory on my root filesystem. This is causing the following error when I build the docs: Handler <function sync_contents at 0x7f9b8fca9c10> for event 'builder-inited' threw an exception (exception: [Errno 18] Invalid cross-device link: '/tmp/tmpfscfo20o/index.rst' -> '/home/mbolivar/zp/zephyr/doc/_build/src/reference/drivers/index.rst') Fix this by using shutil.move() instead of Path.rename(). The shutil function handles cross-filesystem moves correctly. It did not take a path-like object for both its src and dst arguments until Python 3.9, though, so we need to convert to strings for portability on earlier but still supported versions. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
f64346963a
commit
9464798068
1 changed files with 1 additions and 1 deletions
|
@ -154,7 +154,7 @@ def sync_contents(app: Sphinx) -> None:
|
|||
|
||||
if not filecmp.cmp(src_adjusted, dst):
|
||||
dst.unlink()
|
||||
src_adjusted.rename(dst)
|
||||
shutil.move(os.fspath(src_adjusted), os.fspath(dst))
|
||||
|
||||
# remove any previously copied file not present in the origin folder,
|
||||
# excepting those marked to be kept.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue