Skip to content

Commit

Permalink
fix: make requires_file additive and fix Requires-Dist bug
Browse files Browse the repository at this point in the history
  • Loading branch information
weixiao-huang authored and huangweixiao committed Oct 12, 2022
1 parent f197f76 commit cd7edd7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/packaging.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions python/packaging.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def _py_wheel_impl(ctx):
if ctx.attr.python_requires:
metadata_contents.append("Requires-Python: %s" % ctx.attr.python_requires)

if len(ctx.attr.requires) == 0 and ctx.attr.requires_file:
if ctx.attr.requires_file:
requires_file = ctx.file.requires_file
args.add("--requires_file", requires_file)
other_inputs.append(requires_file)
Expand Down Expand Up @@ -358,7 +358,7 @@ _requirement_attrs = {
"for details and examples of the format of this argument."),
),
"requires_file": attr.label(
doc = "Requirements file for list of requirements for this package. If set `requires`, this flag will be ignored.",
doc = "Requirements file for list of requirements for this package, which will be additive after `requires`",
allow_single_file = True,
),
}
Expand Down
6 changes: 3 additions & 3 deletions tools/wheelmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,7 @@ def parse_args() -> argparse.Namespace:
metadata_group.add_argument(
"--requires_file",
type=Path,
default="",
help="Requirements file for list of requirements for this package",
help="Requirements file for list of requirements for this package, which will be additive after `requires`",
)

output_group = parser.add_argument_group("Output file location")
Expand Down Expand Up @@ -406,7 +405,8 @@ def main() -> None:

if arguments.requires_file:
with open(arguments.requires_file) as fp:
metadata += "\n" + fp.read().strip().split("\n")
additive_requires_list = ["Requires-Dist: {}".format(line) for line in fp.read().strip().split("\n")]
metadata += "\n" + "\n".join(additive_requires_list)
maker.add_metadata(metadata=metadata, description=description)

if arguments.entry_points_file:
Expand Down

0 comments on commit cd7edd7

Please sign in to comment.