projg2/pycargoebuild

Unexpected exception: "Unknown license key(s): MPL-2.0+"

Closed this issue · 4 comments

I wanted to create an ebuild for https://github.com/rustic-rs/rustic, so I downloaded the tarball and decided to give pycargoebuild a try. It didn't go well:

[WARNING] Crate owo-colors-3.5.0.crate uses license-file='LICENSE', please inspect the license manually and add it *separately* from crate licenses
[WARNING] Crate ring-0.16.20.crate uses license-file='LICENSE', please inspect the license manually and add it *separately* from crate licenses
[WARNING] Crate webpki-0.22.0.crate uses license-file='LICENSE', please inspect the license manually and add it *separately* from crate licenses
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.11/pycargoebuild", line 8, in <module>
    sys.exit(entry_point())
             ^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pycargoebuild/__main__.py", line 205, in entry_point
    sys.exit(main(*sys.argv))
             ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pycargoebuild/__main__.py", line 161, in main
    ebuild = get_ebuild(pkg_meta,
             ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pycargoebuild/ebuild.py", line 163, in get_ebuild
    crate_licenses=get_crate_LICENSE(crate_files),
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pycargoebuild/ebuild.py", line 115, in get_crate_LICENSE
    parsed_license = spdx.parse(combined_license, validate=True, strict=True)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/license_expression/__init__.py", line 560, in parse
    self.validate_license_keys(expression)
  File "/usr/lib/python3.11/site-packages/license_expression/__init__.py", line 467, in validate_license_keys
    raise ExpressionError(msg)
license_expression.ExpressionError: Unknown license key(s): MPL-2.0+

I understand the LICENSE-related warnings (e.g. owo-colors has both license: and license-file: in its Cargo.toml), but don't know what to do about them.
Neither do I understand what to do about the exception.

cargo-ebuild emits the same warnings, but at least creates a usable ebuild:

holger>cargo-ebuild ebuild
WARNING: unknown license "MIT-0" at package "dunce", please correct manually
WARNING: owo-colors uses a license-file, not handled
WARNING: ring uses a license-file, not handled
WARNING: unknown license "MPL-2.0+" at package "smartstring", please correct manually
WARNING: unknown license "Unicode-DFS-2016" at package "unicode-ident", please correct manually
WARNING: webpki uses a license-file, not handled
Wrote: rustic-rs-0.5.0.ebuild

Am I holding it wrong? In any case it would be useful to say what and where the problem is and - if possible - suggest how to fix it.
I also tried to "update" an empty ebuild skeleton with the required CRATE and LICENSE entries, but that ended in the same exception.

mgorny commented

The error comes from license_expression Python package. I need to figure out whether it's a bug in that package or in the license string of smartstring. Then, figure out how to workaround it.

mgorny commented

Ok, so apparently it's by design, sigh. I'm going to see if we can just disable the license validation there.

mgorny commented

I've pushed 0.6.3 with the fix. Thanks for the report!