python – how to require one out of two packages in meta.yaml

I have two packages, lets call them pack1 and pack2
both have different requirements but I don’t mind using either of them in my package. so I want to have in my meta.yaml something like:

requirements:
run:
– pack1 or pack2

such that if pack1 is compatible with my user’s requirements it will install pack1 and if not, and pack2 is, it will install pack2. Is something like that possible?

I tried searching online and I haven’t found a solution yet.

If I understand correctly, you’re using a Conda recipe to produce a python package? The short answer is that you can’t!

Python packages can specify conditional dependencies, which are only installed based on a particular OS or Python version, using environment markers:

https://peps.python.org/pep-0508/

But that’s not what you’re asking for here. Another solution would be to use something like pips optional dependences feature using package extras. But it seems Conda doesn’t support that either!

https://github.com/conda/conda/issues/2984

So I think you’ll just have to pick the most popular and support that!

Leave a Comment