Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 5 additions & 2 deletions examples/wheel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,11 @@ py_wheel(
# An example of how to change the wheel package root directory using 'strip_path_prefixes'.
py_wheel(
name = "custom_package_root",
# Package data. We're building "custom_package_root-0.0.1-py3-none-any.whl"
distribution = "example_custom_package_root",
# Package data. We're building "examples_custom_package_root-0.0.1-py3-none-any.whl"
distribution = "examples_custom_package_root",
entry_points = {
"console_scripts": ["main = foo.bar:baz"],
},
python_tag = "py3",
strip_path_prefixes = [
"examples",
Expand Down
9 changes: 5 additions & 4 deletions examples/wheel/wheel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def test_custom_package_root_wheel(self):
"rules_python",
"examples",
"wheel",
"example_custom_package_root-0.0.1-py3-none-any.whl",
"examples_custom_package_root-0.0.1-py3-none-any.whl",
)

with zipfile.ZipFile(filename) as zf:
Expand All @@ -230,9 +230,10 @@ def test_custom_package_root_wheel(self):
"wheel/lib/module_with_data.py",
"wheel/lib/simple_module.py",
"wheel/main.py",
"example_custom_package_root-0.0.1.dist-info/WHEEL",
"example_custom_package_root-0.0.1.dist-info/METADATA",
"example_custom_package_root-0.0.1.dist-info/RECORD",
"examples_custom_package_root-0.0.1.dist-info/WHEEL",
"examples_custom_package_root-0.0.1.dist-info/METADATA",
"examples_custom_package_root-0.0.1.dist-info/entry_points.txt",
"examples_custom_package_root-0.0.1.dist-info/RECORD",
],
)

Expand Down
4 changes: 4 additions & 0 deletions tools/wheelmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def __init__(
+ ".dist-info/"
)
self._zipfile = None
# Entries for the RECORD file as (filename, hash, size) tuples.
self._record = []

def __enter__(self):
Expand Down Expand Up @@ -119,6 +120,9 @@ def add_file(self, package_filename, real_filename):
def arcname_from(name):
# Always use unix path separators.
normalized_arcname = name.replace(os.path.sep, "/")
# Don't manipulate names filenames in the .distinfo directory.
if normalized_arcname.startswith(self._distinfo_dir):
return normalized_arcname
for prefix in self._strip_path_prefixes:
if normalized_arcname.startswith(prefix):
return normalized_arcname[len(prefix) :]
Expand Down