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 a single character shortcut for --no-reuse-existing-virtualenvs #624

Closed
johnthagen opened this issue May 26, 2022 · 8 comments · Fixed by #639
Closed

Add a single character shortcut for --no-reuse-existing-virtualenvs #624

johnthagen opened this issue May 26, 2022 · 8 comments · Fixed by #639

Comments

@johnthagen
Copy link
Contributor

johnthagen commented May 26, 2022

How would this feature be useful?

A common way to use Nox that saves a lot of time when re-running sessions over and over by avoiding recreating venvs is to set:

nox.options.reuse_existing_virtualenvs = True

You can see the pip developers use this:

When dependencies do change, the developer can then run:

nox --no-reuse-existing-virtualenvs -s test

Given this can be a very common work flow, avoiding having to type out --no-reuse-existing-virtualenvs on the command line would be a great improvement to UX.

A note on tox

What I'm describing above is also the default workflow for tox users. Many people moving from tox will be familiar with this workflow. (e.g. tox re-uses venvs by default, and tox -r is an opt-in recreation).

Describe the solution you'd like

Add a new alias for --no-reuse-existing-virtualenvs, for example -C for "Create"

nox -C -s test
@johnthagen
Copy link
Contributor Author

Related to #488

@ktbarrett
Copy link
Contributor

The CLI supports multicharacter short options and does not currently use -n (which would cause ambiguity), so it may be possible to use the more intuitive -nr short option.

@johnthagen
Copy link
Contributor Author

-nr would also be a suitable fix for this if the team agrees.

@DiddiLeija
Copy link
Collaborator

I don't see any blockers to do this. Any thoughts @wntrblm/nox?

@crwilcox
Copy link
Collaborator

By default environments are destroyed and recreated, so wouldn't this be a noop?

@johnthagen
Copy link
Contributor Author

johnthagen commented Jul 25, 2022

By default environments are destroyed and recreated, so wouldn't this be a noop?

@crwilcox Not if the user has set in their noxfile.py:

nox.options.reuse_existing_virtualenvs = True

@crwilcox
Copy link
Collaborator

crwilcox commented Jul 25, 2022

Alright. So, to me this sort of feels like an antipattern, but since we already have the long flag, I'd be okay with adding -nr.

Basically, I don't know how prevalent setting args in noxfile.py really is, but as it is allowed, that might not be that relevant ;)

@johnthagen
Copy link
Contributor Author

I don't know how prevalent setting args in noxfile.py really is, but as it is allowed, that might not be that relevant

The pip developers seem to like them 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants