Skip to content

Commit

Permalink
runner: test method to lint egg venv
Browse files Browse the repository at this point in the history
  • Loading branch information
ljgray committed Aug 8, 2023
1 parent 99fccd3 commit 2869dc1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions caput/scripts/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ def load_venv(configfile):
click.echo("Path defined in 'cluster'/'venv' doesn't exist ({})".format(base))
sys.exit(1)

if (base.parent / "code").exists():
_load_venv_egg(base.parent / "code")

site_packages = base / "lib" / "python{}".format(sys.version[:3]) / "site-packages"
prev_sys_path = list(sys.path)

Expand All @@ -85,9 +88,20 @@ 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 oad the venv code under cluster/venv in the given
configfile, 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",
Expand Down

0 comments on commit 2869dc1

Please sign in to comment.