projg2/pycargoebuild

"RuntimeError: Create ... does not specify a license" when `license-file` is used in `Cargo.toml`

Closed this issue · 2 comments

Crates may use license-file in Cargo.toml to specify a LICENSE file to be used rather than giving a string of licenses.

Ring (https://github.com/briansmith/ring) is an example, its Cargo.toml has:

license-file = "LICENSE"

pycargoebuild fails to handle such crates.

Steps to reproduce:

$ wget -q https://github.com/rustls/rustls-ffi/archive/refs/tags/v0.8.2.tar.gz -O /tmp/rustls-v0.8.2.tar.gz
$ mkdir /tmp/rustls && tar xf /tmp/rustls-v0.8.2.tar.gz -C /tmp/rustls
$ cd /tmp/rustls/rustls-ffi-0.8.2/ && cargo fetch -q
$ pycargoebuild
[...]
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 202, in entry_point
    sys.exit(main(*sys.argv))
             ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pycargoebuild/__main__.py", line 162, in main
    ebuild = get_ebuild(pkg_meta,
             ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pycargoebuild/ebuild.py", line 134, in get_ebuild
    crate_licenses=get_crate_LICENSE(crate_files),
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pycargoebuild/ebuild.py", line 102, in get_crate_LICENSE
    crate_licenses = set(map(get_license_from_crate, crate_files))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pycargoebuild/ebuild.py", line 91, in get_license_from_crate
    raise RuntimeError(
RuntimeError: Create ring-0.16.20.crate does not specify a license!

I'm not sure how we actually want to handle this because it.. could be anything? I suppose at least we should offer a way to proceed and let the user manually handle it later, and maybe add a note in the ebuild above LICENSE as a TODO to ensure they don't forget?

Eh, I was hoping we'd avoid crates like these :-(.