From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id wA+PFE4jhGDIFwAAgWs5BA (envelope-from ) for ; Sat, 24 Apr 2021 15:55:26 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id 4BYhEE4jhGA9XgAAB5/wlQ (envelope-from ) for ; Sat, 24 Apr 2021 13:55:26 +0000 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 24A202B479 for ; Sat, 24 Apr 2021 15:55:25 +0200 (CEST) Received: from localhost ([::1]:42832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1laIkk-0003GZ-S0 for larch@yhetil.org; Sat, 24 Apr 2021 09:55:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1laIkQ-0003GS-3o for help-guix@gnu.org; Sat, 24 Apr 2021 09:55:02 -0400 Received: from mail-40133.protonmail.ch ([185.70.40.133]:15605) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1laIkL-0006sG-5G for help-guix@gnu.org; Sat, 24 Apr 2021 09:55:01 -0400 Date: Sat, 24 Apr 2021 13:54:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=elenq.tech; s=protonmail3; t=1619272490; bh=XQCsJnu+mHQ8PaPtZ2EvMD7S0TYhXJddsj7sla0DlFg=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=Tte58/cTxGgY9oEsNkqrv3zwjfKe+3V1SS0mEu6DlFDXqa2LzfvELn700G13kNr9t ajcX5XeQz2erotMT2TgUXUAJk8jdDSO5NzUue3Bhig4IytSACMsAC65NNAojy5D4xP wOpLpseP/KMvXegmDhmw08x0QgeDMECMr6T+KeZj0nr1mupcpnrmIDjKU+AKl2wlWZ tw7566yCTRU11tysgck3o66WHlXjGRLarFCs8diJyz8Bl7On7EDmsygCf0V3YEmwzP F2Iwlj97XQeKpYYSsoF6cfLGrMAd/syiKpWw9iB1gaHGShQu9u41yqZU4RF11hKakD GwyF9miUxG7Rw== To: phodina From: Ekaitz Zarraga Subject: Re: Import package and generate use-module Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.70.40.133; envelope-from=ekaitz@elenq.tech; helo=mail-40133.protonmail.ch X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-guix@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Ekaitz Zarraga Cc: "help-guix@gnu.org" Errors-To: help-guix-bounces+larch=yhetil.org@gnu.org Sender: "Help-Guix" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1619272526; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=XQCsJnu+mHQ8PaPtZ2EvMD7S0TYhXJddsj7sla0DlFg=; b=C2mS6EIEH6zQgGqokXCcGko6bvClRCmg/gmFU7trDJoJv0bawy+mYotmONQ5WSsA7mJqsn b2IGk87TMz4TDqSTkIVBOAC7unqgwlcmsCJg0qIvB5TTXa5/6TiSZVmrv6RdBfAyxm4VRs sQ98aUr1J9Wz2acsd3pcG3bEjOLhaYSsz/niAEHM+tVPXpBsf7QK6KXBDCUAlx/KOK85S3 ZUhpIp+FqKKxRxsgd3cftzNhQnTdxzjOlBYtRHZfRvxVKUYXs/UN4Niz7faTHM5xZ5srMC KKWyBflL7aX/VM1myi15mD5M+4PSp6ylH1uJ39WgJCz4aBsvmoOs68Co588SSA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1619272526; a=rsa-sha256; cv=none; b=XGaDOzcWuJDWoSct4iyqIdSxkCdX+RI7LTB0LO7RL+e41ZHuaBSSAx296pSkFMYglgYmjl tRy+wpt34nMuD3mZ4e5F69XG9mJOk8YRNN9MOOBTONoZVcX7rXYhOpeZ5jLFo20UounIjM oVqzJgeDN04U3Z7IGhmePNjlMYjCKXqsbTKko7fhm0fLdX18i3cTjVomy4AiFyaJKS+HGE rG6BZbVUXWeOye//xMRNyD2QHgHvVBzwjPHx7qWcMPjRFTwEr2iz2fKhZZU0F54DZsp6bl qigYctwTU4ojQbpt8n5Koa/EYvmW47wF1Q8iG+rhNHYmXvf/cJ5oU1XEE5phiQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=elenq.tech header.s=protonmail3 header.b="Tte58/cT"; dmarc=pass (policy=none) header.from=elenq.tech; spf=pass (aspmx1.migadu.com: domain of help-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=help-guix-bounces@gnu.org X-Migadu-Spam-Score: -3.14 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=elenq.tech header.s=protonmail3 header.b="Tte58/cT"; dmarc=pass (policy=none) header.from=elenq.tech; spf=pass (aspmx1.migadu.com: domain of help-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=help-guix-bounces@gnu.org X-Migadu-Queue-Id: 24A202B479 X-Spam-Score: -3.14 X-Migadu-Scanner: scn0.migadu.com X-TUID: LYpIpT8/lC1N Hi, =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 Original Me= ssage =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 On Saturday, April 24, 2021 11:26 AM, phodina via wrote= : > I'm making a package for octoprint which is imported from PyPI. guix impo= rt -r octoprint generates the template to build the package. > > However, I'm missing the :#use-module ... in order to build the package w= hen I add (define-module (python-octoprint). Given the fact there are tens = of inputs doing it manually seems tedious and writing a script to parse the= package definition seems like reinventing the wheel as I'm certainly not t= he first person to run into this issue. > > So is there a way to automate also this part? > > Let me give you context:If I look at Guix package repository gnu/packages= /python-xyz.scm I see there definitions of packages: > > (define-public python-numpy > (package > (name "python-numpy") > ... > > If I have another package that depends on python-numpy I just provide the= name in e.g. inputs and I don't have to import it with #:use-module within= this file. > > However, when I run guix import pypi PKG I get package definition and whe= n I run guix build -f python-octoprint.scm I get this error: > > /tmp/python-octoprint.scm:275:6: In procedure propagated-inputs: > error: python-flask: unbound variable > hint: Did you forget `(use-modules (gnu packages python-web))'? > > Of course writing down all the unbound variables by hand is tedious and e= rror-prone. And since guix gives a hint is there a way to write the depende= ncy into the file? > > And the question in general is: When I find out that the program is not p= ackaged and I want to write the package definition and then verify it insta= lls and runs correctly, what steps should I take? > > guix pull pypi PKG > PKG.scm > > Add 'define-module' > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > ?? > guix build -f PKG.scm > > Note: Doesn't matter if it's python or rust program. I'm interested in th= e workflow > > Kind regards > Petr Hodina > > Sent with ProtonMail Secure Email. I'm not sure if I understand it correctly. What I understand is you need to add the define-module like in any guile file, but you don't need to import every single variable in the module you are importing. You just import the whole module and every `define-public` from the module will be available. See for instance this: https://gitlab.com/ekaitz-zarraga/guix-packages/-/blob/master/electronics.s= cm#L7 That import provides *all* the public variables from the `python` module, not only one. The case of `python-numpy` you describe works because variables share module scope, so they don't need to import other vars in the same file: they can already see them. In your case you are pretty much fine importing a couple of modules: python-web for flask, and probably python-science or so. The lazy approach is: I try to `guix build` if there's a missing module add it with #:use-modules, as shown in the example. Rinse and repeat. The direct approach is to use tools like `guix show` to check the module where your inputs are described and import them. For example: ``` $ guix show python-flask name: python-flask version: 1.1.2 outputs: out systems: x86_64-linux i686-linux dependencies: python-click@7.1.2 [...] location: gnu/packages/python-web.scm:2946:2 homepage: https://www.palletsprojects.com/p/flask/ license: Modified BSD [...] ``` So now you know it is defined in `python-web`, as it says in the `location` field. Now, you can add the `#:use-modules` form that includes `python-web` to your module definition. If other of your inputs is located in the same module you *don't* need to import it again, because it will be already known by that import. So the point here to clarify is: Use modules don't import PACKAGES, they import THE WHOLE FILE, with all the (public) packages it contains. So it's not as tedious as you suggested.[^1] I hope this helps. Best, Ekaitz [^1]: you can actually choose specific variables to import, exclude some or use a prefix for the imported ones. But our normal usage is just to import the whole file. See: https://www.gnu.org/software/guile/manual/html_node/Creating-Guile-Modules.= html and: https://www.gnu.org/software/guile/manual/html_node/Using-Guile-Modules.htm= l