aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/python/PythonOptions.java
diff options
context:
space:
mode:
authorGravatar Brian Silverman <bsilver16384@gmail.com>2016-01-04 12:43:39 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2016-01-04 12:59:10 +0000
commit27bdc238e5855a25e54f1e7300beebb2f17bcab7 (patch)
tree789c6b9e1e03d4a0fd691c5155d67c0267c32ce6 /src/main/java/com/google/devtools/build/lib/rules/python/PythonOptions.java
parent900acfbc0d84cac1933ebb28ac1ec8cb47f1f84d (diff)
Add a --host_force_python flag
This allows using PY3 binaries in the HOST configuration. -- Change-Id: I9603bb19a72cb3d0d731de5b35e135ce952cc545 Reviewed-on: https://bazel-review.googlesource.com/2401 MOS_MIGRATED_REVID=111311727
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/python/PythonOptions.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/python/PythonOptions.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PythonOptions.java b/src/main/java/com/google/devtools/build/lib/rules/python/PythonOptions.java
index 7ae76511f9..0b6deb2086 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/python/PythonOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/python/PythonOptions.java
@@ -31,6 +31,7 @@ public class PythonOptions extends FragmentOptions {
super(PythonVersion.class, "Python version");
}
}
+
@Option(name = "force_python",
defaultValue = "null",
category = "version",
@@ -38,6 +39,17 @@ public class PythonOptions extends FragmentOptions {
help = "Overrides default_python_version attribute. Can be \"PY2\" or \"PY3\".")
public PythonVersion forcePython;
+ @Option(
+ name = "host_force_python",
+ defaultValue = "null",
+ category = "version",
+ converter = PythonVersionConverter.class,
+ help =
+ "Overrides default_python_version attribute for the host configuration."
+ + " Can be \"PY2\" or \"PY3\"."
+ )
+ public PythonVersion hostForcePython;
+
public PythonVersion getPythonVersion() {
return (forcePython == null) ? DEFAULT_PYTHON_VERSION : forcePython;
}
@@ -45,7 +57,11 @@ public class PythonOptions extends FragmentOptions {
@Override
public FragmentOptions getHost(boolean fallback) {
PythonOptions hostPythonOpts = (PythonOptions) getDefault();
- hostPythonOpts.forcePython = PythonVersion.PY2;
+ if (hostForcePython != null) {
+ hostPythonOpts.forcePython = hostForcePython;
+ } else {
+ hostPythonOpts.forcePython = PythonVersion.PY2;
+ }
return hostPythonOpts;
}
}