@@ -127,13 +127,7 @@ class _Entry(typing.NamedTuple):
127127
128128
129129def _canonicalize_distinfo (dir_name : str ) -> str :
130- """Canonicalize a `<name>-<version>.dist-info` directory for equality
131- comparison. Collapses runs of ``-``, ``_``, ``.`` to a single ``-`` and
132- lowercases, so that e.g. ``dist-info-sboms-1.0.dist-info`` and
133- ``dist_info_sboms-1.0.dist-info`` compare equal. PEP 491 uses ``_`` as
134- the separator while users typing ``meson.project_name()`` often carry
135- hyphens from their original name.
136- """
130+ """Canonical form for .dist-info directory equality comparison."""
137131 return re .sub (r'[-_.]+' , '-' , dir_name ).lower ()
138132
139133
@@ -142,15 +136,7 @@ def _map_to_wheel(
142136 exclude : List [str ], include : List [str ],
143137 distinfo_dir : str ,
144138) -> DefaultDict [str , List [_Entry ]]:
145- """Map files to the wheel, organized by wheel installation directory.
146-
147- ``distinfo_dir`` is the ``<name>-<version>.dist-info`` directory name this
148- wheel will carry, derived from PEP 621 metadata. Files staged under
149- ``{py_purelib}/<distinfo_dir>/...`` are rerouted into the wheel's
150- ``.dist-info/`` at pack time — this is the mechanism projects use to
151- place PEP 770 SBOMs and other dist-info-bound metadata files in the
152- wheel.
153- """
139+ """Map files to the wheel, organized by wheel installation directory."""
154140 wheel_files : DefaultDict [str , List [_Entry ]] = collections .defaultdict (list )
155141 packages : Dict [str , str ] = {}
156142 excluded = _compile_patterns (exclude )
@@ -172,14 +158,8 @@ def _map_to_wheel(
172158 if path is None :
173159 raise BuildError (f'Could not map installation path to an equivalent wheel directory: { str (destination )!r} ' )
174160
175- # Files staged under {py_purelib}/<our-distinfo>/... or
176- # {py_platlib}/<our-distinfo>/... are routed into the wheel's
177- # .dist-info/ at pack time. Both roots are recognized because a
178- # project built with pure: false installs into platlib (pandas,
179- # numpy, scipy) while a pure-Python project uses purelib.
180- # Authority for the distinfo dir name is the PEP 621 metadata;
181- # the user's meson.build can write the name with either hyphens
182- # or underscores and we compare canonically.
161+ # Route <distinfo>/... staged under purelib or platlib into
162+ # the wheel's .dist-info/.
183163 if (
184164 path in ('purelib' , 'platlib' )
185165 and dst .parts
@@ -544,11 +524,7 @@ def _wheel_write_metadata(
544524 def build (self , directory : Path ) -> pathlib .Path :
545525 wheel_file = pathlib .Path (directory , f'{ self .name } .whl' )
546526 with mesonpy ._wheelfile .WheelFile (wheel_file , 'w' ) as whl :
547- # Track files written under .dist-info/ to surface collisions
548- # (two files at the same wheel path would silently clobber
549- # each other in the archive). Populated by both
550- # _wheel_write_metadata (license files) and the manifest loop
551- # below (files routed via python.dist_info_install_dir()).
527+ # Collision tracker for files written under .dist-info/.
552528 distinfo_seen : Dict [str , str ] = {}
553529 self ._wheel_write_metadata (whl , distinfo_seen )
554530
@@ -566,16 +542,12 @@ def build(self, directory: Path) -> pathlib.Path:
566542 # custom installation path for bundled libraries
567543 dst = pathlib .Path (self ._libs_dir , dst )
568544 elif path == 'distinfo' :
569- # files detected under {purelib}/<distinfo>/... in
570- # the install plan; see _map_to_wheel().
571545 target = pathlib .Path (self ._distinfo_dir , dst ).as_posix ()
572- previous = distinfo_seen .get (target )
573- if previous is not None :
546+ if target in distinfo_seen :
574547 raise BuildError (
575- f'Two files would be installed to { target !r} '
576- f'in the wheel: { previous !r} and { str (src )!r} . '
577- f'Files placed in .dist-info/ must have '
578- f'unique basenames within their subdirectory.' )
548+ f'Two files would be installed to { target !r} in the wheel: '
549+ f'{ distinfo_seen [target ]!r} and { str (src )!r} . '
550+ f'Files placed in .dist-info/ must have unique paths.' )
579551 distinfo_seen [target ] = str (src )
580552 dst = pathlib .Path (self ._distinfo_dir , dst )
581553 else :
0 commit comments