rules_py icon indicating copy to clipboard operation
rules_py copied to clipboard

[Bug]: no such attribute 'stamp' in 'py_test' rule

Open jamison-lahman-ai opened this issue 2 years ago • 3 comments

What happened?

Support for py_test.stamp, https://bazel.build/reference/be/python#py_test.stamp

$ bazel test //examples/py:py_test 
ERROR: /home/jamison/code/rules_py/examples/py/BUILD.bazel:3:8: //examples/py:py_test: no such attribute 'stamp' in 'py_test' rule
ERROR: error loading package 'examples/py': Package 'examples/py' contains errors
INFO: Elapsed time: 0.095s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)

Version

Development (host) and target OS/architectures:

Output of bazel --version:

bazel 5.4.0

Version of the Aspect rules, or other relevant rules from your WORKSPACE or MODULE.bazel file:

local rules_py workspace, HEAD

How to reproduce

https://github.com/jl-applied/rules_py/tree/jamison/161,

bazel test //examples/py:py_test

Any other information?

No response

jamison-lahman-ai avatar May 25 '23 00:05 jamison-lahman-ai

Interesting, @jl-applied is there a use case for setting a stamp attribute on a test target? I think in theory we want to support the full py_* native rule API to make migrations easy, but this one feels more like a bug than a feature to me.

alexeagle avatar Aug 29 '23 02:08 alexeagle

We explicitly default to stamp = false in a macro for our py_* rules. I suspect with a small refactor + slight code duplication at worse, we could workaround this without needing this attribute on any of our py_tests.

This was the first snag I hit when trying to migrate and was enough to get the migration shelved, so figured I'd open a ticket. Disallowing stamp seems reasonable to me, though an explicit comment stating this is intentional would be nice.

jamison-lahman-ai avatar Aug 29 '23 02:08 jamison-lahman-ai

Our macro can have a stamp attribute, but we just error when you pass it so you get the documentation in the right spot.

alexeagle avatar Oct 02 '23 19:10 alexeagle