Description
Bug summary
The function _copy_css_file
in sphinxext/plot_directive.py
assumes that the _static
directory already exists. If it doesn't, then rather than creating _static/plot_directive.css
with the appropriate content, it instead writes that content to a file _static
. If another part of Sphinx then tries to create a directory _static
, it results in an error.
We run into this problem in Sagemath (see https://trac.sagemath.org/ticket/32262) because we have a complicated directory layout for Sphinx output, and the _static
directory may not be created right away.
Code for reproduction
Build Sagemath + the latest matplotlib (https://trac.sagemath.org/ticket/31580).
Actual outcome
Sphinx raises an error: OSError: WARNING: cannot copy static file FileExistsError(17, 'File exists')
. A more complete traceback is at https://trac.sagemath.org/ticket/31580.
Expected outcome
Used to work with version 3.3.4 of matplotlib
, which I believe is before the function _copy_css_file
was introduced.
Operating system
Observed on OS X and linux
Matplotlib Version
3.4.2
Matplotlib Backend
No response
Python version
3.9
Jupyter version
No response
Other libraries
No response
Installation
No response
Conda channel
No response