[Bf-blender-cvs] [c5c542089c7] temp-lineart-contained: Cleanup: make_source_archive.py minor changes & comments

Campbell Barton noreply at git.blender.org
Sat Mar 13 02:00:59 CET 2021


Commit: c5c542089c70631b446e00e13ee9b951555423a5
Author: Campbell Barton
Date:   Fri Mar 12 13:39:08 2021 +1100
Branches: temp-lineart-contained
https://developer.blender.org/rBc5c542089c70631b446e00e13ee9b951555423a5

Cleanup: make_source_archive.py minor changes & comments

- Add notes on portability.
- Use encoding argument for all file IO.
- Use integer math to calculate major/minor version, while float
  division should be fine prefer matching Blender.

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

M	build_files/utils/make_source_archive.py

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

diff --git a/build_files/utils/make_source_archive.py b/build_files/utils/make_source_archive.py
index 24928742a2d..271ca358f7e 100755
--- a/build_files/utils/make_source_archive.py
+++ b/build_files/utils/make_source_archive.py
@@ -9,6 +9,10 @@ from typing import Iterable, TextIO
 
 # This script can run from any location,
 # output is created in the $CWD
+#
+# NOTE: while the Python part of this script is portable,
+# it relies on external commands typically found on GNU/Linux.
+# Support for other platforms could be added by moving GNU `tar` & `md5sum` use to Python.
 
 SKIP_NAMES = {
     ".gitignore",
@@ -52,8 +56,9 @@ class BlenderVersion:
         >>> str(BlenderVersion(327, 0, "release"))
         '3.27.0'
         """
-
-        as_string = f"{self.version/100:.2f}.{self.patch}"
+        version_major = self.version // 100
+        version_minor = self.version % 100
+        as_string = f"{version_major}.{version_minor}.{self.patch}"
         if self.is_release:
             return as_string
         return f"{as_string}-{self.cycle}"
@@ -101,6 +106,7 @@ def submodules_to_manifest(version: BlenderVersion, outfile: TextIO) -> None:
     for line in git_command("submodule"):
         submodule = line.split()[1]
 
+        # Don't use native slashes as GIT for MS-Windows outputs forward slashes.
         if skip_addon_contrib and submodule == "release/scripts/addons_contrib":
             continue
 
@@ -110,6 +116,7 @@ def submodules_to_manifest(version: BlenderVersion, outfile: TextIO) -> None:
 
 def create_tarball(version: BlenderVersion, tarball: Path, manifest: Path) -> None:
     print(f'Creating archive:            "{tarball}" ...', end="", flush=True)
+    # Requires GNU `tar`, since `--transform` is used.
     command = [
         "tar",
         "--transform",
@@ -139,7 +146,7 @@ def create_checksum_file(tarball: Path) -> None:
     md5_cmd = subprocess.run(
         command, stdout=subprocess.PIPE, check=True, text=True, timeout=300
     )
-    with md5_path.open("w") as outfile:
+    with md5_path.open("w", encoding="utf-8") as outfile:
         outfile.write(md5_cmd.stdout)
     print("OK")



More information about the Bf-blender-cvs mailing list