Closed rlaphoenix closed 1 year ago
@rlaphoenix Thank you for contributing this and at the same time raising an issue I wasn't aware of.
Would you mind contributing a minimal working example which replicates the error?
Hi, sorry for the wait. I've made a minimal reproducible example repository here: https://github.com/rlaphoenix/rtd-dir-reproducible-example (https://rtd-dir-reproducible-example.readthedocs.io/en/latest/)
It seems the root of the issue may actually be caused by sphinxcontrib-youtube 1.2.0 (the new thumbnail feature it has).
You can see I progressively added further advanced usage of sphinxcontrib-images and it built correctly up until I added sphinxcontrib-youtube 1.2.0.
The build failed on rtd at the final stage:
/home/docs/checkouts/readthedocs.org/user_builds/rtd-dir-reproducible-example/envs/latest/bin/python -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html
You can see in the log it made a download of the thumbnail to a _video_thumbnail
directory, yet normally it saves to _static
, which was registered in the config.
Downloading remote images...[ 60%] https://www.lipsum.com/images/banners/white_234x60.gif
https://www.lipsum.com/images/banners/white_234x60.gif -> /home/docs/checkouts/readthedocs.org/user_builds/rtd-dir-reproducible-example/checkouts/latest/docs/_images/24e5061ca764d033cde60a7b0c29ed6fceeb9865 (downloading)
Downloading remote images...[ 80%] https://vumbnail.com/657905289.jpg
https://vumbnail.com/657905289.jpg -> /home/docs/checkouts/readthedocs.org/user_builds/rtd-dir-reproducible-example/checkouts/latest/docs/_video_thumbnail/657905289.jpg (downloading)
@rlaphoenix Thank you for the example. I've studied it and the behavior of the build.
I find the same thing as you, with sphinxcontrib-youtube added things fail with the current version 0.9.4 of sphinxcontrib-images (sphinx 5.1.1 and sphinxcontrib-youtube 1.2.0, likely with other version combinations as well).
The error I get, when building with 'make html' is this:
Extension error (sphinxcontrib.images):
Handler <function download_images at 0x7f346e5a85e0> for event 'env-updated' threw an exception (exception: [Errno 2] No such file or directory: 'contrib-images-31/rtd-dir-reproducible-example/docs/_video_thumbnail/657905289.jpg')
And what I do not after looking at things this afternoon is why this extension should process files in _video_thumbnail/
. That directory has to do with sphinxcontrib-youtube, not sphinxcontrib-images.
So currently I can not shake the feeling that this extension should ignore those files but do not. Making an extra directory (as you PR#31 does) might very well keep the extension from failing, but I'm not convinced it is the right place to fix the error.
I'll look at it again later.
Hi everyone, I'm just passing by for some context. I'm responsible for the conflict between sphinxcontrib-youtube and sphinxcontrib-image as I inspired myself from this lib to download image thumbnails for youtube and vimeo videos.
Normally this conflict is solved since https://github.com/sphinx-contrib/youtube/pull/40 if it is of any help. I'll listen to this thread if any further help is needed.
Yeah I can confirm it's now fixed by https://github.com/sphinx-contrib/youtube/pull/40, now we are just waiting for a new release.
Otherwise, a FileNotFound exception will be raised on the open() call. This issue may be somewhat related to Pull Request #23 I'm not sure.
It wasn't as simple as making the
env.srcdir
, as theenv.remote_images[src]
typically contains at least one folder stem. e.g.,'_video_thumbnail/657905289.jpg'
. This is why it takes the fulldst
, gets its parent directory, and makes the directory of that including its parents' leafs.I've personally encountered this on readthedocs in a poetry build environment. I can confirm the rtd environment did already have
env.srcdir
made, but not the further_video_thumbnail/
folder fromenv.remote_images[src]
.