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

feat: make pypi-generated targets include pyi files #2545

Merged
merged 3 commits into from
Jan 8, 2025
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ Unreleased changes template.
`python_version` attribute is still used to specify the Python version.
* (pypi) Updated versions of packages: `pip` to 24.3.1 and
`packaging` to 24.2.
* (pypi) For pypi-generated targets, `*.pyi` files are included in the
`pyi_srcs` attribute instead of the `data` attribute.

{#v0-0-0-deprecations}
#### Deprecations
Expand Down Expand Up @@ -120,6 +122,7 @@ Unreleased changes template.
only dependencies added. See {obj}`py_library.pyi_srcs` and
`py_library.pyi_deps` (and the same named attributes for `py_binary` and
`py_test`).
* (pypi) pypi-generated targets set `pyi_srcs` to include `*.pyi` files.
* (providers) {obj}`PyInfo` has new fields to aid static analysis tools:
{obj}`direct_original_sources`, {obj}`direct_pyi_files`,
{obj}`transitive_original_sources`, {obj}`transitive_pyi_files`.
Expand Down
5 changes: 5 additions & 0 deletions python/private/pypi/whl_library_targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ def whl_library_targets(
"**/*.py",
"**/*.pyc",
"**/*.pyc.*", # During pyc creation, temp files named *.pyc.NNNN are created
"**/*.pyi",
# RECORD is known to contain sha256 checksums of files which might include the checksums
# of generated files produced when wheels are installed. The file is ignored to avoid
# Bazel caching issues.
Expand All @@ -244,6 +245,10 @@ def whl_library_targets(
# pure-Python code, e.g. pymssql, which is written in Cython.
allow_empty = True,
),
pyi_srcs = native.glob(
["site-packages/**/*.pyi"],
allow_empty = True,
),
data = data + native.glob(
["site-packages/**/*"],
exclude = _data_exclude,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,14 @@ def _test_whl_and_library_deps(env):
exclude = [],
allow_empty = True,
),
"pyi_srcs": _glob(["site-packages/**/*.pyi"], allow_empty = True),
"data": [] + _glob(
["site-packages/**/*"],
exclude = [
"**/*.py",
"**/*.pyc",
"**/*.pyc.*",
"**/*.pyi",
"**/*.dist-info/RECORD",
] + glob_excludes.version_dependent_exclusions(),
),
Expand Down Expand Up @@ -316,12 +318,14 @@ def _test_group(env):
{
"name": "_pkg",
"srcs": _glob(["site-packages/**/*.py"], exclude = [], allow_empty = True),
"pyi_srcs": _glob(["site-packages/**/*.pyi"], allow_empty = True),
"data": [] + _glob(
["site-packages/**/*"],
exclude = [
"**/*.py",
"**/*.pyc",
"**/*.pyc.*",
"**/*.pyi",
"**/*.dist-info/RECORD",
] + glob_excludes.version_dependent_exclusions(),
),
Expand Down