From: ludo@gnu.org (Ludovic Courtès)
To: Andreas Enge <andreas@enge.fr>
Cc: guix-devel@gnu.org
Subject: Re: Naming scheme for Python packages
Date: Sun, 08 Sep 2013 16:03:23 +0200 [thread overview]
Message-ID: <87hadv1kd0.fsf@gnu.org> (raw)
In-Reply-To: <20130907212513.GA27881@debian> (Andreas Enge's message of "Sat, 7 Sep 2013 23:25:13 +0200")
Andreas Enge <andreas@enge.fr> skribis:
> On Sat, Sep 07, 2013 at 02:49:07PM +0200, Ludovic Courtès wrote:
>> Still it’s better to keep it, as a generic version. Then, we can 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 ‘package-with-name-prefix’ 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 case 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 ‘rewrite-if-package’, 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 ‘define’ like this, rather than ‘let’, to
introduce the ‘rewrite’ procedure; that doesn’t change the semantics,
but I find it easier to read.)
Thanks,
Ludo’.
next prev parent reply other threads:[~2013-09-08 14:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E1VHJTB-0006ys-7X@vcs.savannah.gnu.org>
2013-09-04 20:51 ` Naming scheme for Python packages Ludovic Courtès
2013-09-04 20:52 ` Cyril Roelandt
2013-09-04 21:16 ` Andreas Enge
2013-09-04 21:07 ` Cyril Roelandt
2013-09-04 21:36 ` Andreas Enge
2013-09-04 21:08 ` Andreas Enge
2013-09-04 21:32 ` Andreas Enge
2013-09-05 13:00 ` Ludovic Courtès
2013-09-06 21:53 ` Andreas Enge
2013-09-07 12:49 ` Ludovic Courtès
2013-09-07 21:25 ` Andreas Enge
2013-09-08 14:03 ` Ludovic Courtès [this message]
2013-09-08 14:51 ` Andreas Enge
2013-09-08 20:00 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87hadv1kd0.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=andreas@enge.fr \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.