Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It is... but basically it need to remember which groups are sync'd. For example if you use an extra, you have to keep track of it constantly because sync thrashes around between states all the time unless you play close and tedious attention. At least I haven't figured out how to make it remember which extras are "active".

    uv sync --extra gpu
    uv add matplotlib # the sync this runs undoes the --extra gpu
    uv sync # oops also undoes all the --extra
What you have to do to avoid this is to remember to use --no-sync all the time and then meticulously manually sync while remembering all the extras that I do actually currently want:

    uv sync --extra gpu --extra foo --extra bar
    uv add --no-sync matplotlib
    uv sync --extra gpu --extra foo --extra bar
It's just so... tedious and kludgy. It needs an "extras.lock" or "sync.lock" or something. I would love it if someone tells me I'm wrong and missing something obvious in the docs.


To make the change in your environment:

1. Create or edit the UV configuration file in one of these locations:

- `~/.config/uv/config.toml` (Linux/macOS)

- `%APPDATA%\uv\config.toml` (Windows)

2. Add a section for default groups to sync:

```toml

[sync]

include-groups = ["dev", "test", "docs"] # Replace with your desired group names

```

Alternatively, you can do something similar in pyproject.toml if you want to apply this to the repo:

```toml

[tool.uv]

sync.include-groups = ["dev", "test", "docs"] # Replace with your desired group names

```


Thank you! That's good to know. Unfortunately it doesn't seem to work for "extras". There may be some target other than sync.include-groups but I haven't found it yet.

What I am struggling with is what you get after following the Configuring Accelerators With Optional Dependencies example:

https://docs.astral.sh/uv/guides/integration/pytorch/#config...

Part of what that does is set up rules that prevent simultaneously installing cpu and gpu versions (which isn't possible). If you use the optional dependencies example pyproject.toml then this is what happens:

    $ uv sync --extra cpu --extra cu124
    Using CPython 3.12.7
    Creating virtual environment at: .venv
    Resolved 32 packages in 1.65s
    error: Extras `cpu` and `cu124` are incompatible with the declared conflicts: {`project[cpu]`, `project[cu124]`}
And if you remove the declared conflict, then uv ends up with two incompatible sources to install the same packages from

    uv sync --extra cpu --extra cu124
    error: Requirements contain conflicting indexes for package `torch` in all marker environments:
    - https://download.pytorch.org/whl/cpu
    - https://download.pytorch.org/whl/cu124
After your comment I initially thought that perhaps the extras might be rewritten as group dependencies somehow to use the ~/.config/uv/config.toml but according to the docs group dependencies are not allowed to have conflicts with each other and must be installable simultaneously (makes sense since there is an --all-groups flag). That is you must be able to install all group dependencies simultaneously.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: