aspect-build / rules_py

More compatible Bazel rules for running Python tools and building Python projects
Apache License 2.0
72 stars 22 forks source link

[Bug]: `python_version` silently fall backs to a default toolchain in case it is unable to find specified version #363

Open dizzy57 opened 4 days ago

dizzy57 commented 4 days ago

What happened?

I expect to get an error when rules_py can't find configured toolchain for the specified python version. I also expect examples to pin minor version (e.g. "3.10") instead of full version("3.10.13") to accommodate for future patch version upgrades by rules_python. (e.g. it can silently bump patch versions)

Version

Development (host) and target OS/architectures:

Output of bazel --version: 7.0.2

Version of the Aspect rules, or other relevant rules from your WORKSPACE or MODULE.bazel file: HEAD (v0.7.3+)

Language(s) and/or frameworks involved:

How to reproduce

Check out https://github.com/dizzy57/rules_py/tree/wrong_python_version_defaults_to_default
Run `bazel test //examples/multi_version:py_version_test`.

Expected: `//examples/multi_version:py_version_test` fails with `AssertionError: 10 == 8` since `python_version = "3.10.13"` is specified in `examples/multi_version/BUILD.bazel`.

Actual: `//examples/multi_version:py_version_test fails with `AssertionError: 9 == 8` since it selects the default toolchain because `3.10` toolchain was never configured.

Any other information?

Please note that silently switching to the default toolchain and specifying full version ("3.10.13") will result in poor user experience after rules_python bumps the default version for 3.10 interpreter in MINOR_MAPPING

thesayyn commented 4 days ago

We should never silently fallback to the default interpreter if there no matching python toolchain registered for the given python_version.

We should also make sure that specifying python_version without the patch should 3.10 work.