Skip to content
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

Add constraints to limit dependency versions #3278

Open
pavelzw opened this issue Mar 5, 2025 · 1 comment
Open

Add constraints to limit dependency versions #3278

pavelzw opened this issue Mar 5, 2025 · 1 comment
Labels
✨ enhancement Feature request

Comments

@pavelzw
Copy link
Contributor

pavelzw commented Mar 5, 2025

Problem description

It would be cool if we were able to add constraints in pixi.toml as well without needing to install them

[dependencies]
numpy = "*"

[constraints]
abc = "<5"

In this scenario, if abc is added to the env, we get abc<5.

@Hofer-Julian Hofer-Julian added the ✨ enhancement Feature request label Mar 5, 2025
@bollwyvl
Copy link
Contributor

Likely implied, but I would assume this would work for features as well.

I've presently been doing this via dedicated full dependency-only features that provide refinements e.g.

feature.run.dependencies.python = ">=3.9"
feature.run-oldest.dependencies.python = "3.9.*"
# the same for other factors

I guess an feature.oldest.constraints would allow all of those (even unrelated ones) to be stored together, and only impact the solve when needed.

Semi-related for the common case of minimum dependencies: another way to avoid extra specs that need to be kept in check fattening up [environments.*.features] with strategy:

[feature.py.dependencies]
python = ">=3.9"

[feature.test.dependencies]
pytest = ">=7"

[environments]
test = {features = ["py", "test"] }
test-oldest = {features = [
  {name = "py", strategy = "lowest"},
  {name = "test", strategy = "lowest-direct"},
]}

This would start to get crazy with solve-group, but it was already crazy.

As for export: I don't think environment.yml would be able to support this at all, as it doesn't expose an equivalent to run_constraints or run_constrained. pip would need a second file, though it could be specified inline with a second file e.g. -c env_platform_pip-constraints.txt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement Feature request
Projects
None yet
Development

No branches or pull requests

3 participants