~ruther/guix-local

73fe38fd568e94b765ea3e346a3f632d945208ec — Nicolas Graves 10 months ago e1cc126
import: pypi: Improve license detection.

A lot of python packages are generated with an #f license, despite the
license being on pypi and in metadata.  Fix this.

* gnu/import/pypi.scm (find-license): Add procedure.
(make-pypi-sexp): Use procedure find-license.

Change-Id: Ia8e476f85a4b9193a0634de7a9bd66e40dcf2d44
Signed-off-by: Sharlatan Hellseher <sharlatanus@gmail.com>
1 files changed, 13 insertions(+), 3 deletions(-)

M guix/import/pypi.scm
M guix/import/pypi.scm => guix/import/pypi.scm +13 -3
@@ 631,9 631,8 @@ VERSION."
        (description ,(and=> (non-empty-string-or-false
                              (project-info-summary info))
                             beautify-description))
        (license ,(license->symbol
                   (string->license
                    (project-info-license info)))))
        (license ,(find-license (project-info-license info)
                                (project-info-classifiers info))))
     (map upstream-input-name (upstream-source-inputs source)))))

(define pypi->guix-package


@@ 686,6 685,17 @@ source.  To build it from source, refer to the upstream repository at
    ("MPL 2.0" license:mpl2.0)
    (_ #f)))

(define (find-license license classifiers)
  (license->symbol
   (string->license
    (if (and license (string? license) (not (string= license "")))
        license
        (let* ((license-prefix "License :: OSI Approved :: ")
               (license (find (cut string-prefix? license-prefix <>)
                              classifiers)))
          (and license (not (null? license))
               (string-drop license (string-length license-prefix))))))))

(define pypi-package?
  (url-predicate
   (lambda (url)