From a37de44a24b8495be69f91952b53abf3ef6fa5b9 Mon Sep 17 00:00:00 2001 From: DesertSpringsCivil Date: Sat, 31 Jan 2026 14:43:13 -0700 Subject: [PATCH] Fix dev_environment.py Windows compatibility for symlink handling Git checkout with glob patterns (*.ifc) doesn't work on Windows. This change: - Expands glob via git ls-files and checks out files individually - Skips symlink recreation if they already exist and are valid - Refreshes git index before checkout to recognize deleted files Co-Authored-By: Claude Opus 4.5 --- src/bonsai/scripts/dev_environment.py | 28 +++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/bonsai/scripts/dev_environment.py b/src/bonsai/scripts/dev_environment.py index 4598d0bf49..6889a79f3e 100644 --- a/src/bonsai/scripts/dev_environment.py +++ b/src/bonsai/scripts/dev_environment.py @@ -117,10 +117,30 @@ def main() -> None: # (they could be disabled by default on Windows). subprocess.check_call(("git", "config", "--local", "core.symlinks", "true"), cwd=REPO_PATH) symlinks_glob = "src/bonsai/bonsai/bim/data/templates/projects/*.ifc" - # Delete and checkout is the only way to ensure files are added as symlinks. - for path in REPO_PATH.glob(symlinks_glob): - path.unlink() - subprocess.check_call(("git", "checkout", "--", symlinks_glob), cwd=REPO_PATH) + symlink_paths = list(REPO_PATH.glob(symlinks_glob)) + + # Check if symlinks already exist and are valid + all_symlinks_valid = symlink_paths and all(p.is_symlink() for p in symlink_paths) + + if not all_symlinks_valid: + # Delete existing files/broken symlinks and recreate from git + for path in symlink_paths: + path.unlink() + # Refresh git index to recognize deleted files + subprocess.run(("git", "update-index", "--refresh"), cwd=REPO_PATH, capture_output=True) + # Get tracked files matching the glob (git checkout with glob doesn't work on Windows) + result = subprocess.run( + ("git", "ls-files", symlinks_glob), + cwd=REPO_PATH, + capture_output=True, + text=True, + check=True, + ) + for file_path in result.stdout.strip().split("\n"): + if file_path: + subprocess.check_call(("git", "checkout", "HEAD", "--", file_path), cwd=REPO_PATH) + else: + print("Symlinks already exist and are valid, skipping recreation.") print("Copying compiled dependencies to the repo...") dest = REPO_PATH / "src" / "ifcopenshell-python" / "ifcopenshell"