Skip to content

Commit 1856170

Browse files
committed
fix: escape name segment of stamped wheel files
1 parent 6854dc3 commit 1856170

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ Unreleased changes template.
9090
transitions transitioning on the `python_version` flag.
9191
Fixes [#2685](https://github.com/bazel-contrib/rules_python/issues/2685).
9292
* (toolchains) Run the check on the Python interpreter in isolated mode, to ensure it's not affected by userland environment variables, such as `PYTHONPATH`.
93+
* (py_wheel) Ensure the filename segment is escaped in when using stamping wheel names.
9394

9495
{#v0-0-0-added}
9596
### Added

Diff for: examples/wheel/wheel_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def test_rule_creates_directory_and_is_included_in_wheel(self):
440440

441441
def test_rule_expands_workspace_status_keys_in_wheel_metadata(self):
442442
filename = self._get_path(
443-
"example_minimal_library{BUILD_USER}-0.1.{BUILD_TIMESTAMP}-py3-none-any.whl"
443+
"example_minimal_library{BUILD_USER}-0.1._BUILD_TIMESTAMP_-py3-none-any.whl"
444444
)
445445

446446
with zipfile.ZipFile(filename) as zf:

Diff for: python/private/py_wheel.bzl

+4-2
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,15 @@ def _input_file_to_arg(input_file):
304304
return "%s;%s" % (py_package_lib.path_inside_wheel(input_file), input_file.path)
305305

306306
def _py_wheel_impl(ctx):
307+
is_stamping = is_stamping_enabled(ctx.attr)
308+
307309
abi = _replace_make_variables(ctx.attr.abi, ctx)
308310
python_tag = _replace_make_variables(ctx.attr.python_tag, ctx)
309311
version = _replace_make_variables(ctx.attr.version, ctx)
310312

311313
filename_segments = [
312314
_escape_filename_distribution_name(ctx.attr.distribution),
313-
normalize_pep440(version),
315+
_escape_filename_segment(normalize_pep440(version)) if is_stamping else normalize_pep440(version),
314316
_escape_filename_segment(python_tag),
315317
_escape_filename_segment(abi),
316318
_escape_filename_segment(ctx.attr.platform),
@@ -352,7 +354,7 @@ def _py_wheel_impl(ctx):
352354
args.add_all(ctx.attr.strip_path_prefixes, format_each = "--strip_path_prefix=%s")
353355

354356
# Pass workspace status files if stamping is enabled
355-
if is_stamping_enabled(ctx.attr):
357+
if is_stamping:
356358
args.add("--volatile_status_file", ctx.version_file)
357359
args.add("--stable_status_file", ctx.info_file)
358360
other_inputs.extend([ctx.version_file, ctx.info_file])

0 commit comments

Comments
 (0)