Skip to content

Commit 16cd9b4

Browse files
Merge pull request #3415 from nexB/release-prep-v32.0.2
Release Prep v32.0.2
2 parents 887d56c + 12fd01b commit 16cd9b4

File tree

9 files changed

+92
-10
lines changed

9 files changed

+92
-10
lines changed

CHANGELOG.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ v32.1.0 (next, roadmap)
4141
of these in other summary plugins.
4242
See https://github.com/nexB/scancode-toolkit/issues/1745
4343

44+
45+
v32.0.2 - 2023-05-26
46+
---------------------
47+
48+
This is a minor bugfix release with the following update:
49+
50+
- New release v30.1.1 of license-expression with support for new license keys
51+
added. Also fail verbosely in `build_spdx_license_expression` for invalid and
52+
deprecated license keys.
53+
54+
4455
v32.0.1 - 2023-05-23
4556
---------------------
4657

etc/thirdparty/virtualenv.pyz

-382 KB
Binary file not shown.

etc/thirdparty/virtualenv.pyz.ABOUT

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
about_resource: virtualenv.pyz
22
name: get-virtualenv
3-
version: 20.16.3
4-
download_url: https://github.com/pypa/get-virtualenv/blob/20.16.3/public/virtualenv.pyz
3+
version: 20.23.0
4+
download_url: https://github.com/pypa/get-virtualenv/raw/20.23.0/public/virtualenv.pyz
55
description: virtualenv is a tool to create isolated Python environments.
66
homepage_url: https://github.com/pypa/virtualenv
77
license_expression: lgpl-2.1-plus AND (bsd-new OR apache-2.0) AND mit AND python AND bsd-new
@@ -10,6 +10,6 @@ copyright: Copyright (c) The Python Software Foundation and others
1010
redistribute: yes
1111
attribute: yes
1212
track_changes: yes
13-
package_url: pkg:github/pypa/get-virtualenv@20.16.3#public/virtualenv.pyz
13+
package_url: pkg:github/pypa/get-virtualenv@20.23.0#public/virtualenv.pyz
1414
notes: this archive has been modified from the original to remove extra
1515
embedded wheels that are not needed as we support only Python 3.7+

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jaraco.functools==3.5.1
3434
javaproperties==0.8.1
3535
Jinja2==3.1.2
3636
jsonstreams==0.6.0
37-
license-expression==30.0.0
37+
license-expression==30.1.1
3838
lxml==4.9.2
3939
MarkupSafe==2.1.2
4040
more-itertools==8.13.0

setup-mini.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = scancode-toolkit
3-
version = 32.0.1
3+
version = 32.0.2
44
license = Apache-2.0 AND CC-BY-4.0 AND LicenseRef-scancode-other-permissive AND LicenseRef-scancode-other-copyleft
55

66
# description must be on ONE line https://github.com/pypa/setuptools/issues/1390
@@ -85,7 +85,7 @@ install_requires =
8585
javaproperties >= 0.5
8686
jinja2 >= 2.7.0
8787
jsonstreams >= 0.5.0
88-
license_expression >= 30.0.0
88+
license_expression >= 30.1.1
8989
lxml >= 4.9.2
9090
MarkupSafe >= 2.1.2
9191
packageurl_python >= 0.9.0

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = scancode-toolkit
3-
version = 32.0.1
3+
version = 32.0.2
44
license = Apache-2.0 AND CC-BY-4.0 AND LicenseRef-scancode-other-permissive AND LicenseRef-scancode-other-copyleft
55

66
# description must be on ONE line https://github.com/pypa/setuptools/issues/1390
@@ -85,7 +85,7 @@ install_requires =
8585
javaproperties >= 0.5
8686
jinja2 >= 2.7.0
8787
jsonstreams >= 0.5.0
88-
license_expression >= 30.0.0
88+
license_expression >= 30.1.1
8989
lxml >= 4.9.2
9090
MarkupSafe >= 2.1.2
9191
packageurl_python >= 0.9.0

