On 06/06/2024 20:03, Brian Inglis via Cygwin-apps wrote:
I found github/nexB/license-expression Python package to do SPDX licence checks developed by the same team doing SPDX-toolkit for SPDX, using the same current data, by and working with Fedora folks et al.

Thanks for taking a look at this problem.

Having a package for this seems fine, but: this package is what calm uses, and still has the drawbacks I mentioned:

* embeds the SPDX license data, doesn't dynamically fetch it
* can't really handle LicenseRef reasonably


Successful attempt to package Python license-expression (without tests):

     https://cygwin.com/cgi-bin2/jobs.cgi?id=8210

log at:

     https://github.com/cygwin/scallywag/actions/runs/9293093201

cygport attached and at:

https://cygwin.com/cgit/cygwin-packages/playground/commit/?id=3626386b10c967f780547d1703ad23bd50f6331a

The package installs and runs using PoC attached in spdx-license-expression.py script hooked into /usr/share/cygport/lib/pkg_pkg.cygpart license hint addition patch attached.

I'm not super-keen on adding a cygport dependency on python, just to do this check.

It would probably be preferable to do this check initially after the .cygport is read, rather than only telling you about problems when you get around to doing to the package step.

I also ran a test of the Python script and module against all package source cygport files declaring licences which I maintain or ever looked at, including a git/cygwin-packages/*.cygport download from 2023-02, showing the results in the attached log. I also attempted to trap the exceptions in the script, but that does not seem to work in any documented obvious manner, but I do not know enough Python to address this fully.

Yeah, the way validate() handles parse errors is bizarre and unhelpful.

What I ended up doing is calling parse() first to catch those errors, so something like:

    try:
        licensing.parse(expression)
        errs = licensing.validate(expression).errors
    except (ExpressionError, ExpressionParseError) as e:
        print(e, file=sys.stderr)
        return 2


If someone else who knows python cared to adopt and improve this in a more normal manner, and incorporate this more smoothly into cygport, we could all appreciate that. Alternatively, some candid comments and frank feedback might allow me to do so! ;^>


Reply via email to