guix-devel
[Top][All Lists]
Advanced

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

Re: Naming scheme for Python packages


From: Ludovic Courtès
Subject: Re: Naming scheme for Python packages
Date: Sun, 08 Sep 2013 16:03:23 +0200
User-agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux)

Andreas Enge <address@hidden> 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’.



reply via email to

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