Skip to content

precompiling results in action output conflicts #2445

@keith

Description

@keith

🐞 bug report

Affected Rule

load("@rules_python//python:defs.bzl", "py_test")

py_test(
    name = "first",
    srcs = ["foo.py"],
    main = "foo.py",
)

py_test(
    name = "second",
    srcs = ["foo.py"],
    exec_properties = {"foo": "bar"},
    main = "foo.py",
)

With this BUILD file, where 2 python rules include the same file, building both of these targets results in:

ERROR: file '__pycache__/foo.cpython-311.pyc' is generated by these conflicting actions:
Label: //:second, //:first
RuleClass: py_test rule
JavaActionClass: class com.google.devtools.build.lib.analysis.actions.StarlarkAction
Configuration: 8e4ab22e89843aa348ba782be25eadb5bae40f2ae62dec3edd2cdaf809e8d7b1
Mnemonic: PyCompile
Action key: aa843bb97b9c08aba98aa87861cf3bba7f6f80370dcc227a3aa766a618449a45, d8983143b0af1168a9ab184492ac6ef78a440269bfd600178f4e6d984e208bf7
Progress message: Python precompiling foo.py into bazel-out/darwin_arm64-fastbuild/bin/__pycache__/foo.cpython-311.pyc
Action describeKey: Python precompiling foo.py into bazel-out/darwin_arm64-fastbuild/bin/__pycache__/foo.cpython-311.pyc
  Environment variable: PYTHONHASHSEED=0
  Environment variable: PYTHONNOUSERSITE=1
  Environment variable: PYTHONSAFEPATH=1
  Argument: bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/rules_python~/python/private/python3
  Argument: bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/rules_python~/tools/precompiler/precompiler
  Argument: --invalidation_mode
  Argument: checked_hash
  Argument: --src
  Argument: foo.py
  Argument: --src_name
  Argument: foo.py
  Argument: --pyc
  Argument: bazel-out/darwin_arm64-fastbuild/bin/__pycache__/foo.cpython-311.pyc
  Argument: --optimize
  Argument: 0
  Argument: --python_version
  Argument: 3.11
  Output paths mode: OFF

PrimaryInput: File:[/Users/ksmiley/Downloads/repro[source]]foo.py
PrimaryOutput: File:[[<execution_root>]bazel-out/darwin_arm64-fastbuild/bin]__pycache__/foo.cpython-311.pyc
Owner information: ConfiguredTargetKey{label=//:second, config=BuildConfigurationKey[8e4ab22e89843aa348ba782be25eadb5bae40f2ae62dec3edd2cdaf809e8d7b1]}, ConfiguredTargetKey{label=//:first, config=BuildConfigurationKey[8e4ab22e89843aa348ba782be25eadb5bae40f2ae62dec3edd2cdaf809e8d7b1]}
MandatoryInputs: are equal
Outputs: are equal
Use --verbose_failures to see the command lines of failed build steps.
ERROR: com.google.devtools.build.lib.actions.MutableActionGraph$ActionConflictException: for __pycache__/foo.cpython-311.pyc, previous action: action 'Python precompiling foo.py into bazel-out/darwin_arm64-fastbuild/bin/__pycache__/foo.cpython-311.pyc', attempted action: action 'Python precompiling foo.py into bazel-out/darwin_arm64-fastbuild/bin/__pycache__/foo.cpython-311.pyc'

Is this a regression?

I bisected to eb2225c, we hit it when updating from 0.36.0 to 0.40.0

🔬 Minimal Reproduction

Build in this repo: repro.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions