Skip to content

BUG: make _anim_rst windows compatible#1399

Merged
larsoner merged 1 commit intosphinx-gallery:masterfrom
story645:video-scraper
Nov 1, 2024
Merged

BUG: make _anim_rst windows compatible#1399
larsoner merged 1 commit intosphinx-gallery:masterfrom
story645:video-scraper

Conversation

@story645
Copy link
Copy Markdown
Contributor

@story645 story645 commented Nov 1, 2024

Changes to using os.path.relpath cause on windows Path.relative_to yields the following build errors:

    File "C:\Users\story\miniconda3\envs\mpl-dev\Lib\site-packages\sphinx_gallery\scrapers.py", line 276, in _anim_rst
        video_uri = video.relative_to(gallery_conf["src_dir"]).as_posix()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\story\miniconda3\envs\mpl-dev\Lib\pathlib.py", line 682, in relative_to
        raise ValueError(f"{str(self)!r} is not in the subpath of {str(other)!r}")
    ValueError: 'C:\\Users\\story\\Projects\\matplotlib\\doc\\gallery\\animation\\images\\sphx_glr_simple_scatter_009.mp4' is not in the subpath of 'C:/Users/story/Projects/matplotlib/doc'

@story645 story645 changed the title FOC: make _anim_rst windows compatible BUG: make _anim_rst windows compatible Nov 1, 2024
video_uri = video.relative_to(gallery_conf["src_dir"]).as_posix()
# relative_to doesn't work on windows
# video_uri = video.relative_to(gallery_conf["src_dir"]).as_posix()
video_uri = os.path.relpath(video, gallery_conf["src_dir"])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't expect this to work. This will have backslashes and URLs in HTML like the one in video below should have forward slashes, no? So there needs to be some posix-izing of the path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

somehow the tests pass, maybe cause the paths end up consistent for each system? but yeah will update

Copy link
Copy Markdown
Contributor

@larsoner larsoner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last question -- have you checked that the resulting video actually works on Windows?

@story645
Copy link
Copy Markdown
Contributor Author

story645 commented Nov 1, 2024

ran a make clean then make on tinybuild and the animation in the resulting doc works?

@larsoner larsoner merged commit efab080 into sphinx-gallery:master Nov 1, 2024
@larsoner
Copy link
Copy Markdown
Contributor

larsoner commented Nov 1, 2024

Sounds good, thanks @story645 !

@story645 story645 deleted the video-scraper branch November 1, 2024 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants