mirror of
https://github.com/google/nomulus.git
synced 2025-04-29 19:47:51 +02:00
Find a suitable version of python. (#1338)
* Find a suitable version of python. When running presubmit, we were using /usr/bin/python3, which works fine on systems that have a reasonably recent python version there. However, our CI system has a very old version of python there and prefers the use of "pyenv" to modify the PATH to provide the desired version of python as simply "python". So add a check to use the first of "python" or "/usr/bin/python3" that is at least version 3.7.3.
This commit is contained in:
parent
4387af98e9
commit
ba3552e81a
2 changed files with 25 additions and 1 deletions
25
build.gradle
25
build.gradle
|
@ -196,8 +196,31 @@ allprojects {
|
|||
}
|
||||
}
|
||||
|
||||
rootProject.ext {
|
||||
pyver = { exe ->
|
||||
try {
|
||||
ext.execInBash(
|
||||
exe + " -c 'import sys; print(sys.hexversion)'", "/") as Integer
|
||||
} catch (org.gradle.process.internal.ExecException e) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task runPresubmits(type: Exec) {
|
||||
executable '/usr/bin/python3'
|
||||
|
||||
// Find a python version greater than 3.7.3 (this is somewhat arbitrary, we
|
||||
// know we'd like at least 3.6, but 3.7.3 is the latest that ships with
|
||||
// Debian so it seems like that should be available anywhere).
|
||||
def MIN_PY_VER = 0x3070300
|
||||
if (pyver('python') >= MIN_PY_VER) {
|
||||
executable 'python'
|
||||
} else if (pyver('/usr/bin/python3') >= MIN_PY_VER) {
|
||||
executable '/usr/bin/python3'
|
||||
} else {
|
||||
throw new GradleException("No usable Python version found (build " +
|
||||
"requires at least python 3.7.3)");
|
||||
}
|
||||
args('config/presubmits.py')
|
||||
}
|
||||
|
||||
|
|
|
@ -344,6 +344,7 @@ def get_files():
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print('python version is %s' % sys.version)
|
||||
failed = False
|
||||
for file in get_files():
|
||||
error_messages = []
|
||||
|
|
Loading…
Add table
Reference in a new issue