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

Gazelle python_root directive only adds imports to subfolders #2571

Open
rfevang opened this issue Jan 21, 2025 · 0 comments
Open

Gazelle python_root directive only adds imports to subfolders #2571

rfevang opened this issue Jan 21, 2025 · 0 comments

Comments

@rfevang
Copy link

rfevang commented Jan 21, 2025

🐞 bug report

Affected Rule

Gazelle plugin target generation

Is this a regression?

No

Description

python targets that do not share root with the workspace needs imports = [...] statements added for imports to work correctly. The gazelle plugin supports this through adding # gazelle:python_root directives in BUILD files that are at the root of python trees. This works great for source files in subfolders, they have attributes like imports = ["../.."], added. However the sources files in the root folder itself does not get any imports attribute, while they need to have imports = ["."] to work correctly.

🔬 Minimal Reproduction

🔥 Exception or Error

Target py_binary file fails on run due to missing import.

🌍 Your Environment

Operating System:

  
     Ubuntu 24.10
  

Output of bazel version:

  
    Bazelisk version: v1.25.0
    Build label: 8.0.1
    Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
    Build time: Fri Jan 17 19:16:16 2025 (1737141376)
    Build timestamp: 1737141376
    Build timestamp as int: 1737141376
  

Rules_python version:

  
     bazel_dep(name = "rules_python", version = "1.1.0")
     bazel_dep(name = "rules_python_gazelle_plugin", version = "1.1.0")
  

Anything else relevant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant