1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-04-06 13:10: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
;;; 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 © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
@@ -570,7 +570,7 @@ referenced in build system files."
;; Quiet imports
"(suppressPackageStartupMessages\\()?"
;; the actual import statement.
"(require|library|check_installed)\\(\"?([^, \")]+)"
"(require|library|check_installed)\\([\"']?([^, \"')]+)"
;; Or perhaps...
"|"
;; ...direct namespace access.
@@ -654,16 +654,10 @@ in vignette files in the directory DIR."
(cond
((eof-object? line) packages)
(else
(loop
(fold (lambda (match acc)
(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))))
packages
(list-matches import-pattern line))))))))))
(loop (extract-imports line
#:initial-set packages
#:ignored-names (cons package-directory-name
default-r-packages))))))))))
(set)
(append-map (lambda (directory)
(find-files directory "\\.Rnw"))

View File

@@ -1,5 +1,5 @@
;;; 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>
;;;
;;; 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)
"\"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"
(list)
(set->list ((@ (guix import cran) extract-imports)