Skip to content

Commit

Permalink
Refactor pip as python -m pip (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
V1NAY8 authored Dec 28, 2020
1 parent a188be7 commit cdb391f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ before_install:
- conda update --yes conda
- export SETUPTOOLS_USE_DISTUTILS=stdlib
install:
- pip install --upgrade pip setuptools
- pip install .
- python -m pip install --upgrade pip setuptools
- python -m pip install .
script: nox --non-interactive --session "$NOXSESSION"
deploy:
provider: pypi
Expand Down
4 changes: 2 additions & 2 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ When you run ``nox``, it will create a two distinct sessions:
$ nox
nox > Running session tests(django='1.9')
nox > pip install django==1.9
nox > python -m pip install django==1.9
...
nox > Running session tests(django='2.0')
nox > pip install django==2.0
nox > python -m pip install django==2.0
:func:`nox.parametrize` has an interface and usage intentionally similar to `pytest's parametrize <https://pytest.org/latest/parametrize.html#_pytest.python.Metafunc.parametrize>`_.
Expand Down
4 changes: 2 additions & 2 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ Would run both ``install`` commands, but skip the ``run`` command:
nox > Running session tests
nox > Creating virtualenv using python3.7 in ./.nox/tests
nox > pip install pytest
nox > pip install .
nox > python -m pip install pytest
nox > python -m pip install .
nox > Skipping pytest run, as --install-only is set.
nox > Session tests was successful.
Expand Down
2 changes: 1 addition & 1 deletion nox/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def install(self, *args: str, **kwargs: Any) -> None:
if "silent" not in kwargs:
kwargs["silent"] = True

self._run("pip", "install", *args, external="error", **kwargs)
self._run("python", "-m", "pip", "install", *args, external="error", **kwargs)

def notify(self, target: "Union[str, SessionRunner]") -> None:
"""Place the given session at the end of the queue.
Expand Down
20 changes: 17 additions & 3 deletions tests/test_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def test_run_install_only_should_install(self):
session.run("spam", "eggs")

run.assert_called_once_with(
("pip", "install", "spam"),
("python", "-m", "pip", "install", "spam"),
env=mock.ANY,
external=mock.ANY,
paths=mock.ANY,
Expand Down Expand Up @@ -445,7 +445,14 @@ class SessionNoSlots(nox.sessions.Session):
with mock.patch.object(session, "_run", autospec=True) as run:
session.install("requests", "urllib3")
run.assert_called_once_with(
"pip", "install", "requests", "urllib3", silent=True, external="error"
"python",
"-m",
"pip",
"install",
"requests",
"urllib3",
silent=True,
external="error",
)

def test_install_non_default_kwargs(self):
Expand All @@ -467,7 +474,14 @@ class SessionNoSlots(nox.sessions.Session):
with mock.patch.object(session, "_run", autospec=True) as run:
session.install("requests", "urllib3", silent=False)
run.assert_called_once_with(
"pip", "install", "requests", "urllib3", silent=False, external="error"
"python",
"-m",
"pip",
"install",
"requests",
"urllib3",
silent=False,
external="error",
)

def test_notify(self):
Expand Down

0 comments on commit cdb391f

Please sign in to comment.