Skip to content

[Bug]: _copy_css_file assumes that the _static directory already exists #20747

Closed

Description

@jhpalmieri

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

Activity

  1. added this to the v3.4.3 milestone on Jul 27, 2021
  2. added a commit that references this issue on Jul 27, 2021
    9c6f3bb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions