Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Unreleased changes template.
transitions transitioning on the `python_version` flag.
Fixes [#2685](https://github.com/bazel-contrib/rules_python/issues/2685).
* (toolchains) Run the check on the Python interpreter in isolated mode, to ensure it's not affected by userland environment variables, such as `PYTHONPATH`.
* (py_wheel) Ensure the filename segment is escaped in when using stamping wheel names.

{#v0-0-0-added}
### Added
Expand Down
2 changes: 1 addition & 1 deletion examples/wheel/wheel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The distribution likely needs escaping too.

)

with zipfile.ZipFile(filename) as zf:
Expand Down
6 changes: 4 additions & 2 deletions python/private/py_wheel.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something strange is going on, or I'm missing something.

The net code change is the same as before: normalize(...) if ... else normalize(...)

The test was updated, though? Which would mean it's working?? Is the test not covering something...?

_escape_filename_segment(python_tag),
_escape_filename_segment(abi),
_escape_filename_segment(ctx.attr.platform),
Expand Down Expand Up @@ -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])
Expand Down