Skip to content

Commit 1164146

Browse files
committed
Change sphinx_abs_dir return abs path on Windows
1 parent f45bad4 commit 1164146

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

jupyter_sphinx/utils.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from sphinx.errors import ExtensionError
55
import nbformat
66
from jupyter_client.kernelspec import get_kernel_spec, NoSuchKernel
7+
from pathlib import Path
78

89

910
def blank_nb(kernel_name):
@@ -74,12 +75,20 @@ def sphinx_abs_dir(env, *paths):
7475
# output_directory / jupyter_execute / path relative to source directory
7576
# Sphinx expects download links relative to source file or relative to
7677
# source dir and prepended with '/'. We use the latter option.
77-
return "/" + os.path.relpath(
78+
out_path = Path(
7879
os.path.abspath(
7980
os.path.join(output_directory(env), os.path.dirname(env.docname), *paths)
80-
),
81-
os.path.abspath(env.app.srcdir),
82-
)
81+
)
82+
).as_posix()
83+
84+
if os.name == "nt":
85+
# Can't get relative path between drives on Windows
86+
return out_path
87+
88+
return "/" + os.path.relpath(
89+
out_path,
90+
os.path.abspath(env.app.srcdir),
91+
)
8392

8493

8594
def output_directory(env):

0 commit comments

Comments
 (0)