Skip to content

Commit 545aa22

Browse files
surbinacursoragent
andauthored
Missing python build assets (#835)
### Changelog Fixes a bug where the `widget.js` static asset was missing from Python library builds, restoring Jupyter notebook integration. ### Docs None ### Description This PR addresses bug ERT-1463, where the `widget.js` static asset was missing from Python builds, specifically when wheels were built from the sdist artifact. This resulted in broken Jupyter notebook functionality for the `foxglove-sdk` Python library. The root cause was identified as: 1. An incorrect `tool.maturin.include` path in `pyproject.toml` that no longer matched the actual location of the generated `widget.js` file, causing it to be excluded from the sdist. 2. The `custom_build.py` script used `assert` statements, which could be skipped in CI environments running Python with optimizations, allowing builds to succeed even when the asset was not generated or found. This PR implements the following changes to resolve the issue and prevent future regressions: * **Corrected `maturin` include path**: The `pyproject.toml` has been updated to `python/foxglove/notebook/static/*` to correctly include `widget.js` in the sdist. * **Robust asset existence check**: The `assert` in `custom_build.py` has been replaced with `raise FileNotFoundError` to ensure that the build fails reliably if `widget.js` is not present, regardless of Python optimization settings. * **CI sdist validation**: A new step has been added to the `python.yml` workflow to explicitly verify that the generated sdist artifact contains the `widget.js` file, providing an early warning if the asset is missing from the package. These changes ensure that the Python library is correctly packaged with all necessary static assets, restoring full functionality for Jupyter notebook users, and adding a robust safeguard against similar issues in the future. <!-- In addition to unit tests, describe any manual testing you did to validate this change. Agents should instead insert a TODO list of manual testing steps for reviewers, if any are necessary. --> CI will validate the sdist contents with the newly added check. Reviewers can manually verify by building the sdist locally and inspecting its contents. <table><tr><th>Before</th><th>After</th></tr><tr><td> <!-- Screenshot or visual demonstration of the old behavior --> Build does not include static assets: <img width="376" height="349" alt="Screenshot 2026-01-23 at 12 48 55" src="https://github.com/user-attachments/assets/e575cfed-7cf0-4e2a-b6b5-87823c85f77d" /> </td><td> <!-- Screenshot or visual demonstration of the new behavior --> Build includes static assets: <img width="368" height="377" alt="Screenshot 2026-01-23 at 12 51 09" src="https://github.com/user-attachments/assets/1ab05699-1977-4893-b663-f1556d6da239" /> </td></tr></table> Fixes: [ERT-1463](https://linear.app/foxglove/issue/ERT-1463) --- <a href="https://cursor.com/background-agent?bcId=bc-def95794-4a20-48eb-af7a-9e7be3f6dfc2"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-cursor-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-cursor-light.svg"><img alt="Open in Cursor" src="https://cursor.com/open-in-cursor.svg"></picture></a>&nbsp;<a href="https://cursor.com/agents?id=bc-def95794-4a20-48eb-af7a-9e7be3f6dfc2"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-web-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-web-light.svg"><img alt="Open in Web" src="https://cursor.com/open-in-web.svg"></picture></a> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 3b6f12f commit 545aa22

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

.github/workflows/python.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,26 @@ jobs:
333333
- name: Build sdist
334334
run: uv build --sdist
335335
working-directory: python/foxglove-sdk
336+
- name: Verify notebook widget asset in sdist
337+
run: |
338+
python - <<'PY'
339+
import glob
340+
import sys
341+
import tarfile
342+
343+
paths = glob.glob("dist/foxglove_sdk-*.tar.gz")
344+
if not paths:
345+
sys.exit("No sdist artifact found to validate in dist/")
346+
347+
tar_path = paths[0]
348+
expected_suffix = "python/foxglove/notebook/static/widget.js"
349+
with tarfile.open(tar_path, "r:gz") as tar:
350+
names = tar.getnames()
351+
352+
if not any(name.endswith(expected_suffix) for name in names):
353+
sys.exit(f"Missing {expected_suffix} in {tar_path}")
354+
PY
355+
working-directory: python/foxglove-sdk
336356
- name: Upload sdist
337357
uses: actions/upload-artifact@v6
338358
with:

python/foxglove-sdk/custom_build.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
def _assert_frontend_targets_exist() -> None:
2727
for target in FRONTEND_TARGETS:
2828
path = Path.cwd() / target
29-
assert path.exists(), f"{target} not found"
29+
if not path.exists():
30+
raise FileNotFoundError(f"{target} not found")
3031

3132

3233
def _frontend_codegen(editable: bool = False) -> None:

python/foxglove-sdk/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ include = [
4848
# Custom build backend, required for building from sdist.
4949
{ path = "custom_build.py", format = ["sdist"] },
5050
# Include Jupyter widget static assets
51-
"foxglove/notebook/static/*",
51+
"python/foxglove/notebook/static/*",
5252
]
5353
jupyterlab = "^4.4.7"
5454

0 commit comments

Comments
 (0)