| 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 | (define-module (gnu packages python)
|
| 84 | #:use-module ((guix licenses) #:prefix license:)
|
| 85 | #:use-module (gnu packages)
|
| 86 | #:use-module (gnu packages base)
|
| 87 | #:use-module (gnu packages bash)
|
| 88 | #:use-module (gnu packages check)
|
| 89 | #:use-module (gnu packages compression)
|
| 90 | #:use-module (gnu packages crypto)
|
| 91 | #:use-module (gnu packages dbm)
|
| 92 | #:use-module (gnu packages libffi)
|
| 93 | #:use-module (gnu packages pkg-config)
|
| 94 | #:use-module (gnu packages python-build)
|
| 95 | #:use-module (gnu packages readline)
|
| 96 | #:use-module (gnu packages sqlite)
|
| 97 | #:use-module (gnu packages tcl)
|
| 98 | #:use-module (gnu packages tls)
|
| 99 | #:use-module (gnu packages xml)
|
| 100 | #:use-module (guix gexp)
|
| 101 | #:use-module (guix git-download)
|
| 102 | #:use-module (guix packages)
|
| 103 | #:use-module (guix download)
|
| 104 | #:use-module (guix search-paths)
|
| 105 | #:use-module (guix utils)
|
| 106 | #:use-module (guix build-system copy)
|
| 107 | #:use-module (guix build-system gnu)
|
| 108 | #:use-module (guix build-system trivial)
|
| 109 | #:use-module (ice-9 optargs)
|
| 110 | #:use-module (srfi srfi-1)
|
| 111 | #:use-module (srfi srfi-26)
|
| 112 |
|
| 113 | #:export (customize-site
|
| 114 | guix-pythonpath-search-path))
|
| 115 |
|
| 116 | (define* (customize-site version)
|
| 117 | "Generate a install-sitecustomize.py phase, using VERSION."
|
| 118 | `(lambda* (#:key native-inputs inputs outputs #:allow-other-keys)
|
| 119 | (let* ((out (assoc-ref outputs "out"))
|
| 120 | (site-packages (string-append
|
| 121 | out "/lib/python"
|
| 122 | ,(version-major+minor version)
|
| 123 | "/site-packages"))
|
| 124 | (sitecustomize.py (assoc-ref (or native-inputs inputs)
|
| 125 | "sitecustomize.py"))
|
| 126 | (dest (string-append site-packages "/sitecustomize.py")))
|
| 127 | (mkdir-p site-packages)
|
| 128 | (copy-file sitecustomize.py dest)
|
| 129 | |
| 130 | |
| 131 | (chmod dest #o644))))
|
| 132 |
|
| 133 | (define (guix-pythonpath-search-path version)
|
| 134 | "Generate a GUIX_PYTHONPATH search path specification, using VERSION."
|
| 135 | (search-path-specification (variable "GUIX_PYTHONPATH")
|
| 136 | (files (list (string-append
|
| 137 | "lib/python"
|
| 138 | (version-major+minor version)
|
| 139 | "/site-packages")))))
|
| 140 |
|
| 141 | |
| 142 | |
| 143 | (define (common-python-phases-edits)
|
| 144 | #~((add-before 'configure 'patch-lib-shells
|
| 145 | (lambda _
|
| 146 | |
| 147 | |
| 148 | |
| 149 | #$@(if (%current-target-system)
|
| 150 | #~((setenv "_PYTHON_HOST_PLATFORM" ""))
|
| 151 | #~())
|
| 152 | |
| 153 | |
| 154 | (substitute* (filter file-exists?
|
| 155 | '("Lib/subprocess.py"
|
| 156 | "Lib/popen2.py"
|
| 157 | "Lib/distutils/tests/test_spawn.py"
|
| 158 | "Lib/test/support/__init__.py"
|
| 159 | "Lib/test/test_subprocess.py"))
|
| 160 | (("/bin/sh") (which "sh")))))
|
| 161 | (add-before 'configure 'do-not-record-configure-flags
|
| 162 | (lambda* (#:key configure-flags #:allow-other-keys)
|
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | (substitute* "configure"
|
| 171 | (("^CONFIG_ARGS=.*$")
|
| 172 | (format #f "CONFIG_ARGS='~a'\n"
|
| 173 | (if (member "--with-system-ffi" configure-flags)
|
| 174 | "--with-system-ffi"
|
| 175 | ""))))))
|
| 176 | (add-before 'check 'pre-check
|
| 177 | (lambda _
|
| 178 | |
| 179 | (setenv "HOME" (getcwd))))
|
| 180 | (add-after 'unpack 'set-source-file-times-to-1980
|
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | (lambda _
|
| 186 | (let ((circa-1980 (* 10 366 24 60 60)))
|
| 187 | (ftw "." (lambda (file stat flag)
|
| 188 | (utime file circa-1980 circa-1980)
|
| 189 | #t)))))
|
| 190 | (add-after 'install 'add-libxcrypt-reference-pkgconfig
|
| 191 | (lambda* (#:key inputs outputs #:allow-other-keys)
|
| 192 | (define out (assoc-ref outputs "out"))
|
| 193 | (define libxcrypt
|
| 194 | (false-if-exception
|
| 195 | (dirname (search-input-file inputs "lib/libcrypt.so.1"))))
|
| 196 | (when libxcrypt
|
| 197 | (substitute*
|
| 198 | (find-files (string-append out "/lib/pkgconfig")
|
| 199 | ".*\\.pc")
|
| 200 | (("-lcrypt")
|
| 201 | (string-append "-L" libxcrypt " -lcrypt"))))))
|
| 202 | (add-after 'install 'remove-tests
|
| 203 | |
| 204 | |
| 205 | (lambda* (#:key outputs #:allow-other-keys)
|
| 206 | (let ((out (assoc-ref outputs "out")))
|
| 207 | (match (scandir (string-append out "/lib")
|
| 208 | (lambda (name)
|
| 209 | (string-prefix? "python" name)))
|
| 210 | ((pythonX.Y)
|
| 211 | (let ((testdir (string-append out "/lib/" pythonX.Y
|
| 212 | "/test")))
|
| 213 | (with-directory-excursion testdir
|
| 214 | (for-each delete-file-recursively
|
| 215 | (scandir testdir
|
| 216 | (match-lambda
|
| 217 | ((or "." "..") #f)
|
| 218 | ("support" #f)
|
| 219 | (file
|
| 220 | (not
|
| 221 | (string-prefix? "test_support."
|
| 222 | file))))))
|
| 223 | (call-with-output-file "__init__.py" (const #t))))
|
| 224 | (let ((libdir (string-append out "/lib/" pythonX.Y)))
|
| 225 | (for-each
|
| 226 | (lambda (directory)
|
| 227 | (let ((dir (string-append libdir "/" directory)))
|
| 228 | (when (file-exists? dir)
|
| 229 | (delete-file-recursively dir))))
|
| 230 | '("email/test" "ctypes/test" "unittest/test" "tkinter/test"
|
| 231 | "sqlite3/test" "bsddb/test" "lib-tk/test" "json/tests"
|
| 232 | "distutils/tests"))))))))
|
| 233 | (add-after 'remove-tests 'move-tk-inter
|
| 234 | (lambda* (#:key outputs #:allow-other-keys)
|
| 235 | |
| 236 | |
| 237 | (let ((out (assoc-ref outputs "out"))
|
| 238 | (tk (assoc-ref outputs "tk")))
|
| 239 | (when tk
|
| 240 | (match (find-files out "tkinter.*\\.so")
|
| 241 | ((tkinter.so)
|
| 242 | |
| 243 | |
| 244 | (let* ((len (string-length out))
|
| 245 | (target (string-append
|
| 246 | tk "/"
|
| 247 | (string-drop
|
| 248 | (dirname (dirname tkinter.so))
|
| 249 | len)
|
| 250 | "/site-packages")))
|
| 251 | (install-file tkinter.so target)
|
| 252 | (delete-file tkinter.so))))))))
|
| 253 | (add-after 'move-tk-inter 'move-idle
|
| 254 | (lambda* (#:key outputs #:allow-other-keys)
|
| 255 | |
| 256 | |
| 257 | (let ((out (assoc-ref outputs "out"))
|
| 258 | (idle (assoc-ref outputs "idle")))
|
| 259 | (when idle
|
| 260 | (for-each
|
| 261 | (lambda (file)
|
| 262 | (let ((target (string-append idle "/bin/" (basename file))))
|
| 263 | (install-file file (dirname target))
|
| 264 | (delete-file file)))
|
| 265 | (find-files (string-append out "/bin") "^idle"))
|
| 266 | (match (find-files out "^idlelib$" #:directories? #t)
|
| 267 | ((idlelib)
|
| 268 | (let* ((len (string-length out))
|
| 269 | (target (string-append idle "/"
|
| 270 | (string-drop idlelib len)
|
| 271 | "/site-packages")))
|
| 272 | (mkdir-p (dirname target))
|
| 273 | (rename-file idlelib target))))))))))
|
| 274 |
|
| 275 | |
| 276 | |
| 277 | (define (common-python3-phases-edits)
|
| 278 | #~(#$@(common-python-phases-edits)
|
| 279 | #$@(if (system-hurd?)
|
| 280 | #~((add-after 'unpack 'disable-multi-processing
|
| 281 | (lambda _
|
| 282 | (substitute* "Makefile.pre.in"
|
| 283 | (("-j0") "-j1")))))
|
| 284 | #~())
|
| 285 | (add-after 'unpack 'remove-windows-binaries
|
| 286 | (lambda _
|
| 287 | |
| 288 | (for-each
|
| 289 | (lambda (whl)
|
| 290 | (let ((dir "whl-content")
|
| 291 | (circa-1980 (* 10 366 24 60 60)))
|
| 292 | (mkdir-p dir)
|
| 293 | (with-directory-excursion dir
|
| 294 | (let ((whl (string-append "../" whl)))
|
| 295 | (invoke "unzip" whl)
|
| 296 | (for-each delete-file (find-files "." "\\.exe$"))
|
| 297 | (delete-file whl)
|
| 298 | |
| 299 | |
| 300 | (ftw "." (lambda (file stat flag)
|
| 301 | (utime file circa-1980 circa-1980)))
|
| 302 | (apply invoke "zip" "-X" whl
|
| 303 | (find-files "." #:directories? #t))))
|
| 304 | (delete-file-recursively dir)))
|
| 305 | (find-files "Lib/ensurepip" "\\.whl$"))))
|
| 306 | (add-after 'move-tk-inter 'move-tk-inter:remove-explicit-store-path
|
| 307 | (lambda* (#:key outputs inputs #:allow-other-keys)
|
| 308 | |
| 309 | |
| 310 | (let ((out (assoc-ref outputs "out"))
|
| 311 | (tk (assoc-ref outputs "tk")))
|
| 312 | (when tk
|
| 313 | |
| 314 | (let ((tcl (assoc-ref inputs "tcl"))
|
| 315 | (tk (assoc-ref inputs "tk")))
|
| 316 | (substitute* (find-files (string-append out "/lib")
|
| 317 | "^(_sysconfigdata_.*\\.py|Makefile)$")
|
| 318 | (((string-append "-L" tk "/lib"))
|
| 319 | "")
|
| 320 | (((string-append "-L" tcl "/lib"))
|
| 321 | "")))))))
|
| 322 | (add-before 'check 'set-TZDIR
|
| 323 | (lambda* (#:key inputs native-inputs #:allow-other-keys)
|
| 324 | |
| 325 | (setenv "TZDIR"
|
| 326 | (string-append (assoc-ref (or native-inputs
|
| 327 | inputs) "tzdata")
|
| 328 | "/share/zoneinfo"))))
|
| 329 | (add-after 'move-idle 'rebuild-bytecode
|
| 330 | (lambda* (#:key outputs #:allow-other-keys)
|
| 331 | |
| 332 | |
| 333 | (setenv "PYTHONHASHSEED" "0")
|
| 334 |
|
| 335 | (for-each (lambda (output)
|
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | (for-each (lambda (pyc)
|
| 341 | (delete-file pyc))
|
| 342 | (find-files output "\\.pyc$"))
|
| 343 |
|
| 344 | (apply invoke
|
| 345 | #$(if (%current-target-system)
|
| 346 | "python3"
|
| 347 | #~(string-append #$output "/bin/python3"))
|
| 348 | `("-m" "compileall"
|
| 349 | "-o" "0"
|
| 350 | "-o" "1"
|
| 351 | "-o" "2"
|
| 352 | "-f" |
| 353 | "--invalidation-mode=unchecked-hash"
|
| 354 | |
| 355 | |
| 356 | "-x" "lib2to3/.*"
|
| 357 | ,output)))
|
| 358 | (map cdr outputs))))))
|
| 359 |
|
| 360 | (define-public python-2.7
|
| 361 | (package
|
| 362 | (name "python2")
|
| 363 | (version "2.7.18")
|
| 364 | (source
|
| 365 | (origin
|
| 366 | (method url-fetch)
|
| 367 | (uri (string-append "https://www.python.org/ftp/python/"
|
| 368 | version "/Python-" version ".tar.xz"))
|
| 369 | (sha256
|
| 370 | (base32
|
| 371 | "0hzgxl94hnflis0d6m4szjx0b52gah7wpmcg5g00q7am6xwhwb5n"))
|
| 372 | (patches (search-patches "python-2.7-search-paths.patch"
|
| 373 | "python-2-deterministic-build-info.patch"
|
| 374 | "python-2.7-site-prefixes.patch"
|
| 375 | "python-2.7-source-date-epoch.patch"
|
| 376 | "python-2.7-adjust-tests.patch"
|
| 377 | "python-cross-compile.patch"
|
| 378 | "python-2.7-CVE-2021-3177.patch"
|
| 379 | "python-2.7-expat-compat.patch"
|
| 380 | "python-2.7-no-static-lib.patch"))
|
| 381 | (modules '((guix build utils)))
|
| 382 | (snippet
|
| 383 | '(begin
|
| 384 | |
| 385 | (for-each delete-file-recursively
|
| 386 | '("Modules/_ctypes/libffi" "Modules/expat" "Modules/zlib"))
|
| 387 |
|
| 388 | (substitute* "Modules/Setup.dist"
|
| 389 | |
| 390 | (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n"))
|
| 391 |
|
| 392 | |
| 393 | |
| 394 | |
| 395 | (for-each delete-file
|
| 396 | '("Lib/test/test_compileall.py"
|
| 397 | "Lib/test/test_ctypes.py" |
| 398 | "Lib/test/test_distutils.py"
|
| 399 | "Lib/test/test_import.py"
|
| 400 | "Lib/test/test_shutil.py"
|
| 401 | "Lib/test/test_socket.py"
|
| 402 | "Lib/test/test_subprocess.py"))))))
|
| 403 | (outputs '("out"
|
| 404 | "tk" |
| 405 | "idle")) |
| 406 | (build-system gnu-build-system)
|
| 407 | (arguments
|
| 408 | (list
|
| 409 | #:test-target "test"
|
| 410 | #:configure-flags
|
| 411 | #~(list |
| 412 | |
| 413 | |
| 414 | |
| 415 | |
| 416 | |
| 417 | "CFLAGS=-Wno-error=incompatible-pointer-types -fno-semantic-interposition"
|
| 418 | "--enable-shared" |
| 419 | "--with-system-expat" |
| 420 | "--with-system-ffi" |
| 421 | "--with-ensurepip=install" |
| 422 | "--with-computed-gotos" |
| 423 | "--enable-unicode=ucs4"
|
| 424 |
|
| 425 | |
| 426 | |
| 427 | |
| 428 | |
| 429 |
|
| 430 | |
| 431 | |
| 432 | "INSTALL=install -c"
|
| 433 | "MKDIR_P=mkdir -p"
|
| 434 |
|
| 435 | |
| 436 | |
| 437 | #$@(if (%current-target-system)
|
| 438 | #~("ac_cv_buggy_getaddrinfo=no"
|
| 439 | "ac_cv_file__dev_ptmx=no"
|
| 440 | "ac_cv_file__dev_ptc=no")
|
| 441 | #~())
|
| 442 | (string-append "LDFLAGS=-Wl,-rpath="
|
| 443 | (assoc-ref %outputs "out") "/lib"
|
| 444 | " -fno-semantic-interposition")
|
| 445 | |
| 446 | |
| 447 | |
| 448 | (let ((libxcrypt
|
| 449 | (false-if-exception
|
| 450 | (dirname
|
| 451 | (search-input-file %build-inputs
|
| 452 | "lib/libcrypt.so.1")))))
|
| 453 | (string-append
|
| 454 | "LIBS="
|
| 455 | (if libxcrypt
|
| 456 | (string-append "-L" libxcrypt)
|
| 457 | ""))))
|
| 458 | |
| 459 | #:make-flags
|
| 460 | #~(list (string-append
|
| 461 | (format #f "TESTOPTS=-j~d" (parallel-job-count))
|
| 462 | |
| 463 | |
| 464 | |
| 465 | |
| 466 | |
| 467 | " --exclude test_urllib2_localnet test_httplib"))
|
| 468 |
|
| 469 | #:modules '((ice-9 ftw)
|
| 470 | (ice-9 match)
|
| 471 | (guix build utils)
|
| 472 | (guix build gnu-build-system))
|
| 473 | #:phases
|
| 474 | #~(modify-phases %standard-phases
|
| 475 | #$@(common-python-phases-edits)
|
| 476 | #$@(if (system-hurd?)
|
| 477 | #~((add-before 'build 'patch-regen-for-hurd
|
| 478 | (lambda* (#:key inputs #:allow-other-keys)
|
| 479 | (let ((libc (assoc-ref inputs "libc")))
|
| 480 | (substitute* "Lib/plat-generic/regen"
|
| 481 | (("/usr/include/") (string-append libc "/include/")))))))
|
| 482 | #~())
|
| 483 | (add-after 'move-idle 'rebuild-bytecode
|
| 484 | (lambda* (#:key outputs #:allow-other-keys)
|
| 485 | (let ((out (assoc-ref outputs "out")))
|
| 486 | |
| 487 | |
| 488 | (setenv "PYTHONHASHSEED" "0")
|
| 489 | (for-each
|
| 490 | (lambda (output)
|
| 491 | (for-each (lambda (opt)
|
| 492 | (format #t "Compiling with optimization level: ~a\n"
|
| 493 | (if (null? opt) "none" (car opt)))
|
| 494 | (apply invoke
|
| 495 | `(,#$(if (%current-target-system)
|
| 496 | "python2"
|
| 497 | #~(string-append out "/bin/python"))
|
| 498 | ,@opt
|
| 499 | "-m" "compileall"
|
| 500 | "-f" |
| 501 | |
| 502 | |
| 503 | "-x" "lib2to3/.*"
|
| 504 | ,output)))
|
| 505 | |
| 506 | |
| 507 | |
| 508 | (list '() '("-OO"))))
|
| 509 | (map cdr outputs)))))
|
| 510 | (add-after 'install 'install-sitecustomize.py
|
| 511 | #$(customize-site version)))))
|
| 512 | (inputs
|
| 513 | (list bzip2
|
| 514 | expat
|
| 515 | gdbm
|
| 516 | libffi |
| 517 | libxcrypt |
| 518 | |
| 519 | sqlite |
| 520 | openssl-1.1
|
| 521 | readline
|
| 522 | zlib
|
| 523 | tcl
|
| 524 | tk)) |
| 525 | (native-inputs
|
| 526 | `(("pkg-config" ,pkg-config)
|
| 527 | ("sitecustomize.py" ,(local-file (search-auxiliary-file
|
| 528 | "python/sitecustomize.py")))
|
| 529 | |
| 530 | ,@(if (%current-target-system)
|
| 531 | `(("python2" ,this-package)
|
| 532 | ("which" ,which))
|
| 533 | '())))
|
| 534 | (native-search-paths
|
| 535 | (list (guix-pythonpath-search-path version)))
|
| 536 | (home-page "https://www.python.org")
|
| 537 | (synopsis "High-level, dynamically-typed programming language")
|
| 538 | (description
|
| 539 | "Python is a remarkably powerful dynamic programming language that
|
| 540 | is used in a wide variety of application domains. Some of its key
|
| 541 | distinguishing features include: clear, readable syntax; strong
|
| 542 | introspection capabilities; intuitive object orientation; natural
|
| 543 | expression of procedural code; full modularity, supporting hierarchical
|
| 544 | packages; exception-based error handling; and very high level dynamic
|
| 545 | data types.")
|
| 546 | (properties '((cpe-name . "python")
|
| 547 | (cpe-vendor . "python")
|
| 548 | |
| 549 | |
| 550 | (lint-hidden-cve . ("CVE-2023-36632"))))
|
| 551 | (license license:psfl)))
|
| 552 |
|
| 553 | |
| 554 | (define-public python-2 python-2.7)
|
| 555 |
|
| 556 | (define-public python-3.10
|
| 557 | (package
|
| 558 | (inherit python-2)
|
| 559 | (name "python")
|
| 560 | (version "3.10.22")
|
| 561 | (source (origin
|
| 562 | (method url-fetch)
|
| 563 | (uri (string-append "https://www.python.org/ftp/python/"
|
| 564 | version "/Python-" version ".tar.xz"))
|
| 565 | (patches (search-patches
|
| 566 | "python-3-arm-alignment.patch"
|
| 567 | "python-3-deterministic-build-info.patch"
|
| 568 | "python-3-fix-tests.patch"
|
| 569 | "python-3-hurd-configure.patch"
|
| 570 | "python-3-reproducible-build.patch"
|
| 571 | "python-3-search-paths.patch"))
|
| 572 | (sha256
|
| 573 | (base32
|
| 574 | "0hr5rgybvxdb4390cdlym0jm72ipghc69rl80c5jmv57l6qyj7y6"))
|
| 575 | (modules '((guix build utils)))
|
| 576 | (snippet
|
| 577 | '(begin
|
| 578 | |
| 579 | (delete-file-recursively "Modules/expat")
|
| 580 | (substitute* "Modules/Setup"
|
| 581 | |
| 582 | (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n"))
|
| 583 | |
| 584 | (for-each delete-file
|
| 585 | (find-files "Lib/distutils/command" "\\.exe$"))))))
|
| 586 | (build-system gnu-build-system)
|
| 587 | (arguments
|
| 588 | (list
|
| 589 | #:test-target "test"
|
| 590 | #:configure-flags
|
| 591 | |
| 592 | |
| 593 | (let-keywords (package-arguments python-2) #t
|
| 594 | ((configure-flags #~(list)))
|
| 595 | #~(append #$configure-flags
|
| 596 | |
| 597 | '("--without-static-libpython")))
|
| 598 | #:make-flags
|
| 599 | #~(list (string-append
|
| 600 | (format #f "TESTOPTS=-j~d" (parallel-job-count))
|
| 601 | |
| 602 | " --exclude test_mmap test_socket"
|
| 603 | " test_ssl" |
| 604 | #$@(if (system-hurd?)
|
| 605 | #~(" test_posix" |
| 606 | " test_time"
|
| 607 | " test_pty"
|
| 608 | " test_shutil"
|
| 609 | " test_tempfile" |
| 610 | |
| 611 | " test_asyncio" |
| 612 | " test_os" |
| 613 | |
| 614 | " test_openpty" |
| 615 | " test_selectors" |
| 616 | |
| 617 | " test_compileall" |
| 618 | " test_poll" |
| 619 | " test_subprocess" |
| 620 | " test_asyncore" |
| 621 | " test_threadsignals"
|
| 622 | " test_eintr" |
| 623 | " test_io" |
| 624 | " test_logging"
|
| 625 | " test_signal"
|
| 626 | " test_threading" |
| 627 | " test_flags" |
| 628 | " test_bidirectional_pty"
|
| 629 | " test_create_unix_connection"
|
| 630 | " test_unix_sock_client_ops"
|
| 631 | " test_open_unix_connection"
|
| 632 | " test_open_unix_connection_error"
|
| 633 | " test_read_pty_output"
|
| 634 | " test_write_pty"
|
| 635 | " test_concurrent_futures" |
| 636 | " test_venv" |
| 637 | " test_multiprocessing_forkserver" |
| 638 | " test_multiprocessing_spawn" |
| 639 | " test_builtin"
|
| 640 | " test_capi"
|
| 641 | " test_dbm_ndbm"
|
| 642 | " test_exceptions"
|
| 643 | " test_faulthandler"
|
| 644 | " test_getopt"
|
| 645 | " test_importlib"
|
| 646 | " test_json"
|
| 647 | " test_multiprocessing_fork"
|
| 648 | " test_multiprocessing_main_handling"
|
| 649 | " test_pdb "
|
| 650 | " test_regrtest"
|
| 651 | " test_sqlite")
|
| 652 | #~())))
|
| 653 | #:modules '((ice-9 ftw)
|
| 654 | (ice-9 match)
|
| 655 | (guix build utils)
|
| 656 | (guix build gnu-build-system))
|
| 657 | #:phases
|
| 658 | #~(modify-phases %standard-phases
|
| 659 | #$@(common-python3-phases-edits)
|
| 660 | (replace 'remove-windows-binaries
|
| 661 | (lambda _
|
| 662 | |
| 663 | (for-each
|
| 664 | (lambda (whl)
|
| 665 | (let ((dir "whl-content")
|
| 666 | (circa-1980 (* 10 366 24 60 60)))
|
| 667 | (mkdir-p dir)
|
| 668 | (with-directory-excursion dir
|
| 669 | (let ((whl (string-append "../" whl)))
|
| 670 | (invoke "unzip" whl)
|
| 671 | (for-each delete-file
|
| 672 | (find-files "." "\\.exe$"))
|
| 673 | (delete-file whl)
|
| 674 |
|
| 675 | |
| 676 | |
| 677 | (let ((cacert (find-files "." "cacert\\.pem")))
|
| 678 | (unless (null? cacert)
|
| 679 | (let ((certifi (dirname (car cacert))))
|
| 680 | (delete-file (string-append certifi "/cacert.pem"))
|
| 681 | (delete-file (string-append certifi "/core.py"))
|
| 682 | (with-output-to-file (string-append certifi "/core.py")
|
| 683 | (lambda _
|
| 684 | (display "\"\"\"
|
| 685 | certifi.py
|
| 686 | ~~~~~~~~~~
|
| 687 | This file is a Guix-specific version of core.py.
|
| 688 |
|
| 689 | This module returns the installation location of SSL_CERT_FILE or
|
| 690 | /etc/ssl/certs/ca-certificates.crt, or its contents.
|
| 691 | \"\"\"
|
| 692 | import os
|
| 693 |
|
| 694 | _CA_CERTS = None
|
| 695 |
|
| 696 | try:
|
| 697 | _CA_CERTS = os.environ [\"SSL_CERT_FILE\"]
|
| 698 | except:
|
| 699 | _CA_CERTS = os.path.join(\"/etc\", \"ssl\", \"certs\", \"ca-certificates.crt\")
|
| 700 |
|
| 701 | def where() -> str:
|
| 702 | return _CA_CERTS
|
| 703 |
|
| 704 | def contents() -> str:
|
| 705 | with open(where(), \"r\", encoding=\"ascii\") as data:
|
| 706 | return data.read()"))))))
|
| 707 |
|
| 708 | |
| 709 | |
| 710 | (ftw "." (lambda (file stat flag)
|
| 711 | (utime file circa-1980 circa-1980)
|
| 712 | #t))
|
| 713 | (apply invoke "zip" "-X" whl
|
| 714 | (find-files "." #:directories? #t))))
|
| 715 | (delete-file-recursively dir)))
|
| 716 | (find-files "Lib/ensurepip" "\\.whl$"))))
|
| 717 | (add-after 'install 'install-sitecustomize.py
|
| 718 | #$(customize-site version)))))
|
| 719 | (inputs
|
| 720 | (modify-inputs (package-inputs python-2.7)
|
| 721 | (replace "openssl" openssl)))
|
| 722 | (native-inputs
|
| 723 | (let ((inputs (modify-inputs native-inputs
|
| 724 | (prepend tzdata-for-tests
|
| 725 | unzip
|
| 726 | (@ (gnu packages compression) zip)))))
|
| 727 | (if (%current-target-system)
|
| 728 | (modify-inputs inputs (prepend this-package))
|
| 729 | inputs)))
|
| 730 | (native-search-paths
|
| 731 | (list (guix-pythonpath-search-path version)
|
| 732 | |
| 733 | |
| 734 | (search-path-specification
|
| 735 | (variable "PYTHONTZPATH")
|
| 736 | (files (list "share/zoneinfo")))))))
|
| 737 |
|
| 738 | (define-public python-3.11
|
| 739 | (package
|
| 740 | (inherit python-3.10)
|
| 741 | (name "python")
|
| 742 | (version "3.11.17")
|
| 743 | (source (origin
|
| 744 | (method url-fetch)
|
| 745 | (uri (string-append "https://www.python.org/ftp/python/"
|
| 746 | version "/Python-" version ".tar.xz"))
|
| 747 | (patches (search-patches
|
| 748 | "python-3-deterministic-build-info.patch"
|
| 749 | "python-3.11-fix-tests.patch"
|
| 750 | "python-3-hurd-configure.patch"
|
| 751 | "python-3-search-paths.patch"))
|
| 752 | (sha256
|
| 753 | (base32
|
| 754 | "168ml5nn9dfdn70cylb8qn99j3z012s4l4qga7d7rqpskv9lmdxz"))
|
| 755 | (modules '((guix build utils)))
|
| 756 | (snippet
|
| 757 | '(begin
|
| 758 | |
| 759 | (delete-file-recursively "Modules/expat")
|
| 760 | (substitute* "Modules/Setup"
|
| 761 | |
| 762 | (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n"))
|
| 763 | |
| 764 | (for-each delete-file
|
| 765 | (find-files "Lib/distutils/command" "\\.exe$"))))))
|
| 766 | (arguments
|
| 767 | (list
|
| 768 | #:test-target "test"
|
| 769 | #:configure-flags
|
| 770 | #~(list "--enable-shared" |
| 771 | "--with-system-expat" |
| 772 | "--with-system-ffi" |
| 773 | "--with-ensurepip=install" |
| 774 | "--with-computed-gotos" |
| 775 | "--enable-unicode=ucs4"
|
| 776 | "--without-static-libpython"
|
| 777 | "--enable-loadable-sqlite-extensions"
|
| 778 |
|
| 779 | |
| 780 | |
| 781 | |
| 782 | |
| 783 |
|
| 784 | |
| 785 | |
| 786 | "INSTALL=install -c"
|
| 787 | "MKDIR_P=mkdir -p"
|
| 788 |
|
| 789 | |
| 790 | |
| 791 | |
| 792 | (let ((libxcrypt
|
| 793 | (false-if-exception
|
| 794 | (dirname
|
| 795 | (search-input-file %build-inputs
|
| 796 | "lib/libcrypt.so.1")))))
|
| 797 | (string-append
|
| 798 | "LIBS="
|
| 799 | (if libxcrypt
|
| 800 | (string-append "-L" libxcrypt)
|
| 801 | "")))
|
| 802 |
|
| 803 | |
| 804 | |
| 805 | #$@(if (%current-target-system)
|
| 806 | #~("ac_cv_buggy_getaddrinfo=no"
|
| 807 | "ac_cv_file__dev_ptmx=no"
|
| 808 | "ac_cv_file__dev_ptc=no"
|
| 809 | (string-append "--with-build-python="
|
| 810 | #+(this-package-native-input "python")
|
| 811 | "/bin/python3"))
|
| 812 | '())
|
| 813 | |
| 814 | |
| 815 | |
| 816 | "CFLAGS=-fno-semantic-interposition"
|
| 817 | (string-append "LDFLAGS=-Wl,-rpath=" #$output "/lib"
|
| 818 | " -fno-semantic-interposition"))
|
| 819 | |
| 820 | #:make-flags
|
| 821 | `(list (string-append (format #f "TESTOPTS=-j~d"
|
| 822 | (parallel-job-count))
|
| 823 | |
| 824 | " --exclude"
|
| 825 | " test_mmap"
|
| 826 | " test_socket"
|
| 827 | " test_threading"
|
| 828 | " test_asyncio"
|
| 829 | " test_shutdown"
|
| 830 | " test_ssl" |
| 831 | ,@(if (target-ppc32?)
|
| 832 | '(" test_ssl")
|
| 833 | '())
|
| 834 | ,@(if (system-hurd?)
|
| 835 | '(" test_posix" |
| 836 | " test_time"
|
| 837 | " test_pty"
|
| 838 | " test_shutil"
|
| 839 | " test_tempfile" |
| 840 | |
| 841 | " test_os" |
| 842 | |
| 843 | " test_openpty" |
| 844 | " test_selectors" |
| 845 | |
| 846 | " test_compileall" |
| 847 | " test_poll" |
| 848 | " test_subprocess" |
| 849 | " test_asyncore" |
| 850 | " test_threadsignals"
|
| 851 | " test_eintr" |
| 852 | " test_io" |
| 853 | " test_logging"
|
| 854 | " test_signal"
|
| 855 | " test_flags" |
| 856 | " test_bidirectional_pty"
|
| 857 | " test_create_unix_connection"
|
| 858 | " test_unix_sock_client_ops"
|
| 859 | " test_open_unix_connection"
|
| 860 | " test_open_unix_connection_error"
|
| 861 | " test_read_pty_output"
|
| 862 | " test_write_pty"
|
| 863 | " test_concurrent_futures" |
| 864 | " test_venv" |
| 865 | " test_multiprocessing_forkserver" |
| 866 | " test_multiprocessing_spawn" |
| 867 | " test_glob" |
| 868 | " test_site" |
| 869 | " test_termios" |
| 870 | " test_tty" |
| 871 | " test_sqlite3" |
| 872 | " test_tarfile" |
| 873 | " test_builtin"
|
| 874 | " test_capi"
|
| 875 | " test_dbm_ndbm"
|
| 876 | " test_exceptions"
|
| 877 | " test_faulthandler"
|
| 878 | " test_getopt"
|
| 879 | " test_importlib"
|
| 880 | " test_json"
|
| 881 | " test_multiprocessing_fork"
|
| 882 | " test_multiprocessing_main_handling"
|
| 883 | " test_pdb "
|
| 884 | " test_regrtest"
|
| 885 | " test_ssl" |
| 886 | " test_sqlite")
|
| 887 | '())
|
| 888 | ,@(if (system-hurd64?)
|
| 889 | '(" test_largefile") |
| 890 | '())))
|
| 891 |
|
| 892 | #:modules
|
| 893 | '((ice-9 ftw)
|
| 894 | (ice-9 match)
|
| 895 | (guix build utils)
|
| 896 | (guix build gnu-build-system))
|
| 897 |
|
| 898 | #:phases
|
| 899 | #~(modify-phases %standard-phases
|
| 900 | #$@(common-python3-phases-edits)
|
| 901 | (add-after 'install 'install-sitecustomize.py
|
| 902 | #$(customize-site version)))))
|
| 903 | (inputs (list bzip2
|
| 904 | expat
|
| 905 | gdbm
|
| 906 | libffi |
| 907 | libxcrypt |
| 908 | sqlite |
| 909 | openssl
|
| 910 | readline
|
| 911 | zlib
|
| 912 | tcl
|
| 913 | tk)) |
| 914 | (native-inputs `(("tzdata" ,tzdata-for-tests)
|
| 915 | ("unzip" ,unzip)
|
| 916 | ("zip" ,(@ (gnu packages compression) zip))
|
| 917 | ("pkg-config" ,pkg-config)
|
| 918 | ("sitecustomize.py" ,(local-file (search-auxiliary-file
|
| 919 | "python/sitecustomize.py")))
|
| 920 | |
| 921 | ,@(if (%current-target-system)
|
| 922 | `(("python" ,this-package)
|
| 923 | ("which" ,which))
|
| 924 | '())))
|
| 925 | (native-search-paths
|
| 926 | (list (guix-pythonpath-search-path version)
|
| 927 | |
| 928 | |
| 929 | (search-path-specification
|
| 930 | (variable "PYTHONTZPATH")
|
| 931 | (files (list "share/zoneinfo")))))))
|
| 932 |
|
| 933 | (define-public python-3.12
|
| 934 | (package
|
| 935 | (name "python")
|
| 936 | (version "3.12.15")
|
| 937 | (source
|
| 938 | (origin
|
| 939 | (method url-fetch)
|
| 940 | (uri (string-append "https://www.python.org/ftp/python/" version
|
| 941 | "/Python-" version ".tar.xz"))
|
| 942 | (sha256
|
| 943 | (base32 "0npxjh86qc4ym4z8g4kr9jcv6ahwab7wxq36knczpc7sc4ck5i62"))
|
| 944 | (patches (search-patches "python-3-deterministic-build-info.patch"
|
| 945 | "python-3.12-fix-tests.patch"
|
| 946 | "python-3-hurd-configure.patch"))
|
| 947 | (modules '((guix build utils)))
|
| 948 | (snippet '(begin
|
| 949 | |
| 950 | (delete-file-recursively "Modules/expat")
|
| 951 | (substitute* "Modules/Setup"
|
| 952 | |
| 953 | (("^#pyexpat.*")
|
| 954 | "pyexpat pyexpat.c -lexpat\n"))
|
| 955 | |
| 956 | (for-each delete-file
|
| 957 | (find-files "Lib/distutils/command" "\\.exe$"))))))
|
| 958 | (outputs '("out" "tk" |
| 959 | "idle")) |
| 960 | (build-system gnu-build-system)
|
| 961 | (arguments
|
| 962 | (list
|
| 963 | #:test-target "test"
|
| 964 | #:configure-flags
|
| 965 | #~(list "--enable-shared" |
| 966 | "--with-system-expat" |
| 967 | "--with-system-ffi" |
| 968 | "--with-ensurepip=install" |
| 969 | "--with-computed-gotos" |
| 970 | "--enable-unicode=ucs4"
|
| 971 | "--without-static-libpython"
|
| 972 | "--enable-loadable-sqlite-extensions"
|
| 973 |
|
| 974 | |
| 975 | |
| 976 | |
| 977 | |
| 978 |
|
| 979 | |
| 980 | |
| 981 | "INSTALL=install -c"
|
| 982 | "MKDIR_P=mkdir -p"
|
| 983 |
|
| 984 | |
| 985 | |
| 986 | #$@(if (%current-target-system)
|
| 987 | #~("ac_cv_buggy_getaddrinfo=no"
|
| 988 | "ac_cv_file__dev_ptmx=no"
|
| 989 | "ac_cv_file__dev_ptc=no"
|
| 990 | (string-append "--with-build-python="
|
| 991 | #+(this-package-native-input "python")
|
| 992 | "/bin/python3"))
|
| 993 | #~())
|
| 994 | |
| 995 | |
| 996 | |
| 997 | "CFLAGS=-fno-semantic-interposition"
|
| 998 | (string-append "LDFLAGS=-Wl,-rpath="
|
| 999 | (assoc-ref %outputs "out")
|
| 1000 | "/lib"
|
| 1001 | " -fno-semantic-interposition"))
|
| 1002 | |
| 1003 | #:make-flags
|
| 1004 | #~(list (string-append (format #f "TESTOPTS=-j~d"
|
| 1005 | (parallel-job-count))
|
| 1006 | |
| 1007 | " --exclude"
|
| 1008 | " test_mmap"
|
| 1009 | " test_socket"
|
| 1010 | " test_threading"
|
| 1011 | " test_asyncio"
|
| 1012 | " test_shutdown"
|
| 1013 | #$@(if (target-ppc32?)
|
| 1014 | #~(" test_ssl")
|
| 1015 | #~())
|
| 1016 | #$@(if (system-hurd?)
|
| 1017 | #~(" test_posix" |
| 1018 | " test_time"
|
| 1019 | " test_pty"
|
| 1020 | " test_shutil"
|
| 1021 | " test_tempfile" |
| 1022 | |
| 1023 | " test_os" |
| 1024 | |
| 1025 | " test_openpty" |
| 1026 | " test_selectors" |
| 1027 | |
| 1028 | " test_compileall" |
| 1029 | " test_poll" |
| 1030 | " test_subprocess" |
| 1031 | " test_asyncore" |
| 1032 | " test_threadsignals"
|
| 1033 | " test_eintr" |
| 1034 | " test_io" |
| 1035 | " test_logging"
|
| 1036 | " test_signal"
|
| 1037 | " test_flags" |
| 1038 | " test_bidirectional_pty"
|
| 1039 | " test_create_unix_connection"
|
| 1040 | " test_unix_sock_client_ops"
|
| 1041 | " test_open_unix_connection"
|
| 1042 | " test_open_unix_connection_error"
|
| 1043 | " test_read_pty_output"
|
| 1044 | " test_write_pty"
|
| 1045 | " test_concurrent_futures" |
| 1046 | " test_venv" |
| 1047 | " test_multiprocessing_forkserver" |
| 1048 | " test_multiprocessing_spawn" |
| 1049 | " test_glob" |
| 1050 | " test_site" |
| 1051 | " test_termios" |
| 1052 | " test_tty" |
| 1053 | " test_sqlite3" |
| 1054 | " test_tarfile" |
| 1055 | " test_builtin"
|
| 1056 | " test_capi"
|
| 1057 | " test_dbm_ndbm"
|
| 1058 | " test_exceptions"
|
| 1059 | " test_faulthandler"
|
| 1060 | " test_getopt"
|
| 1061 | " test_importlib"
|
| 1062 | " test_json"
|
| 1063 | " test_multiprocessing_fork"
|
| 1064 | " test_multiprocessing_main_handling"
|
| 1065 | " test_pdb "
|
| 1066 | " test_regrtest"
|
| 1067 | " test_ssl" |
| 1068 | " test_sqlite")
|
| 1069 | #~())
|
| 1070 | #$@(if (system-hurd64?)
|
| 1071 | #~(" test_largefile") |
| 1072 | #~())))
|
| 1073 |
|
| 1074 | #:modules '((ice-9 ftw)
|
| 1075 | (ice-9 match)
|
| 1076 | (guix build utils)
|
| 1077 | (guix build gnu-build-system))
|
| 1078 |
|
| 1079 | #:phases
|
| 1080 | #~(modify-phases %standard-phases
|
| 1081 | #$@(common-python3-phases-edits)
|
| 1082 | (add-after 'install 'install-sitecustomize.py
|
| 1083 | #$(customize-site version)))))
|
| 1084 | (inputs (list bzip2
|
| 1085 | expat
|
| 1086 | gdbm
|
| 1087 | libffi |
| 1088 | sqlite |
| 1089 | openssl
|
| 1090 | readline
|
| 1091 | zlib
|
| 1092 | tcl
|
| 1093 | tk)) |
| 1094 | (native-inputs `(("tzdata" ,tzdata-for-tests)
|
| 1095 | ("unzip" ,unzip)
|
| 1096 | ("zip" ,(@ (gnu packages compression) zip))
|
| 1097 | ("pkg-config" ,pkg-config)
|
| 1098 | ("sitecustomize.py" ,(local-file (search-auxiliary-file
|
| 1099 | "python/sitecustomize.py")))
|
| 1100 | |
| 1101 | ,@(if (%current-target-system)
|
| 1102 | `(("python" ,this-package)
|
| 1103 | ("which" ,which))
|
| 1104 | '())))
|
| 1105 | (native-search-paths
|
| 1106 | (list (guix-pythonpath-search-path version)
|
| 1107 | |
| 1108 | |
| 1109 | (search-path-specification
|
| 1110 | (variable "PYTHONTZPATH")
|
| 1111 | (files (list "share/zoneinfo")))))
|
| 1112 | (home-page "https://www.python.org")
|
| 1113 | (synopsis "High-level, dynamically-typed programming language")
|
| 1114 | (description
|
| 1115 | "Python is a remarkably powerful dynamic programming language that
|
| 1116 | is used in a wide variety of application domains. Some of its key
|
| 1117 | distinguishing features include: clear, readable syntax; strong
|
| 1118 | introspection capabilities; intuitive object orientation; natural
|
| 1119 | expression of procedural code; full modularity, supporting hierarchical
|
| 1120 | packages; exception-based error handling; and very high level dynamic
|
| 1121 | data types.")
|
| 1122 | (properties '((cpe-name . "python")
|
| 1123 | (cpe-vendor . "python")))
|
| 1124 | (license license:psfl)))
|
| 1125 |
|
| 1126 | (define-public python-3.13
|
| 1127 | (package
|
| 1128 | (name "python-next")
|
| 1129 | (version "3.13.16")
|
| 1130 | (source
|
| 1131 | (origin
|
| 1132 | (method url-fetch)
|
| 1133 | (uri (string-append "https://www.python.org/ftp/python/" version
|
| 1134 | "/Python-" version ".tar.xz"))
|
| 1135 | (sha256
|
| 1136 | (base32 "0pdkdb5vc9jziy6q4yfnnkdc1d33858152i2ildv2nwvqyrvzcgl"))
|
| 1137 | (patches (search-patches "python-3-deterministic-build-info.patch"
|
| 1138 | "python-3.13-fix-tests.patch"
|
| 1139 | "python-3-hurd-configure.patch"))
|
| 1140 | (modules '((guix build utils)))
|
| 1141 | (snippet '(begin
|
| 1142 | |
| 1143 | (delete-file-recursively "Modules/expat")
|
| 1144 | (substitute* "Modules/Setup"
|
| 1145 | |
| 1146 | (("^#pyexpat.*")
|
| 1147 | "pyexpat pyexpat.c -lexpat\n"))
|
| 1148 | |
| 1149 | (for-each delete-file
|
| 1150 | (find-files "Lib/distutils/command" "\\.exe$"))))))
|
| 1151 | (outputs '("out" "tk" |
| 1152 | "idle")) |
| 1153 | (build-system gnu-build-system)
|
| 1154 | (arguments
|
| 1155 | (list
|
| 1156 | #:test-target "test"
|
| 1157 | #:configure-flags
|
| 1158 | #~(list "--enable-shared" |
| 1159 | "--with-system-expat" |
| 1160 | "--with-system-ffi" |
| 1161 | "--with-ensurepip=install" |
| 1162 | "--with-computed-gotos" |
| 1163 | "--enable-unicode=ucs4"
|
| 1164 | "--without-static-libpython"
|
| 1165 | "--enable-loadable-sqlite-extensions"
|
| 1166 |
|
| 1167 | |
| 1168 | |
| 1169 | |
| 1170 | |
| 1171 |
|
| 1172 | |
| 1173 | |
| 1174 | "INSTALL=install -c"
|
| 1175 | "MKDIR_P=mkdir -p"
|
| 1176 |
|
| 1177 | |
| 1178 | |
| 1179 | #$@(if (%current-target-system)
|
| 1180 | #~("ac_cv_buggy_getaddrinfo=no"
|
| 1181 | "ac_cv_file__dev_ptmx=no"
|
| 1182 | "ac_cv_file__dev_ptc=no"
|
| 1183 | (string-append "--with-build-python="
|
| 1184 | #+(this-package-native-input "python")
|
| 1185 | "/bin/python3"))
|
| 1186 | #~())
|
| 1187 | |
| 1188 | |
| 1189 | |
| 1190 | "CFLAGS=-fno-semantic-interposition"
|
| 1191 | (string-append "LDFLAGS=-Wl,-rpath="
|
| 1192 | (assoc-ref %outputs "out")
|
| 1193 | "/lib"
|
| 1194 | " -fno-semantic-interposition"))
|
| 1195 | |
| 1196 | #:make-flags
|
| 1197 | #~(list (string-append (format #f "TESTOPTS=-j~d"
|
| 1198 | (parallel-job-count))
|
| 1199 | |
| 1200 | " --exclude"
|
| 1201 | " test_mmap"
|
| 1202 | " test_socket"
|
| 1203 | " test_threading"
|
| 1204 | " test_asyncio"
|
| 1205 | " test_shutdown"
|
| 1206 | " test_pdb" |
| 1207 | #$@(if (target-ppc32?)
|
| 1208 | #~(" test_ssl")
|
| 1209 | #~())
|
| 1210 | #$@(if (system-hurd?)
|
| 1211 | #~(" test_posix" |
| 1212 | " test_time"
|
| 1213 | " test_pty"
|
| 1214 | " test_shutil"
|
| 1215 | " test_tempfile" |
| 1216 | |
| 1217 | " test_os" |
| 1218 | |
| 1219 | " test_openpty" |
| 1220 | " test_selectors" |
| 1221 | |
| 1222 | " test_compileall" |
| 1223 | " test_poll" |
| 1224 | " test_subprocess" |
| 1225 | " test_asyncore" |
| 1226 | " test_threadsignals"
|
| 1227 | " test_eintr" |
| 1228 | " test_io" |
| 1229 | " test_logging"
|
| 1230 | " test_signal"
|
| 1231 | " test_flags" |
| 1232 | " test_bidirectional_pty"
|
| 1233 | " test_create_unix_connection"
|
| 1234 | " test_unix_sock_client_ops"
|
| 1235 | " test_open_unix_connection"
|
| 1236 | " test_open_unix_connection_error"
|
| 1237 | " test_read_pty_output"
|
| 1238 | " test_write_pty"
|
| 1239 | " test_concurrent_futures" |
| 1240 | " test_venv" |
| 1241 | " test_multiprocessing_forkserver" |
| 1242 | " test_multiprocessing_spawn" |
| 1243 | " test_glob" |
| 1244 | " test_site" |
| 1245 | " test_termios" |
| 1246 | " test_tty" |
| 1247 | " test_sqlite3" |
| 1248 | " test_tarfile" |
| 1249 | " test_builtin"
|
| 1250 | " test_capi"
|
| 1251 | " test_dbm_ndbm"
|
| 1252 | " test_exceptions"
|
| 1253 | " test_faulthandler"
|
| 1254 | " test_getopt"
|
| 1255 | " test_importlib"
|
| 1256 | " test_json"
|
| 1257 | " test_multiprocessing_fork"
|
| 1258 | " test_multiprocessing_main_handling"
|
| 1259 | " test_regrtest"
|
| 1260 | " test_ssl" |
| 1261 | " test_sqlite")
|
| 1262 | #~())
|
| 1263 | #$@(if (system-hurd64?)
|
| 1264 | #~(" test_largefile") |
| 1265 | #~())))
|
| 1266 |
|
| 1267 | #:modules '((ice-9 ftw)
|
| 1268 | (ice-9 match)
|
| 1269 | (guix build utils)
|
| 1270 | (guix build gnu-build-system))
|
| 1271 |
|
| 1272 | #:phases
|
| 1273 | #~(modify-phases %standard-phases
|
| 1274 | #$@(common-python3-phases-edits)
|
| 1275 | (add-after 'install 'install-sitecustomize.py
|
| 1276 | #$(customize-site version)))))
|
| 1277 | (inputs (list bzip2
|
| 1278 | expat
|
| 1279 | gdbm
|
| 1280 | libffi |
| 1281 | sqlite |
| 1282 | openssl
|
| 1283 | readline
|
| 1284 | zlib
|
| 1285 | tcl
|
| 1286 | tk)) |
| 1287 | (native-inputs `(("tzdata" ,tzdata-for-tests)
|
| 1288 | ("unzip" ,unzip)
|
| 1289 | ("zip" ,(@ (gnu packages compression) zip))
|
| 1290 | ("pkg-config" ,pkg-config)
|
| 1291 | ("sitecustomize.py" ,(local-file (search-auxiliary-file
|
| 1292 | "python/sitecustomize.py")))
|
| 1293 | |
| 1294 | ,@(if (%current-target-system)
|
| 1295 | `(("python" ,this-package)
|
| 1296 | ("which" ,which))
|
| 1297 | '())))
|
| 1298 | (native-search-paths
|
| 1299 | (list (guix-pythonpath-search-path version)
|
| 1300 | |
| 1301 | |
| 1302 | (search-path-specification
|
| 1303 | (variable "PYTHONTZPATH")
|
| 1304 | (files (list "share/zoneinfo")))))
|
| 1305 | (home-page "https://www.python.org")
|
| 1306 | (synopsis "High-level, dynamically-typed programming language")
|
| 1307 | (description
|
| 1308 | "Python is a remarkably powerful dynamic programming language that
|
| 1309 | is used in a wide variety of application domains. Some of its key
|
| 1310 | distinguishing features include: clear, readable syntax; strong
|
| 1311 | introspection capabilities; intuitive object orientation; natural
|
| 1312 | expression of procedural code; full modularity, supporting hierarchical
|
| 1313 | packages; exception-based error handling; and very high level dynamic
|
| 1314 | data types.")
|
| 1315 | (properties '((cpe-name . "python")
|
| 1316 | (cpe-vendor . "python")))
|
| 1317 | (license license:psfl)))
|
| 1318 |
|
| 1319 | |
| 1320 | |
| 1321 | |
| 1322 | (define-public python-next python-3.13)
|
| 1323 |
|
| 1324 | |
| 1325 | (define-public python-3 python-3.12)
|
| 1326 |
|
| 1327 | |
| 1328 | (define-public python python-3)
|
| 1329 |
|
| 1330 | |
| 1331 | |
| 1332 |
|
| 1333 | |
| 1334 | |
| 1335 | |
| 1336 |
|
| 1337 | (define-public python-minimal
|
| 1338 | (package/inherit python
|
| 1339 | (name "python-minimal")
|
| 1340 | (outputs '("out"))
|
| 1341 |
|
| 1342 | |
| 1343 | |
| 1344 | |
| 1345 | |
| 1346 | (inputs (list expat libffi openssl zlib))))
|
| 1347 |
|
| 1348 | (define-public python-next-minimal
|
| 1349 | (package/inherit python-next
|
| 1350 | (name "python-next-minimal")
|
| 1351 | (outputs '("out"))
|
| 1352 | (inputs (list expat libffi openssl zlib))))
|
| 1353 |
|
| 1354 | (define-public python-debug
|
| 1355 | (package/inherit python
|
| 1356 | (name "python-debug")
|
| 1357 | (outputs '("out" "debug"))
|
| 1358 | (build-system gnu-build-system)
|
| 1359 | (arguments
|
| 1360 | (substitute-keyword-arguments arguments
|
| 1361 | ((#:configure-flags configure-flags)
|
| 1362 | #~(append #$configure-flags
|
| 1363 | (list "--with-pydebug")))))
|
| 1364 | (synopsis "Python with the debug hooks enabled")
|
| 1365 | (description
|
| 1366 | "This variant of Python provides an interpreter built with
|
| 1367 | @code{--with-pydebug} to help develop and debug extensions. See
|
| 1368 | @url{https://pythonextensionpatterns.readthedocs.io/en/latest/debugging/debug.html},
|
| 1369 | for more information.")))
|
| 1370 |
|
| 1371 | (define* (wrap-python3 python
|
| 1372 | #:optional
|
| 1373 | (name (string-append (package-name python) "-wrapper")))
|
| 1374 | (package/inherit python
|
| 1375 | (name name)
|
| 1376 | (source #f)
|
| 1377 | (build-system trivial-build-system)
|
| 1378 | (outputs '("out"))
|
| 1379 | (inputs `(("bash" ,bash)))
|
| 1380 | (propagated-inputs `(("python" ,python)))
|
| 1381 | (arguments
|
| 1382 | (list #:modules '((guix build utils))
|
| 1383 | #:builder
|
| 1384 | #~(begin
|
| 1385 | (use-modules (guix build utils))
|
| 1386 | (let ((bin (string-append #$output "/bin"))
|
| 1387 | (python (string-append
|
| 1388 | |
| 1389 | |
| 1390 | #$(if (%current-target-system)
|
| 1391 | (this-package-input "python")
|
| 1392 | #~(assoc-ref %build-inputs "python"))
|
| 1393 | "/bin/")))
|
| 1394 | (mkdir-p bin)
|
| 1395 | (for-each
|
| 1396 | (lambda (old new)
|
| 1397 | (symlink (string-append python old)
|
| 1398 | (string-append bin "/" new)))
|
| 1399 | `("python3" ,"pydoc3" ,"pip3")
|
| 1400 | `("python" ,"pydoc" ,"pip"))
|
| 1401 | |
| 1402 | |
| 1403 | (let ((bash (string-append (assoc-ref %build-inputs "bash")
|
| 1404 | "/bin/bash"))
|
| 1405 | (old (string-append python "python3-config"))
|
| 1406 | (new (string-append bin "/python-config")))
|
| 1407 | (with-output-to-file new
|
| 1408 | (lambda ()
|
| 1409 | (format #t "#!~a~%" bash)
|
| 1410 | (format #t "exec \"~a\" \"$@\"~%" old)
|
| 1411 | (chmod new #o755))))))))
|
| 1412 | (synopsis "Wrapper for the Python 3 commands")
|
| 1413 | (description
|
| 1414 | "This package provides wrappers for the commands of Python@tie{}3.x such
|
| 1415 | that they can also be invoked under their usual names---e.g., @command{python}
|
| 1416 | instead of @command{python3} or @command{pip} instead of @command{pip3}.
|
| 1417 |
|
| 1418 | To function properly, this package should not be installed together with the
|
| 1419 | @code{python} package: this package uses the @code{python} package as a
|
| 1420 | propagated input, so installing this package already makes both the versioned
|
| 1421 | and the unversioned commands available.")))
|
| 1422 |
|
| 1423 | (define-public python-wrapper (wrap-python3 python))
|
| 1424 | (define-public python-minimal-wrapper (wrap-python3 python-minimal))
|
| 1425 |
|
| 1426 | (define-public python-next-wrapper (wrap-python3 python-next))
|
| 1427 | (define-public python-next-minimal-wrapper (wrap-python3 python-next-minimal))
|
| 1428 |
|
| 1429 | |
| 1430 | (define-public (remove-pip python)
|
| 1431 | (hidden-package
|
| 1432 | (package/inherit python
|
| 1433 | (arguments
|
| 1434 | (substitute-keyword-arguments arguments
|
| 1435 | ((#:configure-flags flags #~())
|
| 1436 | #~(append '("--with-ensurepip=no")
|
| 1437 | (delete "--with-ensurepip=install" #$flags))))))))
|
| 1438 |
|
| 1439 | (define-public python-sans-pip
|
| 1440 | (remove-pip python))
|
| 1441 |
|
| 1442 | (define-public python-sans-pip-wrapper
|
| 1443 | (wrap-python3 python-sans-pip))
|
| 1444 |
|
| 1445 | (define-public python-next-sans-pip
|
| 1446 | (remove-pip python-next))
|
| 1447 |
|
| 1448 | (define-public python-next-sans-pip-wrapper
|
| 1449 | (wrap-python3 python-next-sans-pip))
|
| 1450 |
|
| 1451 | (define-public python-next-setuptools-bootstrap
|
| 1452 | ((package-input-rewriting/spec
|
| 1453 | `(("python" . ,(const python-next-sans-pip))))
|
| 1454 | python-setuptools-bootstrap))
|
| 1455 |
|
| 1456 | (define-public with-python-next
|
| 1457 | (package-input-rewriting
|
| 1458 | `((,python . ,python-next)
|
| 1459 | (,python-minimal . ,python-next-minimal)
|
| 1460 | (,python-wrapper . ,python-next-wrapper)
|
| 1461 | (,python-minimal-wrapper . ,python-next-minimal-wrapper)
|
| 1462 | (,python-sans-pip . ,python-next-sans-pip)
|
| 1463 | (,python-sans-pip-wrapper . ,python-next-sans-pip-wrapper)
|
| 1464 | (,python-setuptools-bootstrap . ,python-next-setuptools-bootstrap)
|
| 1465 | (,python-pytest-guix . ,python-next-pytest-guix))))
|
| 1466 |
|
| 1467 | (define-public pythoncapi-compat
|
| 1468 | |
| 1469 | (let ((commit "b8fe76f597af6593dfcb43a6dd388bab98938b91")
|
| 1470 | (revision "2"))
|
| 1471 | (package
|
| 1472 | (name "pythoncapi-compat")
|
| 1473 | (version (git-version "0.0.0" revision commit))
|
| 1474 | (source (origin
|
| 1475 | (method git-fetch)
|
| 1476 | (uri (git-reference
|
| 1477 | (url "https://github.com/python/pythoncapi-compat")
|
| 1478 | (commit commit)))
|
| 1479 | (file-name (git-file-name name version))
|
| 1480 | (sha256
|
| 1481 | (base32
|
| 1482 | "1br8adfqr8m3lsjrmzxkhx2q4rxzlmvyww6cxn8m7q5gh1w61432"))))
|
| 1483 | (build-system copy-build-system)
|
| 1484 | (arguments (list #:install-plan
|
| 1485 | #~'(("pythoncapi_compat.h" "include/"))))
|
| 1486 | (home-page "https://github.com/python/pythoncapi-compat")
|
| 1487 | (synopsis "Python C API compatibility")
|
| 1488 | (description "The pythoncapi-compat project can be used to write a C or
|
| 1489 | C++ extension supporting a wide range of Python versions with a single code
|
| 1490 | base, via the @file{pythoncapi_compat.h} header file.")
|
| 1491 | (license license:bsd-0))))
|
| 1492 |
|
| 1493 | (define-public micropython
|
| 1494 | (package
|
| 1495 | (name "micropython")
|
| 1496 | (version "1.29.0")
|
| 1497 | (source
|
| 1498 | (origin
|
| 1499 | (method url-fetch)
|
| 1500 | (uri (string-append "https://github.com/micropython/micropython/"
|
| 1501 | "releases/download/v" version
|
| 1502 | "/micropython-" version ".tar.xz"))
|
| 1503 | (sha256
|
| 1504 | (base32 "187cxw8mfv1vazpd82ssqcf08dr2bsx8bcpw7pgjp6p7ck3af9fr"))
|
| 1505 | (modules '((guix build utils)))
|
| 1506 | (snippet
|
| 1507 | '(begin
|
| 1508 | (delete-file-recursively "ports/cc3200/FreeRTOS")
|
| 1509 | (with-directory-excursion "lib"
|
| 1510 | |
| 1511 | (for-each delete-file-recursively
|
| 1512 | '("libffi" "lwip" "stm32lib" "nrfx")))))))
|
| 1513 | (build-system gnu-build-system)
|
| 1514 | (arguments
|
| 1515 | (list #:phases
|
| 1516 | #~(modify-phases %standard-phases
|
| 1517 | (add-before 'build 'build-mpy-cross
|
| 1518 | (lambda* (#:key make-flags #:allow-other-keys)
|
| 1519 | (with-directory-excursion "mpy-cross"
|
| 1520 | (apply invoke "make" make-flags))))
|
| 1521 | (add-after 'build-mpy-cross 'prepare-build
|
| 1522 | (lambda _
|
| 1523 | (chdir "ports/unix")
|
| 1524 | |
| 1525 | (substitute* "Makefile"
|
| 1526 | (("-Os") "-Os -ffp-contract=off"))))
|
| 1527 | (add-before 'install-license-files 'chdir-back
|
| 1528 | |
| 1529 | (lambda _
|
| 1530 | (chdir "../..")))
|
| 1531 | (delete 'configure)) |
| 1532 | #:make-flags
|
| 1533 | #~(list (string-append "PREFIX=" #$output)
|
| 1534 | "V=1")
|
| 1535 | #:test-target "test"))
|
| 1536 | (native-inputs (list pkg-config python-wrapper))
|
| 1537 | (inputs
|
| 1538 | (list libffi))
|
| 1539 | (home-page "https://micropython.org/")
|
| 1540 | (synopsis "Python implementation for microcontrollers and constrained systems")
|
| 1541 | (description "MicroPython is a lean and efficient implementation of the
|
| 1542 | Python 3 programming language that includes a small subset of the Python
|
| 1543 | standard library and is optimised to run on microcontrollers and in constrained
|
| 1544 | environments. MicroPython is packed full of advanced features such as an
|
| 1545 | interactive prompt, arbitrary precision integers, closures, list comprehension,
|
| 1546 | generators, exception handling and more. Still it is compact enough to fit and
|
| 1547 | run within just 256k of code space and 16k of RAM. MicroPython aims to be as
|
| 1548 | compatible with normal Python as possible to allow you to transfer code with
|
| 1549 | ease from the desktop to a microcontroller or embedded system.")
|
| 1550 | (license license:expat)))
|