Skip to content

Commit e807e8e

Browse files
committed
symlink compilers into views
1 parent 412962f commit e807e8e

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

stackinator/etc/envvars.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,11 @@ def view_impl(args):
434434
print(f"error - activation script {activate_path} does not exist")
435435
exit(1)
436436

437+
bin_path = os.path.join(root_path, "bin")
438+
# ensure that the bin path exists
439+
if not os.path.exists(bin_path):
440+
os.makedirs(bin_path)
441+
437442
envvars = read_activation_script(activate_path)
438443

439444
# force all prefix path style variables (list vars) to use PREPEND the first operation.
@@ -456,13 +461,15 @@ def view_impl(args):
456461
if c is not None:
457462
compilers.append(c)
458463

459-
compiler_paths = []
460464
for c in compilers:
461-
local_paths = set([os.path.dirname(v) for _, v in c.items() if v is not None])
462-
compiler_paths += local_paths
463-
print(f"adding compiler {c} -> {[p for p in local_paths]}")
464-
465-
envvars.set_list("PATH", compiler_paths, EnvVarOp.PREPEND)
465+
source_paths = list(set([os.path.abspath(v) for _, v in c.items() if v is not None]))
466+
target_paths = [os.path.join(bin_path, os.path.basename(f)) for f in source_paths]
467+
for src, dst in zip(source_paths, target_paths):
468+
print(f"creating compiler symlink: {src} -> {dst}")
469+
if os.path.exists(dst):
470+
print(f" first removing {dst}")
471+
os.remove(dst)
472+
os.symlink(src, dst)
466473

467474
if args.prefix_paths:
468475
# get the root path of the env

0 commit comments

Comments
 (0)