aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kevi...@apache.org
Subject git commit: AURORA-227: Aurora build should check for the Python version
Date Thu, 15 May 2014 02:55:35 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 3361dbedf -> fb11cd381


AURORA-227: Aurora build should check for the Python version

Testing Done:
Running ./gradlew checkPythonVersion with Python != 2.6 or 2.7 results in:

:checkPythonVersion FAILED

FAILURE: Build failed with an exception.

* Where:
Build file '/home/daniel/Projects/incubator-aurora/build.gradle' line: 257

* What went wrong:
Execution failed for task ':checkPythonVersion'.
> Build requires Python 2.6 or Python 2.7

Bugs closed: AURORA-227

Reviewed at https://reviews.apache.org/r/18537/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/fb11cd38
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/fb11cd38
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/fb11cd38

Branch: refs/heads/master
Commit: fb11cd381686b16c6d9e45a634d542ee288423e5
Parents: 3361dbe
Author: Dan Norris <protochron@gmail.com>
Authored: Wed May 14 19:53:56 2014 -0700
Committer: Kevin Sweeney <kevints@apache.org>
Committed: Wed May 14 19:53:56 2014 -0700

----------------------------------------------------------------------
 build-support/pex | 10 ++++++++++
 build.gradle      | 35 +++++++++++++++++++++++++++++++++--
 2 files changed, 43 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/fb11cd38/build-support/pex
----------------------------------------------------------------------
diff --git a/build-support/pex b/build-support/pex
index 4cecded..e940e22 100755
--- a/build-support/pex
+++ b/build-support/pex
@@ -18,6 +18,16 @@
 set -e
 
 TWITTER_COMMON_PYTHON_VERSION=0.5.6
+
+if which python2.7 >/dev/null; then
+  PY=`which python2.7`
+elif which python2.6 >/dev/null; then
+  PY=`which python2.6`
+else
+  echo 'No python interpreter found on the path.  Python will not work!' 1>&2
+  exit 1
+fi
+
 HERE=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)
 
 if ! [ -f "$HERE/pex.venv/BOOTSTRAPPED" ] || \

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/fb11cd38/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 6f43fea..09fe3bf 100644
--- a/build.gradle
+++ b/build.gradle
@@ -245,6 +245,37 @@ tasks.withType(FindBugs) {
   excludeFilter = rootProject.file('config/findbugs/excludeFilter.xml')
 }
 
+task checkPython() {
+  def py_versions = ['python2.7', 'python2.6', 'python']
+
+  project.ext.set('py', '')
+
+  py_versions.each { python_exe ->
+    if (project.py.isEmpty()) {
+      // Look for the first version of python listed in py_versions greater than 2.6.
+      // Execute will throw an exception if that python command does not exist,
+      // and set project.py to be empty
+      try {
+        def check = "import sys; sys.stdout.write(str(sys.version_info > (2,6) and sys.version_info
< (3,)))"
+        def cmd = [python_exe, "-c", check].execute()
+        def output = cmd.in.text.trim()
+
+        if(output.toLowerCase() == 'true') {
+          project.py = python_exe
+        }
+      } catch (Exception e) {
+          project.py = ''
+      }
+    }
+  }
+
+  doLast {
+    if (project.py.isEmpty()) {
+      throw new GradleException('Build requires Python 2.6 or Python 2.7')
+    }
+  }
+}
+
 /**
  * Check if Apache Thrift is all ready installed and is the same version as we
  * depend on, otherwise compile the version in build-support. project.thrift will
@@ -279,7 +310,7 @@ task bootstrapThrift {
   }
 }
 
-task generateSources(dependsOn: 'bootstrapThrift') {
+task generateSources(dependsOn: ['bootstrapThrift', 'checkPython']) {
   ext.inputFiles = fileTree(dir: 'src/main/thrift').matching { include '**/*.thrift' }
   ext.outputDir = file(generatedDir)
   inputs.file inputFiles
@@ -302,7 +333,7 @@ task generateSources(dependsOn: 'bootstrapThrift') {
     iStructs.each {
       def structName = it
       exec {
-        executable = 'python'
+        executable = project.py
         args = ['src/main/python/apache/aurora/tools/java/thrift_wrapper_codegen.py',
                 'src/main/thrift/org/apache/aurora/gen/api.thrift',
                 structName,


Mime
View raw message