Conversation
88e6d1a to
e9d7688
Compare
|
fyi @franred this is the PR I mentioned last week! |
ab51a17 to
3966699
Compare
3966699 to
6a70d14
Compare
There was a problem hiding this comment.
Pull request overview
This PR modernizes plotly.py’s packaging/build configuration by switching the Python build backend to hatchling, cleaning up legacy pyproject.toml sections, and tightening the JupyterLab extension build/versioning workflow to reduce CI drift and cross-platform build artifact differences.
Changes:
- Switch Python build backend from
setuptoolstohatchlingand remove legacy setuptools/jupyter-packaging config. - Align JupyterLab extension versions and stabilize webpack output across platforms.
- Add CI checks to keep Python and JS version numbers in sync and improve the JS build artifact comparison workflow.
Reviewed changes
Copilot reviewed 10 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
uv.lock |
Updates dev/dev-build deps away from the jupyter meta-package toward explicit jupyterlab pins. |
pyproject.toml |
Switches to hatchling and replaces packaging data/sharing configuration for the labextension. |
plotly/labextension/static/remoteEntry.*.js |
Updates committed prebuilt labextension artifacts (hash/version changes). |
plotly/labextension/static/*.LICENSE.txt |
Adds/updates bundled license output from the JS build. |
plotly/labextension/package.json |
Updates extension version and build metadata (including webpack config and new remoteEntry filename). |
js/webpack.config.js |
Forces stable webpack IDs/content hashing for cross-platform deterministic outputs. |
js/package.json |
Updates JS package version and points JupyterLab builder at the custom webpack config. |
js/package-lock.json |
Updates lockfile; currently shows a version mismatch vs js/package.json. |
js/install.json |
Simplifies install metadata intended for JupyterLab extension installation UX. |
RELEASE.md |
Adds release step to update js/package.json version. |
MANIFEST.in |
Removed as part of moving away from setuptools. |
.github/workflows/check-js-build.yml |
Adds version-sync check and tweaks the artifact-compare workflow; still uses deprecated setup-node@v2. |
Files not reviewed (1)
- js/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -18,7 +18,6 @@ maintainers = [ | |||
| { name="Emily Kellison-Linn", email="emily@plot.ly" } | |||
| ] | |||
| description = "An open-source interactive data visualization library for Python" | |||
| license = {file="LICENSE.txt"} | ||
| license = "MIT" | ||
| license-files = ["LICENSE.txt"] | ||
| version = "6.6.0" |
There was a problem hiding this comment.
Does uv have something similar to npm version? If so, maybe they have post script hooks, also like npm?
There was a problem hiding this comment.
Hatch itself has a whole system for build hooks which we could definitely make use of.
I started going down that path for compiling the JS artifacts (i.e., adding the npm run build step as a hook which would run every time the Python package was built) but the jupyter labextension build step is VERY slow (like 20-30 seconds) and it didn't seem easy to control whether it runs or not. Worth looking more into in the future though.
94c6afd to
00c264f
Compare
a89b4ae to
2434577
Compare
2434577 to
1a13239
Compare
Link to issue
Closes #5537
Description of change
setuptoolstohatchhatchis distributed by PyPA and has a number of advantages compared tosetuptools, including being newer and more modernpyproject.tomlconfig to work withhatch, and remove unused config sectionsMANIFEST.infile, since it's only required bysetuptools, not needed forhatchjs/package.jsonto reflect the correct version number matching plotly.py version, which we've forgotten to do for the last few releasesjs/webpack.config.jsto make lab extension build output identical across platforms, which fixes the false failure of the "Check JS build" workflowRELEASE.mdinstructions to add step to update version number injs/package.jsonjs/install.jsonfile which I believe are not neededNOTE: The build command remains the same:
python -m build .Demo
python-m-build.mov
When running
python -m build .locally, the output should look like the above.Testing strategy
I've added a CI step in
.github/workflows/check-js-build.ymlto check that the version number inpyproject.tomlmatches the version number injs/project.json, which should prevent the two from getting out of sync again.Show success case
Show failure case
However, we should verify manually that the resulting build is the same before and after these changes.
This can be done by checking out this branch, running
python -m build ., and comparing the.tar.gzand.whlfiles to the official 6.6.0 release artifacts.Additional information (optional)
Because we manually pre-build the assets for the JupyterLab extension (by running
npm run buildfrom thejs/directory, as documented in theCONTRIBUTING.md), we do not use any of thehatchbuild hooks settings in thepyproject.toml, so this PR removes them.The existing
.github/check-js-build.ymlstep builds the lab extension in CI and ensures that the output matches the build artifacts inplotly/labextension/.I don't like that this setup requires updating the version number in two places. But
package.jsondoesn't support dynamic version numbers, so the only way to set up a single source of truth would be for thepackage.jsonto be the single source of truth, andpyproject.tomlto load that version number dynamically. I don't like that for a Python project. But open to suggestions.Guidelines