Skip to content

Split phantom-audio[separation] into a separate distribution #7

@mfeeney

Description

@mfeeney

Problem

phantom-audio[separation] pulls ~2.5 GB of PyTorch + torchaudio + Demucs + model weights. Today this is hidden behind an extras flag, but the dependency tree exists in pyproject.toml as a first-class option of the main package. That couples the core analysis library's release cadence and platform-support matrix to PyTorch's.

Why it's a problem

Most users want analysis first and stem separation later, if at all. PyTorch's platform / Python-version matrix is more restrictive than essentia's, and a bad PyTorch release can cause pip install phantom-audio[separation] to break even when pure analysis is fine. Splitting the packages keeps the main install fast, lean, and resilient to upstream PyTorch issues, and it lets the separation feature evolve on its own cadence.

Suggested approach

  1. Publish a sibling package phantom-audio-separation that:
    • Depends on phantom-audio>=1.1.0, demucs, torch, torchaudio.
    • Exposes the existing phantom.separation module as a plugin (entry-points or a registered subclass).
  2. Move the lazy-imported separation logic out of src/phantom/separation.py into the new package; keep a thin shim in phantom-audio that detects and dispatches to the installed plugin and otherwise raises DependencyMissingError.
  3. Keep the phantom-audio[separation] extra as a meta-installer that pulls phantom-audio-separation for backward compatibility.
  4. Update phantom doctor (issue Add phantom doctor install diagnostic command #3) and the MCP startup preflight (issue Pre-flight optional-dependency imports at MCP server startup #8) to report whether the separation plugin is detected.

Verification

  • pip install phantom-audio produces a wheel with no Torch in the dependency graph (verify via pip install --dry-run or uv pip compile).
  • pip install 'phantom-audio[separation]' (or pip install phantom-audio-separation) installs both packages and phantom separate works end-to-end.
  • A test in tests/test_separation.py confirms that without phantom-audio-separation installed, calling separate_stems raises DependencyMissingError with the correct install hint.
  • phantom doctor reports separation: OK only when the plugin is actually importable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority:mediumReal improvement, not blocking

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions