Hello folks,
@Jedd and I have been hard at work figuring out a proper installation mechanism for Blender.
I can tell you we have made great advancements in ironing out all the known issues on all the supported platforms.
We will be able to provide a properly working installer from manager and also a .zip file based installer to be able to use on non officially supported Blender versions (like alpha and beta).
We are including the changes in the upcoming release, until that there is a workaround that you can take if you are daring.
As hinted by the very detailed investigations by @zoomer, unfortunately our current installer on M1 mac-s doesn’t install the python dependencies of the blender connector. But that can be fixed with a python script ran inside blender’s scripting environment:
from pathlib import Path
from importlib import import_module
import bpy
import sys
print("Starting Speckle Blender installation")
print(sys.executable)
PYTHON_PATH = sys.executable
def modules_path() -> Path:
modules_path = Path(bpy.utils.script_path_user(), "addons", "modules")
modules_path.mkdir(exist_ok=True, parents=True)
# set user modules path at beginning of paths for earlier hit
if sys.path[1] != modules_path:
sys.path.insert(1, modules_path)
return modules_path
print(f"Found blender modules path {modules_path()}")
def is_pip_available() -> bool:
try:
import_module("pip") # noqa F401
return True
except ImportError:
return False
def ensure_pip() -> None:
print("Installing pip... "),
from subprocess import run
completed_process = run([PYTHON_PATH, "-m", "ensurepip"])
if completed_process.returncode == 0:
print("Successfully installed pip")
else:
raise Exception("Failed to install pip.")
def get_requirements_path() -> Path:
# we assume that a requirements.txt exists next to the __init__.py file
path = Path(Path(__file__).parent, "requirements.txt")
assert path.exists()
return path
def install_requirements() -> None:
# set up addons/modules under the user
# script path. Here we'll install the
# dependencies
path = modules_path()
print(f"Installing Speckle dependencies to {path}")
from subprocess import run
completed_process = run(
[
PYTHON_PATH,
"-m",
"pip",
"install",
"-t",
str(path),
"specklepy"
],
capture_output=True,
text=True,
)
if completed_process.returncode != 0:
print("Please try manually installing speckle-blender")
raise Exception(
"""
Failed to install speckle-blender.
See console for manual install instruction.
"""
)
def install_dependencies() -> None:
if not is_pip_available():
ensure_pip()
install_requirements()
def _import_dependencies() -> None:
import_module("specklepy")
def ensure_dependencies() -> None:
try:
_import_dependencies()
print("Found all dependencies, proceed with loading")
except ImportError:
print("Failed to load all dependencies, trying to install them...")
install_dependencies()
raise Exception("Please restart Blender.")
ensure_dependencies()
disclaimer, I’ve copy pasted and modified code from our new installer, let me know if it has any issues.
After running this, enabling the addon should succeed.