Skip to content

Commit 90bd23d

Browse files
dnicolodirgommers
authored andcommitted
MAINT: move license_file property to wheel builder
The license.file field in the metadata is also already an absolute path, there is no need to concatenate it to the source directory. Doing so multiple times is even less necessary.
1 parent a00f2a6 commit 90bd23d

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

mesonpy/__init__.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,13 @@ def distinfo_dir(self) -> str:
311311
def data_dir(self) -> str:
312312
return f'{self.basename}.data'
313313

314+
@property
315+
def _license_file(self) -> Optional[pathlib.Path]:
316+
license_ = self._metadata.license
317+
if license_:
318+
return license_.file
319+
return None
320+
314321
@cached_property
315322
def is_pure(self) -> bool:
316323
"""Is the wheel "pure" (architecture independent)?"""
@@ -443,11 +450,8 @@ def _wheel_write_metadata(self, whl: mesonpy._wheelfile.WheelFile) -> None:
443450
whl.writestr(f'{self.distinfo_dir}/entry_points.txt', self.entrypoints_txt)
444451

445452
# add license (see https://github.com/mesonbuild/meson-python/issues/88)
446-
if self._project.license_file:
447-
whl.write(
448-
self._source_dir / self._project.license_file,
449-
f'{self.distinfo_dir}/{os.path.basename(self._project.license_file)}',
450-
)
453+
if self._license_file:
454+
whl.write(self._license_file, f'{self.distinfo_dir}/{os.path.basename(self._license_file)}')
451455

452456
def build(self, directory: Path) -> pathlib.Path:
453457
# ensure project is built
@@ -839,13 +843,6 @@ def version(self) -> str:
839843
"""Project version."""
840844
return str(self._metadata.version)
841845

842-
@property
843-
def license_file(self) -> Optional[pathlib.Path]:
844-
license_ = self._metadata.license
845-
if license_ and license_.file:
846-
return pathlib.Path(license_.file)
847-
return None
848-
849846
@property
850847
def is_pure(self) -> bool:
851848
"""Is the wheel "pure" (architecture independent)?"""

0 commit comments

Comments
 (0)