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

Add option --no-install to skip install commands in reused environments #432

Merged
merged 15 commits into from
Jun 1, 2021

Conversation

cjolowicz
Copy link
Collaborator

@cjolowicz cjolowicz commented May 28, 2021

Add option --no-install to skip the re-installation of packages when a virtualenv is reused.

Use either of these to reuse a virtualenv without re-installing packages:

nox -R
nox --reuse-existing-virtualenvs --no-install

The --no-install option causes the following session methods to return early:

  • session.install
  • session.conda_install
  • session.run_always

This option has no effect if the virtualenv is not being reused.

Closes #394
Supercedes #411

Co-authored-by: @jamandbees

@emilmelnikov
Copy link

LGTM, thanks!

@@ -320,6 +327,18 @@ def _session_completer(
group=options.groups["secondary"],
help="Re-use existing virtualenvs instead of recreating them.",
),
_option_set.Option(
"R",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be lowercase, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The option is uppercase (-R), so using r as the option name would lead to an error:

Traceback (most recent call last):
  File ".../nox/venv/bin/nox", line 33, in <module>
    sys.exit(load_entry_point('nox', 'console_scripts', 'nox')())
  File ".../nox/nox/__main__.py", line 30, in main
    args = _options.options.parse_args()
  File ".../nox/nox/_option_set.py", line 267, in parse_args
    self._finalize_args(args)
  File ".../nox/nox/_option_set.py", line 255, in _finalize_args
    value = getattr(args, option.name)
AttributeError: 'Namespace' object has no attribute 'r'

Our option.name must match the name that argparse derives for the option. In this case, the option is uppercase -R with no equivalent long option, so argparse derives R as the option name.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha

@cjolowicz cjolowicz merged commit 56c7d56 into wntrblm:main Jun 1, 2021
@cjolowicz cjolowicz deleted the no-install branch June 1, 2021 10:16
@cjolowicz cjolowicz mentioned this pull request Jun 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add an option to skip install commands
3 participants