Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog/xxx.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Switch pip invocations to use the module ``-m pip`` instead of direct invocation. This could help
avoid some of the shebang limitations. - by :user:`gaborbernat`
4 changes: 2 additions & 2 deletions src/tox/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def postprocess(self, testenv_config, value):
class InstallcmdOption:
name = "install_command"
type = "argv"
default = "pip install {opts} {packages}"
default = "python -m pip install {opts} {packages}"
help = "install command for dependencies and package under test."

def postprocess(self, testenv_config, value):
Expand Down Expand Up @@ -730,7 +730,7 @@ def develop(testenv_config, value):
parser.add_testenv_attribute(
name="list_dependencies_command",
type="argv",
default="pip freeze",
default="python -m pip freeze",
help="list dependencies for a virtual environment",
)

Expand Down
15 changes: 10 additions & 5 deletions tests/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ def test_install_deps_wildcard(newmocksession):
assert len(pcalls) == 2
args = pcalls[-1].args
assert pcalls[-1].cwd == venv.envconfig.config.toxinidir
assert "pip" in str(args[0])
assert args[1] == "install"

assert py.path.local.sysfind("python") == args[0]
assert ["-m", "pip"] == args[1:3]
assert args[3] == "install"
args = [arg for arg in args if str(arg).endswith("dep1-1.1.zip")]
assert len(args) == 1

Expand Down Expand Up @@ -449,7 +451,8 @@ def test_install_python3(newmocksession):
venv._install(["hello"], action=action)
assert len(pcalls) == 1
args = pcalls[0].args
assert "pip" in args[0]
assert py.path.local.sysfind("python") == args[0]
assert ["-m", "pip"] == args[1:3]
for _ in args:
assert "--download-cache" not in args, args

Expand Down Expand Up @@ -744,8 +747,10 @@ def test_run_install_command(newmocksession):
venv.run_install_command(packages=["whatever"], action=action)
pcalls = mocksession._pcalls
assert len(pcalls) == 1
assert "pip" in pcalls[0].args[0]
assert "install" in pcalls[0].args
args = pcalls[0].args
assert py.path.local.sysfind("python") == args[0]
assert ["-m", "pip"] == args[1:3]
assert "install" in args
env = pcalls[0].env
assert env is not None

Expand Down