diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c2f84f83a..3ae28a9678 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,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/ diff --git a/gazelle/python/testdata/dont_ignore_setup/BUILD.in b/gazelle/python/testdata/dont_ignore_setup/BUILD.in new file mode 100644 index 0000000000..af2c2cea4b --- /dev/null +++ b/gazelle/python/testdata/dont_ignore_setup/BUILD.in @@ -0,0 +1 @@ +# gazelle:python_generation_mode file diff --git a/gazelle/python/testdata/dont_ignore_setup/BUILD.out b/gazelle/python/testdata/dont_ignore_setup/BUILD.out new file mode 100644 index 0000000000..acf9324d3d --- /dev/null +++ b/gazelle/python/testdata/dont_ignore_setup/BUILD.out @@ -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__"], +) diff --git a/gazelle/python/testdata/dont_ignore_setup/README.md b/gazelle/python/testdata/dont_ignore_setup/README.md new file mode 100644 index 0000000000..d170364cb2 --- /dev/null +++ b/gazelle/python/testdata/dont_ignore_setup/README.md @@ -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. diff --git a/gazelle/python/testdata/dont_ignore_setup/WORKSPACE b/gazelle/python/testdata/dont_ignore_setup/WORKSPACE new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/dont_ignore_setup/setup.py b/gazelle/python/testdata/dont_ignore_setup/setup.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/dont_ignore_setup/test.yaml b/gazelle/python/testdata/dont_ignore_setup/test.yaml new file mode 100644 index 0000000000..c27e6c854b --- /dev/null +++ b/gazelle/python/testdata/dont_ignore_setup/test.yaml @@ -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. + +--- diff --git a/gazelle/python/testdata/python_ignore_files_directive/BUILD.out b/gazelle/python/testdata/python_ignore_files_directive/BUILD.out index 1fe6030053..234ff71b13 100644 --- a/gazelle/python/testdata/python_ignore_files_directive/BUILD.out +++ b/gazelle/python/testdata/python_ignore_files_directive/BUILD.out @@ -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__"], ) diff --git a/gazelle/pythonconfig/pythonconfig.go b/gazelle/pythonconfig/pythonconfig.go index 55121381dd..fde0a98da2 100644 --- a/gazelle/pythonconfig/pythonconfig.go +++ b/gazelle/pythonconfig/pythonconfig.go @@ -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