diff --git a/examples/wheel/BUILD b/examples/wheel/BUILD index 0c24da8218..151a9c94ec 100644 --- a/examples/wheel/BUILD +++ b/examples/wheel/BUILD @@ -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", diff --git a/examples/wheel/wheel_test.py b/examples/wheel/wheel_test.py index ffdc6409e4..be74792a70 100644 --- a/examples/wheel/wheel_test.py +++ b/examples/wheel/wheel_test.py @@ -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: @@ -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", ], ) diff --git a/tools/wheelmaker.py b/tools/wheelmaker.py index 4b87a596ab..0bd585f3bb 100644 --- a/tools/wheelmaker.py +++ b/tools/wheelmaker.py @@ -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): @@ -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) :]