From: "Daniel Meißner" <daniel.meissner-i4k@ruhr-uni-bochum.de>
To: guile-user@gnu.org
Subject: Re: Meaning of symbol prefixed with "#$"
Date: Fri, 26 May 2023 20:22:26 +0200 [thread overview]
Message-ID: <559C3810-7276-4E02-9145-0B25A732AB5E@ruhr-uni-bochum.de> (raw)
In-Reply-To: <CAEavL=UnjHtxpWmjE0sxMFV7QFYoRdNdov6=N-sfUKxfbeX3bg@mail.gmail.com>
Hi Ning!
ningyuan.sg@gmail.com writes:
> Hi all,
>
> I was wondering what is the meaning of symbols prefixed with "#$", for
> example "#$version" in Guix package definitions.
>
> I was trying to write a package definition for a python package whose
> version number was intended to be inferred from git metadata during build
> time via versioneer. However, since Guix does not retain git metadata
> during build, the setup.py statement declaring the version number as to be
> inferred from git metadata had to be changed to refer to a simple version
> number string. I wrote,
>
> #+begin_src
> (arguments
> '(#:phases (modify-phases %standard-phases
> (add-after 'unpack 'amend-version
> (lambda _
> (substitute* "setup.py"
> (("versioneer.get_version\\(\\)")
> (string-append "\"" #$version "\"")))))
> #+end_src
>
> With reference to a patch describing the same issue with a different python
> package with the same inferred git metadata version number issue:
> https://issues.guix.gnu.org/63628#0-lineno26.
>
> However, I get an error I do not understand:
>
> #+begin_src
> starting phase `amend-version'
> error: in phase 'amend-version': uncaught exception:
> unbound-variable #f "Unbound variable: ~S" (ungexp) #f
> #+end_src
>
> I thought I could begin to debug this by understanding what "#$" means in
> "#$version".
The problem in your package definition is that you use an ungexp form outside of a gexp form. The correct code could be (untested):
(arguments
(list
#:phases
#~(modify-phases %standard-phases
(add-after 'unpack 'amend-version
(lambda _
(substitute* "setup.py"
(("versioneer.get_version\\(\\)")
(string-append "\"" #$version "\"")))))
As already mentioned by Robby #$version is equivalent to (ungexp version) and similar to quasiquotation in Scheme.
Also: Be sure to import the (guix gexp) module. Otherwise gexp and ungexp might not be defined.
Best
--
Daniel
prev parent reply other threads:[~2023-05-26 18:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-26 1:43 Meaning of symbol prefixed with "#$" N. Y.
2023-05-26 4:26 ` Robby Zambito
2023-05-26 18:22 ` Daniel Meißner [this message]
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://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=559C3810-7276-4E02-9145-0B25A732AB5E@ruhr-uni-bochum.de \
--to=daniel.meissner-i4k@ruhr-uni-bochum.de \
--cc=guile-user@gnu.org \
/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.
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).