fix: prefer X.Y over X.Y.Z version aliases in python.toolchain#1340
fix: prefer X.Y over X.Y.Z version aliases in python.toolchain#1340aignas wants to merge 3 commits intobazel-contrib:mainfrom
Conversation
How is this a breaking change? Can we make it non breaking? |
|
@chrislovecnm, because the bzlmod support is still in early stages I am not sure if we should spend more time to actually generate extra aliases in the |
To clarify, these XYZ names were only occurring if My main question with allowing/supporting a patch-level specificity is how non-patch-level-specificity behaves when two different patch levels are requested. e.g. given Keep in mind those may occur across different modules. What version does |
|
@rickeylev, I'll add a test for this in the |
|
It seems that if the micro versions are different, then it will fail because of duplicate If we do not register the coverage for the second I am not sure if it is in scope for this PR though. |
0e93efb to
d8d4b8d
Compare
|
@rickeylev wrote:
So with the latest iteration of the patch, The log from the CI is: |
d8d4b8d to
a68af10
Compare
a68af10 to
a916199
Compare
|
@chrislovecnm, @rickeylev made this a non-breaking change and updated the legacy setup to also use the same approach, where only a single |
python/extensions/python.bzl
Outdated
| for toolchain_attr in mod.tags.toolchain: | ||
| toolchain_version = toolchain_attr.python_version | ||
| toolchain_name = "python_" + toolchain_version.replace(".", "_") | ||
| toolchain_version = full_version(toolchain_attr.python_version) |
There was a problem hiding this comment.
Please also add a warning if the passed in python_version includes the patch-level to make it more clear we don't support it.
if toolchain_version_short != toolchain_attr.python_version:
_warn_patch_level_toolchain_version(...)
And something like
WARNING: Python version changed from X to Y in toolchain T in module M: patch level specificity is not supported
Or something to that effect. Get all the bits of info in there so users can better identify which module and part of it's configuration is problematic.
There was a problem hiding this comment.
I think that supporting patch level specificity in the python.toolchain could be actually desirable for only one reason, but it would be a good reason enough to keep it - different Python toolchain versions come from different indygreg toolchain releases and some of them may have different packaging behaviour, like the last release contains the following changelog:
CPython 3.9.16 -> 3.9.17
CPython 3.10.11 -> 3.10.12
CPython 3.11.3 -> 3.11.4
setuptools 67.7.2 -> 68.0.0
pip 23.1.2 -> 23.2.2
musl 1.2.3 -> 1.2.4
OpenSSL 1.1.1s -> 1.1.1u
SQLite 3.41.2 -> 3.42.0
libxzma 5.2.9 -> 5.2.12
Release artifacts for Linux s390x are now published.
_crypt extension module is now distributed as a standalone shared library (as opposed to being statically linked in libpython). This removes a hard dependency on libcrypt.so.1 for compatibility with modern Linux distributions. See astral-sh/python-build-standalone#173 for context. Affects Linux non-musl distributions.
So actually supporting pinning to the X.Y.Z could be an important feature to consider, because some users may want to stick with an older version than what is available in the MINOR_MAPPING.
What we should not support though is two toolchains of X.Y.Z1 and X.Y.Z2 at the same time being used where X.Y are the same.
I am inclined to leave the addition of the warning in a separate PR, if you are not against it.
There was a problem hiding this comment.
different indygreg releases have different behavior
Ah, good point. I added that to the FR.
We should not support two toolchains with different patch versions
Oh? Why? That position would avoid several complications. Can you post your rationale to the FR issue?
re: warning in a separate PR: SGTM.
| python.toolchain( | ||
| configure_coverage_tool = True, | ||
| python_version = "3.10", | ||
| # One can also provide the full Python version. |
There was a problem hiding this comment.
Because this isn't supported, please remove it from the examples. Having an example and saying "you can also..." implies its supported, which isn't true.
| python.toolchain( | ||
| configure_coverage_tool = True, | ||
| python_version = "3.9", | ||
| python_version = "3.9.10", |
There was a problem hiding this comment.
Same here: please remove the patch level
| "3.9", | ||
| "3.10", | ||
| "3.11", | ||
| "3.11.1", |
There was a problem hiding this comment.
Same here: please remove the patch level
a916199 to
35e763c
Compare
… X.Y.Z (#1423) Before this PR in numerous places we would check the MINOR_MAPPING dict. This PR adds a function that also fails if the X.Y format is not in the MINOR_MAPPING dict making the code more robust. Split from #1340 to unblock #1364. --------- Co-authored-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com>
e890a5a to
3ecc4df
Compare
|
Note that this is working without these code changes, see comment in #1371. |
Before this PR the
bzlmodand legacy setups would only expose themulti-version python toolchain aliases as the string that is passed to
the
python_register_multi_toolchainsfunction. This meant that if theuser decided to pass the full version (e.g.
3.11.1) then they had toimport the version aware
py_*defs via@foo//3.11.1:defs.bzl. ThisPR changes it such that the user can still do the old way of importing
but we print a deprecation warning and ask the user to use
3.11:defs.bzlinstead which better reflects how the multi-versiontoolchain should be used. This also means that the PRs bumping the minor
versions like in #1352 won't need updating Python code elsewhere.
Whilst at it, we introduce a validation that disallows multiple Python
toolchains of the same
X.Yversion. This is handled in thebzlmodbyprinting warnings that the toolchains are ignored, whilst the non-bzlmod
users will get validation errors, which is a potentially breaking
change.
Fixes #1339