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 command line option for setting python=False #301

Closed
sethmlarson opened this issue Mar 27, 2020 · 3 comments · Fixed by #316
Closed

Add a command line option for setting python=False #301

sethmlarson opened this issue Mar 27, 2020 · 3 comments · Fixed by #316

Comments

@sethmlarson
Copy link
Contributor

How would this feature be useful?
If you have a noxfile.py that you use for development but also use Docker as a part of your CI you can skip having to create a virtualenv and reinstall dependencies that may have been installed as a part of your Docker image build step. For instance if I have:

FROM python:3

COPY dev-requirements.txt .
RUN python -m pip install -r dev-requirements.txt

COPY . .
RUN nox -s test --use-current-env

then my session.install("-r", "dev-requirements.txt") step within my noxfile.py would only require checking cache, much faster to run.

Describe the solution you'd like

Using --use-current-env (or alternative name, I'm fine with anything!) would override any python=[] within noxfile.py to python=False and use interpreter at sys.executable.

@theacodes
Copy link
Collaborator

I thought we already had this, but I'm not opposed to a venv backend that's a"passthrough".

@smarie
Copy link
Contributor

smarie commented Apr 21, 2020

There seem to be something like this already : from the doc

If you want to disable virtualenv creation altogether, you can set python to False

However you cannot use install nor conda_install then, you get ValueError: A session without a virtualenv can not install dependencies. or ValueError: A session without a conda environment can not install dependencies from conda..

I'll try to propose something to fix this

@smarie
Copy link
Contributor

smarie commented Apr 22, 2020

PR #316 provides a solution to this: you can now use --force-venv-backend (or -fb) to force a venv backend for all sessions to be run. Among supported backend, I added the "none" backend that is strictly equivalent to python=False.

So @sethmlarson you could do what you wish using nox -fb none. Of course we can imagine an even shorter option name such as --no-venv as a shortcut, actually I will try to submit it in the PR as it is much more readable. The advantage of --force-venv-backend (-fb) is that you can use it to switch to conda or venv too.

See #316 for details, there is also a new option to define the default venv backend.

smarie pushed a commit to smarie/nox that referenced this issue Apr 22, 2020
theacodes pushed a commit that referenced this issue May 24, 2020
* New global option `nox.options.venv_backend` to set the default backend. Fixes #315

* Added doc about the new option

* Blackened

* fixed tests

* Fixed docs

* Fixed coverage by adding tests for the venv_backend_completer

* fixed test

* Added tests for short and long versions of the new option.

* Replaced the venv_backend completer with a simple `choices` from argparse :)

* Renamed venv_backend to default_venv_backend, and created new force_venv_backend

* New "none" choice for venv_backends, equivalent to python=False

* Updated doc concerning default_venv_backend and force_venv_backend, as well as the new 'none' backend

* Fixed all manifest tests

* Fixed test_tasks for venv_backend

* Fixed coverage

* Blackened code

* The warning message was appearing for all sessions, even those deselected. It is now only logged when session is run.

* Added `--no-venv` option. Fixes #301

* Blackened

* Fixed tests

* Improved coverage

* Blackened

* Fixed an issue with parametrization: warning would not be issued. Added corresponding tests. This should make coverage happy, too.

* Blackened

* Now `install` and `conda_install` work when there is no venv backend (or python=False). Previously a `ValueError` was raised. Fixes #318

* Fixed test

* Minor edit to trigger CI build again as it seems stuck.

* Minor doc fix to trigger the CI again (appveyor false fail)

Co-authored-by: Sylvain MARIE <sylvain.marie@se.com>
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.

3 participants