bazelbuild / rules_python

Bazel Python Rules
https://rules-python.readthedocs.io
Apache License 2.0
534 stars 541 forks source link

Removal of PyInfo from Bazel causes semantic change #2414

Open comius opened 4 hours ago

comius commented 4 hours ago

🐞 bug report

Description

I upgraded Bazel to use rules_python 0.39.0 -> all the tests pass. I removed python providers from Bazel -> smoke tests started failing.

🔬 Minimal Reproduction

Checkout https://github.com/bazelbuild/bazel/pull/24343 bazel build //src/test/shell/bazel:bazel_example_test --test_filter=test_native_python

🔥 Exception or Error

https://storage.googleapis.com/bazel-untrusted-buildkite-artifacts/01932fe0-131a-4503-8eac-2516742f6f27/src/test/shell/bazel/bazel_example_test/shard_1_of_3/test_attempts/attempt_1.log

Example in: https://github.com/bazelbuild/bazel/blob/master/examples/py_native/bin.py


-- Test log: -----------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/Bazel.runfiles_vczmqfyg/runfiles/_main/examples/py_native/bin.py", line 4, in 
    from fib import Fib
ModuleNotFoundError: No module named 'fib'

My thoughs

It looks like that part of information was in Builtin providers that now gets lost.

rickeylev commented 3 hours ago

Just thinking out loud. If fib isn't importable, then it would mean sys.path is different or the file isn't present. If PyInfo got lost, either is likely. Our test coverage for built-in PyInfo interop is pretty light.

Otherwise, the other thing might be safe path (we enable it by default) it removes the main files dir from system.path, which the example is relying on. The version of python used can affect this. That it varies by bazel version makes me doubt this cause, though. edit: the example has fib in another dir using imports=[.]. safepath wouldn't affect tihs

rickeylev commented 1 hour ago

I was able to repro.

repro note: PR was updated to use a repo-root based import. Needs to be changed back to from fib import Fib to demonstrate the failure.

sys.path is missing the fibonacci. So yeah, something is causing the imports=[.] part to be lost.