Fix matplotlib sandboxing

This appears to fix plotting with matplotlib in python3.  This lets
things like //y2020/control_loops/python:finisher --plot work.

Change-Id: I8ff1c91cf078e3aa8b4d5660881c22c8de66f051
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/debian/matplotlib.BUILD b/debian/matplotlib.BUILD
index 881521c..ad44398 100644
--- a/debian/matplotlib.BUILD
+++ b/debian/matplotlib.BUILD
@@ -2,10 +2,5 @@
 
 build_matplotlib(
     "3",
-    tkinter_py_version = "3.5",
-)
-
-build_matplotlib(
-    "2.7",
-    copy_shared_files = False,
+    tkinter_py_version = "3.7",
 )
diff --git a/debian/matplotlib.bzl b/debian/matplotlib.bzl
index d94efd9..3ae0786 100644
--- a/debian/matplotlib.bzl
+++ b/debian/matplotlib.bzl
@@ -185,11 +185,19 @@
         name = "matplotlib" + version,
         srcs = _src_copied + [
             version + "/matplotlib/__init__.py",
-        ],
+        ] + native.glob(
+            include = ["usr/lib/python" + tkinter_py_version + "/**/*.py"],
+        ),
         data = _data_files + _builtin_so_copied + _system_so_copied + [
             ":usr/share/matplotlib/mpl-data/matplotlibrc",
-        ] + native.glob(["etc/**"]),
-        imports = ["usr/lib/python" + version + "/dist-packages", version, "."],
+        ] + native.glob(["etc/**", "usr/share/fonts/**"]),
+        imports = [
+            "rpathed3/usr/lib/python" + version + "/dist-packages",
+            "rpathed3/usr/lib/python" + version + ".7/lib-dynload",
+            version,
+            ".",
+            "usr/lib/python" + tkinter_py_version,
+        ],
         target_compatible_with = ["@platforms//cpu:x86_64"],
         visibility = ["//visibility:public"],
     )
diff --git a/debian/matplotlib_init.patch b/debian/matplotlib_init.patch
index 4cc155a..2818cd6 100644
--- a/debian/matplotlib_init.patch
+++ b/debian/matplotlib_init.patch
@@ -26,7 +26,7 @@
 +
 +# Tell fontconfig where to find matplotlib's sandboxed font files.
 +os.environ["FONTCONFIG_PATH"] = os.path.join(_matplotlib_base, "etc/fonts")
-+os.environ["FONTCONFIG_FILE"] = os.path.join(_matplotlib_base, "etc/fonts/fonts.conf")
++os.environ["FONTCONFIG_FILE"] = "fonts.conf"
 +os.environ["FONTCONFIG_SYSROOT"] = _matplotlib_base
 +
  try: