unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Nicolas Graves <ngraves@ngraves.fr>
Cc: Josselin Poiret <dev@jpoiret.xyz>,
	Tobias Geerinckx-Rice <me@tobias.gr>,
	Simon Tournier <zimon.toutoune@gmail.com>,
	Mathieu Othacehe <othacehe@gnu.org>,
	42338@debbugs.gnu.org, Ricardo Wurmus <rekado@elephly.net>,
	Christopher Baines <guix@cbaines.net>
Subject: [bug#42338] [PATCH v3 1/7] guix: import: Add composer importer.
Date: Sat, 14 Oct 2023 17:48:18 +0200	[thread overview]
Message-ID: <87edhxfbnh.fsf@gnu.org> (raw)
In-Reply-To: <6abfbb4d4d57642fea6bae5835ff0d365de7e24a.1695724304.git.ngraves@ngraves.fr> (Nicolas Graves's message of "Tue, 26 Sep 2023 12:31:38 +0200")

Hi Nicolas,

Nicolas Graves <ngraves@ngraves.fr> skribis:

> * guix/import/composer.scm: New file.
> * guix/scripts/import/composer.scm: New file.
> * guix/tests/composer.scm: New file.
> * Makefile.am: Add them.
> * guix/scripts/import.scm: Add composer importer.
> * doc/guix.texi (Invoking guix import): Mention it.

I’m a bit at loss with this patch series because there are two v3
threads, one v4 thread that contains a single patch, and the original
versions contained many more patches.

I think it’s OK to separate out the “gnu: Add php-*” patches, it’s
probably clearer.  However, could you come up with a v5 that includes
all the ‘guix import composer’ changes that we would need to apply?
How does that sound?

I have a couple of comments:

> +@item composer
> +@cindex Composer
> +@cindex PHP
> +Import metadat from the @uref{https://getcomposer.org/, Composer} package
                ^
Typo.

> +++ b/guix/import/composer.scm
> @@ -0,0 +1,270 @@
> +;;; GNU Guix --- Functional package management for GNU
> +;;; Copyright © 2019 Julien Lepiller <julien@lepiller.eu>

Maybe add yourself too?

> +;; XXX adapted from (guix scripts hash)
> +(define (file-hash file select? recursive?)
> +  ;; Compute the hash of FILE.
> +  (if recursive?
> +      (let-values (((port get-hash) (open-sha256-port)))
> +        (write-file file port #:select? select?)
> +        (force-output port)
> +        (get-hash))
> +      (call-with-input-file file port-sha256)))
> +
> +;; XXX taken from (guix scripts hash)
> +(define (vcs-file? file stat)

These two procedures are now exported from (guix hash), so you can
remove them and #:use-module (guix hash) instead.

> +(define* (composer-fetch name #:optional version)
> +  "Return an alist representation of the Composer metadata for the package NAME,
> +or #f on failure."
> +  (let ((package (json-fetch
> +                   (string-append (%composer-base-url) "/p/" name ".json"))))
> +    (if package
> +        (let* ((packages (assoc-ref package "packages"))
> +               (package (or (assoc-ref packages name) package))
> +               (versions (filter
> +                           (lambda (version)
> +                             (and (not (string-contains version "dev"))
> +                                  (not (string-contains version "beta"))))
> +                           (map car package)))
> +               (version (or (if (null? version) #f version)
> +                            (latest-version versions))))
> +          (assoc-ref package version))

Instead of returning an alist, directly return a <composer-package>
record.

> +(define (php-package? package)
> +  "Return true if PACKAGE is a PHP package from Packagist."
> +  (and
> +    (eq? (build-system-name (package-build-system package)) 'composer)

Rather: (eq? (package-build-system package) composer-build-system).

(The ‘name’ field is for debugging purposes only.)

> +(define (latest-release package)
> +  "Return an <upstream-source> for the latest release of PACKAGE."
> +  (let* ((php-name (guix-package->composer-name package))
> +         (metadata (composer-fetch php-name))
> +         (package (json->composer-package metadata))
> +         (version (composer-package-version package))
> +         (url (composer-source-url (composer-package-source package))))
> +    (upstream-source
> +     (package (package-name package))
> +     (version version)
> +     (urls (list url)))))

Maybe we can do that later, but note that <upstream-source> has an
‘inputs’ field nowadays; if you feel it in, ‘guix refresh -u’ is able to
update dependencies in addition to version/hash.

(If you leave it for later, please add a TODO.)

> +;; Avoid collisions with other tests.
> +(%http-server-port 10450)

This is now unnecessary: by default a random unused port is chosen and
everything’s fine.

> +(test-begin "composer")
> +
> +(test-assert "composer->guix-package"
> +  ;; Replace network resources with sample data.
> +  (with-http-server `((200 ,test-json)
> +                      (200 ,test-source))
> +    (parameterize ((%composer-base-url (%local-url))
> +                   (current-http-proxy (%local-url)))
> +      (match (composer->guix-package "foo/bar")
> +        (('package
> +           ('name "php-foo-bar")
> +           ('version "0.1")

For clarity, you can write:

  (match …
    (`(package
        (name "php-foo-bar")
        (version "0.1")
        …) …))

See commit 654fcf9971bb01389d577be07c6ec0f68940c743.

> +           ('native-inputs
> +            ('quasiquote
> +             (("php-phpunit-phpunit" ('unquote 'php-phpunit-phpunit)))))

Please change the importer so that it emits inputs without labels:

  (native-inputs (list php-phpunit-phpunit))

One last thing: consider adding an ‘etc/news.scm’ entry so people can
learn about the new importer.

Thanks in advance!

Ludo’.




  parent reply	other threads:[~2023-10-14 15:48 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-12 22:20 [bug#42338] [PATCH] Add composer build system (PHP) Julien Lepiller
2020-07-12 22:25 ` [bug#42338] [PATCH 01/34] guix: import: Add composer importer Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 02/34] gnu: Add composer-classloader Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 03/34] guix: Add composer-build-system Julien Lepiller
2020-09-07 14:09     ` Ludovic Courtès
2020-09-17 22:44       ` Julien Lepiller
2020-09-18  8:45         ` Ludovic Courtès
2020-09-18 23:24           ` Julien Lepiller
2020-09-25 10:33             ` Ludovic Courtès
2020-09-29 14:49               ` Julien Lepiller
2020-09-30  9:24                 ` Ludovic Courtès
2020-12-18 23:43                   ` Julien Lepiller
2020-12-21 14:51                     ` Ludovic Courtès
2020-07-12 22:25   ` [bug#42338] [PATCH 04/34] gnu: Add php-doctrine-instantiator Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 05/34] gnu: Add php-sebastian-recursion-context Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 06/34] gnu: Add php-sebastian-exporter Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 07/34] gnu: Add php-myclabs-deep-copy Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 08/34] gnu: Add php-phar-io-version Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 09/34] gnu: Add php-phar-io-manifest Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 10/34] gnu: Add php-symfony-polyfill-ctype Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 11/34] gnu: Add php-webmozart-assert Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 12/34] gnu: Add php-phpdocumentor-reflection-common Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 13/34] gnu: Add php-phpdocumentor-type-resolver Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 14/34] gnu: Add php-phpdocumentor-reflection-docblock Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 15/34] gnu: Add php-theseer-tokenizer Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 16/34] gnu: Add php-sebastian-code-unit-reverse-lookup Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 17/34] gnu: Add php-phpunit-php-token-stream Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 18/34] gnu: Add php-sebastian-version Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 19/34] gnu: Add php-phpunit-php-file-iterator Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 20/34] gnu: Add php-phpunit-php-text-template Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 21/34] gnu: Add php-sebastian-diff Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 22/34] gnu: Add php-sebastian-comparator Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 23/34] gnu: Add php-sebastian-environment Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 24/34] gnu: Add php-phpspec-prophecy Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 25/34] gnu: Add php-sebastian-object-reflector Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 26/34] gnu: Add php-sebastian-global-state Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 27/34] gnu: Add php-sebastian-object-enumerator Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 28/34] gnu: Add php-sebastian-resource-operations Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 29/34] gnu: Add php-sebastian-type Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 30/34] gnu: Add php-phpunit-php-code-coverage Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 31/34] gnu: Add php-phpunit-php-timer Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 32/34] gnu: Add php-phpunit-php-invoker Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 33/34] gnu: Add php-sebastian-code-unit Julien Lepiller
2020-07-12 22:25   ` [bug#42338] [PATCH 34/34] gnu: Add phpunit Julien Lepiller
2020-09-07 14:06   ` [bug#42338] [PATCH 01/34] guix: import: Add composer importer Ludovic Courtès
2020-09-17 22:43     ` Julien Lepiller
2020-09-18  8:31       ` Ludovic Courtès
2020-09-18 23:20         ` Julien Lepiller
2020-09-25 10:27           ` Ludovic Courtès
2021-10-16  4:15             ` [bug#42338] [PATCH] Add composer build system (PHP) Maxim Cournoyer
2021-08-23  9:46 ` [bug#42338] db
2022-08-13 20:30 ` [bug#42338] Ping about php composer guix-patches--- via
2022-08-13 20:38   ` Julien Lepiller
2022-10-06 16:27 ` [bug#42338] [PATCH] Add composer build system (PHP) Maxime Devos
2022-10-11 18:07   ` guix-patches--- via
2023-04-21  0:23 ` Adam Faiz via Guix-patches via
2023-09-26 10:31 ` [bug#42338] [PATCH v3 1/7] guix: import: Add composer importer Nicolas Graves via Guix-patches via
2023-09-26 10:31   ` [bug#42338] [PATCH v3 2/7] gnu: Add composer-classloader Nicolas Graves via Guix-patches via
2023-09-26 10:31   ` [bug#42338] [PATCH v3 3/7] guix: Add composer-build-system Nicolas Graves via Guix-patches via
2023-09-26 10:31   ` [bug#42338] [PATCH v3 4/7] guix: import: composer: Use memoization Nicolas Graves via Guix-patches via
2023-09-26 10:31   ` [bug#42338] [PATCH v3 5/7] guix: import: composer: Fix json->require Nicolas Graves via Guix-patches via
2023-09-26 10:31   ` [bug#42338] [PATCH v3 6/7] guix: import: composer: More robust string->license Nicolas Graves via Guix-patches via
2023-09-26 10:31   ` [bug#42338] [PATCH v3 7/7] guix: import: composer: Modern inputs formatting Nicolas Graves via Guix-patches via
2023-09-26 10:43   ` [bug#42338] [PATCH v3 1/7] guix: import: Add composer importer Nicolas Graves via Guix-patches via
2023-10-14 15:48   ` Ludovic Courtès [this message]
2023-09-26 11:25 ` [bug#42338] [PATCH v3] guix: import: composer: Fix match-lambda with a default fallback Nicolas Graves via Guix-patches via
2023-09-26 11:27   ` Nicolas Graves via Guix-patches via
2023-09-26 11:29 ` [bug#42338] [PATCH v4] guix: composer-build-system: Fix match-lambda with a fallback Nicolas Graves via Guix-patches via
2023-11-02 15:04 ` [bug#42338] [PATCH 0/9] Composer build system Nicolas Graves via Guix-patches via
2023-11-02 15:04   ` [bug#42338] [PATCH 1/9] guix: import: Add composer importer Nicolas Graves via Guix-patches via
2023-11-02 15:04   ` [bug#42338] [PATCH 2/9] gnu: Add composer-classloader Nicolas Graves via Guix-patches via
2023-11-02 15:04   ` [bug#42338] [PATCH 3/9] guix: Add composer-build-system Nicolas Graves via Guix-patches via
2023-11-02 15:04   ` [bug#42338] [PATCH 4/9] guix: import: composer: Use memoization Nicolas Graves via Guix-patches via
2023-11-02 15:04   ` [bug#42338] [PATCH 5/9] guix: import: composer: Fix json->require Nicolas Graves via Guix-patches via
2023-11-02 15:04   ` [bug#42338] [PATCH 6/9] guix: import: composer: More robust string->license Nicolas Graves via Guix-patches via
2023-11-02 15:04   ` [bug#42338] [PATCH 7/9] guix: import: composer: Modern inputs formatting Nicolas Graves via Guix-patches via
2023-11-02 15:04   ` [bug#42338] [PATCH 8/9] guix: import: composer: Full rewrite composer-fetch Nicolas Graves via Guix-patches via
2023-11-02 15:04   ` [bug#42338] [PATCH 9/9] gnu: composer-build-system: Full check phase rewrite Nicolas Graves via Guix-patches via
2023-11-02 15:16 ` [bug#42338] [PATCH v5 0/9] Composer build-system Nicolas Graves via Guix-patches via
2023-11-02 15:16   ` [bug#42338] [PATCH v5 1/9] guix: import: Add composer importer Nicolas Graves via Guix-patches via
2023-11-02 15:16   ` [bug#42338] [PATCH v5 2/9] gnu: Add composer-classloader Nicolas Graves via Guix-patches via
2023-11-02 15:16   ` [bug#42338] [PATCH v5 3/9] guix: Add composer-build-system Nicolas Graves via Guix-patches via
2023-11-02 15:16   ` [bug#42338] [PATCH v5 4/9] guix: import: composer: Use memoization Nicolas Graves via Guix-patches via
2023-11-02 15:16   ` [bug#42338] [PATCH v5 5/9] guix: import: composer: Fix json->require Nicolas Graves via Guix-patches via
2023-11-02 15:16   ` [bug#42338] [PATCH v5 6/9] guix: import: composer: More robust string->license Nicolas Graves via Guix-patches via
2023-11-02 15:16   ` [bug#42338] [PATCH v5 7/9] guix: import: composer: Modern inputs formatting Nicolas Graves via Guix-patches via
2023-11-02 15:16   ` [bug#42338] [PATCH v5 8/9] guix: import: composer: Full rewrite composer-fetch Nicolas Graves via Guix-patches via
2023-11-02 15:16   ` [bug#42338] [PATCH v5 9/9] gnu: composer-build-system: Full check phase rewrite Nicolas Graves via Guix-patches via
     [not found]   ` <87ttq3u8m4.fsf@ngraves.fr>
2023-12-07 12:36     ` [bug#42338] [Nicolas Graves via Guix-patches via] [bug#42338] [PATCH v5 0/9] Composer build-system Nicolas Graves via Guix-patches via
2023-12-18 22:33   ` Ludovic Courtès
2023-12-19  7:43     ` Nicolas Graves via Guix-patches via
2023-12-09 22:00 ` [bug#42338] [PATCH] Add composer build system (PHP) Charlie McMackin
2023-12-20 10:41 ` Wilko Meyer
2023-12-20 11:31   ` Julien Lepiller
2023-12-20 11:40     ` Wilko Meyer

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=87edhxfbnh.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=42338@debbugs.gnu.org \
    --cc=dev@jpoiret.xyz \
    --cc=guix@cbaines.net \
    --cc=me@tobias.gr \
    --cc=ngraves@ngraves.fr \
    --cc=othacehe@gnu.org \
    --cc=rekado@elephly.net \
    --cc=zimon.toutoune@gmail.com \
    /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).