19
19
20
20
nox .options .reuse_existing_virtualenvs = True
21
21
nox .options .sessions = ["lint" ]
22
+ nox .needs_version = ">=2024.03.02" # for session.run_install()
22
23
23
24
LOCATIONS = {
24
25
"common-wheels" : "tests/data/common_wheels" ,
@@ -44,7 +45,9 @@ def run_with_protected_pip(session: nox.Session, *arguments: str) -> None:
44
45
env = {"VIRTUAL_ENV" : session .virtualenv .location }
45
46
46
47
command = ("python" , LOCATIONS ["protected-pip" ]) + arguments
47
- session .run (* command , env = env , silent = True )
48
+ # By using run_install(), these installation steps can be skipped when -R
49
+ # or --no-install is passed.
50
+ session .run_install (* command , env = env , silent = True )
48
51
49
52
50
53
def should_update_common_wheels () -> bool :
@@ -84,8 +87,13 @@ def test(session: nox.Session) -> None:
84
87
session .log (msg )
85
88
86
89
# Build source distribution
90
+ # HACK: we want to skip building and installing pip when nox's --no-install
91
+ # flag is given (to save time when running tests back to back with different
92
+ # arguments), but unfortunately nox does not expose this configuration state
93
+ # yet. https://github.com/wntrblm/nox/issues/710
94
+ no_install = "-R" in sys .argv or "--no-install" in sys .argv
87
95
sdist_dir = os .path .join (session .virtualenv .location , "sdist" )
88
- if os .path .exists (sdist_dir ):
96
+ if not no_install and os .path .exists (sdist_dir ):
89
97
shutil .rmtree (sdist_dir , ignore_errors = True )
90
98
91
99
run_with_protected_pip (session , "install" , "build" )
@@ -94,7 +102,7 @@ def test(session: nox.Session) -> None:
94
102
# pip, so uninstall pip to force build to provision a known good version of pip.
95
103
run_with_protected_pip (session , "uninstall" , "pip" , "-y" )
96
104
# fmt: off
97
- session .run (
105
+ session .run_install (
98
106
"python" , "-I" , "-m" , "build" , "--sdist" , "--outdir" , sdist_dir ,
99
107
silent = True ,
100
108
)
0 commit comments