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/y2017/control_loops/python/BUILD b/y2017/control_loops/python/BUILD
index 83473ae..47c24e8 100644
--- a/y2017/control_loops/python/BUILD
+++ b/y2017/control_loops/python/BUILD
@@ -1,153 +1,181 @@
-package(default_visibility = ['//y2017:__subpackages__'])
+package(default_visibility = ["//y2017:__subpackages__"])
py_binary(
- name = 'drivetrain',
- srcs = [
- 'drivetrain.py',
- ],
- deps = [
- '//external:python-gflags',
- '//external:python-glog',
- '//frc971/control_loops/python:drivetrain',
- ],
- restricted_to = ['//tools:k8'],
+ name = "drivetrain",
+ srcs = [
+ "drivetrain.py",
+ ],
+ legacy_create_init = False,
+ restricted_to = ["//tools:k8"],
+ deps = [
+ ":python_init",
+ "//external:python-gflags",
+ "//external:python-glog",
+ "//frc971/control_loops/python:drivetrain",
+ ],
)
py_binary(
- name = 'polydrivetrain',
- srcs = [
- 'polydrivetrain.py',
- 'drivetrain.py',
- ],
- deps = [
- '//external:python-gflags',
- '//external:python-glog',
- '//frc971/control_loops/python:polydrivetrain',
- ],
- restricted_to = ['//tools:k8'],
+ name = "polydrivetrain",
+ srcs = [
+ "drivetrain.py",
+ "polydrivetrain.py",
+ ],
+ legacy_create_init = False,
+ restricted_to = ["//tools:k8"],
+ deps = [
+ ":python_init",
+ "//external:python-gflags",
+ "//external:python-glog",
+ "//frc971/control_loops/python:polydrivetrain",
+ ],
)
py_library(
- name = 'polydrivetrain_lib',
- srcs = [
- 'polydrivetrain.py',
- 'drivetrain.py',
- ],
- deps = [
- '//external:python-gflags',
- '//external:python-glog',
- '//frc971/control_loops/python:controls',
- '//frc971/control_loops/python:drivetrain',
- ],
- restricted_to = ['//tools:k8'],
+ name = "polydrivetrain_lib",
+ srcs = [
+ "drivetrain.py",
+ "polydrivetrain.py",
+ ],
+ restricted_to = ["//tools:k8"],
+ deps = [
+ "//external:python-gflags",
+ "//external:python-glog",
+ "//frc971/control_loops/python:controls",
+ "//frc971/control_loops/python:drivetrain",
+ ],
)
py_binary(
- name = 'shooter',
- srcs = [
- 'shooter.py',
- ],
- deps = [
- '//external:python-gflags',
- '//external:python-glog',
- '//frc971/control_loops/python:controls',
- ],
- restricted_to = ['//tools:k8'],
+ name = "shooter",
+ srcs = [
+ "shooter.py",
+ ],
+ legacy_create_init = False,
+ restricted_to = ["//tools:k8"],
+ deps = [
+ ":python_init",
+ "//external:python-gflags",
+ "//external:python-glog",
+ "//frc971/control_loops/python:controls",
+ "@matplotlib",
+ ],
)
py_binary(
- name = 'indexer',
- srcs = [
- 'indexer.py',
- ],
- deps = [
- '//external:python-gflags',
- '//external:python-glog',
- '//frc971/control_loops/python:controls',
- ],
- restricted_to = ['//tools:k8'],
+ name = "indexer",
+ srcs = [
+ "indexer.py",
+ ],
+ legacy_create_init = False,
+ restricted_to = ["//tools:k8"],
+ deps = [
+ ":python_init",
+ "//external:python-gflags",
+ "//external:python-glog",
+ "//frc971/control_loops/python:controls",
+ ],
)
py_binary(
- name = 'intake',
- srcs = [
- 'intake.py',
- ],
- deps = [
- '//aos/common/util:py_trapezoid_profile',
- '//external:python-gflags',
- '//external:python-glog',
- '//frc971/control_loops/python:controls',
- ],
- restricted_to = ['//tools:k8'],
+ name = "intake",
+ srcs = [
+ "intake.py",
+ ],
+ legacy_create_init = False,
+ restricted_to = ["//tools:k8"],
+ deps = [
+ ":python_init",
+ "//aos/common/util:py_trapezoid_profile",
+ "//external:python-gflags",
+ "//external:python-glog",
+ "//frc971/control_loops/python:controls",
+ "@matplotlib",
+ ],
)
py_binary(
- name = 'turret',
- srcs = [
- 'turret.py',
- ],
- deps = [
- '//aos/common/util:py_trapezoid_profile',
- '//external:python-gflags',
- '//external:python-glog',
- '//frc971/control_loops/python:controls',
- ],
- restricted_to = ['//tools:k8'],
+ name = "turret",
+ srcs = [
+ "turret.py",
+ ],
+ legacy_create_init = False,
+ restricted_to = ["//tools:k8"],
+ deps = [
+ ":python_init",
+ "//aos/common/util:py_trapezoid_profile",
+ "//external:python-gflags",
+ "//external:python-glog",
+ "//frc971/control_loops/python:controls",
+ "@matplotlib",
+ ],
)
py_binary(
- name = 'hood',
- srcs = [
- 'hood.py',
- ],
- deps = [
- '//aos/common/util:py_trapezoid_profile',
- '//external:python-gflags',
- '//external:python-glog',
- '//frc971/control_loops/python:controls',
- ],
- restricted_to = ['//tools:k8'],
+ name = "hood",
+ srcs = [
+ "hood.py",
+ ],
+ legacy_create_init = False,
+ restricted_to = ["//tools:k8"],
+ deps = [
+ ":python_init",
+ "//aos/common/util:py_trapezoid_profile",
+ "//external:python-gflags",
+ "//external:python-glog",
+ "//frc971/control_loops/python:controls",
+ "@matplotlib",
+ ],
)
py_library(
- name = 'turret_lib',
- srcs = [
- 'turret.py',
- ],
- deps = [
- '//aos/common/util:py_trapezoid_profile',
- '//external:python-gflags',
- '//external:python-glog',
- '//frc971/control_loops/python:controls',
- ],
- restricted_to = ['//tools:k8'],
+ name = "turret_lib",
+ srcs = [
+ "turret.py",
+ ],
+ restricted_to = ["//tools:k8"],
+ deps = [
+ "//aos/common/util:py_trapezoid_profile",
+ "//external:python-gflags",
+ "//external:python-glog",
+ "//frc971/control_loops/python:controls",
+ ],
)
py_library(
- name = 'indexer_lib',
- srcs = [
- 'indexer.py',
- ],
- deps = [
- '//external:python-gflags',
- '//external:python-glog',
- '//frc971/control_loops/python:controls',
- ],
- restricted_to = ['//tools:k8'],
+ name = "indexer_lib",
+ srcs = [
+ "indexer.py",
+ ],
+ restricted_to = ["//tools:k8"],
+ deps = [
+ "//external:python-gflags",
+ "//external:python-glog",
+ "//frc971/control_loops/python:controls",
+ ],
)
py_binary(
- name = 'column',
- srcs = [
- 'column.py',
- ],
- deps = [
- ':turret_lib',
- ':indexer_lib',
- '//external:python-gflags',
- '//external:python-glog',
- '//frc971/control_loops/python:controls',
- ],
- restricted_to = ['//tools:k8'],
+ name = "column",
+ srcs = [
+ "column.py",
+ ],
+ legacy_create_init = False,
+ restricted_to = ["//tools:k8"],
+ deps = [
+ ":indexer_lib",
+ ":python_init",
+ ":turret_lib",
+ "//external:python-gflags",
+ "//external:python-glog",
+ "//frc971/control_loops/python:controls",
+ "@matplotlib",
+ ],
+)
+
+py_library(
+ name = "python_init",
+ srcs = ["__init__.py"],
+ visibility = ["//visibility:public"],
+ deps = ["//y2017/control_loops:python_init"],
)
diff --git a/y2017/control_loops/python/__init__.py b/y2017/control_loops/python/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/y2017/control_loops/python/__init__.py
diff --git a/y2017/control_loops/python/column.py b/y2017/control_loops/python/column.py
index d6043b3..4cbf4dd 100755
--- a/y2017/control_loops/python/column.py
+++ b/y2017/control_loops/python/column.py
@@ -7,7 +7,6 @@
from y2017.control_loops.python import indexer
import numpy
import sys
-import matplotlib
from matplotlib import pylab
import gflags
import glog
diff --git a/y2017/control_loops/python/hood.py b/y2017/control_loops/python/hood.py
index 6c7c2d0..2704216 100755
--- a/y2017/control_loops/python/hood.py
+++ b/y2017/control_loops/python/hood.py
@@ -5,7 +5,6 @@
from frc971.control_loops.python import controls
import numpy
import sys
-import matplotlib
from matplotlib import pylab
import gflags
import glog
diff --git a/y2017/control_loops/python/intake.py b/y2017/control_loops/python/intake.py
index ae209c3..5f557f1 100755
--- a/y2017/control_loops/python/intake.py
+++ b/y2017/control_loops/python/intake.py
@@ -5,7 +5,6 @@
from frc971.control_loops.python import controls
import numpy
import sys
-import matplotlib
from matplotlib import pylab
import gflags
import glog
diff --git a/y2017/control_loops/python/turret.py b/y2017/control_loops/python/turret.py
index d64fceb..f07e7a5 100755
--- a/y2017/control_loops/python/turret.py
+++ b/y2017/control_loops/python/turret.py
@@ -5,7 +5,6 @@
from frc971.control_loops.python import controls
import numpy
import sys
-import matplotlib
from matplotlib import pylab
import gflags
import glog