Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 68d63ce

Browse files
committed
Validate that LICENSE files are included in build wheels
1 parent de2315b commit 68d63ce

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

.github/workflows/cibuildwheel.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ jobs:
6767
startsWith(github.ref, 'refs/heads/v3.3') ||
6868
startsWith(github.ref, 'refs/tags/v3.3') )
6969
70+
- name: Validate that LICENSE files are included in wheels
71+
run: |
72+
python ./ci/check_wheel_licenses.py
73+
7074
- uses: actions/upload-artifact@v2
7175
with:
7276
name: wheels
File renamed without changes.
File renamed without changes.

ci/check_wheel_licenses.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python3
2+
3+
"""Check that all .whl files in the dist folder have the correct LICENSE files included.
4+
5+
To run:
6+
$ python3 setup.py bdist_wheel
7+
$ ./ci/check_wheel_licenses.py
8+
"""
9+
10+
from pathlib import Path
11+
import sys
12+
import zipfile
13+
14+
EXIT_SUCCESS = 0
15+
EXIT_FAILURE = 1
16+
17+
project_dir = Path(__file__).parent.resolve().parent
18+
dist_dir = project_dir / 'dist'
19+
license_dir = project_dir / 'LICENSE'
20+
21+
license_file_names = [Path(path).name for path in sorted(license_dir.glob('*'))]
22+
for wheel in dist_dir.glob('*.whl'):
23+
print(f'Checking LICENSE files in: {wheel}')
24+
with zipfile.ZipFile(wheel) as f:
25+
wheel_license_file_names = [Path(path).name for path in sorted(f.namelist())
26+
if '.dist-info/LICENSE' in path]
27+
if wheel_license_file_names != license_file_names:
28+
print(f'LICENSE file(s) missing:\n'
29+
f'{wheel_license_file_names} !=\n'
30+
f'{license_file_names}')
31+
sys.exit(EXIT_FAILURE)
32+
sys.exit(EXIT_SUCCESS)

0 commit comments

Comments
 (0)