From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id QNg9CePCI2S+gAAASxT56A (envelope-from ) for ; Wed, 29 Mar 2023 06:47:31 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id WLtcCOPCI2QrfgAAG6o9tA (envelope-from ) for ; Wed, 29 Mar 2023 06:47:31 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 380A3394AB for ; Wed, 29 Mar 2023 06:47:30 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=posteo.net header.s=2017 header.b=GeGjzFqb; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1680065250; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=m9dV7mWbd+fp2cvRse05kV4DJMfhtmhrUCdn2vtnCJM=; b=uJq1uXIdzabX2n//bBvdtj61JDZZnsYyG9AkX5zPzZ8ZDha959DwXf8hfOri1qwkLGkvly nnHpvDJL11M/mwxBWvBX2uvsl68K3q+Vubs597jdx4xGOcFuqI1nNVL9CXw5olyktWoDiN 7ishXwQUaNiAjHPjGuTDTnHinF+oThiPVJfMOEJINJqHrbplKGjMyHCb5AOltjEF3aBm3J jYYWOiy+ExYAdNZ7lXG4EH/Rf1WRpLnG6K2EqL97ULvDA5xbe8J2R21UVj2aVTMSRU/Obk gdmAXUYSXruDYNr6BQ/lDMm1A/vZgjj3N/PtcjbF8O20LICSGc2mZ3YBKOEQnw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1680065250; a=rsa-sha256; cv=none; b=WydP2l9sOAGrTv+jK/jA4jwahTwe9Ems0bMOVzOMGeHj0YwEg6bhoDtXi8omJLCv0vUu9R 4xxpXzERnvyZh4T6MEo9S6ahb9ckAEAzu7VlDble/YY/E+txPNj7OzdpLSUUb6Ddtn5rMZ MDTT458YnW9+x6KJL32WS0IDeSA2ts5hi0eKOX8pqKVPsrEpiwrA9p2GxDPHfrArJJ9E5D 52K47SWA04ZnqTY8/NuVKBJPtq5mDbWOKEXg3UuarN9rDO0JqWvoikbE633mO3zHQyCegS gJ3B4hNg3ds32ikZeFKde04Z+D33K0QQ1aMFrz2txe+4N4xPwEFTFNF0BhXq2Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=posteo.net header.s=2017 header.b=GeGjzFqb; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1phNi2-0002fs-Db; Wed, 29 Mar 2023 00:46:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1phNhy-0002fa-Dh for help-guix@gnu.org; Wed, 29 Mar 2023 00:46:50 -0400 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1phNht-00052s-M3 for help-guix@gnu.org; Wed, 29 Mar 2023 00:46:50 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 923CC2402B1 for ; Wed, 29 Mar 2023 06:46:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1680065202; bh=YINNu+Wp14qC7blGdSwFEgMEXQRX2rpDkrMTBioBcGk=; h=Date:From:To:Subject:From; b=GeGjzFqbr4EcC86tHVZ+6h8hdv9sKPrCPwbq9Ugfage0vCuWvs2eAuGKMbH0kffBe lYhqZwPi4gMpGNDo0QR1+M51ieQ5UQs/JWMBFz4HSx0jPAq9WZiijCYAUcvWUiZYyF 5mEgjsn6tkg2NySYfNDN6HnuvTV99ZsZ9XxN4DU408k/l5uOp+L+U88OEgoD1sj7uz uZtmmyD7J6Ej6YRkEVdE0IoXW6QDst/wcIV+054rd8mBzdZkm/TT8V49ry70t1nzjS H0sHplgY9W6pHKLuu4Gd1wFQrKJUijoKRqyEqWTRq9G9OYbEkNNeLq+lB3h7+0ciDT 1iEmMWyMlzjUw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PmYt92lfqz6tm4; Wed, 29 Mar 2023 06:46:41 +0200 (CEST) Date: Wed, 29 Mar 2023 04:46:37 +0000 From: Kyle To: Philip McGrath , help-guix@gnu.org Subject: Re: Need some help packaging parts of a scientific workflow In-Reply-To: <36a1b658-1137-4f8e-8217-823b6611ad60@app.fastmail.com> References: <874jqcs4s7.fsf@posteo.net> <36a1b658-1137-4f8e-8217-823b6611ad60@app.fastmail.com> Message-ID: <0AD816F0-55E3-415C-AA36-961156C35E6D@posteo.net> MIME-Version: 1.0 Received-SPF: pass client-ip=185.67.36.65; envelope-from=kyle@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: help-guix@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: X-Migadu-Queue-Id: 380A3394AB X-Spam-Score: -1.43 X-Migadu-Spam-Score: -1.43 X-Migadu-Scanner: scn0.migadu.com List-Help: List-Subscribe: , Errors-To: help-guix-bounces+larch=yhetil.org@gnu.org Sender: help-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-TUID: Yb6UqN7HGPvi Thanks, Philip! Your descriptions really made it click for me=2E Might you give a small example of what you mean by adding an error phase? = That sounds like an important debugging strategy, but I can't quite grasp w= hat it would actually look like=2E I'm curious what kinds of data you are p= rinting out=2E=20 On March 23, 2023 5:30:11 PM EDT, Philip McGrath wrote: >Hi Kyle, > >On Wed, Mar 22, 2023, at 5:29 PM, Kyle Andrews wrote: >> Dear Guix, >> >> Part of my scientific workflow involves compiling a small Racket script >> for a command line program into its executable and placing that on >> PATH=2E > >I am always glad to hear of more people using Guix and Racket together! > >> I had bundled this script inside an R package which made sure it >> got compiled and everything was correctly configured at library load >> time=2E >> > >Tangential to your actual question, I think this is not necessarily a ter= rible practice=2E There is not much difference between running `my-script` = and running `racket -y "path/to/my-script=2Erkt"`, and, if you do that or `= raco make` during the build process of your R package, you'll get compiled = files properly=2E There are tradeoffs to weigh, including support for R use= rs without Guix=2E But there are also good reasons to decide to separate th= e Racket script from the R library, so that's what I'll explain below=2E > >> From reading the documentation a lot, I think the actual compilation >> step can be done using the "invoke" procedure like so: >> >> ``` >> (invoke "raco" "exe" "{package_location}/custom-shell-tool=2Erkt") >> ``` >> >> What I'm struggling with the most is understanding all the boilerplate >> code I need to place around that fundamental call=2E >> > >I'll start with a working example suitable for `guix build -f`, then answ= er your specific questions=2E > >``` >;; SPDX-License-Identifier: (CC0-1=2E0 OR (Apache-2=2E0 OR MIT)) >;; SPDX-FileCopyrightText: Philip McGrath > >(use-modules > (gnu packages racket) > (guix build-system copy) > (guix gexp) > (guix packages)) > >(package > (name "racket-hello") > (version "1=2E0") > (source (plain-file "hello=2Erkt" > "#lang racket (displayln '|Hello from Racket!|)")) > (inputs (list racket)) > (build-system copy-build-system) > (arguments > (list > #:install-plan #~'(("hello" "bin/")) > #:phases > #~(modify-phases %standard-phases > (add-before 'install 'build > (lambda args > (invoke "raco" "exe" "hello=2Erkt")))))) > (home-page #f) > (synopsis "Hello world in Racket") > (description > "This is a trivial example of using @code{raco exe} with Guix=2E") > (license #f)) >``` > >In fact this package would be a reasonable candidate for `trivial-build-s= ystem`, but I've stuck with `copy-build-system` because the boilerplate for= `trivial-build-system` is very different than for all other build systems= =2E > >Likewise, I'm assuming you know how you want to build your executable, bu= t you might consider the `--launcher` flag for `raco exe` and an explicit c= all to `raco make`: in particular, it might take use less total disk space = than an ELF executable=2E > >Note that you do have to use `racket`, not `racket-minimal`, because `rac= ket-minimal` doesn't include the `raco exe` command=2E > >> (source >> (local-file "package_location")) ; how to refer to local files? > >In general, `local-file` is the right mechanism; specifics depend on your= situation, including how you are expecting your package definition to be u= sed=2E For a single file, `(local-file "path/to/script=2Erkt")` is probably= what you want, where the path is relative to the Guile file containing the= `local-file` expression=2E For a directory, consider the `#:recursive?` an= d `#:select?` arguments=2E > >> (invoke "raco" "exe" >> (string-append >> #$package-folder ; how to refer to the build itself? >> "custom-shell-tool=2Erkt")))))) > >The `unpack` phase from `gnu-build-system` handles this: if the package s= ource is a directory, you're inside a copy of it; if it's a file, you're in= a temporary directory containing it=2E > >> >> I'm especially interested in figuring out how I can productively learn >> to experiment productively with this stuff for myself=2E >> > >Personally, I often insert a phase that calls `error` to stop the build, = perhaps printing out interesting values first, and use `guix build --keep-f= ailed` to explore the build environment=2E > >-Philip