diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml index f6a09ce2e816..bd88e4f360da 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -67,6 +67,10 @@ jobs: startsWith(github.ref, 'refs/heads/v3.3') || startsWith(github.ref, 'refs/tags/v3.3') ) + - name: Validate that LICENSE files are included in wheels + run: | + python ./ci/check_wheel_licenses.py + - uses: actions/upload-artifact@v2 with: name: wheels diff --git a/LICENSE/LICENSE_CARLOGO.txt b/LICENSE/LICENSE_CARLOGO similarity index 100% rename from LICENSE/LICENSE_CARLOGO.txt rename to LICENSE/LICENSE_CARLOGO diff --git a/LICENSE/Solarized.txt b/LICENSE/LICENSE_SOLARIZED similarity index 100% rename from LICENSE/Solarized.txt rename to LICENSE/LICENSE_SOLARIZED diff --git a/ci/check_wheel_licenses.py b/ci/check_wheel_licenses.py new file mode 100644 index 000000000000..b5cfffbd9aff --- /dev/null +++ b/ci/check_wheel_licenses.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 + +"""Check that all .whl files in the dist folder have the correct LICENSE files included. + +To run: + $ python3 setup.py bdist_wheel + $ ./ci/check_wheel_licenses.py +""" + +from pathlib import Path +import sys +import zipfile + +EXIT_SUCCESS = 0 +EXIT_FAILURE = 1 + +project_dir = Path(__file__).parent.resolve().parent +dist_dir = project_dir / 'dist' +license_dir = project_dir / 'LICENSE' + +license_file_names = [Path(path).name for path in sorted(license_dir.glob('*'))] +for wheel in dist_dir.glob('*.whl'): + 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 wheel_license_file_names != license_file_names: + print(f'LICENSE file(s) missing:\n' + f'{wheel_license_file_names} !=\n' + f'{license_file_names}') + sys.exit(EXIT_FAILURE) +sys.exit(EXIT_SUCCESS)