Skip to content

Commit 5fa7a3f

Browse files
committed
feat: Package pyi files in wheel
1.1.0 introduced separate attributes for the type definitions (`.pyi` files) and type checking. This patch adds those files to the wheel to ensure that they are distributed and available to users.
1 parent edfb4b3 commit 5fa7a3f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Unreleased changes template.
6262
env var.
6363
* (pypi) Downgraded versions of packages: `pip` from `24.3.2` to `24.0.0` and
6464
`packaging` from `24.2` to `24.0`.
65+
* (py_wheel) Package `py_library.pyi_srcs` (`.pyi` files) in the wheel.
6566

6667
{#v0-0-0-fixed}
6768
### Fixed

python/private/py_wheel.bzl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
"Implementation of py_wheel rule"
1616

17+
load(":py_info.bzl", "PyInfo")
1718
load(":py_package.bzl", "py_package_lib")
1819
load(":py_wheel_normalize_pep440.bzl", "normalize_pep440")
1920
load(":stamp.bzl", "is_stamping_enabled")
@@ -319,8 +320,13 @@ def _py_wheel_impl(ctx):
319320

320321
name_file = ctx.actions.declare_file(ctx.label.name + ".name")
321322

323+
direct_pyi_files = []
324+
for dep in ctx.attr.deps:
325+
if PyInfo in dep:
326+
direct_pyi_files.extend(dep[PyInfo].direct_pyi_files.to_list())
327+
322328
inputs_to_package = depset(
323-
direct = ctx.files.deps,
329+
direct = ctx.files.deps + direct_pyi_files,
324330
)
325331

326332
# Inputs to this rule which are not to be packaged.

0 commit comments

Comments
 (0)