From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH] import: pypi: read requirements from wheels. Date: Sun, 24 Jan 2016 21:08:53 +0100 Message-ID: <87twm2n3je.fsf@gnu.org> References: <1453414080-23296-1-git-send-email-tipecaml@gmail.com> 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]:44251) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNQy3-0007TK-M1 for guix-devel@gnu.org; Sun, 24 Jan 2016 15:09:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aNQy0-0003eR-Fx for guix-devel@gnu.org; Sun, 24 Jan 2016 15:08:59 -0500 In-Reply-To: <1453414080-23296-1-git-send-email-tipecaml@gmail.com> (Cyril Roelandt's message of "Thu, 21 Jan 2016 23:08:00 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." 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: Cyril Roelandt Cc: guix-devel@gnu.org Cyril Roelandt skribis: > * guix/import/pypi.scm (latest-wheel-release): New function. s/function/procedure/ :-) Please also mention the changes in =E2=80=98guess-requirements=E2=80=99, =E2=80=98compute-inputs=E2=80=99, etc. So do I get it right that pypi now provides packages both in Wheels and in =E2=80=9Ctraditional=E2=80=9D format, but that Wheels provides more info= about dependencies? IOW: What does this buy us? :-) > +(define (latest-wheel-release pypi-package) > + "Return the url of the wheel for the latest release of pypi-package, o= f #f if Line a bit long. s/of/or/ > + (define (read-wheel-metadata wheel-archive) > + ;; Given WHEEL-ARCHIVE, a ZIP Python wheel archive, return the packa= ge's > + ;; requirements. > + (let* ((dirname (string-append > + (string-join > + (list-head > + (string-split (last (string-split wheel-url #\/))= #\-) 2) > + "-") "-" should be aligned with (list-head. I would be best to turn this transformation into a top-level procedure, say =E2=80=98wheel-url->extracted-directory=E2=80=99. > + ".dist-info")) > + (json-file (string-append dirname "/metadata.json"))) > + (and (system* "unzip" "-q" wheel-archive json-file) > + (dynamic-wind > + (const #t) > + (lambda () > + (call-with-input-file json-file > + (lambda (port) > + (let* ((metadata (json->scm port)) > + (run_requires (hash-ref metadata "run_requires= ")) > + (requirements (hash-ref (list-ref run_requires= 0) > + "requires"))) > + (map (lambda (r) > + (python->package-name (clean-requirement r))) > + requirements))))) > + (lambda () > + (delete-file json-file) > + (rmdir dirname)))))) Eventually I wonder if we should do this in a derivation instead of hoping for =E2=80=98unzip=E2=80=99 & co. to be available there (=E2=80=9Cev= entually=E2=80=9D, because the problem is already present with the =E2=80=98requirements.txt=E2=80=99 = thingie.) Could you add a test in tests/pypi.scm? Thanks! Ludo=E2=80=99.