Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-03-12 05:39:08 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-03-12 08:13:36 +0300
commit2e9fb211c6c8d69b2dc68c05b90a07c6eb9cc37d (patch)
treea4da286473594d2d4622a14793080c7833d42f29
parent7f4530dad2ef5f9370f5c36261387be0127f02f6 (diff)
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.
-rwxr-xr-xbuild_files/utils/make_source_archive.py13
1 files changed, 10 insertions, 3 deletions
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")