Skip to content

Py2/3 generated sources clash in runfiles #6482

@brandjon

Description

@brandjon

When a target depends on the same generated source file in both PY2 and PY3 modes, it's arbitrary which one wins in the runfiles. Here foobar depends on source file a.py and generated source file b.py through both PY2 and PY3 binary targets. In the runfiles, a.py symlinks to the source file, which is the same in both modes, but b.py symlinks to the file generated in the PY2 output root (the one without "-py3" in the path), silently ignoring the PY3 one.

genrule(
    name = "b",
    outs = [":b.py"],
    cmd = "touch $(location :b.py)",
)

py_binary(
    name = "foo",
    srcs = ["a.py", ":b"],
    main = "a.py",
    default_python_version = "PY3",
)

py_binary(
    name = "bar",
    srcs = ["a.py", ":b"],
    main = "a.py",
    default_python_version = "PY2",
)

sh_binary(
    name = "foobar",
    srcs = [":script.sh"],
    data = [":foo", ":bar"],
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3We're not considering working on this, but happy to review a PR. (No assignee)staleIssues or PRs that are stale (no activity for 30 days)team-Rules-PythonNative rules for Pythontype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions