[Bf-blender-cvs] [cb5ed2e5f45] master: Manpage gen script: fix for python < 3.7, and missing Blender build info.

Bastien Montagne noreply at git.blender.org
Thu Sep 19 15:57:47 CEST 2019


Commit: cb5ed2e5f458190cbea2ba41d00f7fe001ab00a7
Author: Bastien Montagne
Date:   Thu Sep 19 15:54:13 2019 +0200
Branches: master
https://developer.blender.org/rBcb5ed2e5f458190cbea2ba41d00f7fe001ab00a7

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.

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

M	doc/manpage/blender.1.py

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

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 <output-filename> is where to write the generated man page.
 
 # <pep8 compliant>
 
+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



More information about the Bf-blender-cvs mailing list