Skip to content

Conversation

@tdejager
Copy link
Contributor

@tdejager tdejager commented Nov 3, 2025

This adds the SourceCodeLocation struct that holds both the location of the manifest and the potential build-source, which is generally the actual source-code itself.

E.g given this pixi.toml (imagine it being part of a workspace with a pixi.toml):

workspace/proj/pixi.toml

[package]
source = "./bar"

Then we get:

  • manifest_source = workspace/proj
  • build_source = ./bar

Which when called using the source_code() method gives you: workspace/proj/bar, in this specific case.

We can use this structure when to pass around and decide if we need the location to the manifest, or to the source code. Like when caching we need to check the source code to see if we need to do rebuilds. For example, in my plotjugger PR constant rebuilds would occur: facontidavide/PlotJuggler#1201. This PR also fixes that behavior.

AI Disclosure

  • I found and fixed the bug as well as create the SourceCodeLocation, I let codex then propagate that struct throughout the codebase.

///
/// This is useful for the case where you want to checkout a source that is at
/// different location than the manifest, most obviously in an out-of-tree build.
pub async fn checkout_source_location(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use this method when wanting to check out the actual source.

Comment on lines 651 to 663
alternative_root: Option<PinnedSourceSpec>,
) -> Result<SourceCheckout, CommandDispatcherError<SourceCheckoutError>> {
match pinned_spec {
PinnedSourceSpec::Path(ref path) => {
PinnedSourceSpec::Path(path_spec) => {
let alternative_root_path = match alternative_root.as_ref() {
Some(PinnedSourceSpec::Path(alt_path)) => Some(
self.data
.resolve_typed_path(alt_path.path.to_path(), None)
.map_err(|e| CommandDispatcherError::Failed(e.into()))?,
),
_ => None,
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This basically fixes the PlotJuggler bug, because code will be checked relative to the package manifest instead of the workspace manifest.

@tdejager tdejager changed the title fix: use type to better capture cache data fix: better out-of source caching and source code propagation Nov 3, 2025
Copy link
Contributor

@remimimimimi remimimimimi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crazy good, code looks much better now! Just couple of comments.

@lucascolley lucascolley added the bug Something isn't working label Nov 3, 2025
match pinned_spec {
PinnedSourceSpec::Path(ref path) => {
PinnedSourceSpec::Path(path_spec) => {
let alternative_root_path = match alternative_root.as_ref() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be replaced with SourceAnchor! Its purpose is to make one sourcespec relative to another.

You can also have a git source with a subdirectory for instance. I dont think the current implementation deals with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it does because there is a test for it, in the build suite and that will never be interpreted as relative.

But I didn't know that had that purpose, should I make the change and also update SourceAnchor documentation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please! If you dont have time I can also do it!

@baszalmstra
Copy link
Contributor

I changed the code significantly. I'm trying to make sure that the pinned build_source_spec is always completely resolved and doesn't depend on the manifest_source anymore. That way, when dealing with a pinned build_source_spec, we can just use it as is without having to convert it in different locations.

@tdejager What is the best way to test this?

@tdejager
Copy link
Contributor Author

tdejager commented Nov 4, 2025

There was a PR on the suite I made: prefix-dev/pixi-build-testsuite#91

And for a real-world test you can try my PR on PlotJuggler. Can find the link if you want but I'm on mobile.

Note that there are also some unit test in pixi that test parts of this, but does not call any builds.

@baszalmstra
Copy link
Contributor

I changed the code to always make the source_build PinnedSourceSpec relative to the workspace instead of to some undefined root. This works well, but it looks very strange in the lockfile. If you have a git dependency which has a out-of-source build the entire git url is repeated in the package_build_source field. I think it makes sense to store the path relative to the location only in the lock-file.

@tdejager
Copy link
Contributor Author

tdejager commented Nov 4, 2025

I looked at the changes :) is now the preferred_source an alternative to the build_source or is it only used for the pinning during a pixi update?

Comment on lines 127 to 129
/// TODO: Currently this doesn't use workspace_root and just resolves build_source
/// relative to manifest_source. Future implementation should resolve both against
/// workspace_root first.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs implementing. The idea is: PinnedSourceSpec is always relative to the workspace root. But the build_source in the lock-file is relative to the location of the package. We need to convert these two. My reasoning was that this can only reliably be done if all relative paths have a base so you can compare apples to apples. The workspace_root should provide this base.

Comment on lines 62 to 64
/// TODO: Currently this doesn't use workspace_root and just makes build_source
/// relative to manifest_source. Future implementation should make both relative
/// to workspace_root first.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs to happen. See my other comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants