From 6fb23fe747d0b4d6b8ec3873748b19f7c2865684 Mon Sep 17 00:00:00 2001 From: henryruhs Date: Sun, 28 Jan 2024 20:35:36 +0100 Subject: [PATCH] Enable venv on the fly --- run.py | 6 +++--- tests/test_cli.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/run.py b/run.py index 803c6bff..af6d5a6d 100755 --- a/run.py +++ b/run.py @@ -1,15 +1,15 @@ #!/usr/bin/env python3 -import subprocess import sys +import subprocess if __name__ == '__main__': - if 'venv' in sys.executable or 'conda' in sys.executable: + if 'venv' in sys.executable or '--skip-venv' in sys.argv: from facefusion import core core.cli() else: try: subprocess.run([ 'venv/bin/python', 'run.py' ]) - except KeyboardInterrupt: + except: sys.exit() diff --git a/tests/test_cli.py b/tests/test_cli.py index cad4ffbb..7e2881a1 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -16,7 +16,7 @@ def before_all() -> None: def test_image_to_image() -> None: - commands = [ sys.executable, 'run.py', '-s', '.assets/examples/source.jpg', '-t', '.assets/examples/target-1080p.jpg', '-o', '.assets/examples', '--headless' ] + commands = [ sys.executable, 'run.py', '-s', '.assets/examples/source.jpg', '-t', '.assets/examples/target-1080p.jpg', '-o', '.assets/examples', '--headless', '--skip-venv' ] run = subprocess.run(commands, stdout = subprocess.PIPE, stderr = subprocess.STDOUT) assert run.returncode == 0 @@ -24,7 +24,7 @@ def test_image_to_image() -> None: def test_image_to_video() -> None: - commands = [ sys.executable, 'run.py', '-s', '.assets/examples/source.jpg', '-t', '.assets/examples/target-1080p.mp4', '-o', '.assets/examples', '--trim-frame-end', '10', '--headless' ] + commands = [ sys.executable, 'run.py', '-s', '.assets/examples/source.jpg', '-t', '.assets/examples/target-1080p.mp4', '-o', '.assets/examples', '--trim-frame-end', '10', '--headless', '--skip-venv' ] run = subprocess.run(commands, stdout = subprocess.PIPE, stderr = subprocess.STDOUT) assert run.returncode == 0