Skip to content

refactor: move PyPI resolution and installation into the command dispatcher#6324

Open
wolfv wants to merge 3 commits into
mainfrom
claude/amazing-davinci-2k2j16
Open

refactor: move PyPI resolution and installation into the command dispatcher#6324
wolfv wants to merge 3 commits into
mainfrom
claude/amazing-davinci-2k2j16

Conversation

@wolfv

@wolfv wolfv commented Jun 10, 2026

Copy link
Copy Markdown
Member

Description

This PR refactors the PyPI resolution and installation pipelines to be driven through the CommandDispatcher, mirroring the existing architecture for conda package management. The changes improve separation of concerns and enable better code reuse across different pixi entry points (workspace, global, etc.).

Key changes:

  1. New command dispatcher modules:

    • solve_pypi.rs: Drives PyPI dependency resolution through SolvePypiEnvironmentSpec
    • install_pypi.rs: Drives PyPI package installation through InstallPypiEnvironmentSpec
  2. Extracted shared code:

    • Moved PypiPackageIdentifier from pixi_core to pixi_install_pypi for reuse across the codebase
    • Created new pixi_uv_reporter crate to share uv progress reporting logic (previously in pixi_reporters)
    • Moved CondaPrefixProvider trait and related types to pixi_install_pypi::resolve for workspace-agnostic resolution
  3. Workspace-side resolution support:

    • Introduced WorkspaceCondaPrefixProvider in pixi_core that implements the CondaPrefixProvider trait
    • This provides lazy instantiation of conda prefixes when source distributions need to be built during PyPI resolution
    • Replaces the previous tightly-coupled LazyBuildDispatch implementation
  4. Simplified PyPI update flow:

    • Replaced complex configuration object construction with a single InstallPypiEnvironmentSpec struct
    • Removed direct dependencies on pixi_install_pypi configuration types from pixi_core
    • Centralized link mode derivation in the command dispatcher
  5. Improved module organization:

    • Cleaned up imports and removed unused dependencies
    • Better documentation of module responsibilities
    • Reduced circular dependencies between crates

How Has This Been Tested?

Existing test suites should validate the refactoring:

  • The PyPI resolution and installation logic remains unchanged; only the calling convention has been refactored
  • Command dispatcher tests cover the new solve_pypi_environment and install_pypi_environment methods
  • Workspace lock file update tests exercise the full pipeline through the new interfaces

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • Changes maintain backward compatibility through the command dispatcher interface

https://claude.ai/code/session_01S4nY8g4frki9JvtuUnZm85

claude added 3 commits June 10, 2026 06:00
Add an install-pypi operation to the CommandDispatcher so that PyPI
packages can be installed into a conda prefix through the same handle
that already drives conda solves and installs. This makes the PyPI
install pipeline reusable outside the workspace install path, e.g. for
pixi global.

- Extract UvReporter/UvReporterOptions into a new pixi_uv_reporter
  crate. pixi_reporters depends on pixi_command_dispatcher, so the
  reporter had to move below the dispatcher to let it depend on
  pixi_install_pypi without a cycle. pixi_reporters re-exports the
  types so existing users are unaffected.
- Add InstallPypiEnvironmentSpec and
  CommandDispatcher::install_pypi_environment, which wraps
  PyPIEnvironmentUpdater and derives the wheel link mode from the
  dispatcher's configured link options.
- Switch the workspace install path in pixi_core to build the spec and
  go through the dispatcher instead of wiring up the updater configs
  inline.
Complete the PyPI refactor started with install: resolution now also
runs through the CommandDispatcher, so both halves of the PyPI story
(solve + install) are reachable outside the workspace code, e.g. for
pixi global.

- Move the resolve pipeline (resolve_pypi, LazyBuildDispatch,
  CondaResolverProvider) from pixi_core::lock_file::resolve into
  pixi_install_pypi::resolve.
- Decouple it from the workspace with a new CondaPrefixProvider trait:
  when uv must build an sdist to get metadata, the provider supplies a
  conda prefix (python interpreter + activation env vars) on demand.
  pixi_core implements it as WorkspaceCondaPrefixProvider wrapping the
  memoized CondaPrefixUpdater and environment activation; both the
  lock-file update path and the satisfiability metadata checks use it.
- Move PypiPackageIdentifier into pixi_install_pypi; the
  satisfiability-specific satisfies() check stays in pixi_core as an
  extension trait.
- Add SolvePypiEnvironmentSpec and
  CommandDispatcher::solve_pypi_environment, deriving the link mode
  from the dispatcher's configured link options.
- Drop the dead conda_task plumbing: LazyBuildDispatch::conda_task was
  never assigned, so resolve_pypi now returns just the locked records
  and the PypiGroupSolved task keeps forwarding None.
- Remove the uv-* dependencies pixi_core no longer needs.
rattler_digest and uv-preview were only used by the PyPI resolve code
that moved to pixi_install_pypi.
@wolfv wolfv changed the title Refactor PyPI resolution and installation into command dispatcher refactor: move PyPI resolution and installation into the command dispatcher Jun 10, 2026
@wolfv wolfv force-pushed the claude/amazing-davinci-2k2j16 branch from b09716a to 247b0d6 Compare June 10, 2026 14:25
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.

2 participants