diff --git a/caput/scripts/runner.py b/caput/scripts/runner.py index deacafed..cf140ff8 100755 --- a/caput/scripts/runner.py +++ b/caput/scripts/runner.py @@ -84,6 +84,9 @@ def load_venv(configfile): click.echo(f"Path defined in 'cluster'/'venv' doesn't exist ({base})") sys.exit(1) + if (base.parent / "code").exists(): + _load_venv_egg(base.parent / "code") + site_packages = base / "lib" / f"python{sys.version[:3]}" / "site-packages" prev_sys_path = list(sys.path) @@ -96,9 +99,19 @@ def load_venv(configfile): if item not in prev_sys_path: new_sys_path.append(item) sys.path.remove(item) + sys.path[:0] = new_sys_path +def _load_venv_egg(codepath): + """Directly load the venv code under cluster/venv. + + where the venv uses egg links. Modifies sys.path. + """ + packages = [f.path for f in os.scandir(codepath) if f.is_dir()] + sys.path = packages + sys.path + + @cli.command() @click.argument( "configfile",