help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to copy a file to the package /bin folder using the r-build-syst


From: Kyle Andrews
Subject: Re: How to copy a file to the package /bin folder using the r-build-system?
Date: Sun, 09 Apr 2023 03:15:46 +0000

Simon Tournier <zimon.toutoune@gmail.com> writes:

> Hi,
>
> On ven., 31 mars 2023 at 23:21, Kyle Andrews <kyle@posteo.net> wrote:
>
>>            (let ((out (assoc-ref outputs "out")))
>>              ;;; TODO: this doesn't work!
>>              ;; copy site-library/littler/bin/r to bin/r
>>              (copy-file
>>               (string-append out "site-library/littler/src/r")
>>               (string-append out "/bin/r"))))))))
>
> I guess what you want is:
>
> --8<---------------cut here---------------start------------->8---
>               (let* ((out (assoc-ref outputs "out"))
>                      (out/bin (string-append out "/bin")))
>                 (mkdir out/bin)
>                 (copy-file "inst/bin/r"
>                  (string-append out/bin "/r"))))))))
> --8<---------------cut here---------------end--------------->8---

Gotcha. That must mean my mental model should be that "out" refers to the 
directory in the store, while the working directory is inside of the 
decompressed source directory. I probably should have inferred that would 
almost always be the case since most build-systems will (re-)use 'unpack.

I also made the mistake of now always starting my path strings with a forward 
slash.

>
> And I would write,
>
>             (lambda _
>               (mkdir (string-append #$output "/bin"))
>               (copy-file "inst/bin/r"
>                          (string-append #$output "/bin/r")))

This perfect makes sense now and is much more concise.

>
>
> Well, using one or the other, I get:
>
> --8<---------------cut here---------------start------------->8---
> $ guix shell -L /tmp/foo r-littler -C -- r --help
>
> Usage: r [options] [-|file]
>
> Launch GNU R to execute the R commands supplied in the specified file, or
> from stdin if '-' is used. Suitable for so-called shebang '#!/'-line scripts.
>
> Options:
>   -h, --help           Give this help list
>       --usage          Give a short usage message
>   -V, --version        Show the version number
>   -v, --vanilla        Pass the '--vanilla' option to R
>   -t, --rtemp          Use per-session temporary directory as R does
>   -i, --interactive    Let interactive() return 'true' rather than 'false'
>   -q, --quick          Skip autoload / delayed assign of default libraries
>   -p, --verbose        Print the value of expressions to the console
>   -l, --packages list  Load the R packages from the comma-separated 'list'
>   -d, --datastdin      Prepend command to load 'X' as csv from stdin
>   -L, --libpath dir    Add directory to library path via '.libPaths(dir)'
>   -e, --eval expr      Let R evaluate 'expr'
>
> --8<---------------cut here---------------end--------------->8---
>

Thanks! I had been "toggling" back and forth between (packages->manifest (list 
r-littler)) and r-littler. In other words, the former gets uncommented when 
running guix shell -m littler.scm while the latter gets uncommented when used 
with guix build -f r-littler with the former getting commented. I can see from 
your example how writing a module would obviate the need to edit the source 
file over and over with the promise that alternatives can be illustrated at the 
same level.

Sadly, when I tried to take that idea and run with it I got an unexpected error.

```
$ guix build -L dev r-littler
...
ld: cannot find -lz
collect2: error: ld returned 1 exit status
...
```

I know I have seen that error before, but I thought it was fixed by importing 
compression, prefixing (guix licenses) to prevent a namespace collision, and 
including zlib in the package inputs.

```
$ diff littler.scm dev/littler.scm 
1,11c1,11
< (use-modules
<  (guix packages)
<  (guix download)
<  (gnu packages statistics)
<  (gnu packages compression)
<  (gnu packages icu4c)
<  (guix gexp)
<  (guix build-system r)
<  (gnu packages cran)
<  (gnu packages autotools)
<  ((guix licenses) #:prefix license:))
---
> (define-module (littler)
>   #:use-module (guix packages)
>   #:use-module (guix download)
>   #:use-module (gnu packages statistics)
>   #:use-module (gnu packages compression)
>   #:use-module (gnu packages icu4c)
>   #:use-module (guix gexp)
>   #:use-module (guix build-system r)
>   #:use-module (gnu packages cran)
>   #:use-module (gnu packages autotools)
>   #:use-module ((guix licenses) #:prefix license:))
47,50d46
< 
< ;; (packages->manifest (list r r-littler))
< 
< r-littler
```

Meanwhile, your command ran the same for me as it did for you.

```
guix shell -L dev r-littler -C -- r --help
```

What am I missing?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]