From c6c2a4da7492d0ce3aa7c2f473b3a0d5305ba515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Thu, 2 May 2024 21:51:08 +0200 Subject: [PATCH] venv_path and bin_path --- kiwi/src/kiwi_scp/main.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/kiwi/src/kiwi_scp/main.py b/kiwi/src/kiwi_scp/main.py index e996885..09492ee 100644 --- a/kiwi/src/kiwi_scp/main.py +++ b/kiwi/src/kiwi_scp/main.py @@ -1,18 +1,21 @@ -import os import subprocess import sys +from pathlib import Path from virtualenv import cli_run def main() -> None: # TODO location - if not os.access("/tmp/kiwi/bin/kiwi-core", os.X_OK): - cli_run(["/tmp/kiwi"]) - subprocess.check_call(["/tmp/kiwi/bin/python3", "-m", "pip", "install", "."]) + venv_path = Path("/") / "tmp" / "kiwi" + bin_path = venv_path / "bin" + + if not (bin_path / "kiwi-core").exists(): + cli_run([str(venv_path)]) + subprocess.check_call([bin_path / "python3", "-m", "pip", "install", "."]) try: - subprocess.check_call(["/tmp/kiwi/bin/kiwi-core", *sys.argv[1::]]) + subprocess.check_call([bin_path / "kiwi-core", *sys.argv[1::]]) except subprocess.CalledProcessError as exc: sys.exit(exc.returncode)