From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: Naming scheme for Python packages Date: Sun, 08 Sep 2013 16:03:23 +0200 Message-ID: <87hadv1kd0.fsf@gnu.org> References: <87li3c8g56.fsf@gnu.org> <20130904210836.GB8425@debian> <20130904213224.GA8767@debian> <87hadz5spg.fsf@gnu.org> <20130906215311.GB15258@debian> <877ges94qk.fsf@gnu.org> <20130907212513.GA27881@debian> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VIffE-0007Yo-Vg for guix-devel@gnu.org; Sun, 08 Sep 2013 10:08:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VIff8-00048p-Qm for guix-devel@gnu.org; Sun, 08 Sep 2013 10:08:32 -0400 Received: from hera.aquilenet.fr ([141.255.128.1]:43468) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VIff8-00048i-Fc for guix-devel@gnu.org; Sun, 08 Sep 2013 10:08:26 -0400 In-Reply-To: <20130907212513.GA27881@debian> (Andreas Enge's message of "Sat, 7 Sep 2013 23:25:13 +0200") List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Andreas Enge Cc: guix-devel@gnu.org Andreas Enge skribis: > On Sat, Sep 07, 2013 at 02:49:07PM +0200, Ludovic Court=C3=A8s wrote: >> Still it=E2=80=99s better to keep it, as a generic version. Then, we ca= n have: >> (define package-with-python-2 >> (cut package-with-explicit-python <> python-2)) >> and then use that as needed. > > I modified with two additional parameters, OLD-PREFIX and NEW-PREFIX: > When going to python-2, one rewrites the prefix "python-" to "python2-". > The current patch would allow to go back to Python 3 by calling > (package-with-explicit-python p python "python2-" "python-"). Right, makes sense. Alternately, to improve separation of concerns, there could be a separate =E2=80=98package-with-name-prefix=E2=80=99 procedure, such that we= would do: (define package-with-python-2 (compose (cut package-with-name-prefix <> "python2-") (cut package-with-explicit-python <> python-2))) WDYT? >> Second remark: inputs are actually tuples of one of two forms: >> (name package) >> (name package output) > > Or a third one, (name-of-patch store-path-of-patch), which was already > handled. The current patch should handle all cases. Yes. > +(define (package-with-explicit-python p python old-prefix new-prefix) > + "Create a package with the same fields as P, which is assumed to use > +PYTHON-BUILD-SYSTEM, such that it is compiled with PYTHON instead. The > +inputs are changed recursively accordingly. If the name of P starts with > +OLD-PREFIX, this is replaced by NEW-PREFIX; otherwise, NEW-PREFIX is > +prepended to the name." > + (let* ((build-system (package-build-system p)) > + (rewrite-if-package > + (lambda (content) > + ;; CONTENT may be a string (e.g., for patches), in which cas= e it > + ;; is returned, or a package, which is rewritten with the new > + ;; PYTHON and NEW-PREFIX. > + (if (package? content) > + (package-with-explicit-python content python > + old-prefix new-prefix) > + content))) > + (rewrite > + (match-lambda > + ((name content . rest) > + (append (list name (rewrite-if-package content)) rest))))) Instead of having =E2=80=98rewrite-if-package=E2=80=99, this can be written= like this: (define rewrite (match-lambda ((name (? package p) rest ...) ...) (x ; something not a package: leave it as is x))) (I would use an internal =E2=80=98define=E2=80=99 like this, rather than = =E2=80=98let=E2=80=99, to introduce the =E2=80=98rewrite=E2=80=99 procedure; that doesn=E2=80=99t cha= nge the semantics, but I find it easier to read.) Thanks, Ludo=E2=80=99.