Make matplotlibcpp work with upstream Python
This patch doesn't work on its own because the users of matplotlibcpp
often still depend on "debian_bundled_python" packages. If you want to
test locally, run with Ic7a8ba6110516aa2446ad2ad4e2495fab62d824c.
I can't get the version from master working. I'm assuming that's
because it refers to Python 3.5 instead of our current Python 3.9.
Regardless, you can see the plots with the new setup like so:
$ bazel run //frc971/control_loops/drivetrain:line_follow_drivetrain_test -- --plot --gtest_filter=LineFollowDrivetrainTest.BasicGoalThetaCheck
(Note that you need `--config=k8_upstream_python` if running without
Ic7a8ba6110516aa2446ad2ad4e2495fab62d824c.)
The above command displays the two plots, but then crashes after the
plots are closed. I'm really not sure what's going on there. It works
without issues, however, when run roughly like so:
$ $ (cd bazel-bin/frc971/control_loops/drivetrain/line_follow_drivetrain_test.runfiles/org_frc971/ && RUNFILES_DIR=$(pwd)/../ ../../line_follow_drivetrain_test --plot --gtest_filter=LineFollowDrivetrainTest.BasicGoalThetaCheck)
Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: I2514a3831f18a7bec3a6d458965e94eb5d19e5fc
diff --git a/third_party/matplotlib-cpp/BUILD b/third_party/matplotlib-cpp/BUILD
index 6221abb..bd10366 100644
--- a/third_party/matplotlib-cpp/BUILD
+++ b/third_party/matplotlib-cpp/BUILD
@@ -5,16 +5,28 @@
hdrs = [
"matplotlibcpp.h",
],
- data = [
- "@matplotlib_repo//:matplotlib3",
- "@python_repo//:all_files",
+ data = select({
+ "//tools/platforms/python:debian_bundled_python": [
+ "@matplotlib_repo//:matplotlib3",
+ ],
+ "//tools/platforms/python:upstream_bundled_python": [
+ "@pip//matplotlib",
+ "@pip//pygobject",
+ ],
+ }) + [
+ "//third_party/python:python_runtime",
],
# While this is technically compatible with "linux", the
# "@python_repo//:all_files" has x86 binaries in it.
target_compatible_with = ["@platforms//cpu:x86_64"],
visibility = ["//visibility:public"],
- deps = [
- "@python_repo//:python3.9_lib",
+ deps = select({
+ "//tools/platforms/python:debian_bundled_python": [],
+ "//tools/platforms/python:upstream_bundled_python": [
+ "//third_party/python:numpy_cc",
+ ],
+ }) + [
+ "//third_party/python",
],
)