Formatting and linting fixes

This commit is contained in:
Bart van der Braak 2024-11-19 21:59:53 +01:00
parent 0a1454d250
commit d6bce1b39d
32 changed files with 675 additions and 268 deletions

View file

@ -9,9 +9,6 @@ import pathlib
import re
import subprocess
from collections import OrderedDict
from typing import Callable, Any
import worker.utils
@ -32,7 +29,9 @@ class CodeBuilder(worker.utils.Builder):
self.architecture = args.architecture
if self.platform == "darwin":
self.build_dir = track_path / f"build_{self.architecture}_{self.build_configuration}"
self.build_dir = (
track_path / f"build_{self.architecture}_{self.build_configuration}"
)
else:
self.build_dir = track_path / f"build_{self.build_configuration}"
@ -47,7 +46,9 @@ class CodeBuilder(worker.utils.Builder):
worker.utils.remove_dir(self.build_doc_path)
# Call command with in compiler environment.
def call(self, cmd: worker.utils.CmdSequence, env: worker.utils.CmdEnvironment = None) -> int:
def call(
self, cmd: worker.utils.CmdSequence, env: worker.utils.CmdEnvironment = None
) -> int:
cmd_prefix: worker.utils.CmdList = []
if self.platform == "darwin":
@ -57,11 +58,16 @@ class CodeBuilder(worker.utils.Builder):
xcode_version = xcode.get("version", None) if xcode else None
if xcode_version:
developer_dir = f"/Applications/Xcode-{xcode_version}.app/Contents/Developer"
developer_dir = (
f"/Applications/Xcode-{xcode_version}.app/Contents/Developer"
)
else:
developer_dir = "/Applications/Xcode.app/Contents/Developer"
if self.service_env_id == "LOCAL" and not pathlib.Path(developer_dir).exists():
if (
self.service_env_id == "LOCAL"
and not pathlib.Path(developer_dir).exists()
):
worker.utils.warning(
f"Skip using non-existent {developer_dir} in LOCAL service environment"
)
@ -84,7 +90,9 @@ class CodeBuilder(worker.utils.Builder):
return worker.utils.call(cmd_prefix + list(cmd), env=env)
def pipeline_config(self) -> dict:
config_file_path = self.code_path / "build_files" / "config" / "pipeline_config.json"
config_file_path = (
self.code_path / "build_files" / "config" / "pipeline_config.json"
)
if not config_file_path.exists():
config_file_path = config_file_path.with_suffix(".yaml")
if not config_file_path.exists():
@ -116,7 +124,9 @@ class CodeBuilder(worker.utils.Builder):
# CMake goes first to avoid using chocolaty cpack command.
worker.utils.info("Setting CMake path")
os.environ["PATH"] = "C:\\Program Files\\CMake\\bin" + os.pathsep + os.environ["PATH"]
os.environ["PATH"] = (
"C:\\Program Files\\CMake\\bin" + os.pathsep + os.environ["PATH"]
)
worker.utils.info("Setting VC Tools env variables")
windows_build_version = "10.0.19041.0"
@ -126,7 +136,9 @@ class CodeBuilder(worker.utils.Builder):
+ os.environ["PATH"]
)
os.environ["PATH"] = (
"C:\\Program Files (x86)\\WiX Toolset v3.11\\bin" + os.pathsep + os.environ["PATH"]
"C:\\Program Files (x86)\\WiX Toolset v3.11\\bin"
+ os.pathsep
+ os.environ["PATH"]
)
if self.architecture == "arm64":
@ -140,7 +152,9 @@ class CodeBuilder(worker.utils.Builder):
)
vs_tool_install_dir_suffix = "\\bin\\Hostx64\\x64"
vcvars_output = subprocess.check_output([vs_build_tool_path, "&&", "set"], shell=True)
vcvars_output = subprocess.check_output(
[vs_build_tool_path, "&&", "set"], shell=True
)
vcvars_text = vcvars_output.decode("utf-8", "ignore")
for line in vcvars_text.splitlines():

