Skip to content

Commit

Permalink
Add stable status to wheel stamping
Browse files Browse the repository at this point in the history
  • Loading branch information
UebelAndre committed Oct 25, 2021
1 parent 66f7187 commit b147448
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion python/packaging.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ def _py_wheel_impl(ctx):
# Pass workspace status files if stamping is enabled
if is_stamping_enabled(ctx.attr):
args.add("--volatile_status_file", ctx.version_file)
other_inputs.append(ctx.version_file)
args.add("--stable_status_file", ctx.version_file)
other_inputs.extend([ctx.version_file, ctx.info_file])

args.add("--input_file_list", packageinputfile)

Expand Down
19 changes: 13 additions & 6 deletions tools/wheelmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,19 @@ def get_files_to_package(input_files):
return files


def resolve_version_stamp(version: str, resolve_version_stamp: Path) -> str:
def resolve_version_stamp(version: str, volatile_status_stamp: Path, stable_status_stamp: Path) -> str:
"""Resolve workspace status stamps format strings found in the version string
Args:
version (str): The raw version represenation for the wheel (may include stamp variables)
resolve_version_stamp (Path): The path to a volatile workspace status file
volatile_status_stamp (Path): The path to a volatile workspace status file
stable_status_stamp (Path): The path to a stable workspace status file
Returns:
str: A resolved version string
"""
for line in resolve_version_stamp.read_text().splitlines():
"""
lines = volatile_status_stamp.read_text().splitlines() + stable_status_stamp.read_text().splitlines()
for line in lines:
if not line:
continue
key, value = line.split(' ', maxsplit=1)
Expand Down Expand Up @@ -298,6 +300,10 @@ def parse_args() -> argparse.Namespace:
'--volatile_status_file', type=Path,
help="Pass in the stamp info file for stamping"
)
build_group.add_argument(
'--stable_status_file', type=Path,
help="Pass in the stamp info file for stamping"
)

return parser.parse_args(sys.argv[1:])

Expand All @@ -323,9 +329,10 @@ def main() -> None:

strip_prefixes = [p for p in arguments.strip_path_prefix]

if arguments.volatile_status_file:
if arguments.volatile_status_file and arguments.stable_status_file:
version = resolve_version_stamp(arguments.version,
arguments.volatile_status_file)
arguments.volatile_status_file,
arguments.stable_status_file)
else:
version = arguments.version

Expand Down

0 comments on commit b147448

Please sign in to comment.