Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rules_python is broken with Bazel@HEAD #18170

Closed
sgowroji opened this issue Apr 21, 2023 · 9 comments
Closed

rules_python is broken with Bazel@HEAD #18170

sgowroji opened this issue Apr 21, 2023 · 9 comments
Assignees
Labels
breakage P1 I'll work on this now. (Assignee required) team-Rules-Python Native rules for Python type: bug

Comments

@sgowroji
Copy link
Member

https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/2972#0187a200-864b-46a7-987d-75766ba7fe83

ERROR: /Users/sgowroji/bazelci/bazelhead_downstream/rules_python/rules_python/docs/BUILD.bazel:36:12: no such target '@bazel_tools//tools/python:private/defs.bzl': target 'private/defs.bzl' not declared in package 'tools/python' defined by /private/var/tmp/_bazel_sgowroji/a5aaba8bdde99d8862842eaaed117753/external/bazel_tools/tools/python/BUILD (Tip: use `query "@bazel_tools//tools/python:*"` to see all the targets in that package) and referenced by '//docs:bazel_python_tools'
ERROR: Analysis of target '//docs:pip_install_bzl' failed; build aborted: 
INFO: Elapsed time: 0.666s
INFO: 0 processes.
ERROR: Build did NOT complete successfully

Steps followed to reproduce :

  1. git clone -v https://github.com/bazelbuild/rules_python.git
  2. git reset c72c7bcf4e0899c275042328e8233e3124ccae86 --hard
  3. export USE_BAZEL_VERSION=d3ebbb7495e65747ac5f512c67a790e9dec12373
  4. bazel build ...

Culprit : 1895585

CC @meteorcloudy

@sgowroji sgowroji added type: bug P1 I'll work on this now. (Assignee required) breakage team-Rules-Python Native rules for Python labels Apr 21, 2023
@rickeylev
Copy link
Contributor

I'm skeptical that 1895585 is the actual cause. I suspect #17545 is more likely the cause (it removed the @bazel_tools//tools/python:private/defs.bzl file that the error complains about).

This sounds like a dupe of #17874, too, but it's not clear.

On the rules_python side, bazelbuild/rules_python#1173 removed the reference to that removed file.

@meteorcloudy
Copy link
Member

SG, let's check if the downstream turns green for python tomorrow

@meteorcloudy
Copy link
Member

rickeylev added a commit to rickeylev/rules_python that referenced this issue Apr 26, 2023
This makes the test pass on Bazel built from head. The failure appears
due to not forcing the test to a Mac platform, so the underlying
logic in `py_test` to detect the Mac platform fails and doesn't add
the ExecutionInfo with the necessary info.

Fixes bazelbuild/bazel/issues/18170
rickeylev added a commit to rickeylev/rules_python that referenced this issue Apr 26, 2023
The latest versions of Bazel have removed the `@bazel_tools//tools/python:private/defs.bzl`
file, so it can no longer be referenced.

Work towards bazelbuild/bazel/issues/18170
rickeylev added a commit to bazelbuild/rules_python that referenced this issue Apr 26, 2023
)

This makes the test pass on Bazel built from head. The failure appears
due to not forcing the test to a Mac platform, so the underlying logic
in `py_test` to detect the Mac platform fails and doesn't add the
ExecutionInfo with the necessary info.

Work towards bazelbuild/bazel/issues/18170
rickeylev added a commit to bazelbuild/rules_python that referenced this issue Apr 26, 2023
The latest versions of Bazel have removed the
`@bazel_tools//tools/python:private/defs.bzl` file, so it can no longer
be referenced.

Work towards bazelbuild/bazel/issues/18170
@rickeylev
Copy link
Contributor

