In a monorepo, different projects often need different versions of the same package. One team is ready to upgrade Django; others aren’t. A library needs to be validated against the current version and the next one at the same time.Documentation Index
Fetch the complete documentation index at: https://docs.aspect.build/llms.txt
Use this file to discover all available pages before exploring further.
uv named dependency configurations are the right tool for this. By defining multiple [dependency-groups] in your pyproject.toml, you get separate, independently resolved sets of packages that Bazel can switch between with a single flag.
Conflicting dependency versions
When two dependency groups require incompatible versions of the same package,uv can resolve them independently using the conflicts key in pyproject.toml. This lets both groups coexist in a single uv.lock without either one compromising the other.
Suppose you want to validate your library against packaging==21.3 and packaging==24.0 at the same time:
uv resolves both groups independently and records both sets of pins in uv.lock. In Bazel, each group becomes a named venv. Individual targets opt into either:
Gradual monorepo upgrades
The same pattern works for managing incremental upgrades across a large codebase. Definecurrent and next configurations, declare them as conflicting, and set current as the default in .bazelrc:
next, update .bazelrc to point at next, then clean up the old group. This completes the upgrade without requiring a simultaneous migration of all targets.
Virtual dependencies
Virtual dependencies are a low-level escape hatch for cases where named configurations don’t apply. They let apy_library declare a dependency by name without pinning a version, leaving the resolution to each py_binary or py_test that uses the library.
Prefer named dependency configurations for monorepo-wide version management. Reach for virtual dependencies only when you need an extremely targeted override with no better option.
Any
py_binary or py_test that transitively depends on a py_library with virtual_deps must use the aspect_rules_py load, not rules_python.Step 1: Declare a virtual dependency in a library
Usevirtual_deps instead of deps to declare the dependency by name only:

