Skip to content

Commit 9472026

Browse files
committed
Fix relative path method
1 parent 0a66ec1 commit 9472026

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

jupyter_sphinx/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,20 @@ def build_finished(app, env):
122122
if app.builder.format != "html":
123123
return
124124

125-
module_path = Path(__file__)
126-
outdir_path = Path(app.outdir)
125+
module_dir = Path(__file__).parent
126+
outdir = Path(app.outdir)
127127

128128
# Copy stylesheet
129-
src = module_path / "css"
130-
dst = outdir_path / "_static"
129+
src = module_dir / "css"
130+
dst = outdir / "_static"
131131
copy_asset(src, dst)
132132

133133
thebe_config = app.config.jupyter_sphinx_thebelab_config
134134
if not thebe_config:
135135
return
136136

137137
# Copy all thebelab related assets
138-
src = module_path / "thebelab"
138+
src = module_dir / "thebelab"
139139
copy_asset(src, dst)
140140

141141

jupyter_sphinx/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ def sphinx_abs_dir(env, *paths):
8181
# Can't get relative path between drives on Windows
8282
return out_path.as_posix()
8383

84-
return "/" + out_path.relative_to(env.app.srcdir).as_posix()
84+
# Path().relative_to() doesn't work when not a direct subpath
85+
return "/" + os.path.relpath(out_path, env.app.srcdir)
8586

8687

8788
def output_directory(env):

0 commit comments

Comments
 (0)