bazel-contrib / bazel-contrib/rules_python
precompiling results in action output conflicts
- Langage dominant
- Starlark
- Étoiles
- 688
- Forks
- 721
- Merge moyen
- 15 h 7 min
- PR mergées (30 j)
- 76
Description
# 🐞 bug report
### Affected Rule
```bzl
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:[[]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 https://github.com/bazelbuild/rules_python/commit/eb2225c31a20a7ee361054b088bcef8cd9434b74, we hit it when updating from 0.36.0 to 0.40.0
## 🔬 Minimal Reproduction
Build in this repo: [repro.zip](https://github.com/user-attachments/files/17926786/repro.zip)
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par le fichier BUILD de repro.zip et reproduisez le conflit en construisant ensemble les première et deuxième cibles py_test. Examinez la régression introduite par le commit eb2225c31a20a7ee361054b088bcef8cd9434b74 et retracez les chemins de sortie de la précompilation ; le travail est terminé lorsque les deux cibles se construisent sans actions en conflit pour le fichier foo.py partagé.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- build-system
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 42/100