Skip to content

feat: Add the ability to skip install of local source dependencies#3092

Merged
tdejager merged 26 commits intoprefix-dev:mainfrom
olivier-lacroix:feat/no-path-dep
Aug 5, 2025
Merged

feat: Add the ability to skip install of local source dependencies#3092
tdejager merged 26 commits intoprefix-dev:mainfrom
olivier-lacroix:feat/no-path-dep

Conversation

@olivier-lacroix
Copy link
Contributor

@olivier-lacroix olivier-lacroix commented Feb 9, 2025

Fixes #1652

This PR implements an additional --skip argument for pixi install, that will skip installation of packages

As this argument is intended to be used in cases where these local dependencies may be absent, we do not want to update the lockfile, and the use of --skip requires the "--frozen" argument.

With this PR, a dockerfile using pixi may look like

FROM python:3.12.2-slim

WORKDIR /app

COPY pixi.lock pixi.toml .

RUN pixi install --frozen --skip package-name

COPY sample-package . 

RUN pixi install --frozen

@olivier-lacroix olivier-lacroix changed the title Add the ability to skip install of local path dependencies feat: Add the ability to skip install of local path dependencies Feb 9, 2025
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.

Thanks @olivier-lacroix, would you be able to add a test to validate that this works for both conda and PyPI path dependencies. And add the CLI documentation?

@olivier-lacroix
Copy link
Contributor Author

Thanks @olivier-lacroix, would you be able to add a test to validate that this works for both conda and PyPI path dependencies. And add the CLI documentation?

Can do yes :-)

@olivier-lacroix
Copy link
Contributor Author

@ruben-arts what sort of test(s) do you think would be best? unit test(s) and/or integration tests?

@ruben-arts
Copy link
Contributor

For Pypi you might use the src/install_pypi/plan/test code. But for the full picture I would write an integration test. Please try to keep these fast, small packages from the local test data channels.

@olivier-lacroix
Copy link
Contributor Author

@ruben-arts integration test added. Let me know what you think.

@tdejager
Copy link
Contributor

tdejager commented Feb 19, 2025 via email

@olivier-lacroix
Copy link
Contributor Author

Yeah you are right that should be fine :) only skipping the folders then, I suppose. You would still want to install sdists from paths and direct urls right? Or do you want to skip those as well with the flag set?

I guess so. the intent is really to skip packages that are being developed.

Quick one, is there a straightforward way to know if a Utf8TypedPathBuf is a directory? not too sure how to convert this to a type that can tell me if its a directory, without going through strings, which, I assume, could be pretty brittle.

@tdejager
Copy link
Contributor

Utf8TypedPathBuf

I think as_std_path().is_dir(), does that work? Also, this does pivot the PR a bit but we could also have a --skip-install <pkg> that could skip the installation of any package, do you think that would make sense?

@olivier-lacroix
Copy link
Contributor Author

I think as_std_path().is_dir(), does that work?

That'd be nice, but this is available in the camino crate, not the typed-path crate that is in use here . I have based the logic on file extension: A location is deemed a 'local source' if it is a path that is NOT a wheel or an egg file

@olivier-lacroix
Copy link
Contributor Author

olivier-lacroix commented Feb 21, 2025

Alright, @tdejager @ruben-arts this PR is about ready to be merged I think.

@tdejager , a --skip flag could definitely be added if there is demand for it. Not sure what use cases there would be for ignoring a specific package though. I propose to defer adding this until some users ask for it? I created #3182 to track

I was not 100% happy with the flag name --no-path-dependencies, as local built artifact are not skipped, and switched to --skip-local-sources. this would make it consistent with a potential future --skip flag as well 😃 . Happy with that?

@olivier-lacroix olivier-lacroix changed the title feat: Add the ability to skip install of local path dependencies feat: Add the ability to skip install of local source dependencies Feb 22, 2025
@tdejager
Copy link
Contributor

