Skip to content

Conversation

@remimimimimi
Copy link
Contributor

@remimimimimi remimimimimi commented Aug 26, 2025

Add support for specifying a git source for the pixi build backend. As suggested, we now use pin_and_checkout for source fetching.

When source package is added to some environment its source will be pinned. Correspondingly pixi build won't update lock file.

Tests are added to pixi-build-testsuite here.

Still draft as it depends on rattler release.

Copy link
Collaborator

@lucascolley lucascolley left a comment

Choose a reason for hiding this comment

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

this looks great! Want to make a companion PR to pixi-build-testsuite?

lucascolley
lucascolley previously approved these changes Aug 29, 2025
Copy link
Contributor

@baszalmstra baszalmstra left a comment

Choose a reason for hiding this comment

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

I think we also need to add this to the lock file!

@remimimimimi
Copy link
Contributor Author

I think we also need to add this to the lock file!

So, I should change the lock file format to include sources as well, in a manner similar to how we currently store conda packages? Do you have any suggestions for implementing this? @baszalmstra

@baszalmstra
Copy link
Contributor

Yes essentially. But we can also do that in a follow up PR, there is more we should add to the lockfile, like the variants.

And/or we can only allow revs and not allow branch, tag or none.

Without the pinned source in the lockfile the changes that a package will break is pretty large.

@remimimimimi
Copy link
Contributor Author

Yes essentially. But we can also do that in a follow up PR, there is more we should add to the lockfile, like the variants.

And/or we can only allow revs and not allow branch, tag or none.

Without the pinned source in the lockfile the changes that a package will break is pretty large.

I'll allow only rev then.

@remimimimimi remimimimimi force-pushed the feat/pixi-build-git-source branch from 6644620 to 9ae74fc Compare August 29, 2025 09:27
@ruben-arts
Copy link
Contributor

Touching the rev gives these explosive errors:

examples/pixi-build/git-source on  feat/pixi-build-git-source [$?] 🧚  took 3s 
➜ pixi i
 WARN overriding build backend with system prefixed tools
ERROR Error fetching Git repository: Object ID can be at most 40 hex characters
Error:   × failed to build 'sdl_example' from '.'
  ╰─▶   × Object ID can be at most 40 hex characters
      

This should mention the rev, hopefully doing this error on parsing so we can point to the span with it.

examples/pixi-build/git-source on  feat/pixi-build-git-source [$?] 🧚  took 2s 
❯ pixi i
 WARN overriding build backend with system prefixed tools
ERROR Error fetching Git repository: failed to fetch https://github.com/prefix-dev/pixi-build-testsuite.git: fatal: couldn't find remote ref refs/tags/ee87916a49d5e96d4f32268c3s650e8ff6b8866b

Error:   × failed to build 'sdl_example' from '.'
  ╰─▶   × failed to fetch https://github.com/prefix-dev/pixi-build-testsuite.git: fatal: couldn't find remote ref refs/tags/ee87916a49d5e96d4f32268c3s650e8ff6b8866b
        │

This prints the error first in a tracing and after in the miette error. I would only do the miette error.

Toml used for testing:

[package.build.source]
git = "https://github.com/prefix-dev/pixi-build-testsuite.git"
rev = "ee87916a49d5e96d4f32268c3s650e8ff6b8866b"
subdirectory = "tests/data/pixi_build/cpp-with-path-to-source/project"

[package.build.backend]
channels = [
    "https://prefix.dev/pixi-build-backends",
    "https://prefix.dev/conda-forge",
]
name = "pixi-build-cmake"
version = "*"

[package]
name = "sdl_example"
version = "0.1.0"

[package.host-dependencies]
# This ensures that SDL2 is available at build time.
sdl2 = ">=2.26.5,<3.0"

[workspace]
channels = ["https://prefix.dev/conda-forge"]
platforms = ["osx-arm64"]
preview = ["pixi-build"]

[dependencies]
sdl_example = { path = "." }

@ruben-arts
Copy link
Contributor

Changing the rev doesn't trigger a new checkout of the project.

[package.build.source]
git = "https://github.com/prefix-dev/pixi.git"
rev = "1eec91ba3be59e93d487f61801882d05d6f76a6c"
#rev = "2e05115c55fd119b7296062d38081c57aa64fdeb"
subdirectory = "examples/pixi-build/cpp-sdl"

Switching these two revs should give you two different main.cpp files which should trigger a rebuild and reinstall.

It only triggered a rebuild but no refetch and reinstall.

@ruben-arts
Copy link
Contributor

I don't agree on merging this without the tag and branch. That is where this becomes really cool IMO.

I would expect the cargo workflow where the lockfile stores therev but the manifest allows for having only git or git with tag, branch or rev.

I would also like to have an example of this in theexamples/pixi-build as it's something I want to refer to more often.

Copy link
Contributor

@ruben-arts ruben-arts left a comment

Choose a reason for hiding this comment

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

Adding this to avoid accidental merging.

@lucascolley
Copy link
Collaborator

@remimimimimi could you resolve the merge conflict?

@lucascolley lucascolley changed the title feat: pixi build git source feat(build): git source Sep 8, 2025
@remimimimimi remimimimimi marked this pull request as draft September 8, 2025 11:33
@ruben-arts
Copy link
Contributor

The UX that I would like to have tested in integration test:

Assuming this manifest:

[package.build.source]
git = "url"
branch = "branch"

Generate the lockfile with:

pixi lock

Test that the correct rev is put in the lockfile

Run:

pixi install --locked

This should work and not error

Now update the branch in the manifest to a different one that points to a different commit.

Run:

pixi install --locked

This should error as the branch doesn't satisfy the lockfile

Run:

pixi lock

This should update the rev in the lockfile
Test that the correct rev is put in the lockfile

@remimimimimi remimimimimi force-pushed the feat/pixi-build-git-source branch 2 times, most recently from 419cc05 to 5510994 Compare September 16, 2025 13:29
@remimimimimi remimimimimi force-pushed the feat/pixi-build-git-source branch from 020cc8b to a98a259 Compare September 30, 2025 09:26
@ruben-arts
Copy link
Contributor

This looks good to me!

@remimimimimi remimimimimi force-pushed the feat/pixi-build-git-source branch from 8df0f72 to 3f8348e Compare October 7, 2025 14:13
@remimimimimi
Copy link
Contributor Author

@Hofer-Julian There here's are the parts of the PR that would help you to review it more easily:

  1. Passing value through: I may have overdone this because I rewrote things several times and might have forgot to remove something.
  2. Conversion between types here.
  3. Overriding required for lock file handling to work correctly with pixi build.
  4. Lock file invalidation.
  5. Tests from here and testsuite PR.

@remimimimimi remimimimimi force-pushed the feat/pixi-build-git-source branch from e9007c5 to 964da16 Compare October 23, 2025 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:build Related to pixi build enhancement New features git

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants