Skip to content

feat: add the option for multiple --only flags.#4477

Merged
ruben-arts merged 4 commits intoprefix-dev:mainfrom
tdejager:feat/multiple-only
Sep 1, 2025
Merged

feat: add the option for multiple --only flags.#4477
ruben-arts merged 4 commits intoprefix-dev:mainfrom
tdejager:feat/multiple-only

Conversation

@tdejager
Copy link
Contributor

@tdejager tdejager commented Sep 1, 2025

This augments the abilities introduced in #4404, with the ability to do multiple --only, before only one --only flag was accepted. In the end the technical change for this was pretty easy, we just add multiple starting points to the reachability analysis instead of one single root. These will then all be iterated through at some point.

An additional thing that was added is a test to verify that pixi install --only a --skip-with-deps a skips the package. Something I felt was missing from the original test-suite.

Tested

  1. Added extra unit tests.
  2. User tested:
╰─ pixi-dev i --only click                                                                                                                                                                                                                         ─╯
✔ The default environment has been installed, including 17 packages excluding 6 other packages.
╰─ pixi-dev i --only flask --only click                                                                                                                                                                                                            ─╯
✔ The default environment has been installed, including 23 packages no packages were skipped (check if cli args were correct).
╰─ pixi-dev i --only click --only python                                                                                                                                                                                                           ─╯
✔ The default environment has been installed, including 17 packages excluding 6 other packages.
╰─ pixi-dev i --only click --skip python                                                                                                                                                                                                           ─╯
✔ The default environment has been installed, including 16 packages excluding 'python' and 7 other packages.
╰─ pixi-dev i --only click --skip-with-deps click                                                                                                                                                                                                  ─╯
✔ The default environment has been installed, including 0 packages excluding 'click' and 23 other packages.
╰─ pixi-dev i --only click --skip click                                                                                                                                                                                                            ─╯
✔ The default environment has been installed, including 16 packages excluding 'click' and 7 other packages.

For pixi.toml:

[workspace]
authors = ["Tim de Jager <tdejager89@gmail.com>"]
channels = ["https://prefix.dev/conda-forge"]
name = "test-py"
platforms = ["osx-arm64"]
version = "0.1.0"

[tasks]

[dependencies]
python = ">=3.13.5,<3.14"
click = ">=8.2.1,<9"

[pypi-dependencies]
flask = ">=3.1.2, <4"

@tdejager tdejager requested a review from ruben-arts September 1, 2025 08:27
@ruben-arts
Copy link
Contributor

➜ pixi i --only yaml-cpp-vendor # non existing
✔ The default environment has been installed, including 0 packages excluding 602 other packages.

This seems like it would need the warning of the mistake in the CLI.

@lucascolley
Copy link
Collaborator

➜ pixi i --only yaml-cpp-vendor # non existing
✔ The default environment has been installed, including 0 packages excluding 602 other packages.

This seems like it would need the warning of the mistake in the CLI.

I think that should error?

@tdejager
Copy link
Contributor Author

tdejager commented Sep 1, 2025

@lucascolley @ruben-arts I'd be fine, the only case I can think against it is that it is not really an error? As there is nothing wrong with it per se.

A reason could be that you might have a bash script that does a loop over environments that it installs, and then it would be annoying if this is an error. Thats the only thing I can think of.

Can I do this in a subsequent PR, as this is the behavior that is currently in main as well, and I dislike doing the changes in the same PR if can be avoided.

@lucascolley
Copy link
Collaborator

sure, happy for it to be a warning instead

@tdejager
Copy link
Contributor Author

tdejager commented Sep 1, 2025

Because this would result in a breaking change, made this into an error in this branch:

image

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 Tim!

@ruben-arts ruben-arts merged commit 034caa9 into prefix-dev:main Sep 1, 2025
41 checks passed
@imagejan
Copy link

imagejan commented Sep 3, 2025

✔ The default environment has been installed, including 16 packages excluding 'python' and 7 other packages.
╰─ pixi-dev i --only click --skip-with-deps click

It seems that the explicit exclusion (python) is included into the "other" count here?! I would have expected a total of 23 = 16 + python + 6 others

@tdejager
Copy link
Contributor Author

tdejager commented Sep 3, 2025

Yeah there is some special logic that Python is always included when targeting PyPI packages maybe something is off there.

This feature was a tad more complex than I initially envisioned 😅

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants