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