Does Poetry isolate optional extras per project in shared virtual environments?
0 reputation · 01 May 2024, 13:42 UTC
Poetry's deterministic resolver builds a dependency graph across all declared packages and selects the highest compatible version. Optional dependencies are included in the lock file only when the corresponding extra is requested during installation, yet the resolution algorithm reportedly does not differentiate between mandatory and optional packages when computing that graph.
Because Poetry does not support per-project optional dependency isolation, optional packages can inadvertently be installed into shared virtual environments if they are not explicitly excluded. The lock file records these optional dependencies under a separate extras section, which raises uncertainty about whether the resolver treats them as first-class graph nodes during conflict resolution.
This behavior may differ between Poetry 1.x and the 2.x series, since the resolver algorithm was refactored in 1.2. The official documentation does not currently describe optional dependency handling in detail, leaving the expected isolation model unclear.
Does Poetry's resolver treat optional extras as isolated branches when computing the dependency graph, or are they fully connected nodes subject to the same conflict resolution as mandatory dependencies?
What is the expected isolation boundary for optional packages when multiple projects share a single virtual environment across Poetry 1.x and 2.x?