Fix latest version resolution when using `python-` prefix (#3056)
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.
Also simplified the conditional for the already
working case, since it had two branches that were virtually identical.