Skip to content

Commit bff2b41

Browse files
authored
Merge branch 'main' into fix/use_py_repo_utils_in_whl_library
2 parents fc30307 + 475a99e commit bff2b41

File tree

21 files changed

+573
-46
lines changed

21 files changed

+573
-46
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ Unreleased changes template.
5656
* Bazel 6 support is dropped and Bazel 7.4.1 is the minimum supported
5757
version, per our Bazel support matrix. Earlier versions are not
5858
tested by CI, so functionality cannot be guaranteed.
59+
* ({bzl:obj}`pip.parse`) From now we will make fewer calls to indexes when
60+
fetching the metadata from SimpleAPI. The calls will be done in parallel to
61+
each index separately, so the extension evaluation time might slow down if
62+
not using {bzl:obj}`pip.parse.experimental_index_url_overrides`.
5963
* ({bzl:obj}`pip.parse`) Only query SimpleAPI for packages that have
6064
sha values in the `requirements.txt` file.
6165

@@ -80,6 +84,8 @@ Unreleased changes template.
8084
* (whl_library) Now the changes to the dependencies are correctly tracked when
8185
PyPI packages used in {bzl:obj}`whl_library` during the `repository_rule` phase
8286
change. Fixes [#2468](https://github.com/bazelbuild/rules_python/issues/2468).
87+
+ (gazelle) Gazelle no longer ignores `setup.py` files by default. To restore
88+
this behavior, apply the `# gazelle:python_ignore_files setup.py` directive.
8389

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

@@ -100,6 +106,13 @@ Unreleased changes template.
100106
* 3.11.11
101107
* 3.12.8
102108
* 3.13.1
109+
* (rules) Attributes for type definition files (`.pyi` files) and type-checking
110+
only dependencies added. See {obj}`py_library.pyi_srcs` and
111+
`py_library.pyi_deps` (and the same named attributes for `py_binary` and
112+
`py_test`).
113+
* (providers) {obj}`PyInfo` has new fields to aid static analysis tools:
114+
{obj}`direct_original_sources`, {obj}`direct_pyi_files`,
115+
{obj}`transitive_original_sources`, {obj}`transitive_pyi_files`.
103116

104117
[20241206]: https://github.com/astral-sh/python-build-standalone/releases/tag/20241206
105118

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# gazelle:python_generation_mode file
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
load("@rules_python//python:defs.bzl", "py_library")
2+
3+
# gazelle:python_generation_mode file
4+
5+
py_library(
6+
name = "setup",
7+
srcs = ["setup.py"],
8+
visibility = ["//:__subpackages__"],
9+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Don't ignore setup.py files
2+
3+
Make sure that files named `setup.py` are processed by Gazelle.
4+
5+
It's believed that `setup.py` was originally ignored because it, when found
6+
in the repository root directory, is part of the `setuptools` build system
7+
and could cause some issues for Gazelle. However, files within source code can
8+
also be called `setup.py` and thus should be processed by Gazelle.

gazelle/python/testdata/dont_ignore_setup/WORKSPACE

Whitespace-only changes.

gazelle/python/testdata/dont_ignore_setup/setup.py

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2024 The Bazel Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
---

gazelle/python/testdata/python_ignore_files_directive/BUILD.out

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ load("@rules_python//python:defs.bzl", "py_library")
44

55
py_library(
66
name = "python_ignore_files_directive",
7-
srcs = ["__init__.py"],
7+
srcs = [
8+
"__init__.py",
9+
"setup.py",
10+
],
811
visibility = ["//:__subpackages__"],
912
)

gazelle/pythonconfig/pythonconfig.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ const (
126126
// defaultIgnoreFiles is the list of default values used in the
127127
// python_ignore_files option.
128128
var defaultIgnoreFiles = map[string]struct{}{
129-
"setup.py": {},
130129
}
131130

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

python/private/attributes.bzl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,35 @@ in the resulting output or not. Valid values are:
375375
* `omit_source`: Don't include the original py source.
376376
""",
377377
),
378+
"pyi_deps": attr.label_list(
379+
doc = """
380+
Dependencies providing type definitions the library needs.
381+
382+
These are dependencies that satisfy imports guarded by `typing.TYPE_CHECKING`.
383+
These are build-time only dependencies and not included as part of a runnable
384+
program (packaging rules may include them, however).
385+
386+
:::{versionadded} VERSION_NEXT_FEATURE
387+
:::
388+
""",
389+
providers = [
390+
[PyInfo],
391+
[CcInfo],
392+
] + _MaybeBuiltinPyInfo,
393+
),
394+
"pyi_srcs": attr.label_list(
395+
doc = """
396+
Type definition files for the library.
397+
398+
These are typically `.pyi` files, but other file types for type-checker specific
399+
formats are allowed. These files are build-time only dependencies and not included
400+
as part of a runnable program (packaging rules may include them, however).
401+
402+
:::{versionadded} VERSION_NEXT_FEATURE
403+
:::
404+
""",
405+
allow_files = True,
406+
),
378407
# Required attribute, but details vary by rule.
379408
# Use create_srcs_attr to create one.
380409
"srcs": None,

0 commit comments

Comments
 (0)