Also support --python= arg format
Signed-off-by: Bernat Gabor <bgabor8@bloomberg.net>
This commit is contained in:
parent
b4e3fd866a
commit
c8fbbba497
|
@ -791,9 +791,12 @@ def handle_non_host_target(args):
|
||||||
" non-host python", file=sys.stderr)
|
" non-host python", file=sys.stderr)
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
argv = sys.argv[1:] # remove current python executable
|
argv = sys.argv[1:] # remove current python executable
|
||||||
py_at = argv.index('--python') # plus the new python target
|
for py_at, value in enumerate(argv):
|
||||||
del argv[py_at]
|
if value == "--python":
|
||||||
del argv[py_at]
|
del argv[py_at]
|
||||||
|
del argv[py_at]
|
||||||
|
elif value.startswith("--python"):
|
||||||
|
del argv[py_at]
|
||||||
# feed the file as argument, instead of file
|
# feed the file as argument, instead of file
|
||||||
# to avoid adding the file path to sys.path, that can affect result
|
# to avoid adding the file path to sys.path, that can affect result
|
||||||
file_path = inspect.getsourcefile(sys.modules[__name__])
|
file_path = inspect.getsourcefile(sys.modules[__name__])
|
||||||
|
|
|
@ -523,9 +523,11 @@ def test_parser_svg():
|
||||||
assert not args.json
|
assert not args.json
|
||||||
|
|
||||||
|
|
||||||
def test_custom_interpreter(tmp_path, monkeypatch, capfd):
|
@pytest.mark.parametrize('args_joined', [True, False])
|
||||||
|
def test_custom_interpreter(tmp_path, monkeypatch, capfd, args_joined):
|
||||||
result = virtualenv.cli_run([str(tmp_path), '--activators', ''])
|
result = virtualenv.cli_run([str(tmp_path), '--activators', ''])
|
||||||
cmd = [sys.executable, '--python', str(result.creator.exe)]
|
cmd = [sys.executable]
|
||||||
|
cmd += ['--python={}'.format(result.creator.exe)] if args_joined else ['--python', str(result.creator.exe)]
|
||||||
monkeypatch.setattr(sys, 'argv', cmd)
|
monkeypatch.setattr(sys, 'argv', cmd)
|
||||||
p.main()
|
p.main()
|
||||||
out, _ = capfd.readouterr()
|
out, _ = capfd.readouterr()
|
||||||
|
|
Loading…
Reference in New Issue