Skip to content

[Regression] Error loading native python modules when binary is defined in another bazel module #3563

@mering

Description

@mering

🐞 bug report

Affected Rule

py_binary

Is this a regression?

Yes, this worked in 1.6.3 and broke in 1.7.0. I bisected this to b8e32c4 as the first failing commit.

Description

Loading a native binary module (like abseil-py) for a py_binary defined in another module fails to find the module.

🔬 Minimal Reproduction

https://github.com/mering/reproduction_rules_python_1_7

🔥 Exception or Error


Traceback (most recent call last):
  File "/absl_app_smoke_binary.runfiles/sub+/_absl_app_smoke_binary_stage2_bootstrap.py", line 499, in 
    main()
  File "/absl_app_smoke_binary.runfiles/sub+/_absl_app_smoke_binary_stage2_bootstrap.py", line 493, in main
    _run_py_path(main_filename, args=sys.argv[1:])
  File "/absl_app_smoke_binary.runfiles/sub+/_absl_app_smoke_binary_stage2_bootstrap.py", line 287, in _run_py_path
    runpy.run_path(main_filename, run_name="__main__")
  File "", line 291, in run_path
  File "", line 98, in _run_module_code
  File "", line 88, in _run_code
  File "/absl_app_smoke_binary.runfiles/sub+/absl_app_smoke_binary.py", line 1, in 
    from absl import app
ModuleNotFoundError: No module named 'absl'

🌍 Your Environment

Operating System:

  
  Debian
  

Output of bazel version:

  
  8.5.1
  

Rules_python version:

  
  1.7.0
  

Anything else relevant?

Metadata

Metadata

Assignees

No one assigned

    Labels

    core-rulesIssues concerning core bin/test/lib rules

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions