Use relative symlinks

This commit is contained in:
doylet 2026-02-21 17:04:38 +11:00
parent 84f0d9e43d
commit 4d99747372

View File

@ -396,8 +396,11 @@ def download_and_install_archive(download_url,
# OS. # OS.
use_hardlink = is_windows or os.name == 'nt' use_hardlink = is_windows or os.name == 'nt'
for symlink_entry in exe_dict["symlink"]: for symlink_entry in exe_dict["symlink"]:
symlink_dest = symlink_dir / symlink_entry symlink_dest = symlink_dir / symlink_entry
symlink_src = exe_path symlink_src = exe_path
symlink_rel_src = pathlib.Path(symlink_src).relative_to(install_dir)
symlink_rel_dest = pathlib.Path(symlink_dest).relative_to(install_dir)
skip_link = False; skip_link = False;
if os.path.exists(symlink_dest): if os.path.exists(symlink_dest):
# Windows uses hardlinks because symlinks require you to enable "developer" mode # Windows uses hardlinks because symlinks require you to enable "developer" mode
@ -414,11 +417,13 @@ def download_and_install_archive(download_url,
else: else:
os.unlink(symlink_dest) os.unlink(symlink_dest)
import contextlib
if not skip_link: if not skip_link:
if use_hardlink: if use_hardlink:
os.link(src=symlink_src, dst=symlink_dest) os.link(src=symlink_src, dst=symlink_dest)
else: else:
os.symlink(src=symlink_src, dst=symlink_dest) with contextlib.chdir(install_dir):
os.symlink(src=symlink_rel_src, dst=symlink_dest)
# Collect paths to add to the devenv script # Collect paths to add to the devenv script
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------