~ruther/guix-exprs

ref: 2d734ecb10ae0c34d7846ca1bf75c2f3b1bba6c5 guix-exprs/ruther/packages/python-next.scm -rw-r--r-- 5.5 KiB
2d734ecb — Rutherther fix: libstdc++ getentropy fix 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
(define-module (ruther packages python-next)
  #:use-module (gnu)
  #:use-module (guix packages)
  #:use-module ((guix licenses) #:prefix license:)

  #:use-module (guix gexp)
  #:use-module (guix build-system)
  #:use-module (guix download)
  #:use-module (guix utils)
  #:use-module ((guix build-system copy) #:prefix copy:)
  #:use-module ((guix build-system python) #:prefix python:)
  #:use-module ((guix build-system pyproject) #:prefix pyproject:)
  #:use-module (gnu packages sphinx)
  #:use-module (gnu packages python)
  #:use-module (gnu packages check)
  #:use-module (gnu packages python-check)
  #:use-module (gnu packages python-build)
  #:use-module (gnu packages python-xyz))

(define with-python-3.12-raw
  (package-input-rewriting `((,python . ,python-3.12))))

(define-public python-3.12-wrapped
  ((@@ (gnu packages python) wrap-python3) python-3.12))

(define-public python-3.12-toolchain
  ((@@ (gnu packages python) wrap-python3)
   (package/inherit python-3.12
     (name "python-next-toolchain")
     (propagated-inputs
      (modify-inputs (package-propagated-inputs python-3.12)
        (append (with-python-3.12-raw python-setuptools))))
     (arguments
      (substitute-keyword-arguments (package-arguments python-3.12)
        ((#:tests? _ #f) #f)))))) ;; Disabled tests, because this was running forever...

(define with-python-3.12-no-cython
  (package-input-rewriting `((,python . ,python-3.12-toolchain))))

;; Cython is dependency of a lot of packages, let's update it here
(define-public python-3.12-cython
  (with-python-3.12-no-cython
   (package/inherit python-cython
     (name "python-3.12-cython")
     (version "0.29.37")
     (source
      (origin
        (method url-fetch)
        (uri (python:pypi-uri "Cython" version))
        (sha256
         (base32 "1ysca2r23h12ai9wrym4ci0nvgwm3lfijrpj9xfyxbclvnkd84zq"))))
     (arguments
      (substitute-keyword-arguments (package-arguments python-cython)
        ((#:tests? _ #f) #f)))))) ;; Failing... I don't know why...

;; This is changed a bit compared to the original function from Guix.
;; This one also works for pyproject
(define* (package-with-explicit-python python old-prefix new-prefix
                                       #:key variant-property)
  "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.

When VARIANT-PROPERTY is present, it is used as a key to search for
pre-defined variants of this transformation recorded in the 'properties' field
of packages.  The property value must be the promise of a package.  This is a
convenient way for package writers to force the transformation to use
pre-defined variants."
  (define package-variant
    (if variant-property
        (lambda (package)
          (assq-ref (package-properties package)
                    variant-property))
        (const #f)))

  (define (transform p)
    (cond
     ;; If VARIANT-PROPERTY is present, use that.
     ((package-variant p)
      => force)

     ;; Otherwise build the new package object graph.
     ((or (eq? (build-system-name (package-build-system p)) (build-system-name python:python-build-system))
          (eq? (build-system-name (package-build-system p)) (build-system-name pyproject:pyproject-build-system)))
      (package/inherit p
        (location (package-location p))
        (name (let ((name (package-name p)))
                (string-append new-prefix
                               (if (string-prefix? old-prefix name)
                                   (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)
    (or (not (or (eq? (build-system-name (package-build-system p)) (build-system-name python:python-build-system))
                 (eq? (build-system-name (package-build-system p)) (build-system-name pyproject:pyproject-build-system))))
        (package-variant p)))

  (package-mapping transform cut?))

(define with-explicit-python-3.12-single
  (package-with-explicit-python python-3.12-toolchain "python-" "python-3.12-"))

(define python-3.12-cython-inner
  (with-explicit-python-3.12-single python-cython))

(define with-python-3.12-single
  (lambda (pkg)
    (let ((rewritten (with-explicit-python-3.12-single pkg)))
      ((package-input-rewriting `((,python-3.12-cython-inner . ,python-3.12-cython)))
       rewritten))))

;; (define with-python-3.12-single
;;   (lambda (pkg)
;;     (let ((rewritten ((package-input-rewriting `((,python-cython . ,python-3.12-cython)
;;                                                 ;; TODO: put more stuff here, if there is something
;;                                                 ;; that's a common dependenc that will get broken on
;;                                                 ;; Python 3.12
;;                                                 )) pkg)))
;;           ((package-with-explicit-python python-3.12-toolchain "python-" "python-3.12") rewritten))))

(define-public (with-python-3.12 el)
  (if
   (list? el)
   (map with-python-3.12 el)
   (with-python-3.12-single el)))
Do not follow this link