Skip to content

Workaround for undeclared conda dependency? #485

Description

@bollwyvl

Description

conda-recipe-manager has an undeclared, unbounded dependency on conda for its MatchSpec implementation, and the conda code organization makes it difficult to patch around heavy binary dependencies.

This makes it hard to bootstrap crm in lightweight/automation environments that don't fully support the conda ecosystem (or vice-versa conda-forge/conda-forge.github.io#2244).

At present, there is at least one alternate MatchSpec implementation from the conda top-level org, namely py-rattler.

Additional context

Discussed on:

Design Ideas

  • A relatively simple approach with import checks:
Details
  • Move all imports of MatchSpec to an import of a local new matchspec.py or conda_compat.py
  • either with ImportError (or slightly more efficient find_spec) checks, determine if conda is available
    • if not available, try finding alternate implementations
    • if any are found, provide that implementation
  • A more scalable approach with entry points:
Details
  • in pyproject.toml, declare a new entry_point, e.g. conda-recipe-manager.v0.matchspec with an initial implementation (similar to the above)
  • declare an interface contract (potentially with abc, maybe just type hints) which includes an is_available check
  • probably again in something like conda_compat.py, wrap the conda implementation in something that conforms and advertise this in pyproject.toml
[project.entry_points."conda-recipe-manager.v0.matchspec"]
conda = "conda_recipe_manager.conda_compat.matchspec:CondaMatchSpec"
  • use entry_points(group="conda-recipe-manager.v0.matchspec") to find an available one when requested
  • define [optional-dependencies] for different providers
    • if only for reference purposes, having the lower bound of conda would probably be good

This would allow third-party packages to add new implementations, either directly, or via some plugin package, e.g. crm-py-rattler, e.g.

[project.entry_points."conda-recipe-manager.v0.matchspec"]
py-rattler = "crm_py_rattler.matchspec:PyRattlerMatchSpec"

In either event:

  • add an environment variable, CLI flag, or other means to force a specific implementation
  • if no implementation is found, add a helpful message and raise a dedicated exception type
    • in the CLI, probably don't show a full traceback

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestsource::user-requestRequests that come from the community and library users.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions