Skip to content

Commit cbe6d38

Browse files
aaronskyrickeylev
andauthored
fix: add py.typed to runfiles py_wheel so it gets packaged (bazel-contrib#3041)
Per the guidance in bazel-contrib#2503, this is a quick fix just to restore type-checking for the runfiles package. It does not address or investigate further whether py.typed data dependencies in direct `py_library` dependencies of `py_wheel` should be automatically included as inputs to the wheel. Fixes bazel-contrib#2503 --------- Co-authored-by: Richard Levasseur <[email protected]>
1 parent 4e22d25 commit cbe6d38

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ END_UNRELEASED_TEMPLATE
6969
* (pypi) Wheels with BUILD.bazel (or other special Bazel files) no longer
7070
result in missing files at runtime
7171
([#2782](https://github.com/bazel-contrib/rules_python/issues/2782)).
72+
* (runfiles) The pypi runfiles package now includes `py.typed` to indicate it
73+
supports type checking
74+
([#2503](https://github.com/bazel-contrib/rules_python/issues/2503)).
7275

7376
{#v0-0-0-added}
7477
### Added

python/runfiles/BUILD.bazel

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,19 @@ filegroup(
2222
visibility = ["//python:__pkg__"],
2323
)
2424

25+
filegroup(
26+
name = "py_typed",
27+
# See PEP 561: py.typed is a special file that indicates the code supports type checking
28+
srcs = ["py.typed"],
29+
)
30+
2531
py_library(
2632
name = "runfiles",
2733
srcs = [
2834
"__init__.py",
2935
"runfiles.py",
3036
],
31-
data = ["py.typed"],
37+
data = [":py_typed"],
3238
imports = [
3339
# Add the repo root so `import python.runfiles.runfiles` works. This makes it agnostic
3440
# to the --experimental_python_import_all_repositories setting.
@@ -57,5 +63,8 @@ py_wheel(
5763
# this can be replaced by building with --stamp --embed_label=1.2.3
5864
version = "{BUILD_EMBED_LABEL}",
5965
visibility = ["//visibility:public"],
60-
deps = [":runfiles"],
66+
deps = [
67+
":py_typed",
68+
":runfiles",
69+
],
6170
)

0 commit comments

Comments
 (0)