Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor pip as python -m pip #363

Merged
merged 3 commits into from
Dec 28, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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