From 2a89cdea94c4678f8c6531a7a36ad8b6baf332ad Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Mon, 7 Mar 2022 17:10:12 +0000 Subject: [PATCH] Revert "use PEP621 metadata to define license file to copy to wheel" This reverts commit cd8b4d0b2307ef0e5ee8952e674a7f9dafa55fd1. embedding the full LICENSE text file as a multi-line RFC5322 text breaks in unexpected ways on Windows, I get double CRLF line endings which lead to twine check fail to validate the README section that follows the LICENSE... Let's revert to adding the license file using wheeltools for the time being. --- build.py | 13 +++++++++++-- pyproject.toml | 1 - requirements.txt | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/build.py b/build.py index 1bf1d30..c953ad1 100755 --- a/build.py +++ b/build.py @@ -6,6 +6,7 @@ import subprocess import sys from pathlib import Path +from wheeltools import InWheel root_dir = Path(__file__).parent.resolve() @@ -37,10 +38,18 @@ def main(): except (IndexError, KeyError): sys.exit("usage: build.py [sdist|wheel]") - return subprocess.call( - cmd + ["-o", str(dist_dir)] + sys.argv[2:], cwd=str(crate_dir) + subprocess.run( + cmd + ["-o", str(dist_dir)] + sys.argv[2:], check=True, cwd=str(crate_dir) ) + # maturin doesn't add the license text to the wheel archive yet so we + # have to do it ourselves: cf. https://github.com/PyO3/maturin/issues/829 + for wheel_file in dist_dir.glob("pngquant*.whl"): + with InWheel(in_wheel=str(wheel_file), out_wheel=str(wheel_file)) as tmpdir: + distinfo = next(Path(tmpdir).glob("*.dist-info")) + assert distinfo.is_dir() + shutil.copyfile(crate_dir / "COPYRIGHT", distinfo / "LICENSE") + if __name__ == "__main__": sys.exit(main()) diff --git a/pyproject.toml b/pyproject.toml index e3d4014..067802a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,6 @@ name = "pngquant-cli" version = "2.17.0.post3" description = "Precompiled binaries for pngquant, the lossy PNG compressor based on libimagequant." maintainers = [{name = "Cosimo Lupo", email = "cosimo@anthrotype.com"}] -license = {file = "COPYRIGHT"} [project.urls] repository = "https://github.com/anthrotype/pngquant-wheels" diff --git a/requirements.txt b/requirements.txt index a9ee414..9b77ee3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ maturin tomli tomli-w twine +wheeltools