Use a (mostly) hermetic Python interpreter
It still requires python to be installed on the host to run the wrapper
scripts, but it's close to being fully hermetic.
This also requires/enables the following changes, unfortunately all at
the same time:
* Use a downloaded f2py
* Use a downloaded scipy/numpy/matplotlib
* Fix a few things that don't run with the python version in their #!
* Stop using bazel-generated __init__.py files, because those interfere
with importing matplotlib nicely
Change-Id: Ife280464613d67cece9587b7d947f0b1d5466d7e
diff --git a/frc971/control_loops/python/BUILD b/frc971/control_loops/python/BUILD
index 64201c4..fb3e971 100644
--- a/frc971/control_loops/python/BUILD
+++ b/frc971/control_loops/python/BUILD
@@ -1,79 +1,98 @@
-package(default_visibility = ['//visibility:public'])
+package(default_visibility = ["//visibility:public"])
py_binary(
- name = 'haptic_wheel',
- srcs = [
- 'haptic_wheel.py',
- ],
- deps = [
- '//external:python-gflags',
- '//external:python-glog',
- '//frc971/control_loops/python:controls',
- ],
- restricted_to = ['//tools:k8'],
+ name = "haptic_wheel",
+ srcs = [
+ "haptic_wheel.py",
+ ],
+ legacy_create_init = False,
+ restricted_to = ["//tools:k8"],
+ deps = [
+ "//external:python-gflags",
+ "//external:python-glog",
+ "//frc971/control_loops/python:controls",
+ "@matplotlib",
+ ],
)
py_library(
- name = 'controls',
- srcs = [
- 'cim.py',
- 'control_loop.py',
- 'controls.py',
- 'polytope.py',
- 'libcdd.py',
- ],
- deps = [
- '//external:python-glog',
- '@slycot_repo//:slycot',
- ],
- data = [
- '//third_party/cddlib:_cddlib.so',
- ],
- restricted_to = ['//tools:k8'],
+ name = "controls",
+ srcs = [
+ "cim.py",
+ "control_loop.py",
+ "controls.py",
+ "libcdd.py",
+ "polytope.py",
+ ],
+ data = [
+ "//third_party/cddlib:_cddlib.so",
+ "@python_repo//:scipy",
+ ],
+ restricted_to = ["//tools:k8"],
+ deps = [
+ ":python_init",
+ "//external:python-glog",
+ "@slycot_repo//:slycot",
+ ],
)
py_test(
- name = 'polytope_test',
- srcs = [
- 'polytope_test.py',
- ],
- deps = [
- ':controls',
- ],
- restricted_to = ['//tools:k8'],
+ name = "polytope_test",
+ srcs = [
+ "polytope_test.py",
+ ],
+ legacy_create_init = False,
+ restricted_to = ["//tools:k8"],
+ deps = [
+ ":controls",
+ ":python_init",
+ ],
)
py_binary(
- name = 'down_estimator',
- srcs = [
- 'down_estimator.py',
- ],
- deps = [
- ':controls',
- ],
- restricted_to = ['//tools:k8'],
+ name = "down_estimator",
+ srcs = [
+ "down_estimator.py",
+ ],
+ legacy_create_init = False,
+ restricted_to = ["//tools:k8"],
+ deps = [
+ ":controls",
+ ":python_init",
+ "@matplotlib",
+ ],
)
py_library(
- name = 'drivetrain',
- srcs = [
- 'drivetrain.py',
- ],
- deps = [
- ':controls',
- ],
- restricted_to = ['//tools:k8'],
+ name = "drivetrain",
+ srcs = [
+ "drivetrain.py",
+ ],
+ restricted_to = ["//tools:k8"],
+ deps = [
+ ":controls",
+ ":python_init",
+ "@matplotlib",
+ ],
)
py_library(
- name = 'polydrivetrain',
- srcs = [
- 'polydrivetrain.py',
- ],
- deps = [
- ':controls',
- ':drivetrain',
- '//external:python-glog',
- ],
- restricted_to = ['//tools:k8'],
+ name = "polydrivetrain",
+ srcs = [
+ "polydrivetrain.py",
+ ],
+ restricted_to = ["//tools:k8"],
+ deps = [
+ ":controls",
+ ":drivetrain",
+ ":python_init",
+ "//external:python-glog",
+ ],
+)
+
+py_library(
+ name = "python_init",
+ srcs = ["__init__.py"],
+ visibility = ["//visibility:public"],
+ deps = ["//frc971/control_loops:python_init"],
)
diff --git a/frc971/control_loops/python/__init__.py b/frc971/control_loops/python/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/frc971/control_loops/python/__init__.py