How to handle different dependencies for different python versions?

I’m working on updating the sphinx-autoapi feedstock, and they have these requirements:

- astroid >=2.7  #[py<312]
- astroid >=3.0  #[py>=312]

Will those selectors work?

I’m still a bit confused – this is certainly pure python package, i.e. no architecture specific, but apparently not completely Python-version independent.

Hmm – astroid itself is python-version-dependent. But there are builds of 3.* for python < 3.12, so this selector is needed (unless the upstream has it wrong…)

replying to myslef – I got a admonition from the linter:

  • noarch packages can’t have selectors. If the selectors are necessary, please remove noarch: python.

So that’s that – I guess I need to get rid of the noarch, which is a shame. I’ll ask upstream.

and yet another reply to myself – I hadn’t looked carefully enough – it looks like I can simply do > 3.0 for all, and good to go.

You could technically have a series of noarch: python packages with some Jinja trickery, but in most cases it’s not worth the trouble; as you said, you can take the strictest subset and you are good to go.

In other cases where the constraints are not really compatible (e.g. astroid<2 and astroid>=2 for two different Python versions), then the simplest thing is to abandon noarch.

Several noarch packages are really a last resort if you had a HUGE matrix.

Thanks, that all makes sense.

I do wish we had a distiction between “any python version” and “any architecture”,

But oh well – only so many axes we want to have in the matrix…

1 Like