@@ -26,28 +26,32 @@ jobs:
2626 - name : Check license compatibility
2727 run : |
2828 echo "=== Dependency Licenses ==="
29- pip-licenses --format=table --with-urls
29+ pip-licenses --format=table --with-urls || true
3030
3131 echo ""
3232 echo "=== Checking for incompatible licenses ==="
33+ pip-licenses --format=json --output-file=licenses.json || true
3334 python -c "
34- import subprocess, sys, json
35- result = subprocess.run(
36- ['pip-licenses', '--format=json'],
37- capture_output=True, text=True
38- )
39- licenses = json.loads(result.stdout)
40- blocked = ['GPL-3.0-only', 'GPL-3.0-or-later', 'AGPL-3.0-only',
41- 'AGPL-3.0-or-later', 'SSPL-1.0', 'GPL-3.0', 'AGPL-3.0']
35+ import json, sys, os
36+
37+ if not os.path.exists('licenses.json') or os.path.getsize('licenses.json') == 0:
38+ print('WARNING: Could not generate license report')
39+ sys.exit(0)
40+
41+ with open('licenses.json') as f:
42+ licenses = json.load(f)
43+
44+ blocked_patterns = ['gpl-3.0', 'agpl-3.0', 'sspl-1.0']
4245 found = []
4346 for pkg in licenses:
44- for b in blocked:
45- if b.lower() in pkg.get('License', '').lower():
46- found.append(f\" {pkg['Name']} ({pkg['License']})\")
47+ lic = pkg.get('License', '') or ''
48+ for b in blocked_patterns:
49+ if b in lic.lower():
50+ found.append(f\" {pkg.get('Name', '?')} ({lic})\")
4751 if found:
4852 print('FAIL: Found incompatible licenses:')
4953 for f in found:
5054 print(f)
5155 sys.exit(1)
52- print('OK: All dependency licenses are compatible with Apache 2.0')
56+ print(f 'OK: All {len(licenses)} dependency licenses are compatible with Apache 2.0')
5357 "
0 commit comments