unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Nikita Karetnikov <nikita@karetnikov.org>
Cc: bug-guix@gnu.org
Subject: Re: 'python-build-system'
Date: Wed, 08 May 2013 18:47:25 +0200	[thread overview]
Message-ID: <87k3n9zaea.fsf@gnu.org> (raw)
In-Reply-To: <87ppx2qlu8.fsf@karetnikov.org> (Nikita Karetnikov's message of "Wed, 08 May 2013 05:52:47 +0400")

Nikita Karetnikov <nikita@karetnikov.org> skribis:

>> If you append (package-native-search-paths python) to the list of search
>> paths, then PYTHONPATH will automagically be defined appropriately (see
>> <http://lists.gnu.org/archive/html/bug-guix/2013-03/msg00158.html>.)
>
>> If you don’t, then PYTHONPATH will be undefined, unless you explicitly
>> define it in build/python-build-system.scm, which is not the recommended
>> option.
>
>> So just mimic the change made in the above commit for perl-build-system.
>
> OK, I've added it.  Should I remove the following part?
>
> +  (let* ((out  (assoc-ref outputs "out"))
> +         (var `("PYTHONPATH" prefix
> +                (,(string-append out "/lib/python"
> +                                 python-version "/site-packages")))))
> +    (for-each (lambda (dir)
> +                (let ((files (list-of-files dir)))
> +                  (for-each (cut wrap-program <> var)
> +                            files)))
> +              bindirs)))
>
> Or is it a different issue?

Yes, see below.

[...]

> +(define* (python-build store name source inputs
> +                       #:key
> +                       (python (@ (gnu packages python) python))
> +                       (python-version
> +                        (string-take (package-version
> +                                      (@ (gnu packages python) python)) 3))
> +                       (tests? #t)
> +                       (configure-flags ''())
> +                       (phases '(@ (guix build python-build-system)
> +                                   %standard-phases))
> +                       (outputs '("out"))
> +                       (search-paths '())
> +                       (system (%current-system))
> +                       (guile #f)
> +                       (imported-modules '((guix build python-build-system)
> +                                           (guix build gnu-build-system)
> +                                           (guix build utils)))
> +                       (modules '((guix build python-build-system)
> +                                  (guix build gnu-build-system)
> +                                  (guix build utils))))
> +  "Build SOURCE using PYTHON, and with INPUTS.  This assumes that SOURCE
> +provides a 'setup.py' file as its build system."
> +  (define python-search-paths
> +    (append (package-native-search-paths python)
> +            (standard-search-paths)))
> +
> +  (define builder
> +    `(begin
> +       (use-modules ,@modules)
> +       (python-build #:name ,name
> +                     #:source ,(if (and source (derivation-path? source))
> +                                   (derivation-path->output-path source)
> +                                   source)
> +                     #:configure-flags ,configure-flags
> +                     #:system ,system
> +                     #:test-target "test"
> +                     #:tests? ,tests?
> +                     #:outputs %outputs
> +                     #:python-version ,python-version
> +                     #:search-paths ',(map search-path-specification->sexp
> +                                           (append python-search-paths
> +                                                   (standard-search-paths)))

Typo here.  Should be:

  (append python-search-paths search-paths)

Otherwise the ‘search-paths’ argument would not be honored.

[...]

> +(define* (wrap #:key outputs python-version #:allow-other-keys)
> +  (define (list-of-files dir)
> +    (map (cut string-append dir "/" <>)
> +         (or (scandir dir (lambda (f)
> +                            (let ((s (stat (string-append dir "/" f))))
> +                              (eq? 'regular (stat:type s)))))
> +             '())))
> +
> +  (define bindirs
> +    (append-map (match-lambda
> +                 ((_ . dir)
> +                  (list (string-append dir "/bin")
> +                        (string-append dir "/sbin"))))
> +                outputs))
> +
> +  (let* ((out  (assoc-ref outputs "out"))
> +         (var `("PYTHONPATH" prefix
> +                (,(string-append out "/lib/python"
> +                                 python-version "/site-packages")))))

We also need to account for extra Python modules the package depends on:

  (let* (...
         (var `("PYTHONPATH" prefix
                ,(cons (string-append out "/lib/python"
                                      python-version "/site-packages")
                       (search-path-as-string->list
                        (or (getenv "PYTHONPATH") "")))))
    ...)

To answer your previous question, this ‘wrap’ phase serves a different
(but related) purpose than the ‘native-search-paths’ thing: it ensures
that the ‘bzr’ program, when run by the user, finds all its Python
modules.

[...]

> +(define-public bazaar
> +  (package
> +    (name "bazaar")
> +    (version "2.5.1")
> +    (source
> +     (origin
> +      (method url-fetch)
> +      (uri (string-append "https://launchpad.net/bzr/2.5/" version
> +                          "/+download/bzr-" version ".tar.gz"))
> +      (sha256
> +       (base32
> +        "10krjbzia2avn09p0cdlbx2wya0r5v11w5ymvyl72af5dkx4cwwn"))))
> +    (build-system python-build-system)
> +    (inputs
> +     ;; FIXME: 'tools/packaging/lp-upload-release' and 'tools/weavemerge.sh'
> +     ;; require Zsh.

“Note:” rather than “FIXME:”.

> +     `(("gettext" ,guix:gettext)))
> +    (arguments
> +     `(#:tests? #f))

Could you add a comment stating what’s wrong with the test suite?  Or,
if it’s easily doable, just make it pass (if it’s not, it can be done
later.)

With these changes in place, OK to commit.

Thanks!

Ludo’.

  reply	other threads:[~2013-05-08 16:47 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-05 18:21 'python-build-system' Nikita Karetnikov
2013-04-07 10:34 ` 'python-build-system' Ludovic Courtès
2013-04-23  9:49   ` ERROR: missing interface for module (gnutls) (was: 'python-build-system') Nikita Karetnikov
2013-04-23 11:51     ` ERROR: missing interface for module (gnutls) Ludovic Courtès
2013-04-23 15:03       ` Nikita Karetnikov
2013-04-23 16:01         ` Ludovic Courtès
2013-04-27 15:14 ` 'python-build-system' Ludovic Courtès
2013-04-28  1:55   ` 'python-build-system' Nikita Karetnikov
2013-04-28 17:18     ` 'python-build-system' Nikita Karetnikov
2013-04-28 20:52       ` 'python-build-system' Ludovic Courtès
2013-04-29  3:50         ` 'python-build-system' Nikita Karetnikov
2013-04-29 11:42           ` 'python-build-system' Ludovic Courtès
2013-05-08  1:52             ` 'python-build-system' Nikita Karetnikov
2013-05-08 16:47               ` Ludovic Courtès [this message]
2013-05-08 23:22                 ` 'python-build-system' Nikita Karetnikov
2013-05-09 20:29                   ` 'python-build-system' Ludovic Courtès
2013-04-29 19:33       ` 'python-build-system' Ludovic Courtès
2013-04-30 15:04         ` 'python-build-system' Ludovic Courtès
2013-04-28 22:50     ` 'python-build-system' Cyril Roelandt
2013-04-29 11:50       ` 'python-build-system' Ludovic Courtès
2013-04-29 19:24         ` 'python-build-system' Cyril Roelandt
2013-04-30 13:47           ` 'python-build-system' Nikita Karetnikov
2013-05-06 21:07             ` 'python-build-system' 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

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k3n9zaea.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=bug-guix@gnu.org \
    --cc=nikita@karetnikov.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 public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).