diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-06-26 14:03:52 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-06-26 14:03:52 +0400 |
commit | 283abdf3b2de08c9e5be764a02e89120fe7b67da (patch) | |
tree | 55e438859ab4c2f53a09be09c35013d832253f56 | |
parent | 0503dc3d021bbb98a0b3a5fa9878f0a0436adcee (diff) |
Fix compilation error with scons and older pythons
-rw-r--r-- | SConstruct | 2 | ||||
-rw-r--r-- | build_files/scons/tools/Blender.py | 22 | ||||
-rw-r--r-- | build_files/scons/tools/btools.py | 17 | ||||
-rw-r--r-- | intern/cycles/kernel/SConscript | 3 |
4 files changed, 30 insertions, 14 deletions
diff --git a/SConstruct b/SConstruct index f27ba1754c1..0c85fe11cdc 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 72eafcdd681..e0f18480c74 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 d22adfda5f6..83daef7c00b 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 bceab7e2b0f..cfe12e8533d 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]) |