[Bf-blender-cvs] [283abdf] master: Fix compilation error with scons and older pythons

Sergey Sharybin noreply at git.blender.org
Thu Jun 26 12:05:58 CEST 2014


Commit: 283abdf3b2de08c9e5be764a02e89120fe7b67da
Author: Sergey Sharybin
Date:   Thu Jun 26 16:03:52 2014 +0600
https://developer.blender.org/rB283abdf3b2de08c9e5be764a02e89120fe7b67da

Fix compilation error with scons and older pythons

===================================================================

M	SConstruct
M	build_files/scons/tools/Blender.py
M	build_files/scons/tools/btools.py
M	intern/cycles/kernel/SConscript

===================================================================

diff --git a/SConstruct b/SConstruct
index f27ba17..0c85fe1 100644
--- a/SConstruct
+++ b/SConstruct
@@ -285,7 +285,7 @@ if env['OURPLATFORM']=='darwin':
     import subprocess
 
     command = ["%s"%env['CC'], "--version"]
-    line = subprocess.check_output(command)
+    line = btools.get_command_output(command)
     ver = re.search(r'[0-9]+(\.[0-9]+[svn]+)+', line) or re.search(r'[0-9]+(\.[0-9]+)+', line) # read the "based on LLVM x.xsvn" version here, not the Apple version
     if ver:
         env['CCVERSION'] = ver.group(0).strip('svn')
diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py
index 72eafcd..e0f1848 100644
--- a/build_files/scons/tools/Blender.py
+++ b/build_files/scons/tools/Blender.py
@@ -413,7 +413,7 @@ def buildinfo(lenv, build_type):
 
     if os.path.isdir(os.path.abspath('.git')):
         try:
-            build_commit_timestamp = subprocess.check_output(args=['git', 'log', '-1', '--format=%ct']).strip()
+            build_commit_timestamp = btools.get_command_output(args=['git', 'log', '-1', '--format=%ct']).strip()
         except OSError:
             build_commit_timestamp = None
         if not build_commit_timestamp:
@@ -425,42 +425,42 @@ def buildinfo(lenv, build_type):
             no_upstream = False
 
             try :
-                build_hash = subprocess.check_output(['git', 'rev-parse', '--short', '@{u}']).strip()
+                build_hash = btools.get_command_output(['git', 'rev-parse', '--short', '@{u}']).strip()
             except subprocess.CalledProcessError:
                 # assume branch has no upstream configured
                 build_hash = ''
 
-            build_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip()
+            build_branch = btools.get_command_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip()
 
             if build_branch == 'HEAD':
-                master_check = subprocess.check_output(['git', 'branch', '--list', 'master', '--contains', build_hash]).strip()
+                master_check = btools.get_command_output(['git', 'branch', '--list', 'master', '--contains', build_hash]).strip()
                 if master_check == 'master':
                     build_branch = 'master'
                 else:
-                    head_hash = subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip()
-                    tag_hashes = subprocess.check_output(['git', 'show-ref', '--tags', '-d'])
+                    head_hash = btools.get_command_output(['git', 'rev-parse', 'HEAD']).strip()
+                    tag_hashes = btools.get_command_output(['git', 'show-ref', '--tags', '-d'])
                     if tag_hashes.find(head_hash) != -1:
                         build_branch = 'master'
 
             if build_hash == '':
-                build_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).strip()
+                build_hash = btools.get_command_output(['git', 'rev-parse', '--short', 'HEAD']).strip()
                 no_upstream = True
             else:
-                older_commits = subprocess.check_output(['git', 'log', '--oneline', 'HEAD..@{u}']).strip()
+                older_commits = btools.get_command_output(['git', 'log', '--oneline', 'HEAD..@{u}']).strip()
                 if older_commits:
-                    build_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).strip()
+                    build_hash = btools.get_command_output(['git', 'rev-parse', '--short', 'HEAD']).strip()
 
             # ## Check for local modifications
             has_local_changes = False
 
             # Update GIT index before getting dirty files
             os.system('git update-index -q --refresh')
-            changed_files = subprocess.check_output(['git', 'diff-index', '--name-only', 'HEAD', '--']).strip()
+            changed_files = btools.get_command_output(['git', 'diff-index', '--name-only', 'HEAD', '--']).strip()
 
             if changed_files:
                 has_local_changes = True
             elif no_upstream == False:
-                unpushed_log = subprocess.check_output(['git', 'log', '--oneline', '@{u}..']).strip()
+                unpushed_log = btools.get_command_output(['git', 'log', '--oneline', '@{u}..']).strip()
                 has_local_changes = unpushed_log != ''
 
             if build_branch.startswith('blender-v'):
diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py
index d22adfd..83daef7 100644
--- a/build_files/scons/tools/btools.py
+++ b/build_files/scons/tools/btools.py
@@ -14,6 +14,21 @@ import sys
 Variables = SCons.Variables
 BoolVariable = SCons.Variables.BoolVariable
 
+def get_command_output(*popenargs, **kwargs):
+    if hasattr(subprocess, "check_output"):
+        return subprocess.check_output(*popenargs, **kwargs)
+    if 'stdout' in kwargs:
+        raise ValueError('stdout argument not allowed, it will be overridden.')
+    process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
+    output, unused_err = process.communicate()
+    retcode = process.poll()
+    if retcode:
+        cmd = kwargs.get("args")
+        if cmd is None:
+            cmd = popenargs[0]
+        raise
+    return output
+
 def get_version():
     import re
 
@@ -57,7 +72,7 @@ def get_version():
 
 def get_hash():
     try:
-        build_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).strip()
+        build_hash = get_command_output(['git', 'rev-parse', '--short', 'HEAD']).strip()
     except OSError:
         build_hash = None
         print("WARNING: could not use git to retrieve current Blender repository hash...")
diff --git a/intern/cycles/kernel/SConscript b/intern/cycles/kernel/SConscript
index bceab7e..cfe12e8 100644
--- a/intern/cycles/kernel/SConscript
+++ b/intern/cycles/kernel/SConscript
@@ -30,6 +30,7 @@ import subprocess
 import sys
 import os
 import Blender as B
+import btools
 
 def normpath(path):
     return os.path.abspath(os.path.normpath(path))
@@ -64,7 +65,7 @@ if env['WITH_BF_CYCLES_CUDA_BINARIES']:
     closure_dir = os.path.join(source_dir, "../closure")
 
     # get CUDA version
-    output = subprocess.check_output([nvcc, "--version"])
+    output = btools.get_command_output([nvcc, "--version"])
     cuda_major_minor = re.findall(r'release (\d+).(\d+)', output)[0]
     cuda_version = int(cuda_major_minor[0])*10 + int(cuda_major_minor[1])




More information about the Bf-blender-cvs mailing list