View file

@ -14,7 +14,6 @@ import worker.blender
import worker.utils
def create_upload(
builder: worker.blender.CodeBuilder, benchmark_path: pathlib.Path, revision: str
) -> None:

View file

@ -95,7 +95,9 @@ def estimate_dmg_size(app_bundles: typing.List[pathlib.Path]) -> int:
return app_bundles_size + _extra_dmg_size_in_bytes
def copy_app_bundles(app_bundles: typing.List[pathlib.Path], dir_path: pathlib.Path) -> None:
def copy_app_bundles(
app_bundles: typing.List[pathlib.Path], dir_path: pathlib.Path
) -> None:
"""
Copy all bundles to a given directory
@ -122,7 +124,9 @@ def get_main_app_bundle(app_bundles: typing.List[pathlib.Path]) -> pathlib.Path:
def create_dmg_image(
app_bundles: typing.List[pathlib.Path], dmg_file_path: pathlib.Path, volume_name: str
app_bundles: typing.List[pathlib.Path],
dmg_file_path: pathlib.Path,
volume_name: str,
) -> None:
"""
Create DMG disk image and put app bundles in it
@ -134,7 +138,9 @@ def create_dmg_image(
worker.utils.remove_file(dmg_file_path)
temp_content_path = tempfile.TemporaryDirectory(prefix="blender-dmg-content-")
worker.utils.info(f"Preparing directory with app bundles for the DMG [{temp_content_path}]")
worker.utils.info(
f"Preparing directory with app bundles for the DMG [{temp_content_path}]"
)
with temp_content_path as content_dir_str:
# Copy all bundles to a clean directory.
content_dir_path = pathlib.Path(content_dir_str)
@ -236,13 +242,17 @@ def eject_volume(volume_name: str) -> None:
if tokens[1] != "on":
continue
if device:
raise Exception(f"Multiple devices found for mounting point [{mount_directory}]")
raise Exception(
f"Multiple devices found for mounting point [{mount_directory}]"
)
device = tokens[0]
if not device:
raise Exception(f"No device found for mounting point [{mount_directory}]")
worker.utils.info(f"[{mount_directory}] is mounted as device [{device}], ejecting...")
worker.utils.info(
f"[{mount_directory}] is mounted as device [{device}], ejecting..."
)
command = ["diskutil", "eject", device]
worker.utils.call(command)
@ -297,7 +307,9 @@ def run_applescript_file_path(
needs_run_applescript = True
if not needs_run_applescript:
worker.utils.info(f"Having issues with apple script on [{architecture}], skipping !")
worker.utils.info(
f"Having issues with apple script on [{architecture}], skipping !"
)
return
temp_script_file_path = tempfile.NamedTemporaryFile(mode="w", suffix=".applescript")
@ -316,8 +328,12 @@ def run_applescript_file_path(
if not background_image_file_path:
continue
else:
background_image_short = f".background:{background_image_file_path.name}"
line = re.sub('to file ".*"', f'to file "{background_image_short}"', line)
background_image_short = (
f".background:{background_image_file_path.name}"
)
line = re.sub(
'to file ".*"', f'to file "{background_image_short}"', line
)
line = line.replace("blender.app", main_app_bundle.name)
stripped_line = line.rstrip("\r\n")
worker.utils.info(f"line={stripped_line}")
@ -343,7 +359,9 @@ def run_applescript_file_path(
time.sleep(5)
def compress_dmg(writable_dmg_file_path: pathlib.Path, final_dmg_file_path: pathlib.Path) -> None:
def compress_dmg(
writable_dmg_file_path: pathlib.Path, final_dmg_file_path: pathlib.Path
) -> None:
"""
Compress temporary read-write DMG
"""
@ -469,5 +487,9 @@ def bundle(
worker.utils.info(f"Will produce DMG [{dmg_file_path.name}]")
create_final_dmg(
app_bundles, dmg_file_path, background_image_file_path, volume_name, applescript_file_path
app_bundles,
dmg_file_path,
background_image_file_path,
volume_name,
applescript_file_path,
)

View file

@ -41,15 +41,21 @@ def fetch_ideal_cpu_count(estimate_core_memory_in_mb: int) -> int:
worker.utils.info(f"usable_memory_in_bytes={usable_memory_in_bytes}")
estimate_memory_per_code_in_bytes = estimate_core_memory_in_mb * 1024 * 1024
worker.utils.info(f"estimate_memory_per_code_in_bytes={estimate_memory_per_code_in_bytes}")
worker.utils.info(
f"estimate_memory_per_code_in_bytes={estimate_memory_per_code_in_bytes}"
)
capable_cpu_count = int(total_memory_in_bytes / estimate_memory_per_code_in_bytes)
capable_cpu_count = int(
total_memory_in_bytes / estimate_memory_per_code_in_bytes
)
worker.utils.info(f"capable_cpu_count={capable_cpu_count}")
min_cpu_count = min(total_cpu_count, capable_cpu_count)
worker.utils.info(f"min_cpu_count={min_cpu_count}")
ideal_cpu_count = min_cpu_count if min_cpu_count <= 8 else min_cpu_count - spare_cpu_count
ideal_cpu_count = (
min_cpu_count if min_cpu_count <= 8 else min_cpu_count - spare_cpu_count
)
worker.utils.info(f"ideal_cpu_count={ideal_cpu_count}")
return ideal_cpu_count
@ -88,9 +94,13 @@ def get_cmake_options(builder: worker.blender.CodeBuilder) -> worker.utils.CmdSe
platform_config_file_path = "build_files/buildbot/config/blender_windows.cmake"
if platform_config_file_path:
worker.utils.info(f'Trying platform-specific buildbot configuration "{platform_config_file_path}"')
worker.utils.info(
f'Trying platform-specific buildbot configuration "{platform_config_file_path}"'
)
if (Path(builder.blender_dir) / platform_config_file_path).exists():
worker.utils.info(f'Using platform-specific buildbot configuration "{platform_config_file_path}"')
worker.utils.info(
f'Using platform-specific buildbot configuration "{platform_config_file_path}"'
)
config_file_path = platform_config_file_path
else:
worker.utils.info(f'Using generic buildbot configuration "{config_file_path}"')
@ -145,13 +155,17 @@ def get_cmake_options(builder: worker.blender.CodeBuilder) -> worker.utils.CmdSe
vc_tool_install_path = pathlib.PureWindowsPath(vc_tools_install_dir)
if builder.architecture == "arm64":
compiler_file_path="C:/Program Files/LLVM/bin/clang-cl.exe"
compiler_file_path="C:/Program Files/LLVM/bin/clang-cl.exe"
linker_file_path="C:/Program Files/LLVM/bin/lld-link.exe"
compiler_file_path = "C:/Program Files/LLVM/bin/clang-cl.exe"
compiler_file_path = "C:/Program Files/LLVM/bin/clang-cl.exe"
linker_file_path = "C:/Program Files/LLVM/bin/lld-link.exe"
else:
vs_tool_install_dir_suffix = "bin/Hostx64/x64"
compiler_file_path = str(vc_tool_install_path / f"{vs_tool_install_dir_suffix}/cl.exe")
linker_file_path = str(vc_tool_install_path / f"{vs_tool_install_dir_suffix}/link.exe")
compiler_file_path = str(
vc_tool_install_path / f"{vs_tool_install_dir_suffix}/cl.exe"
)
linker_file_path = str(
vc_tool_install_path / f"{vs_tool_install_dir_suffix}/link.exe"
)
options += ["-G", "Ninja"]
# -DWITH_WINDOWS_SCCACHE=On
@ -194,7 +208,9 @@ def get_cmake_options(builder: worker.blender.CodeBuilder) -> worker.utils.CmdSe
for cmake_key in cmake_overrides.keys():
for restricted_key_pattern in restricted_key_patterns:
if restricted_key_pattern in cmake_key:
raise Exception(f"CMake key [{cmake_key}] cannot be overriden, aborting")
raise Exception(
f"CMake key [{cmake_key}] cannot be overriden, aborting"
)
for cmake_key, cmake_value in cmake_overrides.items():
options += [f"-D{cmake_key}={cmake_value}"]
@ -238,7 +254,9 @@ def get_cmake_options(builder: worker.blender.CodeBuilder) -> worker.utils.CmdSe
ocloc_version = "dev_01"
options += [f"-DHIP_ROOT_DIR=C:/ProgramData/AMD/HIP/hip_sdk_{hip_version}"]
options += ["-DHIP_PERL_DIR=C:/ProgramData/AMD/HIP/strawberry/perl/bin"]
options += [f"-DOCLOC_INSTALL_DIR=C:/ProgramData/Intel/ocloc/ocloc_{ocloc_version}"]
options += [
f"-DOCLOC_INSTALL_DIR=C:/ProgramData/Intel/ocloc/ocloc_{ocloc_version}"
]
elif builder.platform == "linux":
# CUDA on Linux
options += [f"-DWITH_CYCLES_CUDA_BINARIES={with_gpu_binaries_state}"]
@ -300,22 +318,20 @@ def get_cmake_options(builder: worker.blender.CodeBuilder) -> worker.utils.CmdSe
options += [
f"-DHIPRT_ROOT_DIR:PATH={hiprt_base_dir}/hiprtsdk-{hiprt_version}/hiprt{hiprt_version}"
]
# Enable option to verify enabled libraries and features did not get disabled.
options += ["-DWITH_STRICT_BUILD_OPTIONS=ON"]
needs_cuda_compile = builder.needs_gpu_binaries
if builder.needs_gpu_binaries:
try:
cuda10_version = buildbotConfig["cuda10"]["version"]
except:
except KeyError:
cuda10_version = buildbotConfig["sdks"]["cuda10"]["version"]
cuda10_folder_version = ".".join(cuda10_version.split(".")[:2])
try:
cuda11_version = buildbotConfig["cuda11"]["version"]
except:
except KeyError:
cuda11_version = buildbotConfig["sdks"]["cuda11"]["version"]
cuda11_folder_version = ".".join(cuda11_version.split(".")[:2])
@ -324,7 +340,7 @@ def get_cmake_options(builder: worker.blender.CodeBuilder) -> worker.utils.CmdSe
cuda12_version = buildbotConfig["cuda12"]["version"]
cuda12_folder_version = ".".join(cuda12_version.split(".")[:2])
have_cuda12 = True
except:
except KeyError:
have_cuda12 = False
if builder.platform == "windows" and builder.architecture != "arm64":
@ -408,7 +424,9 @@ def get_cmake_options(builder: worker.blender.CodeBuilder) -> worker.utils.CmdSe
else:
# Use new CMake option.
options += [f"-DCUDA10_NVCC_EXECUTABLE:STRING={cuda10_file_path}"]
options += ["-DCUDA_HOST_COMPILER=/opt/rh/devtoolset-8/root/usr/bin/gcc"]
options += [
"-DCUDA_HOST_COMPILER=/opt/rh/devtoolset-8/root/usr/bin/gcc"
]
# CUDA 11 or 12.
if have_cuda12:
@ -428,7 +446,9 @@ def get_cmake_options(builder: worker.blender.CodeBuilder) -> worker.utils.CmdSe
def clean_directories(builder: worker.blender.CodeBuilder) -> None:
worker.utils.info(f"Cleaning directory [{builder.install_dir})] from the previous run")
worker.utils.info(
f"Cleaning directory [{builder.install_dir})] from the previous run"
)
worker.utils.remove_dir(builder.install_dir)
os.makedirs(builder.build_dir, exist_ok=True)
@ -452,7 +472,9 @@ def cmake_configure(builder: worker.blender.CodeBuilder) -> None:
worker.utils.info("CMake configure options")
cmake_options = get_cmake_options(builder)
cmd = ["cmake", "-S", builder.blender_dir, "-B", builder.build_dir] + list(cmake_options)
cmd = ["cmake", "-S", builder.blender_dir, "-B", builder.build_dir] + list(
cmake_options
)
builder.call(cmd)
# This hack does not work as expected, since cmake cache is the always updated, we end up recompiling on each compile step, code, gpu and install
@ -465,7 +487,10 @@ def cmake_configure(builder: worker.blender.CodeBuilder) -> None:
fout = open(tmp_cmake_cache_file_path, "wt")
for line in fin:
# worker.utils.info(line)
if "OpenMP_pthread_LIBRARY:FILEPATH=OpenMP_pthread_LIBRARY-NOTFOUND" in line:
if (
"OpenMP_pthread_LIBRARY:FILEPATH=OpenMP_pthread_LIBRARY-NOTFOUND"
in line
):
worker.utils.warning(
"Replacing [OpenMP_pthread_LIBRARY-NOTFOUND] to [/usr/lib64/libpthread.a]"
)
@ -489,7 +514,9 @@ def cmake_build(builder: worker.blender.CodeBuilder, do_install: bool) -> None:
else:
estimate_gpu_memory_in_mb = 6000
estimate_core_memory_in_mb = estimate_gpu_memory_in_mb if builder.needs_gpu_binaries else 1000
estimate_core_memory_in_mb = (
estimate_gpu_memory_in_mb if builder.needs_gpu_binaries else 1000
)
ideal_cpu_count = fetch_ideal_cpu_count(estimate_core_memory_in_mb)
# Enable verbose building to make ninja to output more often.

View file

@ -21,7 +21,7 @@ def make_format(builder: worker.blender.CodeBuilder) -> bool:
# Run format
if builder.platform == "windows":
builder.call(["make.bat", "format"])
else:
else:
builder.call(["make", "-f", "GNUmakefile", "format"])
# Check for changes

View file

@ -82,7 +82,10 @@ def create_tar_xz(src: pathlib.Path, dest: pathlib.Path, package_name: str) -> N
for root, dirs, files in os.walk(src):
package_root = os.path.join(package_name, root[ln:])
flist.extend(
[(os.path.join(root, file), os.path.join(package_root, file)) for file in files]
[
(os.path.join(root, file), os.path.join(package_root, file))
for file in files
]
)
# Set UID/GID of archived files to 0, otherwise they'd be owned by whatever
@ -112,7 +115,7 @@ def cleanup_files(dirpath: pathlib.Path, extension: str) -> None:
def pack_mac(builder: worker.blender.CodeBuilder) -> None:
version_info = worker.blender.version.VersionInfo(builder)
worker.blender.version.VersionInfo(builder)
os.chdir(builder.build_dir)
cleanup_files(builder.package_dir, ".dmg")
@ -121,15 +124,24 @@ def pack_mac(builder: worker.blender.CodeBuilder) -> None:
package_file_name = package_name + ".dmg"
package_file_path = builder.package_dir / package_file_name
applescript_file_path = pathlib.Path(__file__).parent.resolve() / "blender.applescript"
background_image_file_path = builder.blender_dir / "release" / "darwin" / "background.tif"
applescript_file_path = (
pathlib.Path(__file__).parent.resolve() / "blender.applescript"
)
background_image_file_path = (
builder.blender_dir / "release" / "darwin" / "background.tif"
)
worker.blender.bundle_dmg.bundle(
builder.install_dir, package_file_path, applescript_file_path, background_image_file_path
builder.install_dir,
package_file_path,
applescript_file_path,
background_image_file_path,
)
# Sign
worker.blender.sign.sign_darwin_files(builder, [package_file_path], "entitlements.plist")
worker.blender.sign.sign_darwin_files(
builder, [package_file_path], "entitlements.plist"
)
# Notarize
worker_config = builder.get_worker_config()
@ -169,7 +181,14 @@ def pack_mac(builder: worker.blender.CodeBuilder) -> None:
# Show logs
worker.utils.call(
["xcrun", "notarytool", "log", "--keychain-profile", keychain_profile, request_id],
[
"xcrun",
"notarytool",
"log",
"--keychain-profile",
keychain_profile,
request_id,
],
retry_count=5,
retry_wait_time=10.0,
)
@ -262,14 +281,17 @@ def pack_win(builder: worker.blender.CodeBuilder, pack_format: str) -> None:
/ "ZIP"
/ f"{final_package_file_name}"
)
worker.utils.info(f"Moving [{source_cpack_file_path}] to [{final_package_file_path}]")
worker.utils.info(
f"Moving [{source_cpack_file_path}] to [{final_package_file_path}]"
)
os.rename(source_cpack_file_path, final_package_file_path)
else:
os.rename(bogus_cpack_file_path, final_package_file_path)
version_info = worker.blender.version.VersionInfo(builder)
description = f"Blender {version_info.version}"
worker.blender.sign.sign_windows_files(builder.service_env_id, [final_package_file_path],
description=description)
worker.blender.sign.sign_windows_files(
builder.service_env_id, [final_package_file_path], description=description
)
generate_file_hash(final_package_file_path)
@ -289,9 +311,13 @@ def pack_linux(builder: worker.blender.CodeBuilder) -> None:
py_target = builder.install_dir / version_info.short_version
if not os.path.exists(py_target):
# Support older format and current issue with 3.00
py_target = builder.install_dir / ("%d.%02d" % (version_info.major, version_info.minor))
py_target = builder.install_dir / (
"%d.%02d" % (version_info.major, version_info.minor)
)
worker.utils.call(["find", py_target, "-iname", "*.so", "-exec", "strip", "-s", "{}", ";"])
worker.utils.call(
["find", py_target, "-iname", "*.so", "-exec", "strip", "-s", "{}", ";"]
)
package_name = get_package_name(builder)
package_file_name = f"{package_name}.tar.xz"

View file

@ -22,7 +22,7 @@ def sign_windows_files(
worker_config = conf.worker.get_config(service_env_id)
# TODO: Rotate them if first 1 fails
timeserver = worker_config.sign_code_windows_time_servers[0]
worker_config.sign_code_windows_time_servers[0]
server_url = worker_config.sign_code_windows_server_url
if not certificate_id:
certificate_id = worker_config.sign_code_windows_certificate
@ -50,7 +50,9 @@ def sign_windows_files(
for i in range(0, len(file_paths), chunk_size):
file_chunks = file_paths[i : i + chunk_size]
worker.utils.call(list(cmd) + list(file_chunks), retry_count=retry_count, dry_run=dry_run)
worker.utils.call(
list(cmd) + list(file_chunks), retry_count=retry_count, dry_run=dry_run
)
def sign_windows(service_env_id: str, install_path: pathlib.Path) -> None:
@ -97,9 +99,11 @@ def sign_windows(service_env_id: str, install_path: pathlib.Path) -> None:
def sign_darwin_files(
builder: worker.blender.CodeBuilder,
file_paths: Sequence[pathlib.Path],
entitlements_file_name: str
entitlements_file_name: str,
) -> None:
entitlements_path = builder.code_path / "release" / "darwin" / entitlements_file_name
entitlements_path = (
builder.code_path / "release" / "darwin" / entitlements_file_name
)
if not entitlements_path.exists():
raise Exception(f"File {entitlements_path} not found, aborting")
@ -128,7 +132,9 @@ def sign_darwin_files(
# Remove signature
if file_path.suffix != ".dmg":
worker.utils.call(
["codesign", "--remove-signature", file_path], exit_on_error=False, dry_run=dry_run
["codesign", "--remove-signature", file_path],
exit_on_error=False,
dry_run=dry_run,
)
# Add signature
@ -163,11 +169,15 @@ def sign_darwin(builder: worker.blender.CodeBuilder) -> None:
sign_darwin_files(builder, list(sign_path.rglob("*")), "entitlements.plist")
# Thumbnailer app extension.
thumbnailer_appex_path = bundle_path / "Contents" / "PlugIns" / "blender-thumbnailer.appex"
thumbnailer_appex_path = (
bundle_path / "Contents" / "PlugIns" / "blender-thumbnailer.appex"
)
if thumbnailer_appex_path.exists():
sign_path = thumbnailer_appex_path / "Contents" / "MacOS"
worker.utils.info(f"Collecting files to process in {sign_path}")
sign_darwin_files(builder, list(sign_path.rglob("*")), "thumbnailer_entitlements.plist")
sign_darwin_files(
builder, list(sign_path.rglob("*")), "thumbnailer_entitlements.plist"
)
# Shared librarys and Python
sign_path = bundle_path / "Contents" / "Resources"

View file

@ -36,7 +36,9 @@ def package_for_upload(builder: worker.blender.CodeBuilder, success: bool) -> No
package_filename = "tests-" + worker.blender.pack.get_package_name(builder)
package_filepath = package_tests_dir / package_filename
shutil.copytree(build_tests_dir, package_filepath)
shutil.make_archive(str(package_filepath), "zip", package_tests_dir, package_filename)
shutil.make_archive(
str(package_filepath), "zip", package_tests_dir, package_filename
)
shutil.rmtree(package_filepath)
# Always upload unpacked folder for main and release tracks,

View file

@ -32,8 +32,12 @@ def update(builder: worker.blender.CodeBuilder) -> None:
make_update_text = make_update_path.read_text()
if "def svn_update" in make_update_text:
worker.utils.error("Can't build branch or pull request that uses Subversion libraries.")
worker.utils.error("Merge with latest main or release branch to use Git LFS libraries.")
worker.utils.error(
"Can't build branch or pull request that uses Subversion libraries."
)
worker.utils.error(
"Merge with latest main or release branch to use Git LFS libraries."
)
sys.exit(1)
# Run make update

View file

@ -14,12 +14,18 @@ class VersionInfo:
# Get version information
buildinfo_h = builder.build_dir / "source" / "creator" / "buildinfo.h"
blender_h = (
builder.blender_dir / "source" / "blender" / "blenkernel" / "BKE_blender_version.h"
builder.blender_dir
/ "source"
/ "blender"
/ "blenkernel"
/ "BKE_blender_version.h"
)
version_number = int(self._parse_header_file(blender_h, "BLENDER_VERSION"))
version_number_patch = int(self._parse_header_file(blender_h, "BLENDER_VERSION_PATCH"))
version_number_patch = int(
self._parse_header_file(blender_h, "BLENDER_VERSION_PATCH")
)
self.major, self.minor, self.patch = (
version_number // 100,
version_number % 100,
@ -38,14 +44,16 @@ class VersionInfo:
self.hash = self._parse_header_file(buildinfo_h, "BUILD_HASH")[1:-1]
else:
self.hash = ""
self.risk_id = self.version_cycle.replace("release", "stable").replace("rc", "candidate")
self.risk_id = self.version_cycle.replace("release", "stable").replace(
"rc", "candidate"
)
self.is_development_build = self.version_cycle == "alpha"
def _parse_header_file(self, filename: pathlib.Path, define: str) -> str:
regex = re.compile(r"^#\s*define\s+%s\s+(.*)" % define)
with open(filename, "r") as file:
for l in file:
match = regex.match(l)
for line in file:
match = regex.match(line)
if match:
return match.group(1)