src/licensedcode/cache.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,5 +510,47 @@ def build_spdx_license_expression(license_expression, licensing=None):
510510
"""
511511
if not licensing:
512512
licensing = get_licensing()
513+
validate_spdx_license_keys(license_expression=license_expression, licensing=licensing)
513514
parsed = licensing.parse(license_expression)
514515
return parsed.render(template='{symbol.wrapped.spdx_license_key}')
516+
517+
518+
def validate_spdx_license_keys(license_expression, licensing):
519+
"""
520+
Raise InvalidLicenseKeyError for the cases where the there is no corresponding :
521+
522+
"""
523+
from licensedcode.models import load_licenses
524+
525+
license_keys = licensing.license_keys(license_expression)
526+
license_db = get_licenses_db()
527+
528+
messages = []
529+
530+
for key in license_keys:
531+
if not type(key) == str:
532+
msg = f"Invalid license key: {key} of type {type(key)}, license key should be a string"
533+
messages.append(msg)
534+
535+
lic = license_db.get(key, None)
536+
if not lic:
537+
licenses = load_licenses(with_deprecated=True)
538+
if licenses.get(key, None):
539+
msg = f"License key: {key} is deprecated license key in LicenseDB"
540+
else:
541+
msg = f"License key: {key} is not a valid license key from LicenseDB"
542+
messages.append(msg)
543+
544+
parsed = licensing.parse(key)
545+
try:
546+
parsed.render(template='{symbol.wrapped.spdx_license_key}')
547+
except AttributeError:
548+
messages.append(msg)
549+
pass
550+
551+
if messages:
552+
raise InvalidLicenseKeyError(messages)
553+
554+
555+
class InvalidLicenseKeyError(Exception):
556+
pass

src/scancode_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ def _create_dir(location):
132132
# 4. hardcoded This is the default, fallback version in case package is not installed or we
133133
# do not have a proper version otherwise.
134134
if not __version__:
135-
__version__ = '32.0.1'
135+
__version__ = '32.0.2'
136136

137137
#######################
138138
# used to warn user when the version is out of date
139-
__release_date__ = datetime.datetime(2023, 5, 23)
139+
__release_date__ = datetime.datetime(2023, 5, 26)
140140

141141
# See https://github.com/nexB/scancode-toolkit/issues/2653 for more information
142142
# on the data format version

tests/licensedcode/test_zzzz_cache.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,32 @@ def test_get_spdx_symbols_checks_duplicates_with_deprecated_on_live_db(self):
155155
from licensedcode.models import load_licenses
156156
test_licenses = load_licenses(with_deprecated=True)
157157
cache.get_spdx_symbols(licenses_db=test_licenses)
158+
159+
def test_build_spdx_license_expression(self):
160+
from licensedcode.cache import build_spdx_license_expression
161+
assert build_spdx_license_expression("mit")
162+
163+
def test_build_spdx_license_expression_fails_on_invalid_key_none(self):
164+
from licensedcode.cache import build_spdx_license_expression
165+
from licensedcode.cache import InvalidLicenseKeyError
166+
try:
167+
build_spdx_license_expression("mit AND None")
168+
except InvalidLicenseKeyError:
169+
pass
170+
171+
def test_build_spdx_license_expression_fails_on_deprecated_license(self):
172+
# TODO: this should not fail, see https://github.com/nexB/scancode-toolkit/issues/3400
173+
from licensedcode.cache import build_spdx_license_expression
174+
from licensedcode.cache import InvalidLicenseKeyError
175+
try:
176+
assert build_spdx_license_expression("broadcom-linking-unmodified")
177+
except InvalidLicenseKeyError:
178+
pass
179+
180+
def test_build_spdx_license_expression_fails_on_invalid_key(self):
181+
from licensedcode.cache import build_spdx_license_expression
182+
from licensedcode.cache import InvalidLicenseKeyError
183+
try:
184+
assert build_spdx_license_expression("mitt")
185+
except InvalidLicenseKeyError:
186+
pass

0 commit comments

Comments
 (0)