nox icon indicating copy to clipboard operation
nox copied to clipboard

Have noxfile.py install dependencies for itself

Open mikeholler opened this issue 3 years ago • 2 comments

How would this feature be useful?

Nox has sessions that create virtualenvs, but nox itself executes using the environment available to the system. It would be nice if we could have as predictable an environment for the nox buildscript as we have for each session.

Describe the solution you'd like

Have a second file, noxfile-settings.py that nox executes if present to create an environment for noxfile.py to run in. The contents of the file might look something like this:

from nox.settings import noxfile_session

noxfile_settings.install("GitPython==3.1.14")

Then, in noxfile.py, a user can have a script that calls from git import Repo and feel confident that they are using the same version of GitPython as other developers.

Note: The settings.gradle files and buildscript { ... } blocks from Gradle are examples of another build system doing this kind of thing.

Describe alternatives you've considered

As far as I know there are no workarounds or allowances for this.

mikeholler avatar Apr 09 '21 19:04 mikeholler

I'd probably put something like this in a non-Python file, say pyproject.toml under [tool.nox] requires=["GitPython==3.1.14"], etc. Sounds like it would be a rather large change, though, since nox would need to run nox in an venv. You'd probably want to control/customize that venv, etc...

henryiii avatar Jul 12 '21 18:07 henryiii

Is there a scenario where requirements-dev.txt would be different from the version of GitPython you would need for nox?

As a pattern, I tend to have a venv per project I work on, so nox already is in a venv, but just shared with the project I work on.

I think there may be a more particular corner case worth describing here?

crwilcox avatar Jun 08 '22 23:06 crwilcox