-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate sdist by hand #2811
Generate sdist by hand #2811
Conversation
59c7597
to
afa3804
Compare
test_js failure looks familiar, I think it's a known flaky test In the sdist artifact, looks like the labextension is packaged as expected (just the one copy):
And the wheel artifact still has the one copy of the labextension, in the .data directory, as expected |
14832ea
to
a8b7bef
Compare
@@ -52,9 +52,12 @@ pyo3-build-config = "0.20.2" | |||
python-config-rs = "0.1.2" | |||
|
|||
[dependencies] | |||
# NOTE: when building from the git repo, these perspective-* dependencies are | |||
# overridden with path dependencies in .cargo/config.toml. This is done to | |||
# support the sdist, which doesn't include these packages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there may be pitfalls in doing it this way I'm not aware of, but it seemed less messy than patching the Cargo.toml file in the tarball.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the new test_python_sdist job in CI runs in a git checkout, the path directives in .cargo/config.toml will apply when that job builds the perspective-python crate (and wheel) from the sdist. That means in test_python_sdist, changes in the git repo to perspective-client and perspective-server which haven't yet been published to crates.io would be tested too. That's what we want, I think: CI tests coherent versions of perspective-client/perspective-server/perspective-python all from the same git commit, which previews how the release sdist will behave.
End users building from that same sdist artifact, if it's from between releases, would get a different result, instead building against the most recent release of the perspective-server and -client crates on crates.io. Workarounds for them would be to set up a .cargo/config.toml
(maybe one in ~? I don't know if pip's build isolation would defeat that) which uses paths pointing into a local perspective git clone. This is a (minor) downside of bundling only perspective-python's source in the sdist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, uh, I stand corrected. The sdist build in CI is downloading perspective-client and -server from crates.io https://github.com/tomjakubowski/perspective-oneoff-tests/actions/runs/11604564693/job/32313519748#step:8:187
I think that's because of pip's build isolation -- the build is happening in some other working directory, so Cargo doesn't find .cargo/config.toml
will want to adjust the CI job. I think, like I mentioned, setting it in $HOME/.cargo/config.toml
will work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option would be including a .cargo/config.toml
in the sdist which patches the perspective-server and perspective-client dependencies to use a git commit, something like:
[patch.crates-io]
perspective-client = { git = "https://github.com/finos/perspective.git", rev = "deadbeef" }
perspective-server = { git = "https://github.com/finos/perspective.git", rev = "deadbeef" }
where deadbeef
is the git commit SHA that CI ran on. We would want to avoid doing this when the job is run on a release tag, of course.
a8b7bef
to
5e94533
Compare
Did a manual run in my I think we probably want at least the option to test in CI that (1) installs from the sdist (2) runs the pytest test suite on the installed package (3) verifies that the labextension is listed in |
Another CI job with a diff of the sdist from this branch compared to the 3.1.2 sdist on pypi: https://github.com/tomjakubowski/perspective-oneoff-tests/actions/runs/11585843746/job/32255425110 link to diff artifact https://github.com/tomjakubowski/perspective-oneoff-tests/actions/runs/11585843746/artifacts/2120979686 One thing that stood out is that the sdist has lost the |
const readme_md = fs.readFileSync("./README.md"); | ||
const pkg_info = generatePkgInfo(pyproject, cargo, readme_md); | ||
fs.writeFileSync("./PKG-INFO", pkg_info); | ||
const include_paths = Array.from(cargo["package"]["include"]).concat([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is excluding some files from the perspective
Python folder that are otherwise added by Maturin, like test arrows
https://github.com/PyO3/maturin/blob/main/src/source_distribution.rs#L624-L646
will port that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
decided against porting, instead I just expanded the set of files included with the crate in Cargo.toml
. that way is more explicit and it's less code, to boot
This updates the perspective-python build to create an sdist tarball by hand, not going through `maturin sdist`. This bypasses some issues we have seen with Maturin mispackaging the perspective Cargo workspace in the sdist. Maturin is still used as the `build-backend` to build a wheel from the sdist. CI still uses `maturin build` to build wheels. Local development builds still use `maturin develop`. The sdist now includes the .data directory so that Maturin will place it in the wheel correctly. Building an sdist with PSP_BUILD_SDIST=1 will now error if it appears the jupyterlab plugin was not built into the .data directory. Most of the work is in generating a PKG-INFO file. Its output matches what's in the 3.1.2 sdist on pypi, minus a correction to fix the `Home-page` field miscapitalized by Maturin and some unimportant whitespace changes in `Require-Dist`. Signed-off-by: Tom Jakubowski <tom@prospective.dev>
2667962
to
84c32e5
Compare
Superceed by #2817 |
This updates the perspective-python build to create an sdist tarball by
hand, not going through
maturin sdist
. This bypasses some issues wehave seen with Maturin mispackaging the perspective Cargo workspace in
the sdist.
Maturin is still used as the
build-backend
to build a wheel from thesdist. CI still uses
maturin build
to build wheels. Localdevelopment builds still use
maturin develop
.The sdist now includes the .data directory so that Maturin will place it
in the wheel correctly. Building an sdist with PSP_BUILD_SDIST=1 will
now error if it appears the jupyterlab plugin was not built into the
.data directory.
Most of the work is in generating a PKG-INFO file. Its output matches
what's in the 3.1.2 sdist on pypi, minus a correction to fix the
Home-page
field miscapitalized by Maturin and some unimportantwhitespace changes in
Require-Dist
.Pull Request Checklist
Discussions, this PR applies to. (N/A)