From 309c46d4cbcc07318e1f4a68adac9bdaaaf7d533 Mon Sep 17 00:00:00 2001
From: Pawel Polewicz
Date: Thu, 21 May 2026 15:46:40 +0000
Subject: [PATCH 1/3] Test built sdist imports in nox build session
---
noxfile.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/noxfile.py b/noxfile.py
index 4458bf30..ed374417 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -178,6 +178,7 @@ def cover(session):
@nox.session(python=PYTHON_DEFAULT_VERSION)
def build(session):
"""Build the distribution."""
+ session.run('rm', '-rf', 'build', 'dist', external=True)
session.run('uv', 'build', external=True)
# Set outputs for GitHub Actions
@@ -190,6 +191,14 @@ def build(session):
version = os.environ['GITHUB_REF'].replace('refs/tags/v', '')
print(f'version={version}', file=github_output)
+ sdists = sorted(pathlib.Path('dist').glob('b2sdk-*.tar.gz'))
+ if len(sdists) != 1:
+ session.error(f'Expected exactly one source distribution, found {len(sdists)}: {sdists!r}')
+
+ session.install(str(sdists[0]))
+ session.cd('dist') # avoid importing from the checkout instead of the built package
+ session.run('python', '-c', 'from b2sdk import v0, v1, v2, v3')
+
@nox.session(python=PYTHON_DEFAULT_VERSION)
def doc(session):
From 72d92026a47b2b4314fa8a9a187c272a5fa0d3bf Mon Sep 17 00:00:00 2001
From: Pawel Polewicz
Date: Thu, 21 May 2026 15:51:55 +0000
Subject: [PATCH 2/3] Add changelog entry for import smoke test
---
changelog.d/+built-sdist-import-check.infrastructure.md | 1 +
1 file changed, 1 insertion(+)
create mode 100644 changelog.d/+built-sdist-import-check.infrastructure.md
diff --git a/changelog.d/+built-sdist-import-check.infrastructure.md b/changelog.d/+built-sdist-import-check.infrastructure.md
new file mode 100644
index 00000000..ba7469b9
--- /dev/null
+++ b/changelog.d/+built-sdist-import-check.infrastructure.md
@@ -0,0 +1 @@
+Add a build-time smoke test that installs the freshly built source distribution and imports the public API shims.
From 2fabc9dc962203ad0c8d2cffe95725539938744f Mon Sep 17 00:00:00 2001
From: Pawel Polewicz
Date: Thu, 21 May 2026 16:34:29 +0000
Subject: [PATCH 3/3] Assert built-package imports come from site-packages
---
noxfile.py | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/noxfile.py b/noxfile.py
index ed374417..fedc60dd 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -197,7 +197,25 @@ def build(session):
session.install(str(sdists[0]))
session.cd('dist') # avoid importing from the checkout instead of the built package
- session.run('python', '-c', 'from b2sdk import v0, v1, v2, v3')
+ session.run(
+ 'python',
+ '-c',
+ (
+ 'import pathlib; '
+ 'from b2sdk import v0, v1, v2, v3; '
+ 'repo_root = pathlib.Path.cwd().parent.resolve(); '
+ 'source_root = repo_root / "b2sdk"; '
+ "module_files = {'v0': pathlib.Path(v0.__file__).resolve(), "
+ "'v1': pathlib.Path(v1.__file__).resolve(), "
+ "'v2': pathlib.Path(v2.__file__).resolve(), "
+ "'v3': pathlib.Path(v3.__file__).resolve()}; "
+ 'print(module_files); '
+ "assert all(not path.is_relative_to(source_root) for path in module_files.values()), "
+ "f'Imported modules from checkout: {module_files!r}'; "
+ "assert all('site-packages' in path.parts for path in module_files.values()), "
+ "f'Imported modules from an unexpected location: {module_files!r}'"
+ ),
+ )
@nox.session(python=PYTHON_DEFAULT_VERSION)