|
2 | 2 |
|
3 | 3 | Script links existing Bonsai installation to the provided IfcOpenShell repository. |
4 | 4 |
|
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) |
6 | 6 | and this script is already part of IfcOpenShell repo you want to link, then you can just run it and it will just work. |
7 | 7 |
|
8 | 8 | Otherwise, see the SETTINGS section below to validate script settings to ensure it fits your evnironment. |
|
14 | 14 |
|
15 | 15 | """ |
16 | 16 |
|
17 | | -import sys |
18 | | -import subprocess |
19 | 17 | import shutil |
| 18 | +import subprocess |
| 19 | +import sys |
20 | 20 | import urllib.request |
21 | 21 | from pathlib import Path |
22 | 22 | from typing import Union |
23 | 23 |
|
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}.") |
26 | 27 | exit(1) |
27 | 28 |
|
28 | 29 | # --------------------------- |
|
37 | 38 |
|
38 | 39 | # BLENDER_PATH: Path to Blender's configuration folder. |
39 | 40 | # 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 |
41 | 47 |
|
42 | 48 |
|
43 | 49 | BONSAI_PATH_CANDIDATES = ( |
@@ -74,7 +80,7 @@ def find_bonsai_path() -> Union[Path, None]: |
74 | 80 | NEW_LINE = chr(10) |
75 | 81 |
|
76 | 82 |
|
77 | | -def main(): |
| 83 | +def main() -> None: |
78 | 84 | global REPO_PATH |
79 | 85 |
|
80 | 86 | if not REPO_PATH: |
@@ -104,12 +110,12 @@ def main(): |
104 | 110 |
|
105 | 111 | # Handle symlinks |
106 | 112 | # (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) |
108 | 114 | symlinks_glob = "src/bonsai/bonsai/bim/data/templates/projects/*.ifc" |
109 | 115 | # Delete and checkout is the only way to ensure files are added as symlinks. |
110 | 116 | for path in REPO_PATH.glob(symlinks_glob): |
111 | 117 | path.unlink() |
112 | | - subprocess.run((f"git checkout -- {symlinks_glob}"), cwd=REPO_PATH) |
| 118 | + subprocess.check_call(("git", "checkout", "--", symlinks_glob), cwd=REPO_PATH) |
113 | 119 |
|
114 | 120 | print("Copying compiled dependencies to the repo...") |
115 | 121 | dest = REPO_PATH / "src" / "ifcopenshell-python" / "ifcopenshell" |
|
0 commit comments