Skip to content

Commit

Permalink
feat: add requires_file for py_wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
weixiao-huang authored and huangweixiao committed Mar 9, 2022
1 parent 79cebad commit 1fb7b94
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python/packaging.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ def _py_wheel_impl(ctx):
for r in ctx.attr.requires:
args.add("--requires", r)

if ctx.attr.requires_file:
requires_file = ctx.file.requires_file
args.add("--requires_file", requires_file)
other_inputs.append(requires_file)

for option, requirements in ctx.attr.extra_requires.items():
for r in requirements:
args.add("--extra_requires", r + ";" + option)
Expand Down Expand Up @@ -314,6 +319,10 @@ _requirement_attrs = {
"requires": attr.string_list(
doc = "List of requirements for this package",
),
"requires_file": attr.label(
doc = "requirements file for List of requirements for this package",
allow_single_file = True,
),
}

_entrypoint_attrs = {
Expand Down
9 changes: 9 additions & 0 deletions tools/wheelmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,11 @@ def parse_args() -> argparse.Namespace:
action="append",
help="List of package requirements. Can be supplied multiple times.",
)
requirements_group.add_argument(
"--requires_file",
type=Path,
help="List of package requirements file.",
)
requirements_group.add_argument(
"--extra_requires",
type=str,
Expand Down Expand Up @@ -434,6 +439,10 @@ def main() -> None:
classifiers = arguments.classifier or []
python_requires = arguments.python_requires or ""
requires = arguments.requires or []
if len(requires) == 0 and arguments.requires_file:
with open(arguments.requires_file) as fp:
requires = fp.read().strip().split("\n")

extra_headers = arguments.header or []

maker.add_metadata(
Expand Down

0 comments on commit 1fb7b94

Please sign in to comment.