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

fix(gazelle): Don't ignore setup.py files when running Gazelle #2536

Merged
merged 4 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ Unreleased changes template.
are now printing more details and include the currently active flag
values. Fixes [#2466](https://github.com/bazelbuild/rules_python/issues/2466).
* (py_proto_library) Fix import paths in Bazel 8.
+ (gazelle) Gazelle no longer ignores `setup.py` files by default. To restore
this behavior, apply the `# gazelle:python_ignore_files setup.py` directive.

[pep-695]: https://peps.python.org/pep-0695/

Expand Down
1 change: 1 addition & 0 deletions gazelle/python/testdata/dont_ignore_setup/BUILD.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# gazelle:python_generation_mode file
9 changes: 9 additions & 0 deletions gazelle/python/testdata/dont_ignore_setup/BUILD.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@rules_python//python:defs.bzl", "py_library")

# gazelle:python_generation_mode file

py_library(
name = "setup",
srcs = ["setup.py"],
visibility = ["//:__subpackages__"],
)
8 changes: 8 additions & 0 deletions gazelle/python/testdata/dont_ignore_setup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Don't ignore setup.py files

Make sure that files named `setup.py` are processed by Gazelle.

It's believed that `setup.py` was originally ignored because it, when found
in the repository root directory, is part of the `setuptools` build system
and could cause some issues for Gazelle. However, files within source code can
also be called `setup.py` and thus should be processed by Gazelle.
Empty file.
Empty file.
15 changes: 15 additions & 0 deletions gazelle/python/testdata/dont_ignore_setup/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ load("@rules_python//python:defs.bzl", "py_library")

py_library(
name = "python_ignore_files_directive",
srcs = ["__init__.py"],
srcs = [
"__init__.py",
"setup.py",
],
visibility = ["//:__subpackages__"],
)
1 change: 0 additions & 1 deletion gazelle/pythonconfig/pythonconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ const (
// defaultIgnoreFiles is the list of default values used in the
// python_ignore_files option.
var defaultIgnoreFiles = map[string]struct{}{
"setup.py": {},
}

// Configs is an extension of map[string]*Config. It provides finding methods
Expand Down