all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#70227] [PATCH 0/2] Improving composer import.
@ 2024-04-06  2:04 Nicolas Graves via Guix-patches via
  2024-04-06  2:08 ` [bug#70227] [PATCH 1/2] guix: import: composer: Handle parsing failures Nicolas Graves via Guix-patches via
  2024-10-06 23:55 ` [bug#70227] [PATCH v2 1/2] guix: import: composer: Handle parsing failures Nicolas Graves via Guix-patches via
  0 siblings, 2 replies; 9+ messages in thread
From: Nicolas Graves via Guix-patches via @ 2024-04-06  2:04 UTC (permalink / raw)
  To: 70227; +Cc: ngraves

This patch series superseeds former patches 67895, 67897 and 67906.
It fixes bugs, handles parsing failures and implements recursive package refresh.

Nicolas Graves (2):
  guix: import: composer: Handle parsing failures.
  guix: import: composer: Implement recursive package refresh.

 guix/import/composer.scm | 41 +++++++++++++++++++++++++++++-----------
 1 file changed, 30 insertions(+), 11 deletions(-)

-- 
2.41.0





^ permalink raw reply	[flat|nested] 9+ messages in thread

* [bug#70227] [PATCH 1/2] guix: import: composer: Handle parsing failures.
  2024-04-06  2:04 [bug#70227] [PATCH 0/2] Improving composer import Nicolas Graves via Guix-patches via
@ 2024-04-06  2:08 ` Nicolas Graves via Guix-patches via
  2024-04-06  2:08   ` [bug#70227] [PATCH 2/2] guix: import: composer: Implement recursive package refresh Nicolas Graves via Guix-patches via
  2024-10-06 23:55 ` [bug#70227] [PATCH v2 1/2] guix: import: composer: Handle parsing failures Nicolas Graves via Guix-patches via
  1 sibling, 1 reply; 9+ messages in thread
From: Nicolas Graves via Guix-patches via @ 2024-04-06  2:08 UTC (permalink / raw)
  To: 70227; +Cc: ngraves

* guix/import/composer (latest-release): Handle parsing
failures. Rename package to composer-package for clarity.

Change-Id: I57f6fba7b05122b031177681e76cf0b5c9547736
---
 guix/import/composer.scm | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/guix/import/composer.scm b/guix/import/composer.scm
index 1ad608964b..75419ca63e 100644
--- a/guix/import/composer.scm
+++ b/guix/import/composer.scm
@@ -243,16 +243,19 @@ (define (php-package? package)
    (eq? (package-build-system package) composer-build-system)
    (string-prefix? "php-" (package-name package))))
 
-(define (latest-release package)
+(define* (latest-release package #:key (version #f))
   "Return an <upstream-source> for the latest release of PACKAGE."
   (let* ((php-name (guix-package->composer-name package))
-         (package (composer-fetch php-name))
-         (version (composer-package-version package))
-         (url (composer-source-url (composer-package-source package))))
-    (upstream-source
-     (package (package-name package))
-     (version version)
-     (urls (list url)))))
+         (composer-package (composer-fetch php-name #:version version)))
+    (if composer-package
+        (upstream-source
+         (package (composer-package-name composer-package))
+         (version (composer-package-version composer-package))
+         (urls (list (composer-source-url
+                      (composer-package-source composer-package)))))
+        (begin
+          (warning (G_ "failed to parse ~a~%") php-name)
+          #f))))
 
 (define %composer-updater
   (upstream-updater
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [bug#70227] [PATCH 2/2] guix: import: composer: Implement recursive package refresh.
  2024-04-06  2:08 ` [bug#70227] [PATCH 1/2] guix: import: composer: Handle parsing failures Nicolas Graves via Guix-patches via
@ 2024-04-06  2:08   ` Nicolas Graves via Guix-patches via
  2024-04-29 21:29     ` Ludovic Courtès
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Graves via Guix-patches via @ 2024-04-06  2:08 UTC (permalink / raw)
  To: 70227; +Cc: ngraves

* guix/import/composer.scm
 (composer-fetch): Replace reduce by fold to correct version selection
 logic.
 (latest-release): Implement recursive package refresh. Rename to
 import-release.
 (import-release): New function, formerly known as latest-release.

Change-Id: I8f629b4d1da866f5986d39b4e159f2b44af9ee49
---
 guix/import/composer.scm | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/guix/import/composer.scm b/guix/import/composer.scm
index 75419ca63e..e2a60969aa 100644
--- a/guix/import/composer.scm
+++ b/guix/import/composer.scm
@@ -113,7 +113,7 @@ (define* (composer-fetch name #:key (version #f))
          (if version
              (assoc-ref packages version)
              (cdr
-              (reduce
+              (fold
                (lambda (new cur-max)
                  (match new
                    (((? valid-version? version) . tail)
@@ -243,16 +243,32 @@ (define (php-package? package)
    (eq? (package-build-system package) composer-build-system)
    (string-prefix? "php-" (package-name package))))
 
-(define* (latest-release package #:key (version #f))
-  "Return an <upstream-source> for the latest release of PACKAGE."
+(define* (import-release package #:key (version #f))
+  "Return an <upstream-source> for VERSION or the latest release of PACKAGE."
   (let* ((php-name (guix-package->composer-name package))
          (composer-package (composer-fetch php-name #:version version)))
     (if composer-package
-        (upstream-source
-         (package (composer-package-name composer-package))
-         (version (composer-package-version composer-package))
-         (urls (list (composer-source-url
-                      (composer-package-source composer-package)))))
+        (let* ((guix-name (composer-package-name composer-package))
+               (inputs
+                (append
+                 (map (lambda (dep)
+                        (upstream-input
+                         (name php-name)
+                         (downstream-name guix-name)
+                         (type 'regular)))
+                      (composer-package-require composer-package))
+                 (map (lambda (dep)
+                        (upstream-input
+                         (name php-name)
+                         (downstream-name guix-name)
+                         (type 'native)))
+                      (composer-package-dev-require composer-package)))))
+          (upstream-source
+           (package guix-name)
+           (version (composer-package-version composer-package))
+           (urls (list (composer-source-url
+                        (composer-package-source composer-package))))
+           (inputs inputs)))
         (begin
           (warning (G_ "failed to parse ~a~%") php-name)
           #f))))
@@ -262,7 +278,7 @@ (define %composer-updater
    (name 'composer)
    (description "Updater for Composer packages")
    (pred php-package?)
-   (import latest-release)))
+   (import import-release)))
 
 (define* (composer-recursive-import package-name #:optional version)
   (recursive-import package-name
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [bug#70227] [PATCH 2/2] guix: import: composer: Implement recursive package refresh.
  2024-04-06  2:08   ` [bug#70227] [PATCH 2/2] guix: import: composer: Implement recursive package refresh Nicolas Graves via Guix-patches via
@ 2024-04-29 21:29     ` Ludovic Courtès
  2024-07-13 13:41       ` [bug#70227] [PATCH 0/2] Improving composer import jgart via Guix-patches via
  0 siblings, 1 reply; 9+ messages in thread
From: Ludovic Courtès @ 2024-04-29 21:29 UTC (permalink / raw)
  To: Nicolas Graves; +Cc: 70227

Hi!

Nicolas Graves <ngraves@ngraves.fr> skribis:

> * guix/import/composer.scm
>  (composer-fetch): Replace reduce by fold to correct version selection
>  logic.
>  (latest-release): Implement recursive package refresh. Rename to
>  import-release.
>  (import-release): New function, formerly known as latest-release.

Nice, glad to see this feature put to good use.  :-)


[...]

> +(define* (import-release package #:key (version #f))
> +  "Return an <upstream-source> for VERSION or the latest release of PACKAGE."
>    (let* ((php-name (guix-package->composer-name package))
>           (composer-package (composer-fetch php-name #:version version)))
>      (if composer-package
> -        (upstream-source
> -         (package (composer-package-name composer-package))
> -         (version (composer-package-version composer-package))
> -         (urls (list (composer-source-url
> -                      (composer-package-source composer-package)))))
> +        (let* ((guix-name (composer-package-name composer-package))
> +               (inputs
> +                (append
> +                 (map (lambda (dep)
> +                        (upstream-input
> +                         (name php-name)
> +                         (downstream-name guix-name)
> +                         (type 'regular)))
> +                      (composer-package-require composer-package))
> +                 (map (lambda (dep)
> +                        (upstream-input
> +                         (name php-name)
> +                         (downstream-name guix-name)
> +                         (type 'native)))

Shouldn’t it be:

  (upstream-input
    (name dep)
    (downstream-name (php-package-name dep))
    (type …))

?

As a slight improvement, since the ‘inputs’ field of <upstream-source>
is delayed (wrapped in a promise, so that its computation only happens
when it’s needed), you could arrange to replace the ‘inputs’ variable
above like so:

  (define (dependency->input dependency type)
    (upstream-input …))

  (upstream-source
    ;; …
    (inputs (append (map (cut dependency->input <> 'regular) …)
                    (map (cut dependency->input <> 'native) …))))

I hope this makes sense.

Thanks!

Ludo’.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [bug#70227] [PATCH 0/2] Improving composer import.
  2024-04-29 21:29     ` Ludovic Courtès
@ 2024-07-13 13:41       ` jgart via Guix-patches via
  2024-07-18  9:21         ` Ludovic Courtès
  0 siblings, 1 reply; 9+ messages in thread
From: jgart via Guix-patches via @ 2024-07-13 13:41 UTC (permalink / raw)
  To: 70227; +Cc: Ludovic Courtès, Nicolas Graves


Hi Nicolas,

Are you still working on this ticket?

Feel free to send a v2 if you find the time with ludo's suggestions.
-- 
all the best,
jgart




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [bug#70227] [PATCH 0/2] Improving composer import.
  2024-07-13 13:41       ` [bug#70227] [PATCH 0/2] Improving composer import jgart via Guix-patches via
@ 2024-07-18  9:21         ` Ludovic Courtès
  0 siblings, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2024-07-18  9:21 UTC (permalink / raw)
  To: jgart; +Cc: Nicolas Graves, 70227

Hello,

jgart <jgart@dismail.de> skribis:

> Feel free to send a v2 if you find the time with ludo's suggestions.

Oh yes, we were close to the finish line!

(Thanks jgart for following up on these forgotten issues; much
appreciated.)

Ludo’.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [bug#70227] [PATCH v2 1/2] guix: import: composer: Handle parsing failures.
  2024-04-06  2:04 [bug#70227] [PATCH 0/2] Improving composer import Nicolas Graves via Guix-patches via
  2024-04-06  2:08 ` [bug#70227] [PATCH 1/2] guix: import: composer: Handle parsing failures Nicolas Graves via Guix-patches via
@ 2024-10-06 23:55 ` Nicolas Graves via Guix-patches via
  2024-10-06 23:56   ` [bug#70227] [PATCH v2 2/2] guix: import: composer: Implement recursive package refresh Nicolas Graves via Guix-patches via
  2024-10-12 17:46   ` bug#70227: [PATCH v2 1/2] guix: import: composer: Handle parsing failures Ludovic Courtès
  1 sibling, 2 replies; 9+ messages in thread
From: Nicolas Graves via Guix-patches via @ 2024-10-06 23:55 UTC (permalink / raw)
  To: 70227; +Cc: Nicolas Graves

* guix/import/composer (latest-release): Handle parsing
failures. Rename package to composer-package for clarity.

Change-Id: I57f6fba7b05122b031177681e76cf0b5c9547736
---
 guix/import/composer.scm | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/guix/import/composer.scm b/guix/import/composer.scm
index 1ad608964b..75419ca63e 100644
--- a/guix/import/composer.scm
+++ b/guix/import/composer.scm
@@ -243,16 +243,19 @@ (define (php-package? package)
    (eq? (package-build-system package) composer-build-system)
    (string-prefix? "php-" (package-name package))))
 
-(define (latest-release package)
+(define* (latest-release package #:key (version #f))
   "Return an <upstream-source> for the latest release of PACKAGE."
   (let* ((php-name (guix-package->composer-name package))
-         (package (composer-fetch php-name))
-         (version (composer-package-version package))
-         (url (composer-source-url (composer-package-source package))))
-    (upstream-source
-     (package (package-name package))
-     (version version)
-     (urls (list url)))))
+         (composer-package (composer-fetch php-name #:version version)))
+    (if composer-package
+        (upstream-source
+         (package (composer-package-name composer-package))
+         (version (composer-package-version composer-package))
+         (urls (list (composer-source-url
+                      (composer-package-source composer-package)))))
+        (begin
+          (warning (G_ "failed to parse ~a~%") php-name)
+          #f))))
 
 (define %composer-updater
   (upstream-updater
-- 
2.46.0





^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [bug#70227] [PATCH v2 2/2] guix: import: composer: Implement recursive package refresh.
  2024-10-06 23:55 ` [bug#70227] [PATCH v2 1/2] guix: import: composer: Handle parsing failures Nicolas Graves via Guix-patches via
@ 2024-10-06 23:56   ` Nicolas Graves via Guix-patches via
  2024-10-12 17:46   ` bug#70227: [PATCH v2 1/2] guix: import: composer: Handle parsing failures Ludovic Courtès
  1 sibling, 0 replies; 9+ messages in thread
From: Nicolas Graves via Guix-patches via @ 2024-10-06 23:56 UTC (permalink / raw)
  To: 70227; +Cc: Nicolas Graves

* guix/import/composer.scm
(guix-package->composer-name): Simplify.
 (composer-fetch): Replace reduce by fold to correct version selection logic.
 (latest-release): Implement recursive package refresh. Rename to import-release.
 (import-release): New function, formerly known as latest-release.

Change-Id: I8f629b4d1da866f5986d39b4e159f2b44af9ee49
---
 guix/import/composer.scm | 34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/guix/import/composer.scm b/guix/import/composer.scm
index 75419ca63e..abc9023be4 100644
--- a/guix/import/composer.scm
+++ b/guix/import/composer.scm
@@ -19,12 +19,14 @@
 (define-module (guix import composer)
   #:use-module (ice-9 match)
   #:use-module (json)
-  #:use-module (guix hash)
   #:use-module (guix base32)
   #:use-module (guix build git)
   #:use-module (guix build utils)
   #:use-module (guix build-system)
   #:use-module (guix build-system composer)
+  #:use-module ((guix diagnostics) #:select (warning))
+  #:use-module (guix hash)
+  #:use-module (guix i18n)
   #:use-module (guix import json)
   #:use-module (guix import utils)
   #:use-module ((guix licenses) #:prefix license:)
@@ -113,7 +115,7 @@ (define* (composer-fetch name #:key (version #f))
          (if version
              (assoc-ref packages version)
              (cdr
-              (reduce
+              (fold
                (lambda (new cur-max)
                  (match new
                    (((? valid-version? version) . tail)
@@ -217,13 +219,8 @@ (define (guix-name->composer-name name)
 (define (guix-package->composer-name package)
   "Given a Composer PACKAGE built from Packagist, return the name of the
 package in Packagist."
-  (let ((upstream-name (assoc-ref
-                         (package-properties package)
-                         'upstream-name))
-        (name (package-name package)))
-    (if upstream-name
-      upstream-name
-      (guix-name->composer-name name))))
+  (or (assoc-ref (package-properties package) 'upstream-name)
+      (guix-name->composer-name (package-name package))))
 
 (define (string->license str)
   "Convert the string STR into a license object."
@@ -243,8 +240,14 @@ (define (php-package? package)
    (eq? (package-build-system package) composer-build-system)
    (string-prefix? "php-" (package-name package))))
 
-(define* (latest-release package #:key (version #f))
-  "Return an <upstream-source> for the latest release of PACKAGE."
+(define (dependency->input dependency type)
+  (upstream-input
+   (name dependency)
+   (downstream-name (php-package-name dependency))
+   (type type)))
+
+(define* (import-release package #:key (version #f))
+  "Return an <upstream-source> for VERSION or the latest release of PACKAGE."
   (let* ((php-name (guix-package->composer-name package))
          (composer-package (composer-fetch php-name #:version version)))
     (if composer-package
@@ -252,7 +255,12 @@ (define* (latest-release package #:key (version #f))
          (package (composer-package-name composer-package))
          (version (composer-package-version composer-package))
          (urls (list (composer-source-url
-                      (composer-package-source composer-package)))))
+                      (composer-package-source composer-package))))
+         (inputs (append
+                  (map (cut dependency->input <> 'regular)
+                       (composer-package-require composer-package))
+                  (map (cut dependency->input <> 'native)
+                       (composer-package-dev-require composer-package)))))
         (begin
           (warning (G_ "failed to parse ~a~%") php-name)
           #f))))
@@ -262,7 +270,7 @@ (define %composer-updater
    (name 'composer)
    (description "Updater for Composer packages")
    (pred php-package?)
-   (import latest-release)))
+   (import import-release)))
 
 (define* (composer-recursive-import package-name #:optional version)
   (recursive-import package-name
-- 
2.46.0





^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#70227: [PATCH v2 1/2] guix: import: composer: Handle parsing failures.
  2024-10-06 23:55 ` [bug#70227] [PATCH v2 1/2] guix: import: composer: Handle parsing failures Nicolas Graves via Guix-patches via
  2024-10-06 23:56   ` [bug#70227] [PATCH v2 2/2] guix: import: composer: Implement recursive package refresh Nicolas Graves via Guix-patches via
@ 2024-10-12 17:46   ` Ludovic Courtès
  1 sibling, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2024-10-12 17:46 UTC (permalink / raw)
  To: Nicolas Graves; +Cc: 70227-done

Hi,

Nicolas Graves <ngraves@ngraves.fr> skribis:

> * guix/import/composer (latest-release): Handle parsing
> failures. Rename package to composer-package for clarity.
>
> Change-Id: I57f6fba7b05122b031177681e76cf0b5c9547736

[...]

> * guix/import/composer.scm
> (guix-package->composer-name): Simplify.
>  (composer-fetch): Replace reduce by fold to correct version selection logic.
>  (latest-release): Implement recursive package refresh. Rename to import-release.
>  (import-release): New function, formerly known as latest-release.
>
> Change-Id: I8f629b4d1da866f5986d39b4e159f2b44af9ee49

Applied, thanks!

There are no new tests (we could improve on that…) but at least those
already in ‘tests/composer.scm’ still pass.

Ludo’.




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-10-12 18:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-06  2:04 [bug#70227] [PATCH 0/2] Improving composer import Nicolas Graves via Guix-patches via
2024-04-06  2:08 ` [bug#70227] [PATCH 1/2] guix: import: composer: Handle parsing failures Nicolas Graves via Guix-patches via
2024-04-06  2:08   ` [bug#70227] [PATCH 2/2] guix: import: composer: Implement recursive package refresh Nicolas Graves via Guix-patches via
2024-04-29 21:29     ` Ludovic Courtès
2024-07-13 13:41       ` [bug#70227] [PATCH 0/2] Improving composer import jgart via Guix-patches via
2024-07-18  9:21         ` Ludovic Courtès
2024-10-06 23:55 ` [bug#70227] [PATCH v2 1/2] guix: import: composer: Handle parsing failures Nicolas Graves via Guix-patches via
2024-10-06 23:56   ` [bug#70227] [PATCH v2 2/2] guix: import: composer: Implement recursive package refresh Nicolas Graves via Guix-patches via
2024-10-12 17:46   ` bug#70227: [PATCH v2 1/2] guix: import: composer: Handle parsing failures Ludovic Courtès

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.