Skip to content
Open
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
30 changes: 20 additions & 10 deletions python/private/pypi/whl_library_deps_targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def whl_library_deps_targets(
repo,
aliases = None,
metadata_name,
requires_dist,
extras,
requires_dist = [],
extras = [],
include = [],
group_deps = [],
group_name = None,
Expand All @@ -40,25 +40,32 @@ def whl_library_deps_targets(

Args:
name: {type}`str` The wheel filename
metadata_name: {type}`str` The package name as written in wheel `METADATA`.
metadata_name: {type}`str` The package name as written in wheel
`METADATA`.
group_deps: {type}`list[str]` names of fellow members of the group (if
any). These will be excluded from generated deps lists so as to avoid
direct cycles. These dependencies will be provided at runtime by the
group rules which wrap this library and its fellows together.
requires_dist: {type}`list[str]` The list of `Requires-Dist` values from
the whl `METADATA`.
extras: {type}`list[str]` The list of requested extras. This essentially includes extra transitive dependencies in the final targets depending on the wheel `METADATA`.
the whl `METADATA`. Optional because some packages don't have them.
extras: {type}`list[str]` The list of requested extras. This essentially
includes extra transitive dependencies in the final targets
depending on the wheel `METADATA`. Optional because some packages
don't request them.
include: {type}`list[str]` The list of packages to include.
group_name: {type}`str | None` name of the dependency group (if any).
dep_template: {type}`str | None` The dep_template to use.
tags: {type}`list[str]` The tags set on the targets.
repo: {type}`str | Label | None` The BUILD.bazel label to the parent repo that has the
sources. If none, then will take the targets from the current dir.
aliases: {type}`dict[str, str] | None` The list of aliases to create in the parent repo. If None, will create
the default values. Empty list means no aliases.
repo: {type}`str | Label | None` The BUILD.bazel label to the parent
repo that has the sources. If none, then will take the targets from
the current dir.
aliases: {type}`dict[str, str] | None` The list of aliases to create in
the parent repo. If None, will create the default values. Empty list
means no aliases.
visibility: {type}`list[str]` The visibility of the targets.
native: {type}`native` The native struct for overriding in tests.
rules: {type}`struct` A struct with references to rules for creating targets.
rules: {type}`struct` A struct with references to rules for creating
targets.
"""
repo_label = Label(repo).same_package_label if repo else (lambda x: x)
if aliases == None:
Expand Down Expand Up @@ -168,6 +175,9 @@ def whl_library_deps_targets(
package_deps = package_deps,
tmpl = dep_template.format(name = "{}", target = PY_LIBRARY_PUBLIC_LABEL),
),
# Disable precompilation on this wrapper target to prevent duplicate
# pyc generation; the underlying PY_SRCS_LABEL target handles it.
precompile = "disabled",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds like a bug in precompiling.

Precompile should be OK with empty sources.

Is it actually for directory sources?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, is the idea here to pass a py_library as sources? And then precompile has to be disabled because, if the py_library is generating pyc, then those end up in srcs, and then the precompiler gives an error?

In any case, I have a WIP to make precompiling work with directory inputs and handle existing pyc in sources.

tags = tags,
visibility = impl_vis,
)
Expand Down
27 changes: 14 additions & 13 deletions python/private/pypi/whl_library_targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,17 @@ def whl_library_targets(
**kwargs
)

whl_library_deps_targets(
name = name,
metadata_name = metadata_name,
requires_dist = requires_dist,
dep_template = dep_template, # only needed if requires_dist or group_name is present
group_deps = group_deps, # only needed if group_name is present
group_name = group_name, # must specify group_deps together
extras = extras, # only needed if requires_dist is present
include = include, # only needed if requires_dist is present
repo = None, # set aliases in the same repo
aliases = {},
**kwargs
)
if dep_template:
whl_library_deps_targets(
name = name,
metadata_name = metadata_name,
requires_dist = requires_dist,
dep_template = dep_template, # only needed if requires_dist or group_name is present
group_deps = group_deps, # only needed if group_name is present
group_name = group_name, # must specify group_deps together
extras = extras, # only needed if requires_dist is present
include = include, # only needed if requires_dist is present
repo = None, # set aliases in the same repo
aliases = {},
**kwargs
)
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def _test_whl_library_deps_targets(env):
":is_include_bar_baz_true": ["@pypi//bar_baz:pkg"],
"//conditions:default": [],
}),
"precompile": "disabled",
"tags": [],
"visibility": ["//visibility:public"],
}) # buildifier: @unsorted-dict-items
Expand Down