mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 01:57:13 +02:00
Added support for multi-licensed packages in library.json using SPDX Expressions // Resolve #4037
This commit is contained in:
@ -24,11 +24,12 @@ PlatformIO Core 5
|
||||
* `pio pkg uninstall <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_uninstall.html>`_ - uninstall the project dependencies or custom packages
|
||||
* `pio pkg update <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_update.html>`__ - update the project dependencies or custom packages
|
||||
|
||||
- Added support for multi-licensed packages in `library.json <https://docs.platformio.org/en/latest/librarymanager/config.html#license>`__ using SPDX Expressions (`issue #4037 <https://github.com/platformio/platformio-core/issues/4037>`_)
|
||||
- Automatically install dependencies of the local (private) libraries (`issue #2910 <https://github.com/platformio/platformio-core/issues/2910>`_)
|
||||
- Added support for dependencies declared in a "tool" type package
|
||||
- Ignore files according to the patterns declared in ".gitignore" when using `pio package pack <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_pack.html>`__ command (`issue #4188 <https://github.com/platformio/platformio-core/issues/4188>`_)
|
||||
- Ignore files according to the patterns declared in ".gitignore" when using the `pio package pack <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_pack.html>`__ command (`issue #4188 <https://github.com/platformio/platformio-core/issues/4188>`_)
|
||||
- Dropped automatic updates of global libraries and development platforms (`issue #4179 <https://github.com/platformio/platformio-core/issues/4179>`_)
|
||||
- Dropped support for "pythonPackages" field in "platform.json" manifest in favor of `Extra Python Dependencies <https://docs.platformio.org/en/latest/scripting/examples/extra_python_packages.html>`__
|
||||
- Dropped support for the "pythonPackages" field in "platform.json" manifest in favor of `Extra Python Dependencies <https://docs.platformio.org/en/latest/scripting/examples/extra_python_packages.html>`__
|
||||
|
||||
* **Static Code Analysis**
|
||||
|
||||
@ -38,7 +39,7 @@ PlatformIO Core 5
|
||||
* **Miscellaneous**
|
||||
|
||||
* Improved PIO Remote setup on credit-card sized computers (Raspberry Pi, BeagleBon, etc) (`issue #3865 <https://github.com/platformio/platformio-core/issues/3865>`_)
|
||||
* Better handling of the failed tests using `Unit Testing <https://docs.platformio.org/en/latest/plus/unit-testing.html>`__ solution
|
||||
* Better handling of the failed tests using the `Unit Testing <https://docs.platformio.org/en/latest/plus/unit-testing.html>`__ solution.
|
||||
|
||||
5.2.5 (2022-02-10)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
2
docs
2
docs
Submodule docs updated: b953caefb7...1e6df4bb83
@ -15,6 +15,7 @@
|
||||
# pylint: disable=too-many-ancestors
|
||||
|
||||
import json
|
||||
import re
|
||||
|
||||
import marshmallow
|
||||
import requests
|
||||
@ -254,9 +255,18 @@ class ManifestSchema(BaseSchema):
|
||||
spdx = self.load_spdx_licenses()
|
||||
except requests.exceptions.RequestException:
|
||||
raise ValidationError("Could not load SPDX licenses for validation")
|
||||
for item in spdx.get("licenses", []):
|
||||
if item.get("licenseId") == value:
|
||||
return True
|
||||
known_ids = set(item.get("licenseId") for item in spdx.get("licenses", []))
|
||||
if value in known_ids:
|
||||
return True
|
||||
# parse license expression
|
||||
# https://spdx.github.io/spdx-spec/SPDX-license-expressions/
|
||||
package_ids = [
|
||||
item.strip()
|
||||
for item in re.sub(r"(\s+(?:OR|AND|WITH)\s+|[\(\)])", " ", value).split(" ")
|
||||
if item.strip()
|
||||
]
|
||||
if known_ids >= set(package_ids):
|
||||
return True
|
||||
raise ValidationError(
|
||||
"Invalid SPDX license identifier. See valid identifiers at "
|
||||
"https://spdx.org/licenses/"
|
||||
|
@ -426,6 +426,25 @@ def test_library_json_schema():
|
||||
},
|
||||
)
|
||||
|
||||
# test multiple licenses
|
||||
contents = """
|
||||
{
|
||||
"name": "MultiLicense",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT AND (LGPL-2.1-or-later OR BSD-3-Clause)"
|
||||
}
|
||||
"""
|
||||
raw_data = parser.LibraryJsonManifestParser(contents).as_dict()
|
||||
data = ManifestSchema().load_manifest(raw_data)
|
||||
assert not jsondiff.diff(
|
||||
data,
|
||||
{
|
||||
"name": "MultiLicense",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT AND (LGPL-2.1-or-later OR BSD-3-Clause)",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def test_library_properties_schema():
|
||||
contents = """
|
||||
|
Reference in New Issue
Block a user