guix_mirror_bot pushed a commit to branch master
in repository guix.
commit 73fe38fd568e94b765ea3e346a3f632d945208ec
Author: Nicolas Graves <[email protected]>
AuthorDate: Tue Sep 16 14:23:54 2025 +0200
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 <[email protected]>
---
guix/import/pypi.scm | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/guix/import/pypi.scm b/guix/import/pypi.scm
index 9bd773b716..5f274aac0f 100644
--- a/guix/import/pypi.scm
+++ b/guix/import/pypi.scm
@@ -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)