Skip to content

Commit 81c2acf

Browse files
authored
Fix issue #682 (#685)
Fix a bug where path prefix could be stripped from the distinfo directory name Fixes bug #682
1 parent deb43b0 commit 81c2acf

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

examples/wheel/BUILD

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,11 @@ py_wheel(
130130
# An example of how to change the wheel package root directory using 'strip_path_prefixes'.
131131
py_wheel(
132132
name = "custom_package_root",
133-
# Package data. We're building "custom_package_root-0.0.1-py3-none-any.whl"
134-
distribution = "example_custom_package_root",
133+
# Package data. We're building "examples_custom_package_root-0.0.1-py3-none-any.whl"
134+
distribution = "examples_custom_package_root",
135+
entry_points = {
136+
"console_scripts": ["main = foo.bar:baz"],
137+
},
135138
python_tag = "py3",
136139
strip_path_prefixes = [
137140
"examples",

examples/wheel/wheel_test.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def test_custom_package_root_wheel(self):
219219
"rules_python",
220220
"examples",
221221
"wheel",
222-
"example_custom_package_root-0.0.1-py3-none-any.whl",
222+
"examples_custom_package_root-0.0.1-py3-none-any.whl",
223223
)
224224

225225
with zipfile.ZipFile(filename) as zf:
@@ -230,9 +230,10 @@ def test_custom_package_root_wheel(self):
230230
"wheel/lib/module_with_data.py",
231231
"wheel/lib/simple_module.py",
232232
"wheel/main.py",
233-
"example_custom_package_root-0.0.1.dist-info/WHEEL",
234-
"example_custom_package_root-0.0.1.dist-info/METADATA",
235-
"example_custom_package_root-0.0.1.dist-info/RECORD",
233+
"examples_custom_package_root-0.0.1.dist-info/WHEEL",
234+
"examples_custom_package_root-0.0.1.dist-info/METADATA",
235+
"examples_custom_package_root-0.0.1.dist-info/entry_points.txt",
236+
"examples_custom_package_root-0.0.1.dist-info/RECORD",
236237
],
237238
)
238239

tools/wheelmaker.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def __init__(
6767
+ ".dist-info/"
6868
)
6969
self._zipfile = None
70+
# Entries for the RECORD file as (filename, hash, size) tuples.
7071
self._record = []
7172

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

0 commit comments

Comments
 (0)