@@ -411,6 +411,10 @@ def _prepare_runtime_dir(self) -> None:
411
411
self ._prepare_virtualenv ()
412
412
self ._write_cloe_env ()
413
413
self ._write_activate_all (
414
+ [
415
+ # From Conan VirtualRunEnv (!= virtualrunenv) generator:
416
+ self .runtime_dir / "conanrun.sh" ,
417
+ ],
414
418
[
415
419
# From Conan virtualenv generator:
416
420
self .runtime_dir / "environment.sh.env" ,
@@ -492,7 +496,22 @@ def _write_zshrc(self) -> None:
492
496
493
497
def _write_cloe_env (self ) -> None :
494
498
"""Derive important CLOE_ variables and write environment_cloe.sh.env file."""
495
- env = Environment (self .runtime_dir / "activate_run.sh" , source_file = True )
499
+ conanrun = self .runtime_dir / "conanrun.sh" # From newer VirtualRunEnv generator
500
+ activate_run = self .runtime_dir / "activate_run.sh" # From older virtualrunenv generator
501
+ if conanrun .exists ():
502
+ if activate_run .exists ():
503
+ logging .warning ("Warning: Found both conanrun.sh and activate_run.sh in runtime directory!" )
504
+ logging .warning ("Note:" )
505
+ logging .warning (" It looks like /both/ VirtualRunEnv and virtualrunenv generators are being run." )
506
+ logging .warning (" This may come from using an out-of-date cloe-launch-profile package." )
507
+ logging .warning ("" )
508
+ logging .warning (" Continuing with hybrid approach. Environment variables may be incorrectly set." )
509
+ env = Environment (conanrun , source_file = True )
510
+ elif activate_run .exists ():
511
+ env = Environment (activate_run , source_file = True )
512
+ else :
513
+ raise RuntimeError ("cannot find conanrun.sh or activate_run.sh in runtime directory" )
514
+
496
515
if env .has ("CLOE_SHELL" ):
497
516
logging .error ("Error: recursive cloe shells are not supported." )
498
517
logging .error ("Note:" )
@@ -512,7 +531,7 @@ def _write_cloe_env(self) -> None:
512
531
cloe_env .path_set ("CLOE_PLUGIN_PATH" , self ._extract_plugin_paths (env ))
513
532
cloe_env .export (self .runtime_dir / "environment_cloe.sh.env" )
514
533
515
- def _write_activate_all (self , files : List [Path ]) -> None :
534
+ def _write_activate_all (self , source_files : List [ Path ], env_files : List [Path ]) -> None :
516
535
"""Write activate_all.sh file."""
517
536
activate_file = self .runtime_dir / "activate_all.sh"
518
537
activate_data = textwrap .dedent (
@@ -529,7 +548,16 @@ def _write_activate_all(self, files: List[Path]) -> None:
529
548
530
549
"""
531
550
)
532
- for file in files :
551
+
552
+ for file in source_files :
553
+ if not file .exists ():
554
+ logging .info (f"Skipping source: { file } " )
555
+ filename = shlex .quote (file .as_posix ())
556
+ activate_data += f". { filename } \n "
557
+
558
+ for file in env_files :
559
+ if not file .exists ():
560
+ logging .info (f"Skipping export: { file } " )
533
561
filename = shlex .quote (file .as_posix ())
534
562
activate_data += f"export_vars_from_file { filename } \n "
535
563
activate_data += "\n unset export_vars_from_file\n "
@@ -548,9 +576,7 @@ def _prepare_virtualenv(self) -> None:
548
576
"--install-folder" ,
549
577
str (self .runtime_dir ),
550
578
"-g" ,
551
- "virtualenv" ,
552
- "-g" ,
553
- "virtualrunenv" ,
579
+ "VirtualRunEnv" ,
554
580
]
555
581
for arg in self .conan_args :
556
582
conan_cmd .append (arg )
0 commit comments