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

Skip to content

Commit c75fad8

Browse files
authored
Merge pull request #18298 from johnthagen/patch-1
Include license files in built distribution
2 parents 52f7f42 + 9ad5dda commit c75fad8

File tree

5 files changed

+47
-0
lines changed

5 files changed

+47
-0
lines changed

.github/workflows/cibuildwheel.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ jobs:
3030
run: |
3131
python -m pip install cibuildwheel==1.5.5
3232
33+
- name: Copy setup.cfg to configure wheel
34+
run: |
35+
cp setup.cfg.template setup.cfg
36+
3337
- name: Build wheels for CPython
3438
run: |
3539
python -m cibuildwheel --output-dir dist
@@ -65,6 +69,10 @@ jobs:
6569
startsWith(github.ref, 'refs/heads/v3.3') ||
6670
startsWith(github.ref, 'refs/tags/v3.3') )
6771
72+
- name: Validate that LICENSE files are included in wheels
73+
run: |
74+
python ./ci/check_wheel_licenses.py
75+
6876
- uses: actions/upload-artifact@v2
6977
with:
7078
name: wheels
File renamed without changes.
File renamed without changes.

ci/check_wheel_licenses.py

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

setup.cfg.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Rename this file to setup.cfg to modify Matplotlib's build options.
22

3+
[metadata]
4+
license_files = LICENSE/*
5+
36
[egg_info]
47

58
[libs]

0 commit comments

Comments
 (0)