From cb5ed2e5f458190cbea2ba41d00f7fe001ab00a7 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 19 Sep 2019 15:54:13 +0200 Subject: Manpage gen script: fix for python < 3.7, and missing Blender build info. Python3.7 is still fairly recent, not all distro use it as system python yet, fallback to code compatible up to py3.5. Also, often distro builds of Blender do not have the buildinfo, in that case fallback to `SOURCE_DATE_EPOCH` envvar, and as last resort to current time, as in orig patch D5756 (we still use blender builddate when available). Issues raised in recent own rBcd5c70630318. --- doc/manpage/blender.1.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/manpage/blender.1.py b/doc/manpage/blender.1.py index 113429cbcb4..fc2200ab859 100755 --- a/doc/manpage/blender.1.py +++ b/doc/manpage/blender.1.py @@ -30,6 +30,7 @@ and is where to write the generated man page. # +import os import subprocess import sys @@ -52,13 +53,17 @@ outfilename = sys.argv[2] cmd = [blender_bin, "--help"] print(" executing:", " ".join(cmd)) blender_help = subprocess.run( - cmd, env={"ASAN_OPTIONS": "exitcode=0"}, check=True, capture_output=True).stdout.decode(encoding="utf-8") + cmd, env={"ASAN_OPTIONS": "exitcode=0"}, check=True, stdout=subprocess.PIPE).stdout.decode(encoding="utf-8") blender_version = subprocess.run( - [blender_bin, "--version"], env={"ASAN_OPTIONS": "exitcode=0"}, check=True, capture_output=True).stdout.decode(encoding="utf-8").strip() -blender_version, blender_date = blender_version.split("build")[0:2] + [blender_bin, "--version"], env={"ASAN_OPTIONS": "exitcode=0"}, check=True, stdout=subprocess.PIPE).stdout.decode(encoding="utf-8").strip() +blender_version, blender_date = (blender_version.split("build") + [None, None])[0:2] blender_version = blender_version.rstrip().partition(" ")[2] # remove 'Blender' prefix. -blender_date = blender_date.strip().partition(" ")[2] # remove 'date:' prefix -date_string = time.strftime("%B %d, %Y", time.strptime(blender_date, "%Y-%m-%d")) +if blender_date is None: + # Happens when built without WITH_BUILD_INFO e.g. + date_string = time.strftime("%B %d, %Y", time.gmtime(int(os.environ.get('SOURCE_DATE_EPOCH', time.time())))) +else: + blender_date = blender_date.strip().partition(" ")[2] # remove 'date:' prefix + date_string = time.strftime("%B %d, %Y", time.strptime(blender_date, "%Y-%m-%d")) outfile = open(outfilename, "w") fw = outfile.write -- cgit v1.2.3