Hi Ning! ningyuan...@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