Skip to content

Support make variable expansion in environment variables when using python_register_multi_toolchains#1486

Description

@michaelboyd2

馃悶 bug report

Affected Rule

I think the problem is that _transition_py_impl does not handle make variable expansion of environment variables (it already does location expansion).

Is this a regression?

No, I don't think so.

Description

When you use py_test (and py_binary I guess) from a specific python version with Make variables for environment variables then they do not work e.g.

load("@python//3.8:defs.bzl", py_binary_3_8 = "py_binary", py_test_3_8 = "py_test")

py_test_3_8(
    ...
    env = {
        "JAVA_HOME": "$(JAVABASE)"
    },
    toolchains = ["@bazel_tools//tools/jdk:current_java_runtime"],

then $(JAVABASE) does not get expanded as it ought to.

馃敩 Minimal Reproduction

See above. I could probably create a GitHub repo if it was needed.

馃敟 Exception or Error

Depends on how the env variable is being used.

馃實 Your Environment

Operating System:

michaelboyd $ sw_vers
ProductName:    macOS
ProductVersion: 12.6.9
BuildVersion:   21G726

Output of bazel version:

michaelboyd $ bazel version
Bazelisk version: development
Build label: 6.3.2
Build target: bazel-out/darwin_arm64-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Aug 8 15:51:44 2023 (1691509904)
Build timestamp: 1691509904
Build timestamp as int: 1691509904

Rules_python version:

0.23.1

I have not tested a more up to date version, but I think it would happen on main too.

Anything else relevant?

No.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions