Skip to content

Commit 0e74ac8

Browse files
committed
dev_environment.py - support Mac
1 parent 31ec482 commit 0e74ac8

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

src/bonsai/scripts/installation/dev_environment.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Script links existing Bonsai installation to the provided IfcOpenShell repository.
44
5-
If you're on Windows, using Blender 4.5, Bonsai is installed from unstable repo (raw_githubusercontent_com)
5+
If you're on Windows/Mac, using Blender 4.5, Bonsai is installed from unstable repo (raw_githubusercontent_com)
66
and this script is already part of IfcOpenShell repo you want to link, then you can just run it and it will just work.
77
88
Otherwise, see the SETTINGS section below to validate script settings to ensure it fits your evnironment.
@@ -14,15 +14,16 @@
1414
1515
"""
1616

17-
import sys
18-
import subprocess
1917
import shutil
18+
import subprocess
19+
import sys
2020
import urllib.request
2121
from pathlib import Path
2222
from typing import Union
2323

24-
if sys.platform != "win32":
25-
print("Currently only available on Windows.")
24+
available_platforms = ("win32", "darwin")
25+
if sys.platform not in available_platforms:
26+
print(f"Currently only available on {','.join(available_platforms)}. Not available on {sys.platform}.")
2627
exit(1)
2728

2829
# ---------------------------
@@ -37,7 +38,12 @@
3738

3839
# BLENDER_PATH: Path to Blender's configuration folder.
3940
# Usually don't need to change, just ensure Blender version matches.
40-
BLENDER_PATH = Path.home() / r"AppData/Roaming/Blender Foundation/Blender/4.5"
41+
if sys.platform == "win32":
42+
BLENDER_PATH = Path.home() / r"AppData/Roaming/Blender Foundation/Blender/4.5"
43+
elif sys.platform == "darwin":
44+
BLENDER_PATH = Path.home() / r"Library/Application Support/Blender/4.5"
45+
else:
46+
assert False
4147

4248

4349
BONSAI_PATH_CANDIDATES = (
@@ -74,7 +80,7 @@ def find_bonsai_path() -> Union[Path, None]:
7480
NEW_LINE = chr(10)
7581

7682

77-
def main():
83+
def main() -> None:
7884
global REPO_PATH
7985

8086
if not REPO_PATH:
@@ -104,12 +110,12 @@ def main():
104110

105111
# Handle symlinks
106112
# (they could be disabled by default on Windows).
107-
subprocess.run("git config --local core.symlinks true", cwd=REPO_PATH)
113+
subprocess.check_call(("git", "config", "--local", "core.symlinks", "true"), cwd=REPO_PATH)
108114
symlinks_glob = "src/bonsai/bonsai/bim/data/templates/projects/*.ifc"
109115
# Delete and checkout is the only way to ensure files are added as symlinks.
110116
for path in REPO_PATH.glob(symlinks_glob):
111117
path.unlink()
112-
subprocess.run((f"git checkout -- {symlinks_glob}"), cwd=REPO_PATH)
118+
subprocess.check_call(("git", "checkout", "--", symlinks_glob), cwd=REPO_PATH)
113119

114120
print("Copying compiled dependencies to the repo...")
115121
dest = REPO_PATH / "src" / "ifcopenshell-python" / "ifcopenshell"

0 commit comments

Comments
 (0)