|
|
@ -25,19 +25,27 @@ class PythonRunner(): |
|
|
|
self.vpython = os.path.join(self.virtual_dir, "bin", "python3") |
|
|
|
|
|
|
|
if not os.path.exists(self.vpython): |
|
|
|
# TODO: Use Popen, hide output if successful |
|
|
|
subprocess.call([sys.executable, "-m", "virtualenv", self.virtual_dir]) |
|
|
|
with subprocess.Popen([sys.executable, "-m", "virtualenv", self.virtual_dir], |
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p: |
|
|
|
p.wait() |
|
|
|
if p.returncode != 0: |
|
|
|
sys.stdout.buffer.write(p.stderr.read()) |
|
|
|
raise RunnerError("PythonRunner: Could not create virtualenv") |
|
|
|
else: |
|
|
|
print(f"PythonRunner: Virtualenv initialized at {self.virtual_dir}") |
|
|
|
else: |
|
|
|
print(f"PythonRunner: Found virtualenv at {self.virtual_dir}") |
|
|
|
|
|
|
|
# Stores common defaults for all jobs - all types! |
|
|
|
# Also - dependency install by config is only allowed in this step |
|
|
|
def update_config(self, config): |
|
|
|
if "dependencies" in config: |
|
|
|
for dependency in config["dependencies"]: |
|
|
|
# TODO: Hide output - but only if successful! |
|
|
|
# TODO: Check what happens with fixed version |
|
|
|
with subprocess.Popen([self.vpython, "-m", "pip", "install", dependency, "--upgrade"]) as p: |
|
|
|
with subprocess.Popen([self.vpython, "-m", "pip", "install", dependency, "--upgrade"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p: |
|
|
|
p.wait() |
|
|
|
if p.returncode != 0: |
|
|
|
sys.stdout.buffer.write(p.stderr.read()) |
|
|
|
raise(RunnerError(f"PythonRunner: Could not install dependency: {dependency} ({p.returncode})")) |
|
|
|
for env_var in config["env"]: |
|
|
|
self.env_vars[env_var["name"]] = env_var["value"] |
|
|
|