File: check_wheel_licenses.py

package info (click to toggle)
matplotlib 3.10.1%2Bdfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 78,340 kB
  • sloc: python: 147,118; cpp: 62,988; objc: 1,679; ansic: 1,426; javascript: 786; makefile: 92; sh: 53
file content (33 lines) | stat: -rw-r--r-- 1,101 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3

"""
Check that all specified .whl files have the correct LICENSE files included.

To run:
    $ python3 -m build --wheel
    $ ./ci/check_wheel_licenses.py dist/*.whl
"""

from pathlib import Path
import sys
import zipfile


if len(sys.argv) <= 1:
    sys.exit('At least one wheel must be specified in command-line arguments.')

project_dir = Path(__file__).parent.resolve().parent
license_dir = project_dir / 'LICENSE'

license_file_names = {path.name for path in sorted(license_dir.glob('*'))}
for wheel in sys.argv[1:]:
    print(f'Checking LICENSE files in: {wheel}')
    with zipfile.ZipFile(wheel) as f:
        wheel_license_file_names = {Path(path).name
                                    for path in sorted(f.namelist())
                                    if '.dist-info/LICENSE' in path}
        if not (len(wheel_license_file_names) and
                wheel_license_file_names.issuperset(license_file_names)):
            sys.exit(f'LICENSE file(s) missing:\n'
                     f'{wheel_license_file_names} !=\n'
                     f'{license_file_names}')