sstadick / cargo-bundle-licenses

Generate a THIRDPARTY file with all licenses in a cargo project.
Apache License 2.0
90 stars 6 forks source link

`license-file` key in Cargo manifest is not read for path dependencies in a workspace #2

Closed lopopolo closed 1 year ago

lopopolo commented 3 years ago

Running

cargo bundle-licenses -f yaml -o thirdparty.yaml

as of https://github.com/artichoke/artichoke/pull/1420

does not resolve the license text for path dependencies in this cargo workspace:

# snip
  - package_name: artichoke-backend
    package_version: 0.2.0
    license: MIT
    licenses:
      - license: MIT
        text: NOT FOUND
  - package_name: artichoke-core
    package_version: 0.9.0
    license: MIT
    licenses:
      - license: MIT
        text: NOT FOUND
  - package_name: artichoke-load-path
    package_version: 0.1.0
    license: MIT
    licenses:
      - license: MIT
        text: NOT FOUND
# snip

See also: https://github.com/EmbarkStudios/cargo-about/issues/162

sstadick commented 3 years ago

@lopopolo Thanks for filing an issue!

The PR I have fixes it if you have your sub-crates only specify the license-file. It would output something like:

  - package_name: spinoso-regexp
    package_version: 0.2.0
    license: License specified in file (/private/tmp/artichoke/spinoso-regexp/../LICENSE)
    licenses:
      - license: License specified in file (/private/tmp/artichoke/spinoso-regexp/../LICENSE)
        text: "The MIT License (MIT)\n\nCopyright (c) 2019 Ryan Lopopolo <rjl@hyperbo.la>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"

LMK where you land on how to get the license into the code dir of the sub-crates. I've seen others "include" it in, but that's annoying because then you have to explicitly include everything. Or do what ripgrep does and just put a copy of the license in each sub-crate.

lopopolo commented 3 years ago

Thanks @sstadick.

I did roll back the license-file addition to the cargo manifests since cargo doesn't like both license and license-file being set.

Thanks for letting me know about the approach ripgrep takes. I might do the same.