From 31529de8a32ca54109c44012e10bff97e869426b Mon Sep 17 00:00:00 2001 From: Gwyn Date: Sat, 17 Apr 2021 07:55:34 -0600 Subject: [PATCH] Removes automatic reuse of venvs when no-install is provided (#394) Also reduces log verbosity by only noting package reinstallation when venv is not explicitly reused. --- docs/config.rst | 1 + nox/sessions.py | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/config.rst b/docs/config.rst index d64d2f88..d1fcf677 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -424,6 +424,7 @@ The following options can be specified in the Noxfile: * ``nox.options.default_venv_backend`` is equivalent to specifying :ref:`-db or --default-venv-backend `. * ``nox.options.force_venv_backend`` is equivalent to specifying :ref:`-fb or --force-venv-backend `. * ``nox.options.reuse_existing_virtualenvs`` is equivalent to specifying :ref:`--reuse-existing-virtualenvs `. You can force this off by specifying ``--no-reuse-existing-virtualenvs`` during invocation. +* ``nox.options.no_install`` is equivalent to specifying :ref:`--no-install `. * ``nox.options.stop_on_first_error`` is equivalent to specifying :ref:`--stop-on-first-error `. You can force this off by specifying ``--no-stop-on-first-error`` during invocation. * ``nox.options.error_on_missing_interpreters`` is equivalent to specifying :ref:`--error-on-missing-interpreters `. You can force this off by specifying ``--no-error-on-missing-interpreters`` during invocation. * ``nox.options.error_on_external_run`` is equivalent to specifying :ref:`--error-on-external-run `. You can force this off by specifying ``--no-error-on-external-run`` during invocation. diff --git a/nox/sessions.py b/nox/sessions.py index 160a5243..f9ddce79 100644 --- a/nox/sessions.py +++ b/nox/sessions.py @@ -379,9 +379,10 @@ def conda_install( ) return None else: - logger.info( - "Venv not created yet: ignoring --no-install and installing from conda." - ) + if not self._runner.global_config.reuse_existing_virtualenvs: + logger.info( + "Venv not created yet: ignoring --no-install and installing from conda." + ) # Escape args that should be (conda-specific; pip install does not need this) args = _dblquote_pkg_install_args(args) @@ -450,9 +451,10 @@ def install(self, *args: str, **kwargs: Any) -> None: ) return None else: - logger.info( - "Venv not created yet: ignoring --no-install and installing." - ) + if not self._runner.global_config.reuse_existing_virtualenvs: + logger.info( + "Venv not created yet: ignoring --no-install and installing." + ) if "silent" not in kwargs: kwargs["silent"] = True @@ -544,9 +546,7 @@ def _create_venv(self) -> None: return reuse_existing = ( - self.func.reuse_venv - or self.global_config.reuse_existing_virtualenvs - or self.global_config.no_install + self.func.reuse_venv or self.global_config.reuse_existing_virtualenvs ) if backend is None or backend == "virtualenv":