diff options
author | gregce <gregce@google.com> | 2017-10-19 20:37:40 +0200 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2017-10-20 14:04:05 +0200 |
commit | 8b5bf1f440ef8d140eb3843861fbce65709438ea (patch) | |
tree | add463ed197b886232382968101bef0e68cfa9ae /src/main/java/com/google/devtools/build/lib/rules/python/PythonVersion.java | |
parent | 70e0b7a6b567d5f6c189ad044e8965e17b729ad4 (diff) |
Support Python 2 and 3 in the same build.
This is also an example of the versatility of dynamic configurations: this feature
only requires changes to rules/python/...
Issue #3871
PiperOrigin-RevId: 172775001
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/python/PythonVersion.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/python/PythonVersion.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PythonVersion.java b/src/main/java/com/google/devtools/build/lib/rules/python/PythonVersion.java index 59dddddca1..586b3a9d60 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/python/PythonVersion.java +++ b/src/main/java/com/google/devtools/build/lib/rules/python/PythonVersion.java @@ -32,6 +32,12 @@ public enum PythonVersion { static final PythonVersion[] ALL_VALUES = new PythonVersion[] { PY2, PY3, PY2AND3, PY2ONLY, PY3ONLY }; + /** + * The Python version to use if not overridden by {@link PythonOptions#forcePython} or a rule's + * {@code default_python_version} or {@code srcs_version} attributes. + */ + static final PythonVersion DEFAULT = PY2; + static final PythonVersion[] NON_CONVERSION_VALUES = new PythonVersion[] { PY2AND3, PY2ONLY, PY3ONLY }; @@ -43,7 +49,7 @@ public enum PythonVersion { } public static PythonVersion defaultTargetPythonVersion() { - return PY2; + return DEFAULT; } private static Iterable<String> convertToStrings(PythonVersion[] values) { @@ -61,7 +67,7 @@ public enum PythonVersion { public static Iterable<String> getNonConversionValues() { return convertToStrings(NON_CONVERSION_VALUES); } - + public static Iterable<String> getTargetPythonValues() { return convertToStrings(TARGET_PYTHON_VALUES); } |