# Require any of several alternative package dependencies

**URL:** <https://discuss.python.org/t/require-any-of-several-alternative-package-dependencies/26293>\
**Category:** Packaging\
**Created:** [April 28, 2023, 9:14am UTC](https://discuss.python.org/t/require-any-of-several-alternative-package-dependencies/26293 "2023-04-28T09:14:47Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![ntessore](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/ntessore/32/10786_2.png) [@ntessore](https://discuss.python.org/u/ntessore)\
**Post date:** [April 28, 2023, 6:23pm UTC](https://discuss.python.org/t/require-any-of-several-alternative-package-dependencies/26293/8 "2023-04-28T18:23:51Z")

</div>

I think this would be useful for numerical codes which can depend on a number of packages as backends, which is becoming more common thanks to the array-api efforts.

> [@pf\_moore](#):
>
> Another question. If I have package `A` that depends on `B` and `C`, and `B` depends on `D|E` and C depends on `E|D`, which of `E` and `D` would you expect to be installed (assuming an initially empty environment)?

If the rule is that all alternatives are equivalent solutions, it would only require a convention that whatever is encountered first is tried first. In the sense that, when building the set of missing dependencies, the first encountered dependency `D|E` adds `D` to the set, and the second encountered dependency `E|D` sees that one of `E` and `D` is already requested.

If you want to force installation of `E`, you can ask for it manually. Similarly, I would expect an extra `[with-E]` that specifically depends on `E` to force that package.

---

_[View the full topic](https://discuss.python.org/t/require-any-of-several-alternative-package-dependencies/26293)._
