1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-04-06 21:20:33 +02:00

import/cran: Fix import of packages in single quotes.

* guix/import/cran.scm (import-pattern): Also match on single quotes.
(needed-vignettes-inputs-in-directory): Use EXTRACT-IMPORTS.
* tests/import/cran.scm: Add test.

Change-Id: Ie69027992519bd8d886860346f4a359514d8e822
This commit is contained in:
Ricardo Wurmus
2026-02-16 19:15:03 +01:00
committed by Andreas Enge
parent c2a92688a9
commit ee0a9f27b9
2 changed files with 12 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015-2025 Ricardo Wurmus <rekado@elephly.net> ;;; Copyright © 2015-2026 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2015-2017, 2019-2021, 2023 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2015-2017, 2019-2021, 2023 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net> ;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
@@ -570,7 +570,7 @@ referenced in build system files."
;; Quiet imports ;; Quiet imports
"(suppressPackageStartupMessages\\()?" "(suppressPackageStartupMessages\\()?"
;; the actual import statement. ;; the actual import statement.
"(require|library|check_installed)\\(\"?([^, \")]+)" "(require|library|check_installed)\\([\"']?([^, \"')]+)"
;; Or perhaps... ;; Or perhaps...
"|" "|"
;; ...direct namespace access. ;; ...direct namespace access.
@@ -654,16 +654,10 @@ in vignette files in the directory DIR."
(cond (cond
((eof-object? line) packages) ((eof-object? line) packages)
(else (else
(loop (loop (extract-imports line
(fold (lambda (match acc) #:initial-set packages
(let ((imported (match:substring match 4))) #:ignored-names (cons package-directory-name
(if (or (not imported) default-r-packages))))))))))
(string=? imported package-directory-name)
(member imported default-r-packages))
acc
(set-insert imported acc))))
packages
(list-matches import-pattern line))))))))))
(set) (set)
(append-map (lambda (directory) (append-map (lambda (directory)
(find-files directory "\\.Rnw")) (find-files directory "\\.Rnw"))

View File

@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015, 2025 Ricardo Wurmus <rekado@elephly.net> ;;; Copyright © 2015, 2025-2026 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
@@ -98,6 +98,11 @@ Date/Publication: 2015-07-14 14:15:16
(set->list ((@ (guix import cran) extract-imports) (set->list ((@ (guix import cran) extract-imports)
"\"hello::world\", \"this is not data.table::some_procedure(), actually\""))) "\"hello::world\", \"this is not data.table::some_procedure(), actually\"")))
(test-equal "extract-imports: extracts text inside single quotes"
(list "FDb.InfiniumMethylation.hg19")
(set->list ((@ (guix import cran) extract-imports)
"suppressPackageStartupMessages(require('FDb.InfiniumMethylation.hg19'))")))
(test-equal "extract-imports: ignores other colon separated things" (test-equal "extract-imports: ignores other colon separated things"
(list) (list)
(set->list ((@ (guix import cran) extract-imports) (set->list ((@ (guix import cran) extract-imports)