I know it's an edge case but I think I find a bug in the add_css_file method.
I build a sphinx extention (https://github.com/sphinx-contrib/icon) to create an icon role adding inline fontawesome icons in the text content for various builder. To work I need to add the fontawesome css and js to the build for html and the fonts for latex.
I want to test my extention in a CI pipeline run on github actions. This action creates temporary build folder and perform sanity checks on the outputs using the "sphinx.testing.fixtures".
In this context in a linux environment everything lives in a home/ disk and everything runs as expected. For the Windows build on the other hand the tests are all failing as Sphinx does not resolve the path to css file correctly.
I try to run app.add_css_file(str(css_file)) with css_file being D:\a\icon\icon\sphinxcontrib\icon\node_modules\@fortawesome\fontawesome-free\css\all.min.css but when the html builder tries to resolve the links, he looks for C:/Users/runneradmin/AppData/Local/Temp/pytest-of-runneradmin/pytest-0/fa6-alias-icon/_build/html/_static/D:/a/icon/icon/sphinxcontrib/icon/node_modules/@fortawesome/fontawesome-free/css/all.min.css which of course does not exist. It seems that the changes of disk between the source of the css file and the build destination is not managed for windows machines. Do you have any idea where it could be coming from ?
How to Reproduce
It's such an edge case it's barely possible to reproduce. I cannot even make it on my local machine (as everything is run and build under C://
Describe the bug
I know it's an edge case but I think I find a bug in the add_css_file method. I build a sphinx extention (https://github.com/sphinx-contrib/icon) to create an icon role adding inline fontawesome icons in the text content for various builder. To work I need to add the fontawesome css and js to the build for html and the fonts for latex.
I want to test my extention in a CI pipeline run on github actions. This action creates temporary build folder and perform sanity checks on the outputs using the "sphinx.testing.fixtures".
In this context in a linux environment everything lives in a home/ disk and everything runs as expected. For the Windows build on the other hand the tests are all failing as Sphinx does not resolve the path to css file correctly.
I try to run
app.add_css_file(str(css_file))
withcss_file
beingD:\a\icon\icon\sphinxcontrib\icon\node_modules\@fortawesome\fontawesome-free\css\all.min.css
but when the html builder tries to resolve the links, he looks forC:/Users/runneradmin/AppData/Local/Temp/pytest-of-runneradmin/pytest-0/fa6-alias-icon/_build/html/_static/D:/a/icon/icon/sphinxcontrib/icon/node_modules/@fortawesome/fontawesome-free/css/all.min.css
which of course does not exist. It seems that the changes of disk between the source of the css file and the build destination is not managed for windows machines. Do you have any idea where it could be coming from ?How to Reproduce
It's such an edge case it's barely possible to reproduce. I cannot even make it on my local machine (as everything is run and build under
C://
You can have a look to the test suit code which is very simple (https://github.com/sphinx-doc/sphinx/blob/ea9c61fb38453e8a4798bcb4c5c9ab2972af03ba/sphinx/builders/html/__init__.py#L321)
In the following build I printed the path that is send to add_css_file: https://github.com/sphinx-contrib/icon/actions/runs/7444814020/job/20251917950
and in this one you will see the call that is made in layout to a non existing file:
Environment Information
Sphinx extensions
Additional context
No response