diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2024-12-01 09:05:37 +0100 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2024-12-03 17:00:01 +0100 |
commit | 8c97926a01f4d23d2af6fff067ce9e465d0d6a69 (patch) | |
tree | 299cedf855b40b43d2a5d734a8532c1802c0078b | |
parent | 1261bf83b85187781b5dc062a04b7dcf3b3caf1c (diff) | |
download | guix-8c97926a01f4d23d2af6fff067ce9e465d0d6a69.tar.gz guix-8c97926a01f4d23d2af6fff067ce9e465d0d6a69.zip |
import/cran: Enhance import pattern.
* guix/import/cran.scm (import-pattern): Comment; capture direct namespace
imports as well as silent imports.
Change-Id: Ia54035d6f230d695aa950adb3e691cbce4f2d416
-rw-r--r-- | guix/import/cran.scm | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/guix/import/cran.scm b/guix/import/cran.scm index 01fb8552f9..fe69cb87f7 100644 --- a/guix/import/cran.scm +++ b/guix/import/cran.scm @@ -552,10 +552,23 @@ referenced in build system files." (set) (find-files dir "(Makevars(.in.*)?|configure.*)")))) -;; A pattern matching "library" or "require" statements, capturing the first -;; argument. +;; A pattern matching package imports. It detects uses of "library" or +;; "require", capturing the first argument; it also detects direct access of +;; namespaces via "::" or ":::", capturing the namespace. (define import-pattern - (make-regexp "^ *(require|library)\\(\"?([^, \")]+)")) + (make-regexp + (string-append + ;; Ignore leading spaces, but don't capture commented expressions. + "(^ *" + ;; Quiet imports + "(suppressPackageStartupMessages\\()?" + ;; the actual import statement. + "(require|library)\\(\"?([^, \")]+)" + ;; Or perhaps... + "|" + ;; ...direct namespace access. + " *([A-Za-z0-9]+):::?" + ")"))) (define (needed-test-inputs-in-directory dir) "Return a set of R package names that are found in library import @@ -581,8 +594,10 @@ statements in files in the directory DIR." (else (loop (fold (lambda (match acc) - (let ((imported (match:substring match 2))) - (if (or (string=? imported package-directory-name) + (let ((imported (or (match:substring match 4) + (match:substring match 5)))) + (if (or (not imported) + (string=? imported package-directory-name) (member imported default-r-packages)) acc (set-insert imported acc)))) @@ -623,8 +638,9 @@ in vignette files in the directory DIR." (else (loop (fold (lambda (match acc) - (let ((imported (match:substring match 2))) - (if (or (string=? imported package-directory-name) + (let ((imported (match:substring match 4))) + (if (or (not imported) + (string=? imported package-directory-name) (member imported default-r-packages)) acc (set-insert imported acc)))) |