Skip to content

Commit af59e23

Browse files
authored
Merge pull request #1090 from compas-dev/symlinks
Use a junction instead of a symbolic link
2 parents 11b869b + b18c505 commit af59e23

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Changed
1313

14+
* Changed `compas._os._polyfill_symlinks` to use junction (/J) instead of symbolic link (/D).
15+
1416
### Removed
1517

1618

src/compas/_os.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def _polyfill_symlinks(symlinks, raise_on_error):
316316
mklink_cmd.write("SET /A symlink_result=0\n")
317317
mklink_cmd.write("ECHO ret=%symlink_result%\n")
318318
for i, (source, link_name) in enumerate(symlinks):
319-
dir_symlink_arg = "/D" if os.path.isdir(source) else ""
319+
dir_symlink_arg = "/J" if os.path.isdir(source) else ""
320320
mklink_cmd.write("mklink {} {}\n".format(dir_symlink_arg, subprocess.list2cmdline([link_name, source])))
321321
mklink_cmd.write("IF %ERRORLEVEL% EQU 0 SET /A symlink_result += {} \n".format(2**i))
322322

src/compas_ghpython/components/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
import glob
2727
import os
2828

29-
from compas._os import create_symlinks
3029
from compas._os import remove_symlinks
30+
from compas._os import copy as _copy
3131
from compas_ghpython import get_grasshopper_userobjects_path
3232
from compas_rhino import _check_rhino_version
3333
import compas_rhino
@@ -75,7 +75,14 @@ def install_userobjects(source):
7575
remove_symlinks(symlinks_to_remove)
7676

7777
# And the create new ones
78-
created = create_symlinks(symlinks_to_add)
78+
created = []
79+
for src, dst in symlinks_to_add:
80+
try:
81+
_copy(src, dst)
82+
except Exception:
83+
created.append(False)
84+
else:
85+
created.append(True)
7986

8087
return list(zip(symlinks_to_add, created))
8188

0 commit comments

Comments
 (0)