diff --git a/CHANGELOG.md b/CHANGELOG.md index cad074e6a6..eb78f3bb96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ END_UNRELEASED_TEMPLATE * (rules) PyInfo provider is now advertised by py_test, py_binary, and py_library; this allows aspects using required_providers to function correctly. ([#2506](https://github.com/bazel-contrib/rules_python/issues/2506)). +* (py_wheel) Ensure the filename segment is escaped in when using stamping wheel names. {#v0-0-0-added} ### Added diff --git a/examples/wheel/wheel_test.py b/examples/wheel/wheel_test.py index 9ec150301d..49e349dac7 100644 --- a/examples/wheel/wheel_test.py +++ b/examples/wheel/wheel_test.py @@ -440,7 +440,7 @@ def test_rule_creates_directory_and_is_included_in_wheel(self): def test_rule_expands_workspace_status_keys_in_wheel_metadata(self): filename = self._get_path( - "example_minimal_library{BUILD_USER}-0.1.{BUILD_TIMESTAMP}-py3-none-any.whl" + "example_minimal_library{BUILD_USER}-0.1._BUILD_TIMESTAMP_-py3-none-any.whl" ) with zipfile.ZipFile(filename) as zf: diff --git a/python/private/py_wheel.bzl b/python/private/py_wheel.bzl index c196ca6ad0..9cbebed348 100644 --- a/python/private/py_wheel.bzl +++ b/python/private/py_wheel.bzl @@ -304,13 +304,15 @@ def _input_file_to_arg(input_file): return "%s;%s" % (py_package_lib.path_inside_wheel(input_file), input_file.path) def _py_wheel_impl(ctx): + is_stamping = is_stamping_enabled(ctx.attr) + abi = _replace_make_variables(ctx.attr.abi, ctx) python_tag = _replace_make_variables(ctx.attr.python_tag, ctx) version = _replace_make_variables(ctx.attr.version, ctx) filename_segments = [ _escape_filename_distribution_name(ctx.attr.distribution), - normalize_pep440(version), + _escape_filename_segment(normalize_pep440(version)) if is_stamping else normalize_pep440(version), _escape_filename_segment(python_tag), _escape_filename_segment(abi), _escape_filename_segment(ctx.attr.platform), @@ -352,7 +354,7 @@ def _py_wheel_impl(ctx): args.add_all(ctx.attr.strip_path_prefixes, format_each = "--strip_path_prefix=%s") # Pass workspace status files if stamping is enabled - if is_stamping_enabled(ctx.attr): + if is_stamping: args.add("--volatile_status_file", ctx.version_file) args.add("--stable_status_file", ctx.info_file) other_inputs.extend([ctx.version_file, ctx.info_file])