-
Notifications
You must be signed in to change notification settings - Fork 539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: prefer X.Y over X.Y.Z version aliases in python.toolchain #1340
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you for figuring out something that has better backwards compatibility.
I filed #1371 for tracking support of patch-level specificity.
The general impl LGTM. Just a few small changes and nits.
python/extensions/python.bzl
Outdated
@@ -74,28 +76,30 @@ def _python_impl(module_ctx): | |||
module_toolchain_versions = [] | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 indygreg/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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -28,7 +28,8 @@ python.toolchain( | |||
# work in progress. | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -27,7 +27,7 @@ PYTHON_NAME_311 = "python_3_11" | |||
python = use_extension("@rules_python//python/extensions:python.bzl", "python") | |||
python.toolchain( | |||
configure_coverage_tool = True, | |||
python_version = "3.9", | |||
python_version = "3.9.10", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here: please remove the patch level
@@ -22,7 +22,7 @@ python_register_multi_toolchains( | |||
"3.8", | |||
"3.9", | |||
"3.10", | |||
"3.11", | |||
"3.11.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
bzlmod
and legacy setups would only expose themulti-version python toolchain aliases as the string that is passed to
the
python_register_multi_toolchains
function. 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.bzl
instead 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.Y
version. This is handled in thebzlmod
byprinting warnings that the toolchains are ignored, whilst the non-bzlmod
users will get validation errors, which is a potentially breaking
change.
Fixes #1339