Bump version to 0.12.15 in project and blender manifest files; add Apple Silicon support in properties.py
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
schema_version = "1.0.0"
|
||||
|
||||
id = "snapform"
|
||||
version = "0.12.14"
|
||||
version = "0.12.15"
|
||||
name = "SnapForm"
|
||||
tagline = "Build spatial structures from images, fast"
|
||||
maintainer = "OmooLab"
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import functools
|
||||
import platform
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import bpy
|
||||
@@ -21,18 +24,50 @@ DEVICE_LABELS = {
|
||||
}
|
||||
|
||||
|
||||
def supported_devices():
|
||||
devices = runtime.environment_manifest().get("devices")
|
||||
if isinstance(devices, list) and devices:
|
||||
return [str(device).lower() for device in devices]
|
||||
if sys.platform == "win32":
|
||||
return ["directml", "cpu"]
|
||||
if sys.platform == "darwin" and platform.machine().lower() in {
|
||||
APPLE_SILICON_PATTERN = re.compile(r"\bApple M(\d+)\b", re.IGNORECASE)
|
||||
|
||||
|
||||
def parse_apple_silicon_generation(brand):
|
||||
match = APPLE_SILICON_PATTERN.search(str(brand))
|
||||
return int(match.group(1)) if match else None
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=1)
|
||||
def apple_silicon_generation():
|
||||
if sys.platform != "darwin" or platform.machine().lower() not in {
|
||||
"arm64",
|
||||
"aarch64",
|
||||
}:
|
||||
return ["mps", "cpu"]
|
||||
return ["cpu"]
|
||||
return None
|
||||
try:
|
||||
result = subprocess.run(
|
||||
("sysctl", "-n", "machdep.cpu.brand_string"),
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=2,
|
||||
)
|
||||
except (OSError, subprocess.SubprocessError):
|
||||
return None
|
||||
return parse_apple_silicon_generation(result.stdout)
|
||||
|
||||
|
||||
def supports_mps(generation=None):
|
||||
if generation is None:
|
||||
generation = apple_silicon_generation()
|
||||
return generation is not None and generation >= 4
|
||||
|
||||
|
||||
def supported_devices():
|
||||
devices = runtime.environment_manifest().get("devices")
|
||||
if isinstance(devices, list) and devices:
|
||||
names = [str(device).lower() for device in devices]
|
||||
if not supports_mps():
|
||||
names = [name for name in names if name != "mps"]
|
||||
return names or ["cpu"]
|
||||
if sys.platform == "win32":
|
||||
return ["directml", "cpu"]
|
||||
return ["mps", "cpu"] if supports_mps() else ["cpu"]
|
||||
|
||||
|
||||
def device_enum_items(_owner, _context):
|
||||
|
||||
Reference in New Issue
Block a user