Repository: pypa/pip

Issue:
Investigate if we can replace our tox+invoke setup with nox
My understanding is that nox is good enough to cover our use-cases for both tox and invoke (eg. the test stuff can possibly be easier, and the vendoring / generation logic).

It'll might be worth the effort to invest time to switch from those two tools to using just nox.

/cc @crwilcox @theacodes 


Discussion:
Happy to help in any way. :) Nox is pretty well suited for what y'all are doing.
I think if we do this -- we see most benefit from replacing our invoke stuff.

I imagine having the chunk of the code living in tools/automation/ and having the noxfile.py just contain the "overview" of what those commands need.
@xavfernandez answering here.

`nox` has functionality from tox and invoke.

As such, the reason I'm considering switching us over, is that nox lets us create isolated environments like tox, with a python syntax like invoke and in general is more comfortable to work with in my experience. These combined, will let us transition our invoke scripts (where we currently have an extra step of install dependencies before running) pretty easily and our test-run-related customizations in tox, would likely be cleaner and easier to work with in nox.

AFAICT, we should also be able to switch our entire automation setup, to use nox, which then gives us 1 tool for all our scripting/automation needs. Which, is a good place to be in. 🙃
The answer is: yes, but we're blocked on https://github.com/theacodes/nox/issues/158 before making it the default.
FYI, I created a draft PR. Will want to chat with others on `nox` about the approach, but this does allow me to do what I think you are asking for? You could always try installing from my branch as a test of sorts :) `pip install git+https://github.com/crwilcox/nox.git@allow-non-specified-python-versions`
This was added to nox several months ago, FYI. :)
Hi everybody! I don't know how is this issue going, but I think we can use Nox a bit more. I'll be more than happy to help with anything you need ;)
There's 2 places we still use tox:

- In our CI system.
- In our contributor documentation.

We need to change those over to nox.
Ok. In the next days, I will take my time to investigate about this.
I think we can just remove `tox.ini` in favor of `noxfile.py`? Or should we transfer some items to `noxfile.py`?
I verified both setup files, and many of the Nox sessions are covering the tox environments. The documentation seems to be easy to modify.

But maybe I should write a `coverage` session, since tox defined a `coverage` env?

https://github.com/pypa/pip/blob/bf71afc1435bf99ad9b027e0e9cc27b703e6d611/tox.ini#L34-L47
Ah! I forgot we had a coverage session!
What can we do here?
I think it's definitely sensible to move that over to nox, and pretty useful as well. I'd model it after the tests, and have a bunch of python versions for the coverage session as well.

Resolving patch:
diff --git a/noxfile.py b/noxfile.py
--- a/noxfile.py
+++ b/noxfile.py
@@ -65,9 +65,6 @@ def should_update_common_wheels() -> bool:
 
 # -----------------------------------------------------------------------------
 # Development Commands
-#   These are currently prototypes to evaluate whether we want to switch over
-#   completely to nox for all our automation. Contributors should prefer using
-#   `tox -e ...` until this note is removed.
 # -----------------------------------------------------------------------------
 @nox.session(python=["3.7", "3.8", "3.9", "3.10", "pypy3"])
 def test(session: nox.Session) -> None:
@@ -223,6 +220,21 @@ def pinned_requirements(path: Path) -> Iterator[Tuple[str, str]]:
         release.commit_file(session, ".", message=message)
 
 
+@nox.session
+def coverage(session: nox.Session) -> None:
+    if not os.path.exists("./.coverage-output"):
+        os.mkdir("./.coverage-output")
+    session.run(
+        "pytest",
+        "--cov=pip",
+        "--cov-config=./setup.cfg",
+        env={
+            "COVERAGE_OUTPUT_DIR": "./.coverage-output",
+            "COVERAGE_PROCESS_START": "./setup.cfg",
+        },
+    )
+
+
 # -----------------------------------------------------------------------------
 # Release Commands
 # -----------------------------------------------------------------------------


Test patch: