Fix compilation error with scons and older pythons

This commit is contained in:
Sergey Sharybin
2014-06-26 16:03:52 +06:00
parent 0503dc3d02
commit 283abdf3b2
4 changed files with 30 additions and 14 deletions

View File

@@ -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')

View File

@@ -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'):

View File

@@ -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...")

View File

@@ -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])