Description
🐞 bug report
Affected Rule
The issue is caused by the rule: multi_pip_parse
Is this a regression?
Yes, the previous version in which this bug was not present was: 1.3.0.
git bisect
says first problematic commit is bfad507.
Description
Error: key "python_version" not found in dictionary
from marker_expr
in python/private/pypi/pep508_evaluate.bzl
🔬 Minimal Reproduction
When you have rules_python
checked out:
cd examples/multi_python_versions/
echo 'websockets ; python_version > "3.9"' >| requirements/requirements.in
for n in 9 10 11; do
bazelisk run --@rules_python//python/config_settings:python_version=3.$n \
//requirements:requirements_3_$n.update
done
bazelisk query --enable_workspace --noenable_bzlmod '@pypi//...'
It is worth noting that bazelisk query --noenable_workspace --enable_bzlmod '@pypi//...'
does work, e.g. it works with Bzlmod, but is broken without.
🔥 Exception or Error
Traceback (most recent call last):
File "[...]/external/rules_python+/python/private/pypi/pip_repository.bzl", line 74, column 50, in _pip_repository_impl
requirements_by_platform = parse_requirements(
File "[...]/external/rules_python+/python/private/pypi/parse_requirements.bzl", line 159, column 51, in parse_requirements
env_marker_target_platforms = evaluate_markers(reqs_with_env_markers)
File "[...]/external/rules_python+/python/private/pypi/evaluate_markers.bzl", line 35, column 24, in evaluate_markers
if evaluate(req.marker, env = env(platform_from_str(platform, None))):
File "[...]/external/rules_python+/python/private/pypi/pep508_evaluate.bzl", line 146, column 27, in evaluate
tokens = ast.parse(env = env, tokens = tokens, strict = strict)
File "[...]/external/rules_python+/python/private/pypi/pep508_evaluate.bzl", line 231, column 40, in lambda
parse = lambda **kwargs: _parse(self, **kwargs),
File "[...]/external/rules_python+/python/private/pypi/pep508_evaluate.bzl", line 258, column 27, in _parse
expr = marker_expr(env = env, strict = strict, *tokens[:3])
File "[...]/external/rules_python+/python/private/pypi/pep508_evaluate.bzl", line 322, column 19, in marker_expr
left = env[left]
Error: key "python_version" not found in dictionary
🌍 Your Environment
Operating System:
Ubuntu 24.04
Output of bazel version
:
Bazelisk version: v1.20.0
Build label: 8.2.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Thu Apr 17 18:22:55 2025 (1744914175)
Build timestamp: 1744914175
Build timestamp as int: 1744914175
Rules_python version:
main
, first problematic commit is bfad507.
Anything else relevant?