Ok, fixing that error revealed another. Both are fixed at rules_python head now. I ran all the rules_python tests with a build from head and it looked ok (I think; there were failures, but they also happen with non-bazel head, so I think my invocation just wasn't ignoring something it should have).

Let me know if the next downstream build has rules_python failures again.

@sgowroji
Copy link
Member Author

sgowroji commented Apr 26, 2023

Failures in downstream rules_python (latest pipeline ) : https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/2982#0187bb51-ca68-4dae-9701-608fcc7178b1



ERROR: /var/lib/buildkite-agent/builds/bk-docker-41r9/bazel-downstream-projects/rules_python/BUILD.bazel:49:10: no such target '@bazel_tools//tools/python:private/defs.bzl': target 'private/defs.bzl' not declared in package 'tools/python' defined by /var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/09bcd3e2e52b893a1df06cbb16f91c53/external/bazel_tools/tools/python/BUILD (Tip: use `query "@bazel_tools//tools/python:*"` to see all the targets in that package) and referenced by '//:bzl'
--
  | (02:22:06) ERROR: /var/lib/buildkite-agent/builds/bk-docker-41r9/bazel-downstream-projects/rules_python/tools/build_defs/python/tests/py_test/BUILD.bazel:18:19: in test_mac_requires_darwin_for_execution_test rule //tools/build_defs/python/tests/py_test:test_mac_requires_darwin_for_execution:
  | Traceback (most recent call last):
  | File "/var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/09bcd3e2e52b893a1df06cbb16f91c53/external/rules_testing/lib/analysis_test.bzl", line 191, column 13, in wrapped_impl
  | impl(env, target)
  | File "/var/lib/buildkite-agent/builds/bk-docker-41r9/bazel-downstream-projects/rules_python/tools/build_defs/python/tests/py_test/py_test_tests.bzl", line 53, column 44, in _test_mac_requires_darwin_for_execution_impl
  | env.expect.that_target(target).provider(
  | File "/var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/09bcd3e2e52b893a1df06cbb16f91c53/external/rules_testing/lib/truth.bzl", line 2323, column 60, in lambda
  | provider = lambda *a, **k: _target_subject_provider(self, *a, **k),
  | File "/var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/09bcd3e2e52b893a1df06cbb16f91c53/external/rules_testing/lib/truth.bzl", line 2499, column 23, in _target_subject_provider
  | info = self.target[provider_key]
  | Error: <merged target //tools/build_defs/python/tests/py_test:test_mac_requires_darwin_for_execution_subject> (rule 'py_test') doesn't contain declared provider 'ExecutionInfo'
  | (02:22:06) ERROR: /var/lib/buildkite-agent/builds/bk-docker-41r9/bazel-downstream-projects/rules_python/tools/build_defs/python/tests/py_test/BUILD.bazel:18:19: Analysis of target '//tools/build_defs/python/tests/py_test:test_mac_requires_darwin_for_execution' failed

@meteorcloudy
Copy link
Member

meteorcloudy commented Apr 26, 2023

Failures in downstream rules_python (latest pipeline ) : https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/2982#0187bb51-ca68-4dae-9701-608fcc7178b1

@sgowroji If you check the rules_python commit in the log, it was still building at bazelbuild/rules_python@ba2a903, which is before the fix was submitted bazelbuild/rules_python@600dbe1

@meteorcloudy
Copy link
Member

meteorcloudy commented Apr 27, 2023

https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/2983#0187c078-0aeb-4374-b54d-c4073136627d
The @bazel_tools//tools/python:private/defs.bzl issue has been fixed now. But rules_python is still failing with Bazel@HEAD with

(04:22:55) ERROR: /Users/buildkite/builds/bk-imacpro-10/bazel-downstream-projects/rules_python/tools/build_defs/python/tests/py_test/BUILD.bazel:18:19: in test_non_mac_doesnt_require_darwin_for_execution_test rule //tools/build_defs/python/tests/py_test:test_non_mac_doesnt_require_darwin_for_execution:
Traceback (most recent call last):
	File "/private/var/tmp/_bazel_buildkite/8e3e233c9482a5bb2bc225479d1df699/external/rules_testing/lib/analysis_test.bzl", line 191, column 13, in wrapped_impl
		impl(env, target)
	File "/Users/buildkite/builds/bk-imacpro-10/bazel-downstream-projects/rules_python/tools/build_defs/python/tests/py_test/py_test_tests.bzl", line 89, column 28, in _test_non_mac_doesnt_require_darwin_for_execution_impl
		).requirements().keys().not_contains("requires-darwin")
Error: 'struct' value has no field or method 'not_contains'
Available attributes: actual, contains, contains_at_least, contains_at_least_predicates, contains_exactly, contains_exactly_predicates, contains_none_of, contains_predicate, has_size, not_contains_predicate

looks like more API changes we need to adapt?

@meteorcloudy
Copy link
Member

@sgowroji Can you file an issue against rules_python and close this one?

rickeylev added a commit to rickeylev/rules_python that referenced this issue Apr 27, 2023
…execution

This is the inverse test of the one testing for the mac platform. As
before, the line forcing the platform to a non-mac platform was
commented out, which meant, when a mac host built it, it would build the
underlying target for Mac, which violated the test's assumptions.

Work towards bazelbuild/bazel/issues/18170
@rickeylev
Copy link
Contributor

Thanks, I've sent bazelbuild/rules_python#1183 to fix that failure. How it's manifesting is a bit weird, but the bug is indeed on rules_python's side.

rickeylev added a commit to bazelbuild/rules_python that referenced this issue Apr 28, 2023
…execution (#1183)

This is the inverse test of the one testing for the mac platform. As
before, the line forcing the platform to a non-mac platform was
commented out, which meant, when a mac host built it, it would build the
underlying target for Mac, which violated the test's assumptions.

Work towards bazelbuild/bazel/issues/18170

Fixes #1185
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breakage P1 I'll work on this now. (Assignee required) team-Rules-Python Native rules for Python type: bug
Projects
None yet
Development

No branches or pull requests

3 participants