GNU bug report logs - #58250
guix import json: GUIX_PACKAGE_PATH -- no code for module

Previous Next

Package: guix;

Reported by: itd <itd <at> net.in.tum.de>

Date: Sun, 2 Oct 2022 14:27:01 UTC

Severity: normal

Full log


View this message in rfc822 format

From: itd <itd <at> net.in.tum.de>
To: 58250 <at> debbugs.gnu.org
Subject: bug#58250: [PATCH 1/2] modules: Remove load path prefix from module name.
Date: Sun, 02 Oct 2022 16:35:33 +0200
* guix/modules.scm (file-name->module-name): Ignore load path prefix
when building module name.
---
It was mentioned on IRC, that (guix modules)'s file-name->module-name
might be function to be used by the JSON importer (and fixed if needed).
This patch attempts to implement the idea from the bug report.

 guix/modules.scm | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/guix/modules.scm b/guix/modules.scm
index 61bc8e1978..269d52ae1e 100644
--- a/guix/modules.scm
+++ b/guix/modules.scm
@@ -100,11 +100,23 @@ (define module-file-dependencies
            '()))))))
 
 (define file-name->module-name
-  (let ((not-slash (char-set-complement (char-set #\/))))
+  (let ((not-slash (char-set-complement (char-set #\/)))
+       (load-path-prefix-length
+        (lambda (file)
+          ;; Length of the longest prefix among all given load paths.
+          (apply max (map
+                      (lambda (path) (if (string-prefix? path file)
+                                       (string-length path)
+                                       0))
+                      %load-path)))))
     (lambda (file)
       "Return the module name (a list of symbols) corresponding to FILE."
       (map string->symbol
-           (string-tokenize (string-drop-right file 4) not-slash)))))
+           (string-tokenize
+             (string-drop
+              (string-drop-right file 4)
+              (load-path-prefix-length file))
+           not-slash)))))
 
 (define (module-name->file-name module)
   "Return the file name for MODULE."

base-commit: ae221813745783ef1b7eee47561a2208cd5ad512
-- 
2.37.3





This bug report was last modified 2 years and 174 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.