|
5 | 5 | import os |
6 | 6 | import os.path |
7 | 7 | from glob import glob |
| 8 | +from pathlib import Path |
8 | 9 | from typing import TYPE_CHECKING |
9 | 10 |
|
10 | 11 | from docutils import nodes |
11 | | -from docutils.utils import relative_path |
12 | 12 |
|
13 | 13 | from sphinx import addnodes |
14 | 14 | from sphinx.environment.collectors import EnvironmentCollector |
15 | 15 | from sphinx.locale import __ |
16 | 16 | from sphinx.util import logging |
17 | 17 | from sphinx.util.i18n import get_image_filename_for_language, search_image_for_language |
18 | 18 | from sphinx.util.images import guess_mimetype |
| 19 | +from sphinx.util.osutil import _relative_path |
19 | 20 |
|
20 | 21 | if TYPE_CHECKING: |
21 | 22 | from docutils.nodes import Node |
@@ -110,14 +111,14 @@ def collect_candidates( |
110 | 111 | ) -> None: |
111 | 112 | globbed: dict[str, list[str]] = {} |
112 | 113 | for filename in glob(imgpath): |
113 | | - new_imgpath = relative_path(os.path.join(env.srcdir, 'dummy'), filename) |
| 114 | + new_imgpath = _relative_path(Path(filename), env.srcdir) |
114 | 115 | try: |
115 | 116 | mimetype = guess_mimetype(filename) |
116 | 117 | if mimetype is None: |
117 | 118 | basename, suffix = os.path.splitext(filename) |
118 | 119 | mimetype = 'image/x-' + suffix[1:] |
119 | 120 | if mimetype not in candidates: |
120 | | - globbed.setdefault(mimetype, []).append(new_imgpath) |
| 121 | + globbed.setdefault(mimetype, []).append(new_imgpath.as_posix()) |
121 | 122 | except OSError as err: |
122 | 123 | logger.warning( |
123 | 124 | __('image file %s not readable: %s'), |
|
0 commit comments