mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 07:46:54 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -117,10 +117,30 @@ def main() -> None:
|
|||||||
# (they could be disabled by default on Windows).
|
# (they could be disabled by default on Windows).
|
||||||
subprocess.check_call(("git", "config", "--local", "core.symlinks", "true"), cwd=REPO_PATH)
|
subprocess.check_call(("git", "config", "--local", "core.symlinks", "true"), cwd=REPO_PATH)
|
||||||
symlinks_glob = "src/bonsai/bonsai/bim/data/templates/projects/*.ifc"
|
symlinks_glob = "src/bonsai/bonsai/bim/data/templates/projects/*.ifc"
|
||||||
# Delete and checkout is the only way to ensure files are added as symlinks.
|
symlink_paths = list(REPO_PATH.glob(symlinks_glob))
|
||||||
for path in REPO_PATH.glob(symlinks_glob):
|
|
||||||
path.unlink()
|
# Check if symlinks already exist and are valid
|
||||||
subprocess.check_call(("git", "checkout", "--", symlinks_glob), cwd=REPO_PATH)
|
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...")
|
print("Copying compiled dependencies to the repo...")
|
||||||
dest = REPO_PATH / "src" / "ifcopenshell-python" / "ifcopenshell"
|
dest = REPO_PATH / "src" / "ifcopenshell-python" / "ifcopenshell"
|
||||||
|
|||||||
Reference in New Issue
Block a user