Skip to content

py_wheel strips dist-info filenames #682

@alexeagle

Description

@alexeagle

Reproduce by changing our examples/wheel example, adding a strip_path_prefixes that removes the same prefix as the name of the distribution:

py_wheel(
    name = "minimal_with_py_library",
    # Package data. We're building "example_minimal_library-0.0.1-py3-none-any.whl"
    distribution = "examples",
    entry_points = {'console_scripts': ["main = examples.wheel.main:main"]},
    strip_path_prefixes = ["examples"],
    python_tag = "py3",
    version = "0.0.1",
    deps = [
        "//examples/wheel/lib:module_with_data",
        "//examples/wheel/lib:simple_module",
    ],
)

Now due to https://github.com/bazelbuild/rules_python/blob/main/tools/wheelmaker.py#L137 we strip the "examples" off one of the dist-info files:

$ bazel build examples/wheel:minimal_with_py_library
Target //examples/wheel:minimal_with_py_library up-to-date:
  bazel-bin/examples/wheel/examples-0.0.1-py3-none-any.whl

$ less bazel-bin/examples/wheel/examples-0.0.1-py3-none-any.whl
Metadata-Version: 2.1
Name: examples
Version: 0.0.1

Archive:  bazel-bin/examples/wheel/examples-0.0.1-py3-none-any.whl
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
     637  Defl:N      402  37% 2022-03-20 10:07 7eaa34f2  wheel/lib/module_with_data.py
     637  Defl:N      403  37% 2022-03-20 10:07 7f0bd522  wheel/lib/simple_module.py
      91  Defl:N       86   6% 2022-04-04 13:07 4f1122ec  examples-0.0.1.dist-info/WHEEL
      61  Defl:N       54  12% 2022-04-04 13:07 b6a3ded8  examples-0.0.1.dist-info/METADATA
      49  Defl:N       46   6% 2022-04-04 13:07 d178372b  -0.0.1.dist-info/entry_points.txt
     464  Defl:N      316  32% 2022-04-04 13:07 d09a1a14  examples-0.0.1.dist-info/RECORD
--------          -------  ---                            -------
    1939             1307  33%                            6 files

The -0.0.1.dist-info/entry_points.txt file inside the wheel has a bad path name.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions