unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: Chris Marusich <cmmarusich@gmail.com>,
	Julien Lepiller <julien@lepiller.eu>
Cc: 47375@debbugs.gnu.org
Subject: bug#47375: guix test failure: tests/print
Date: Thu, 25 Mar 2021 08:55:20 +0100	[thread overview]
Message-ID: <3f09a5671f6a7c04405d8529f7ed60b1e7f8eb6e.camel@telenet.be> (raw)
In-Reply-To: <87im5f7uj6.fsf@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1337 bytes --]

On Wed, 2021-03-24 at 20:59 -0700, Chris Marusich wrote:
> [..]
> 
> In guix/import/print.scm, package->code generates the code by invoking
> (origin-method source) to get the origin's "method", and then invoking
> (procedure-name method) on the method thus obtained.  It seems that
> procedure-name returns the name "url-fetch*" (the name used privately in
> the (guix download) module), but it should be returning the name
> "url-fetch" (the public name exported by the (guix download) module).
> 
> I wonder if there is any way to get the public name of the procedure
> programmatically, instead of the private one?

I believe there isn't, and I have spent some time around Guile's module
system.  Note that one could do ...

<start guile code>
(define-module (mod)
  #:export (x y z))

(define (fun) 'stuff)
(define x fun)
(define y fun
(define z fun)
<end guile code>

... in which case there would be more than one "public name".

However, there's a possible work-around.  It is change the procedure name
of a procedure, with the following

(define name (let ((visible-name (lambda () 'stuff))) visible-name))
(procedure-name name) ; -> visible-name

Patch attached (though written against a somewhat outdated tree).
Does this patch fixes the issue? (I'm not in the loop.)

Greetings, Maxime.

[-- Attachment #1.2: 0001-guix-Let-the-procedure-name-of-url-fetch-be-what-gui.patch --]
[-- Type: text/x-patch, Size: 4035 bytes --]

From 04f36da115e2cb60835561f461899bb0d67bb927 Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximedevos@telenet.be>
Date: Thu, 25 Mar 2021 08:48:24 +0100
Subject: [PATCH] guix: Let the procedure name of "url-fetch*" be what "guix
 import" expects.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fixes: <https://issues.guix.gnu.org/47375>.
Reported-By: Léo Le Bouter <lle-bout@zaclys.net>.

* guix/download.scm
  (define*-visible-name): Define a syntax for overriding the procedure name
  of a procedure returned by "procedure-name".
  (url-fetch*): Use this syntax to change the procedure name to "url-fetch"
  as "guix import" expects.

+++ b/guix/download.scm
@@ -6,6 +6,7 @@
 ;;; Copyright © 2016 David Craven <david@craven.ch>
 ;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2019 Guy Fleury Iteriteka <hoonandon@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
(1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? y
@@ -449,11 +450,19 @@ download by itself using its own dependencies."
                     ;; for that built-in is widespread.
                     #:local-build? #t)))

-(define* (url-fetch* url hash-algo hash
-                     #:optional name
-                     #:key (system (%current-system))
-                     (guile (default-guile))
-                     executable?)
+;; In guix/import/print.scm, the procedure package->code uses procedure-name
+;; and expects to see the user-visible procedure name.
+(define-syntax-rule (define*-with-name (name . args) procedure-name . code)
+  "Define a procedure as with 'define*', but in such a matter that
+'procedure-name' on NAME will return PROCEDURE-NAME instead of NAME."
+  (define name (let ((procedure-name (lambda* args . code))) procedure-name)))
+
+(define*-with-name (url-fetch* url hash-algo hash
+                               #:optional name
+                               #:key (system (%current-system))
+                               (guile (default-guile))
+                               executable?)
+  url-fetch
---
 guix/download.scm | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/guix/download.scm b/guix/download.scm
index 30f69c0325..25c26a2ebb 100644
--- a/guix/download.scm
+++ b/guix/download.scm
@@ -6,6 +6,7 @@
 ;;; Copyright © 2016 David Craven <david@craven.ch>
 ;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2019 Guy Fleury Iteriteka <hoonandon@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -449,11 +450,19 @@ download by itself using its own dependencies."
                     ;; for that built-in is widespread.
                     #:local-build? #t)))
 
-(define* (url-fetch* url hash-algo hash
-                     #:optional name
-                     #:key (system (%current-system))
-                     (guile (default-guile))
-                     executable?)
+;; In guix/import/print.scm, the procedure package->code uses procedure-name
+;; and expects to see the user-visible procedure name.
+(define-syntax-rule (define*-with-name (name . args) procedure-name . code)
+  "Define a procedure as with 'define*', but in such a matter that
+'procedure-name' on NAME will return PROCEDURE-NAME instead of NAME."
+  (define name (let ((procedure-name (lambda* args . code))) procedure-name)))
+
+(define*-with-name (url-fetch* url hash-algo hash
+                               #:optional name
+                               #:key (system (%current-system))
+                               (guile (default-guile))
+                               executable?)
+  url-fetch
   "Return a fixed-output derivation that fetches data from URL (a string, or a
 list of strings denoting alternate URLs), which is expected to have hash HASH
 of type HASH-ALGO (a symbol).  By default, the file name is the base name of
-- 
2.31.0


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

  reply	other threads:[~2021-03-25  7:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-25  1:44 bug#47375: guix test failure: tests/print Léo Le Bouter via Bug reports for GNU Guix
2021-03-25  1:54 ` Julien Lepiller
2021-03-25  3:59   ` Chris Marusich
2021-03-25  7:55     ` Maxime Devos [this message]
2021-03-25  8:15       ` Maxime Devos
2021-03-25 23:23         ` Ludovic Courtès
2021-03-25 23:24 ` Ludovic Courtès
2021-03-25 23:27   ` Léo Le Bouter via Bug reports for GNU Guix
2021-03-28 16:25     ` Ludovic Courtès
2021-03-28 16:31       ` Léo Le Bouter via Bug reports for GNU Guix

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3f09a5671f6a7c04405d8529f7ed60b1e7f8eb6e.camel@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=47375@debbugs.gnu.org \
    --cc=cmmarusich@gmail.com \
    --cc=julien@lepiller.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).