1919
2020UPSTREAM_REPO_URL = 'git@github.com:Backblaze/b2-sdk-python.git'
2121
22- # Required for PDM to use nox's virtualenvs
23- os .environ .update ({'PDM_IGNORE_SAVED_PYTHON' : '1' })
24-
2522CI = os .environ .get ('CI' ) is not None
2623NOX_PYTHONS = os .environ .get ('NOX_PYTHONS' )
2724_NOX_EXTRAS = os .environ .get ('NOX_EXTRAS' )
@@ -59,20 +56,27 @@ def _detect_python_nox_id() -> str:
5956
6057PY_PATHS = ['b2sdk' , 'test' , 'noxfile.py' ]
6158
62- nox .options .reuse_existing_virtualenvs = True
59+ nox .options .default_venv_backend = 'uv'
60+ nox .options .reuse_existing_virtualenvs = False
6361nox .options .sessions = [
6462 'lint' ,
6563 'test' ,
6664]
6765
6866
69- def pdm_install (session : nox .Session , * args : str , dev : bool = True ) -> None :
70- # dev dependencies are installed by default
71- prod_args = [] if dev else ['--prod' ]
72- group_args = []
73- for group in args :
74- group_args .extend (['--group' , group ])
75- session .run ('pdm' , 'install' , * prod_args , * group_args , external = True )
67+ def uv_install (
68+ session : nox .Session , * , groups : tuple [str , ...] = (), extras : tuple [str , ...] = ()
69+ ) -> None :
70+ args = ['sync' , '--locked' ]
71+ for group in groups :
72+ if group :
73+ args .extend (['--group' , group ])
74+ for extra in extras :
75+ if extra :
76+ args .extend (['--extra' , extra ])
77+ uv_env = getattr (session .virtualenv , 'location' , os .getenv ('VIRTUAL_ENV' ))
78+
79+ session .run_install ('uv' , * args , env = {'UV_PROJECT_ENVIRONMENT' : uv_env })
7680
7781
7882def skip_coverage (python_version : str | None ) -> bool :
@@ -82,7 +86,7 @@ def skip_coverage(python_version: str | None) -> bool:
8286@nox .session (name = 'format' , python = PYTHON_DEFAULT_VERSION )
8387def format_ (session ):
8488 """Lint the code and apply fixes in-place whenever possible."""
85- pdm_install (session , 'lint' )
89+ uv_install (session , groups = ( 'format' ,) )
8690 session .run ('ruff' , 'check' , '--fix' , * PY_PATHS )
8791 session .run ('ruff' , 'format' , * PY_PATHS )
8892 # session.run(
@@ -99,7 +103,7 @@ def format_(session):
99103def lint (session ):
100104 """Run linters in readonly mode."""
101105 # We need to install 'doc' group because liccheck needs to inspect it.
102- pdm_install (session , 'doc' , 'lint' , 'full' )
106+ uv_install (session , groups = ( 'doc' , 'lint' ), extras = ( 'full' ,) )
103107 session .run ('ruff' , 'check' , * PY_PATHS )
104108 session .run ('ruff' , 'format' , * PY_PATHS )
105109 # session.run(
@@ -114,15 +118,12 @@ def lint(session):
114118 session .run ('pytest' , 'test/static' )
115119 session .run ('liccheck' , '-s' , 'pyproject.toml' )
116120
117- # Check if the lockfile is up to date
118- session .run ('pdm' , 'lock' , '--check' , external = True )
119-
120121
121122@nox .session (python = PYTHON_VERSIONS )
122123@nox .parametrize ('extras' , NOX_EXTRAS )
123124def unit (session , extras ):
124125 """Run unit tests."""
125- pdm_install (session , 'test' , * extras )
126+ uv_install (session , groups = ( 'test' ,), extras = tuple ( extras ) )
126127 args = ['--doctest-modules' , '-n' , 'auto' ]
127128 if not skip_coverage (session .python ):
128129 args += ['--cov=b2sdk' , '--cov-branch' , '--cov-report=xml' ]
@@ -142,14 +143,14 @@ def unit(session, extras):
142143@nox .parametrize ('extras' , NOX_EXTRAS )
143144def integration (session , extras ):
144145 """Run integration tests."""
145- pdm_install (session , 'test' , * extras )
146+ uv_install (session , groups = ( 'test' ,), extras = tuple ( extras ) )
146147 session .run ('pytest' , '-s' , * session .posargs , 'test/integration' )
147148
148149
149150@nox .session (python = PYTHON_DEFAULT_VERSION )
150151def cleanup_old_buckets (session ):
151152 """Remove buckets from previous test runs."""
152- pdm_install (session , 'test' )
153+ uv_install (session , groups = ( 'test' ,) )
153154 session .run ('python' , '-m' , 'test.integration.cleanup_buckets' )
154155
155156
@@ -167,15 +168,15 @@ def test(session):
167168@nox .session
168169def cover (session ):
169170 """Perform coverage analysis."""
170- pdm_install (session , 'test' )
171+ uv_install (session , groups = ( 'test' ,) )
171172 session .run ('coverage' , 'report' , '--fail-under=75' , '--show-missing' , '--skip-covered' )
172173 session .run ('coverage' , 'erase' )
173174
174175
175176@nox .session (python = PYTHON_DEFAULT_VERSION )
176177def build (session ):
177178 """Build the distribution."""
178- session .run ('pdm ' , 'build' , external = True )
179+ session .run ('uv ' , 'build' , external = True )
179180
180181 # Set outputs for GitHub Actions
181182 if CI :
@@ -191,7 +192,7 @@ def build(session):
191192@nox .session (python = PYTHON_DEFAULT_VERSION )
192193def doc (session ):
193194 """Build the documentation."""
194- pdm_install (session , 'doc' )
195+ uv_install (session , groups = ( 'doc' ,) )
195196 session .cd ('doc' )
196197 sphinx_args = ['-b' , 'html' , '-T' , '-W' , 'source' , 'build/html' ]
197198 session .run ('rm' , '-rf' , 'build' , external = True )
@@ -216,7 +217,7 @@ def doc(session):
216217@nox .session
217218def doc_cover (session ):
218219 """Perform coverage analysis for the documentation."""
219- pdm_install (session , 'doc' )
220+ uv_install (session , groups = ( 'doc' ,) )
220221 session .cd ('doc' )
221222 sphinx_args = ['-b' , 'coverage' , '-T' , '-W' , 'source' , 'build/coverage' ]
222223 report_file = 'build/coverage/python.txt'
@@ -253,7 +254,7 @@ def make_release_commit(session):
253254 if current_branch != 'master' :
254255 session .log ('WARNING: releasing from a branch different than master' )
255256
256- pdm_install (session , 'release' )
257+ uv_install (session , groups = ( 'release' ,) )
257258 session .run ('towncrier' , 'build' , '--yes' , '--version' , version )
258259
259260 session .log (
0 commit comments