Fixes use of version specifiers like `python-3.12`, which:
- have an explicit `python-` prefix
- are using a major version alias that has to be resolved
to an exact version.
As part of fixing this, I've also simplified the conditional for the already
working case, since it had two branches that were virtually identical.
Fixes#3054.