@@ -178,6 +178,7 @@ def cover(session):
178178@nox .session (python = PYTHON_DEFAULT_VERSION )
179179def build (session ):
180180 """Build the distribution."""
181+ session .run ('rm' , '-rf' , 'build' , 'dist' , external = True )
181182 session .run ('uv' , 'build' , external = True )
182183
183184 # Set outputs for GitHub Actions
@@ -190,6 +191,32 @@ def build(session):
190191 version = os .environ ['GITHUB_REF' ].replace ('refs/tags/v' , '' )
191192 print (f'version={ version } ' , file = github_output )
192193
194+ sdists = sorted (pathlib .Path ('dist' ).glob ('b2sdk-*.tar.gz' ))
195+ if len (sdists ) != 1 :
196+ session .error (f'Expected exactly one source distribution, found { len (sdists )} : { sdists !r} ' )
197+
198+ session .install (str (sdists [0 ]))
199+ session .cd ('dist' ) # avoid importing from the checkout instead of the built package
200+ session .run (
201+ 'python' ,
202+ '-c' ,
203+ (
204+ 'import pathlib; '
205+ 'from b2sdk import v0, v1, v2, v3; '
206+ 'repo_root = pathlib.Path.cwd().parent.resolve(); '
207+ 'source_root = repo_root / "b2sdk"; '
208+ "module_files = {'v0': pathlib.Path(v0.__file__).resolve(), "
209+ "'v1': pathlib.Path(v1.__file__).resolve(), "
210+ "'v2': pathlib.Path(v2.__file__).resolve(), "
211+ "'v3': pathlib.Path(v3.__file__).resolve()}; "
212+ 'print(module_files); '
213+ "assert all(not path.is_relative_to(source_root) for path in module_files.values()), "
214+ "f'Imported modules from checkout: {module_files!r}'; "
215+ "assert all('site-packages' in path.parts for path in module_files.values()), "
216+ "f'Imported modules from an unexpected location: {module_files!r}'"
217+ ),
218+ )
219+
193220
194221@nox .session (python = PYTHON_DEFAULT_VERSION )
195222def doc (session ):
0 commit comments