-
Notifications
You must be signed in to change notification settings - Fork 541
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 incorrectly ignores files called setup.py
.
#2108
Comments
I see two main options for fixing:
Thoughts? Other ideas? |
I like the first approach more but would love to see if there are better options for the migration. It could suddenly be the case where gazelle might start failing, but on the other hand pep621 is all about pyproject.toml files, so I would vote to mainly support that. We could do a feature flag but then flipping it will not solve anything. We could add a warning though. What about having 'default python ignore files' directive which is similar to what we did with ... some other ignore pattern options? |
Sorry I haven't been able to follow up on this yet. I applied a patch and now implementing a proper fix has dropped down to a P3 🫤. Can you tell me what the original reasoning for ignoring For anyone finding this before it gets officially fixed, this is what I did: # in MODULE.bazel
single_version_override(
module_name = "rules_python_gazelle_plugin",
patch_strip = 2, # remove "a/gazelle/"
patches = ["//tools/bazel/patches:bazelbuild/rules_python/dont_ignore_setuppy_gh2108.patch"],
) # tools/bazel/patches/bazelbuild/rules_python/dont_ignore_setuppy_gh2108.patch
diff --git a/gazelle/pythonconfig/pythonconfig.go b/gazelle/pythonconfig/pythonconfig.go
index aa925529..86a20c4f 100644
--- a/gazelle/pythonconfig/pythonconfig.go
+++ b/gazelle/pythonconfig/pythonconfig.go
@@ -109,7 +109,6 @@ const (
// defaultIgnoreFiles is the list of default values used in the
// python_ignore_files option.
var defaultIgnoreFiles = map[string]struct{}{
- "setup.py": {},
}
func SanitizeDistribution(distributionName string) string { There are couple things to point out:
|
I'm afraid I don't recall why we ignore it. On the other hand, why would you want to include a setup.py? Is it just a regular file that happens to have the same name as the well-known setup.py of a project? |
Correct. We have a number of files that are called $ find src/ -type f -name "setup.py"
src/pyle_xc/fab/hats/common_blocks/setup.py
src/pyle/sim/cirq/setup.py
src/pyle/cloud/bigquery/pipeline/setup.py
src/pyle/dataking/dc_measure/setup.py |
🐞 bug report
Affected Rule
Is this a regression?
No, seems like it's been present from the begining (a5a7ffb / #514).
Description
Gazelle incorrectly ignores files called
setup.py
.I believe this was added because the root
setup.py
is something that doesn't need a bazel target (I'm not actually sure if that's true...) or maybe it's because the rootsetup.py
is annoying to run Gazelle on.Anyway, the problem is that any file called
setup.py
will also be ignored.I'm fine with the root
setup.py
being ignored, though I reserve the right to change my mind in the future 😆This is the issue:
rules_python/gazelle/pythonconfig/pythonconfig.go
Lines 128 to 130 in fa13b01
We can very easily update the test case to account for this.
🔬 Minimal Reproduction
Dir structure:
Expected result:
A
//src/setup
target is made insrc/BUILD.bazel
.Actual result
A
//src/setup
target is not made insrc/BUILD.bazel
.🔥 Exception or Error
N/A
🌍 Your Environment
Operating System:
gLinux
Output of
bazel version
:7.2.0
Rules_python version:
0.31.0
Anything else relevant?
The text was updated successfully, but these errors were encountered: