From 57eff864263898904a5bc1902f55254892c7d206 Mon Sep 17 00:00:00 2001
From: Thomas A Caswell <tcaswell@gmail.com>
Date: Tue, 6 Sep 2022 12:08:46 -0400
Subject: [PATCH] Backport PR #23805: sphinxext: Do not copy
 plot_directive.css's metadata

---
 lib/matplotlib/sphinxext/plot_directive.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/matplotlib/sphinxext/plot_directive.py b/lib/matplotlib/sphinxext/plot_directive.py
index 00b10aaa4d99..c646f7a63e99 100644
--- a/lib/matplotlib/sphinxext/plot_directive.py
+++ b/lib/matplotlib/sphinxext/plot_directive.py
@@ -264,7 +264,8 @@ def _copy_css_file(app, exc):
         src = cbook._get_data_path('plot_directive/plot_directive.css')
         dst = app.outdir / Path('_static')
         dst.mkdir(exist_ok=True)
-        shutil.copy(src, dst)
+        # Use copyfile because we do not want to copy src's permissions.
+        shutil.copyfile(src, dst / Path('plot_directive.css'))
 
 
 def setup(app):