From 5b7e3c832475105764f4a327dad5ec9c0a7e55f0 Mon Sep 17 00:00:00 2001 From: Romain Dorgueil Date: Sun, 28 May 2017 23:03:22 +0200 Subject: [PATCH] [cli] fixes --install which did not work with --editable packages, aka things added to sys.path by some *.pth file in a very not explicit way. --- bonobo/commands/run.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bonobo/commands/run.py b/bonobo/commands/run.py index 0f85eb8..8bb7b10 100644 --- a/bonobo/commands/run.py +++ b/bonobo/commands/run.py @@ -1,3 +1,4 @@ +import importlib import os import runpy @@ -44,7 +45,13 @@ def execute(filename, module, install=False, quiet=False, verbose=False): if os.path.isdir(filename): if install: requirements = os.path.join(filename, 'requirements.txt') - pip.main(['install', '-qr', requirements]) + pip.main(['install', '-r', requirements]) + # Some shenanigans to be sure everything is importable after this, especially .egg-link files which + # are referenced in *.pth files and apparently loaded by site.py at some magic bootstrap moment of the + # python interpreter. + pip.utils.pkg_resources = importlib.reload(pip.utils.pkg_resources) + import site + importlib.reload(site) filename = os.path.join(filename, DEFAULT_GRAPH_FILENAME) elif install: raise RuntimeError('Cannot --install on a file (only available for dirs containing requirements.txt).')