Skip to content

Add support for opportunistic dependencies #214

@pganssle

Description

@pganssle

Recently the issue pypa/setuptools#1599 was raised, hoping that it would be possible to specify "soft-failing" extra dependencies. This is currently not possible, but I think it's reasonable and would help me in some of the dependency-resolution problems that have been worrying me in dateutil.

The original use case from @Harvie was for a package that works better with opencv, but can operate without it. Their main concern was that opencv is not available on ARM - it's possible that this can be handled via environment markers, but even if it works, that is essentially a hack around what they want to express, which is "if you can install this, you should, but if you can't, that doesn't need to block the installation of my package". Using environment markers, you are hard-coding that "arm doesn't need opencv" when in reality ARM would benefit just as much from opencv as anyone else, and if opencv were to release an ARM-compatible package, you'd want your users to pick that up.

I have a similar use case in dateutil - I would like to write a compiled backend, but dateutil is very widely used, and I am not confident that I can make releases for every platform. Ideally, I would declare an optional dependency on a backend so that people are opportunistically upgraded as their platform becomes available. Obviously there are workarounds in this case since I control both packages, but as with pypa/setuptools#1139, it would be much better if we had a way to explicitly specify the nature of the dependencies.

Possibly the easiest thing to do would be to implement this as an environment marker, maybe something like soft_dependency? e.g.:

opencv >= 1.2.0; soft_dependency

We may also need to get into the possibility of fallback dependencies, like:

open_cv >= 1.2.0; soft_dependency
cv_compat >= 2.1.0; substitutes_for=open_cv

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions