(define* (package-with-explicit-python python old-prefix new-prefix)
  "Return a procedure of one argument, P.  The procedure creates 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."
  (define (transform p)
    (cond
     ;; Build the new package object graph.
     ((eq? (package-build-system p) python-build-system)
      (package/inherit p
        (location (package-location p))
        (name (let ((name (package-name p)))
                (if (string-prefix? old-prefix name)
                    (string-append new-prefix
                                   (substring name (string-length old-prefix)))
                    name)))
        (arguments
         (let ((python (if (promise? python)
                           (force python)
                           python)))
           (ensure-keyword-arguments (package-arguments p)
                                     `(#:python ,python))))))
     (else p)))

  (define (cut? p)
    (not (eq? (package-build-system p) python-build-system)))

  (package-mapping transform cut?))

(define python38-package
  (package-with-explicit-python python-3.8 "python-" "python38-"))

(map python38-package (list my/numpy my/pandas))

Generated by Ricardo Wurmus using scpaste at Fri Oct 27 23:55:11 2023. CEST. (original)