Skip to content

Commit

Permalink
use PEP621 metadata to define license file to copy to wheel
Browse files Browse the repository at this point in the history
turns out maturin does support copying the LICENSE file to the wheel.
The full text is embedded in the wheel's METADATA file.
  • Loading branch information
anthrotype committed Mar 5, 2022
1 parent 2a4e812 commit cd8b4d0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
13 changes: 2 additions & 11 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import subprocess
import sys
from pathlib import Path
from wheeltools import InWheel


root_dir = Path(__file__).parent.resolve()
Expand Down Expand Up @@ -38,18 +37,10 @@ def main():
except (IndexError, KeyError):
sys.exit("usage: build.py [sdist|wheel]")

subprocess.run(
cmd + ["-o", str(dist_dir)] + sys.argv[2:], check=True, cwd=str(crate_dir)
return subprocess.call(
cmd + ["-o", str(dist_dir)] + sys.argv[2:], 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())
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ bindings = "bin"
[project]
name = "pngquant-cli"
# by default, use the same 'version' as Cargo.toml, but can override if needed
version = "2.17.0.post1"
version = "2.17.0.post2"
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"
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ maturin
tomli
tomli-w
twine
wheeltools

0 comments on commit cd8b4d0

Please sign in to comment.