Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Gazelle generation mode per file: Unexpected behavior if a binary is added to a folder containing a binary. #2627

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

Closed
gueraf opened this issue Feb 24, 2025 · 2 comments

Comments

@gueraf
Copy link

gueraf commented Feb 24, 2025

🐞 bug report

Affected Rule

Gazelle

Is this a regression?

The current behavior is misaligned with my interpretation of the documentation.

Description

With # gazelle:python_generation_mode file, if there is a folder with say existing_main.py and :existing_main of type py_binary, then if I add added_main.py, I'd expect a py_binary named :added_main to be generated.

Reading documentation, in particular If python_generation_mode is set to file, then instead of one py_binary target per module, Gazelle will create one py_binary target for each file with such a line, and the name of the target will match the name of the script., I think this aligns with my expectation.

Unfortunately it seems like right now :added_main is not generated. Please see this unit test and corresponding output.

πŸ”¬ Minimal Reproduction

git clone https://github.com/gueraf/rules_python/tree/new_test &&
cd rules_python/gazelle/python && \
bazel test //python:python_test_add_binary_to_existing_binary_per_file

# https://gist.github.com/gueraf/0e837ecdbff82a235bb7ce441c14832d

πŸ”₯ Exception or Error


        python_test.go:186: add_binary_to_existing_binary_per_file/BUILD diff (-want,+got):
              (
              	"""
              	... // 7 identical lines
              	    visibility = ["//:__subpackages__"],
              	)
            - 	
            - 	py_binary(
            - 	    name = "added_main",
            - 	    srcs = ["added_main.py"],
            - 	    visibility = ["//:__subpackages__"],
            - 	)
              	"""
              )

🌍 Your Environment

Operating System:

  
Ubuntu 24.04.2 LTS
  

Output of bazel version:

  
Bazelisk version: v1.25.0
Build label: 8.1.0
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Thu Feb 13 19:02:11 2025 (1739473331)
Build timestamp: 1739473331
Build timestamp as int: 1739473331
  

Rules_python version:

  
git head (fa882817a7a69ae1e6bc3a63530ce158b64d2efd)
  
@aignas
Copy link
Collaborator

aignas commented Feb 25, 2025

Could you check if #2619 fixes the issue?

@gueraf
Copy link
Author

gueraf commented Feb 26, 2025

Fantastic, #2619 indeed fixes it!

Sorry for missing the PR on Monday. I meant to file this issue a couple of months ago and I couldn't find anything related.

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

2 participants