Hey @olivier-lacroix, @ruben-arts and myself have been discussing this PR offline just now, and we wanted to report back. So while we do think the idea is good there are a couple of things, also because of my suggestion that do not work out. So supposing you still want to skip development dependencies:

  1. I wrongly suggested as_source as that also includes git dependencies that you do want to include in the initial layering.
  2. I think you also still want to include the sdists that would not be excluded, e.g: .zip, .tar.gz and maybe other extensions as well: https://github.com/astral-sh/uv/blob/f9c1684b96d1b3a88c4d1f4adb4db5e018a7d54f/crates/uv-distribution-filename/src/extension.rs#L29

Additionally, @ruben-arts and I discussed that we think that a general --skip makes more sense, as it would simplify some of the logic and you would need to be very explicit what you skip.

We are really sorry about the tardiness regarding this PR, and totally understand that it would be to much work to change this so happy to take this over from you if you do not want to make the change.

@olivier-lacroix
Copy link
Contributor Author

Alright, I

  • removed the --skip for reinstall, this can be added later if needed.
  • added the conda test

this PR should be good to go I think @tdejager

Copy link
Contributor

@tdejager tdejager left a comment

Choose a reason for hiding this comment

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

Nice! User tested it a bit and it all seems to work. One final thing I would like to see, if thats possible is that we give a warning and do not change the installation method if a non-existing name has been added.

Now currently if we make a typo - z in clickz:

 pixi i --frozen --skip clickz                                                                                                                                                                                                    
✔ The default environment has been installed excluding clickz.

Would be better if a tracing warn was printed and the excluding is removed.

Thanks!

@olivier-lacroix
Copy link
Contributor Author

Ok @tdejager . will do!

@olivier-lacroix
Copy link
Contributor Author

@tdejager hum, this isn't as straightforward as I thought 😓. My plan was to bubble up the call stack the packages that were actually skipped and report on that; but, if/when the cache is hit, we can't know this... any idea?

Copy link
Contributor

tdejager commented Aug 1, 2025

Would you be able to check the package names that are locked, even though that does not change we should have access about that. And I guess we don't even need to bubble up anymore.

@olivier-lacroix
Copy link
Contributor Author

Alright, hopefully getting there @tdejager 😅 .

I have:

  • Implemented a public method get_skipped_package_names that can test which packages in the lock file will be matched against a list of names, covering the cache hit case. Thanks for the suggestion!
  • Moved the filtering logic to the LockedPackageRef level (i.e. before specification into pypi or conda packages/records), which simplifies things a fair bit (I think).
  • Added a test and modified stdout / stderr output to cover your typo case.

Let me know what you think!

Copy link
Contributor

@tdejager tdejager left a comment

Choose a reason for hiding this comment

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

Looks good to me @olivier-lacroix, let's merge when the CI passes. As always, great work!

@tdejager
Copy link
Contributor

tdejager commented Aug 4, 2025

@pavelzw might be worth it to update the docker documentation, this might be useful for setting up correct layering.

@tdejager tdejager enabled auto-merge (squash) August 4, 2025 11:10
@olivier-lacroix
Copy link
Contributor Author

@ruben-arts this PR requires your approval to be merged.

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.

Thanks @olivier-lacroix !

@tdejager tdejager merged commit 1720903 into prefix-dev:main Aug 5, 2025
41 checks passed
KedoKudo added a commit to neutrons/python_project_template that referenced this pull request Jan 1, 2026
Work around the circular dependency between pixi lock files and dynamic
git-based versioning (versioningit). The issue:
- Lock file contains version computed from git state
- Committing lock file changes git state → version mismatch
- CI with --locked fails because versions don't match

Solution: Use pixi's --skip flag (added in v0.51.0) to skip the local
editable package during locked install, then install it separately
with pip. This preserves lock file integrity for all external deps
while allowing the local package version to float.

Also added documentation in README explaining the issue and solution
for future reference.

See: prefix-dev/pixi#3092

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:install Related to pixi install enhancement New features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Facilitate docker 'layering'

4 participants