From 6bfb0f17a033c485948e09e6c18bc08f5948830c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Thu, 23 Aug 2018 21:19:50 +0200 Subject: [PATCH] Instead of using the virtualenv command, use -m virtualenv Fixes https://github.com/manahl/pytest-plugins/issues/79 --- pytest-virtualenv/pytest_virtualenv.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pytest-virtualenv/pytest_virtualenv.py b/pytest-virtualenv/pytest_virtualenv.py index a7981b3..e54039c 100644 --- a/pytest-virtualenv/pytest_virtualenv.py +++ b/pytest-virtualenv/pytest_virtualenv.py @@ -20,7 +20,8 @@ class FixtureConfig(Config): __slots__ = ('virtualenv_executable') # Default values for system resource locations - patch this to change defaults -DEFAULT_VIRTUALENV_FIXTURE_EXECUTABLE = (cmdline.which('virtualenv') + ['virtualenv'])[0] +# Can be a string or list of them +DEFAULT_VIRTUALENV_FIXTURE_EXECUTABLE = [sys.executable, '-m', 'virtualenv'] CONFIG = FixtureConfig( virtualenv_executable=os.getenv('VIRTUALENV_FIXTURE_EXECUTABLE', DEFAULT_VIRTUALENV_FIXTURE_EXECUTABLE), @@ -132,9 +133,11 @@ def __init__(self, env=None, workspace=None, name='.env', python=None, args=None del(self.env['PYTHONPATH']) self.virtualenv_cmd = CONFIG.virtualenv_executable - cmd = [self.virtualenv_cmd, - '-p', python or cmdline.get_real_python_executable() - ] + if isinstance(self.virtualenv_cmd, str): + cmd = [self.virtualenv_cmd] + else: + cmd = list(self.virtualenv_cmd) + cmd.extend(['-p', python or cmdline.get_real_python_executable()]) cmd.extend(self.args) cmd.append(str(self.virtualenv)) self.run(cmd)