| 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 | (define-module (gnu packages python)
|
| 79 | #:use-module ((guix licenses) #:prefix license:)
|
| 80 | #:use-module (gnu packages)
|
| 81 | #:use-module (gnu packages base)
|
| 82 | #:use-module (gnu packages bash)
|
| 83 | #:use-module (gnu packages certs)
|
| 84 | #:use-module (gnu packages check)
|
| 85 | #:use-module (gnu packages compression)
|
| 86 | #:use-module (gnu packages dbm)
|
| 87 | #:use-module (gnu packages hurd)
|
| 88 | #:use-module (gnu packages libffi)
|
| 89 | #:use-module (gnu packages ncurses)
|
| 90 | #:use-module (gnu packages pkg-config)
|
| 91 | #:use-module (gnu packages python-xyz)
|
| 92 | #:use-module (gnu packages readline)
|
| 93 | #:use-module (gnu packages shells)
|
| 94 | #:use-module (gnu packages sqlite)
|
| 95 | #:use-module (gnu packages tcl)
|
| 96 | #:use-module (gnu packages tls)
|
| 97 | #:use-module (gnu packages xml)
|
| 98 | #:use-module (guix packages)
|
| 99 | #:use-module (guix download)
|
| 100 | #:use-module (guix utils)
|
| 101 | #:use-module (guix build-system gnu)
|
| 102 | #:use-module (guix build-system trivial)
|
| 103 | #:use-module (srfi srfi-1)
|
| 104 | #:use-module (srfi srfi-26))
|
| 105 |
|
| 106 | (define-public python-2.7
|
| 107 | (package
|
| 108 | (name "python2")
|
| 109 | (version "2.7.17")
|
| 110 | (source
|
| 111 | (origin
|
| 112 | (method url-fetch)
|
| 113 | (uri (string-append "https://www.python.org/ftp/python/"
|
| 114 | version "/Python-" version ".tar.xz"))
|
| 115 | (sha256
|
| 116 | (base32
|
| 117 | "0hds28cg226m8j8sr394nm9yc4gxhvlv109w0avsf2mxrlrz0hsd"))
|
| 118 | (patches (search-patches "python-2.7-search-paths.patch"
|
| 119 | "python-2-deterministic-build-info.patch"
|
| 120 | "python-2.7-site-prefixes.patch"
|
| 121 | "python-2.7-source-date-epoch.patch"
|
| 122 | "python-2.7-adjust-tests.patch"
|
| 123 | "python-cross-compile.patch"))
|
| 124 | (modules '((guix build utils)))
|
| 125 | (snippet
|
| 126 | '(begin
|
| 127 | |
| 128 | (for-each delete-file-recursively
|
| 129 | '("Modules/_ctypes/libffi" "Modules/expat" "Modules/zlib"))
|
| 130 |
|
| 131 | (substitute* "Modules/Setup.dist"
|
| 132 | |
| 133 | (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n"))
|
| 134 |
|
| 135 | |
| 136 | |
| 137 | |
| 138 | (for-each delete-file
|
| 139 | '("Lib/test/test_compileall.py"
|
| 140 | "Lib/test/test_ctypes.py" |
| 141 | "Lib/test/test_distutils.py"
|
| 142 | "Lib/test/test_import.py"
|
| 143 | "Lib/test/test_shutil.py"
|
| 144 | "Lib/test/test_socket.py"
|
| 145 | "Lib/test/test_subprocess.py"))
|
| 146 | #t))))
|
| 147 | (outputs '("out"
|
| 148 | "tk")) |
| 149 | (build-system gnu-build-system)
|
| 150 | (arguments
|
| 151 | `(#:test-target "test"
|
| 152 | #:configure-flags
|
| 153 | (list "--enable-shared" |
| 154 | "--with-system-expat" |
| 155 | "--with-system-ffi" |
| 156 | "--with-ensurepip=install" |
| 157 | "--enable-unicode=ucs4"
|
| 158 |
|
| 159 | |
| 160 | |
| 161 | "INSTALL=install -c"
|
| 162 | "MKDIR_P=mkdir -p"
|
| 163 |
|
| 164 | |
| 165 | |
| 166 | ,@(if (%current-target-system)
|
| 167 | '("ac_cv_buggy_getaddrinfo=no"
|
| 168 | "ac_cv_file__dev_ptmx=no"
|
| 169 | "ac_cv_file__dev_ptc=no")
|
| 170 | '())
|
| 171 | (string-append "LDFLAGS=-Wl,-rpath="
|
| 172 | (assoc-ref %outputs "out") "/lib"))
|
| 173 | |
| 174 | #:make-flags
|
| 175 | (list (string-append
|
| 176 | (format #f "TESTOPTS=-j~d" (parallel-job-count))
|
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | " --exclude test_urllib2_localnet test_httplib"))
|
| 183 |
|
| 184 | #:modules ((ice-9 ftw) (ice-9 match)
|
| 185 | (guix build utils) (guix build gnu-build-system))
|
| 186 | #:phases
|
| 187 | (modify-phases %standard-phases
|
| 188 | (add-before
|
| 189 | 'configure 'patch-lib-shells
|
| 190 | (lambda _
|
| 191 | |
| 192 | |
| 193 | |
| 194 | ,@(if (%current-target-system)
|
| 195 | '((setenv "_PYTHON_HOST_PLATFORM" ""))
|
| 196 | '())
|
| 197 | |
| 198 | |
| 199 | (substitute* (filter file-exists?
|
| 200 | '("Lib/subprocess.py"
|
| 201 | "Lib/popen2.py"
|
| 202 | "Lib/distutils/tests/test_spawn.py"
|
| 203 | "Lib/test/support/__init__.py"
|
| 204 | "Lib/test/test_subprocess.py"))
|
| 205 | (("/bin/sh") (which "sh")))
|
| 206 | #t))
|
| 207 | ,@(if (hurd-system?)
|
| 208 | `((add-before 'build 'patch-regen-for-hurd
|
| 209 | (lambda* (#:key inputs #:allow-other-keys)
|
| 210 | (let ((libc (assoc-ref inputs "libc")))
|
| 211 | (substitute* "Lib/plat-generic/regen"
|
| 212 | (("/usr/include/") (string-append libc "/include/")))
|
| 213 | #t))))
|
| 214 | '())
|
| 215 | (add-before 'configure 'do-not-record-configure-flags
|
| 216 | (lambda* (#:key configure-flags #:allow-other-keys)
|
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | (substitute* "configure"
|
| 225 | (("^CONFIG_ARGS=.*$")
|
| 226 | (format #f "CONFIG_ARGS='~a'\n"
|
| 227 | (if (member "--with-system-ffi" configure-flags)
|
| 228 | "--with-system-ffi"
|
| 229 | ""))))
|
| 230 | #t))
|
| 231 | (add-before
|
| 232 | 'check 'pre-check
|
| 233 | (lambda _
|
| 234 | |
| 235 | (setenv "HOME" (getcwd))
|
| 236 | #t))
|
| 237 | (add-after
|
| 238 | 'unpack 'set-source-file-times-to-1980
|
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | (lambda _
|
| 244 | (let ((circa-1980 (* 10 366 24 60 60)))
|
| 245 | (ftw "." (lambda (file stat flag)
|
| 246 | (utime file circa-1980 circa-1980)
|
| 247 | #t))
|
| 248 | #t)))
|
| 249 | (add-after 'install 'remove-tests
|
| 250 | |
| 251 | |
| 252 | (lambda* (#:key outputs #:allow-other-keys)
|
| 253 | (let ((out (assoc-ref outputs "out")))
|
| 254 | (match (scandir (string-append out "/lib")
|
| 255 | (lambda (name)
|
| 256 | (string-prefix? "python" name)))
|
| 257 | ((pythonX.Y)
|
| 258 | (let ((testdir (string-append out "/lib/" pythonX.Y
|
| 259 | "/test")))
|
| 260 | (with-directory-excursion testdir
|
| 261 | (for-each delete-file-recursively
|
| 262 | (scandir testdir
|
| 263 | (match-lambda
|
| 264 | ((or "." "..") #f)
|
| 265 | ("support" #f)
|
| 266 | (file
|
| 267 | (not
|
| 268 | (string-prefix? "test_support."
|
| 269 | file))))))
|
| 270 | (call-with-output-file "__init__.py" (const #t))
|
| 271 | #t)))))))
|
| 272 | (add-after 'remove-tests 'rebuild-bytecode
|
| 273 | (lambda* (#:key outputs #:allow-other-keys)
|
| 274 | (let ((out (assoc-ref outputs "out")))
|
| 275 | |
| 276 | |
| 277 | (setenv "PYTHONHASHSEED" "0")
|
| 278 | (for-each
|
| 279 | (lambda (opt)
|
| 280 | (format #t "Compiling with optimization level: ~a\n"
|
| 281 | (if (null? opt) "none" (car opt)))
|
| 282 | (for-each (lambda (file)
|
| 283 | (apply invoke
|
| 284 | `(,,(if (%current-target-system)
|
| 285 | "python2"
|
| 286 | '(string-append out "/bin/python"))
|
| 287 | ,@opt
|
| 288 | "-m" "compileall"
|
| 289 | "-f" |
| 290 | |
| 291 | "-x" "lib2to3/.*"
|
| 292 | ,file)))
|
| 293 | (find-files out "\\.py$")))
|
| 294 | (list '() '("-O") '("-OO")))
|
| 295 | #t)))
|
| 296 | (add-after 'install 'move-tk-inter
|
| 297 | (lambda* (#:key outputs #:allow-other-keys)
|
| 298 | |
| 299 | |
| 300 | (let ((out (assoc-ref outputs "out"))
|
| 301 | (tk (assoc-ref outputs "tk")))
|
| 302 | (when tk
|
| 303 | (match (find-files out "tkinter.*\\.so")
|
| 304 | ((tkinter.so)
|
| 305 | |
| 306 | |
| 307 | (let* ((len (string-length out))
|
| 308 | (target (string-append
|
| 309 | tk "/"
|
| 310 | (string-drop
|
| 311 | (dirname (dirname tkinter.so))
|
| 312 | len)
|
| 313 | "/site-packages")))
|
| 314 | (install-file tkinter.so target)
|
| 315 | (delete-file tkinter.so)))))
|
| 316 | #t))))))
|
| 317 | (inputs
|
| 318 | `(("bzip2" ,bzip2)
|
| 319 | ("expat" ,expat)
|
| 320 | ("gdbm" ,gdbm)
|
| 321 | ("libffi" ,libffi) |
| 322 | ("sqlite" ,sqlite) |
| 323 | ("openssl" ,openssl)
|
| 324 | ("readline" ,readline)
|
| 325 | ("zlib" ,zlib)
|
| 326 | ("tcl" ,tcl)
|
| 327 | ("tk" ,tk))) |
| 328 | (native-inputs
|
| 329 | `(("pkg-config" ,pkg-config)
|
| 330 | |
| 331 | ,@(if (%current-target-system)
|
| 332 | `(("python2" ,this-package)
|
| 333 | ("which" ,which))
|
| 334 | '())))
|
| 335 | (native-search-paths
|
| 336 | (list (search-path-specification
|
| 337 | (variable "PYTHONPATH")
|
| 338 | (files '("lib/python2.7/site-packages")))))
|
| 339 | (home-page "https://www.python.org")
|
| 340 | (synopsis "High-level, dynamically-typed programming language")
|
| 341 | (description
|
| 342 | "Python is a remarkably powerful dynamic programming language that
|
| 343 | is used in a wide variety of application domains. Some of its key
|
| 344 | distinguishing features include: clear, readable syntax; strong
|
| 345 | introspection capabilities; intuitive object orientation; natural
|
| 346 | expression of procedural code; full modularity, supporting hierarchical
|
| 347 | packages; exception-based error handling; and very high level dynamic
|
| 348 | data types.")
|
| 349 | (properties '((cpe-name . "python")))
|
| 350 | (license license:psfl)))
|
| 351 |
|
| 352 | |
| 353 | (define-public python-2 python-2.7)
|
| 354 |
|
| 355 | (define-public python2-called-python
|
| 356 | |
| 357 | |
| 358 | |
| 359 | (package
|
| 360 | (inherit python-2)
|
| 361 | (name "python")
|
| 362 | (properties `((superseded . ,python-2)))))
|
| 363 |
|
| 364 | (define-public python-3.8
|
| 365 | (package (inherit python-2)
|
| 366 | (name "python")
|
| 367 | (version "3.8.2")
|
| 368 | (source (origin
|
| 369 | (method url-fetch)
|
| 370 | (uri (string-append "https://www.python.org/ftp/python/"
|
| 371 | version "/Python-" version ".tar.xz"))
|
| 372 | (patches (search-patches
|
| 373 | "python-3-fix-tests.patch"
|
| 374 | "python-3.8-fix-tests.patch"
|
| 375 | "python-3-deterministic-build-info.patch"
|
| 376 | "python-3-search-paths.patch"))
|
| 377 | (sha256
|
| 378 | (base32
|
| 379 | "1ps5v323cp5czfshqjmbsqw7nvrdpcbk06f62jbzaqik4gfffii6"))
|
| 380 | (modules '((guix build utils)))
|
| 381 | (snippet
|
| 382 | '(begin
|
| 383 | |
| 384 | (delete-file-recursively "Modules/expat")
|
| 385 | (substitute* "Modules/Setup"
|
| 386 | |
| 387 | (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n"))
|
| 388 | #t))))
|
| 389 | (arguments
|
| 390 | (substitute-keyword-arguments (package-arguments python-2)
|
| 391 | ((#:make-flags _)
|
| 392 | `(list (string-append
|
| 393 | (format #f "TESTOPTS=-j~d" (parallel-job-count))
|
| 394 | |
| 395 | " --exclude test_mmap"
|
| 396 | |
| 397 | |
| 398 | " test_socket")))
|
| 399 | ((#:phases phases)
|
| 400 | `(modify-phases ,phases
|
| 401 | ,@(if (hurd-system?)
|
| 402 | `((delete 'patch-regen-for-hurd)) |
| 403 | '())
|
| 404 | ,@(if (hurd-target?)
|
| 405 | |
| 406 | |
| 407 | |
| 408 | '((add-before 'configure 'support-hurd-cross-compile
|
| 409 | (lambda _
|
| 410 | (substitute* "configure"
|
| 411 | (("\\*-\\*-vxworks.*" all)
|
| 412 | (string-append "*-*-gnu)\nac_sys_system=GNU\n;;\n" all)))
|
| 413 | #t)))
|
| 414 | '())
|
| 415 | (add-before 'check 'set-TZDIR
|
| 416 | (lambda* (#:key inputs native-inputs #:allow-other-keys)
|
| 417 | |
| 418 | (setenv "TZDIR"
|
| 419 | (string-append (assoc-ref
|
| 420 | (or native-inputs inputs) "tzdata")
|
| 421 | "/share/zoneinfo"))
|
| 422 | #t))
|
| 423 | |
| 424 | |
| 425 | (add-before 'check 'unset-SOURCE_DATE_EPOCH
|
| 426 | (lambda _ (unsetenv "SOURCE_DATE_EPOCH") #t))
|
| 427 | (add-after 'check 'reset-SOURCE_DATE_EPOCH
|
| 428 | (lambda _ (setenv "SOURCE_DATE_EPOCH" "1") #t))
|
| 429 | (replace 'rebuild-bytecode
|
| 430 | (lambda* (#:key outputs #:allow-other-keys)
|
| 431 | (let ((out (assoc-ref outputs "out")))
|
| 432 | |
| 433 | |
| 434 | (setenv "PYTHONHASHSEED" "0")
|
| 435 | (for-each
|
| 436 | (lambda (opt)
|
| 437 | (format #t "Compiling with optimization level: ~a\n"
|
| 438 | (if (null? opt) "none" (car opt)))
|
| 439 | (for-each (lambda (file)
|
| 440 | (apply invoke
|
| 441 | `(,,(if (%current-target-system)
|
| 442 | "python3"
|
| 443 | '(string-append out
|
| 444 | "/bin/python3"))
|
| 445 | ,@opt
|
| 446 | "-m" "compileall"
|
| 447 | "-f" |
| 448 | |
| 449 | "-x" "lib2to3/.*"
|
| 450 | ,file)))
|
| 451 | (find-files out "\\.py$")))
|
| 452 | (list '() '("-O") '("-OO")))
|
| 453 | #t)))
|
| 454 | |
| 455 | |
| 456 | ,@(let ((system (or (%current-target-system)
|
| 457 | (%current-system))))
|
| 458 | (if (any (cute string-prefix? <> system)
|
| 459 | '("arm" "aarch64"))
|
| 460 | '((add-after 'unpack 'apply-alignment-patch
|
| 461 | (lambda* (#:key native-inputs inputs #:allow-other-keys)
|
| 462 | (invoke "patch" "-p1" "--force" "--input"
|
| 463 | (assoc-ref (or native-inputs inputs)
|
| 464 | "arm-alignment.patch")))))
|
| 465 | '()))))))
|
| 466 | (native-inputs
|
| 467 | `(("tzdata" ,tzdata-for-tests)
|
| 468 |
|
| 469 | |
| 470 | |
| 471 | |
| 472 | |
| 473 | ,@(let ((system (or (%current-target-system)
|
| 474 | (%current-system))))
|
| 475 | (if (any (cute string-prefix? <> system)
|
| 476 | '("arm" "aarch64"))
|
| 477 | `(("arm-alignment.patch" ,(search-patch "python-3-arm-alignment.patch")))
|
| 478 | '()))
|
| 479 |
|
| 480 | ,@(if (%current-target-system)
|
| 481 | `(("python3" ,this-package))
|
| 482 | '())
|
| 483 | ,@(package-native-inputs python-2)))
|
| 484 | (native-search-paths
|
| 485 | (list (search-path-specification
|
| 486 | (variable "PYTHONPATH")
|
| 487 | (files (list (string-append "lib/python"
|
| 488 | (version-major+minor version)
|
| 489 | "/site-packages"))))))))
|
| 490 |
|
| 491 | |
| 492 | (define-public python-3 python-3.8)
|
| 493 |
|
| 494 | |
| 495 | (define-public python python-3)
|
| 496 |
|
| 497 | |
| 498 | |
| 499 |
|
| 500 | (define-public python2-minimal
|
| 501 | (package/inherit python-2
|
| 502 | (name "python2-minimal")
|
| 503 | (outputs '("out"))
|
| 504 |
|
| 505 | |
| 506 | |
| 507 | |
| 508 | |
| 509 | (inputs `(("expat" ,expat)
|
| 510 | ("libffi" ,libffi)
|
| 511 | ("zlib" ,zlib)))))
|
| 512 |
|
| 513 | (define-public python-minimal
|
| 514 | (package/inherit python
|
| 515 | (name "python-minimal")
|
| 516 | (outputs '("out"))
|
| 517 |
|
| 518 | |
| 519 | |
| 520 | |
| 521 | |
| 522 | (inputs `(("expat" ,expat)
|
| 523 | ("libffi" ,libffi)
|
| 524 | ("openssl" ,openssl)
|
| 525 | ("zlib" ,zlib)))))
|
| 526 |
|
| 527 | (define-public python-debug
|
| 528 | (package/inherit python
|
| 529 | (name "python-debug")
|
| 530 | (outputs '("out" "debug"))
|
| 531 | (build-system gnu-build-system)
|
| 532 | (arguments
|
| 533 | (substitute-keyword-arguments (package-arguments python)
|
| 534 | ((#:configure-flags flags '())
|
| 535 | `(cons "--with-pydebug" ,flags))))
|
| 536 | (synopsis
|
| 537 | "High-level, dynamically-typed programming language (for debugging)")
|
| 538 | (description
|
| 539 | "This variant of Python provides an interpreter built with
|
| 540 | @code{--with-pydebug} to help develop and debug extensions. See
|
| 541 | @url{https://pythonextensionpatterns.readthedocs.io/en/latest/debugging/debug.html},
|
| 542 | for more information.")))
|
| 543 |
|
| 544 | (define* (wrap-python3 python
|
| 545 | #:optional
|
| 546 | (name (string-append (package-name python) "-wrapper")))
|
| 547 | (package/inherit python
|
| 548 | (name name)
|
| 549 | (source #f)
|
| 550 | (build-system trivial-build-system)
|
| 551 | (outputs '("out"))
|
| 552 | (inputs `(("bash" ,bash)))
|
| 553 | (propagated-inputs `(("python" ,python)))
|
| 554 | (arguments
|
| 555 | `(#:modules ((guix build utils))
|
| 556 | #:builder
|
| 557 | (begin
|
| 558 | (use-modules (guix build utils))
|
| 559 | (let ((bin (string-append (assoc-ref %outputs "out") "/bin"))
|
| 560 | (python (string-append (assoc-ref %build-inputs "python") "/bin/")))
|
| 561 | (mkdir-p bin)
|
| 562 | (for-each
|
| 563 | (lambda (old new)
|
| 564 | (symlink (string-append python old)
|
| 565 | (string-append bin "/" new)))
|
| 566 | `("python3" ,"pydoc3" ,"idle3" ,"pip3")
|
| 567 | `("python" ,"pydoc" ,"idle" ,"pip"))
|
| 568 | |
| 569 | |
| 570 | (let ((bash (string-append (assoc-ref %build-inputs "bash")
|
| 571 | "/bin/bash"))
|
| 572 | (old (string-append python "python3-config"))
|
| 573 | (new (string-append bin "/python-config")))
|
| 574 | (with-output-to-file new
|
| 575 | (lambda ()
|
| 576 | (format #t "#!~a~%" bash)
|
| 577 | (format #t "exec \"~a\" \"$@\"~%" old)
|
| 578 | (chmod new #o755)
|
| 579 | #t)))))))
|
| 580 | (synopsis "Wrapper for the Python 3 commands")
|
| 581 | (description
|
| 582 | "This package provides wrappers for the commands of Python@tie{}3.x such
|
| 583 | that they can be invoked under their usual name---e.g., @command{python}
|
| 584 | instead of @command{python3}.")))
|
| 585 |
|
| 586 | (define-public python-wrapper (wrap-python3 python))
|
| 587 | (define-public python-minimal-wrapper (wrap-python3 python-minimal))
|
| 588 |
|
| 589 | (define-public micropython
|
| 590 | (package
|
| 591 | (name "micropython")
|
| 592 | (version "1.12")
|
| 593 | (source
|
| 594 | (origin
|
| 595 | (method url-fetch)
|
| 596 | (uri (string-append "https://github.com/micropython/micropython/"
|
| 597 | "releases/download/v" version
|
| 598 | "/micropython-" version ".tar.gz"))
|
| 599 | (sha256
|
| 600 | (base32
|
| 601 | "1fl1dm2aay23hyqbarnv69qj7z2wljcvkwmvfwfac8yadcv05zcq"))
|
| 602 | (modules '((guix build utils)))
|
| 603 | (snippet
|
| 604 | '(begin
|
| 605 | (delete-file-recursively "ports/cc3200/FreeRTOS")
|
| 606 | (with-directory-excursion "lib"
|
| 607 | |
| 608 | (for-each delete-file-recursively
|
| 609 | '("libffi" "lwip" "stm32lib" "nrfx")))
|
| 610 | #t))))
|
| 611 | (build-system gnu-build-system)
|
| 612 | (arguments
|
| 613 | `(#:phases
|
| 614 | (modify-phases %standard-phases
|
| 615 | (add-before 'build 'build-mpy-cross
|
| 616 | (lambda* (#:key make-flags #:allow-other-keys)
|
| 617 | (with-directory-excursion "mpy-cross"
|
| 618 | (apply invoke "make" make-flags))))
|
| 619 | (add-after 'build-mpy-cross 'prepare-build
|
| 620 | (lambda _
|
| 621 | (chdir "ports/unix")
|
| 622 | |
| 623 | (substitute* "Makefile"
|
| 624 | (("-Os") "-Os -ffp-contract=off"))
|
| 625 | #t))
|
| 626 | (replace 'install-license-files
|
| 627 | |
| 628 | (lambda* (#:key outputs #:allow-other-keys)
|
| 629 | (let* ((out (assoc-ref outputs "out"))
|
| 630 | (dest (string-append out "/share/doc/" ,name "-" ,version "/")))
|
| 631 | (install-file "../../LICENSE" dest))
|
| 632 | #t))
|
| 633 | (delete 'configure)) |
| 634 | #:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
|
| 635 | "V=1")
|
| 636 | #:test-target "test"))
|
| 637 | (native-inputs
|
| 638 | `(("pkg-config" ,pkg-config)
|
| 639 | ("python" ,python-wrapper)))
|
| 640 | (inputs
|
| 641 | `(("libffi" ,libffi)))
|
| 642 | (home-page "https://micropython.org/")
|
| 643 | (synopsis "Python implementation for microcontrollers and constrained systems")
|
| 644 | (description "MicroPython is a lean and efficient implementation of the
|
| 645 | Python 3 programming language that includes a small subset of the Python
|
| 646 | standard library and is optimised to run on microcontrollers and in constrained
|
| 647 | environments. MicroPython is packed full of advanced features such as an
|
| 648 | interactive prompt, arbitrary precision integers, closures, list comprehension,
|
| 649 | generators, exception handling and more. Still it is compact enough to fit and
|
| 650 | run within just 256k of code space and 16k of RAM. MicroPython aims to be as
|
| 651 | compatible with normal Python as possible to allow you to transfer code with
|
| 652 | ease from the desktop to a microcontroller or embedded system.")
|
| 653 | (license license:expat)))
|
| 654 |
|
| 655 | (define-public pypy3
|
| 656 | (package
|
| 657 | (name "pypy3")
|
| 658 | (version "7.3.1")
|
| 659 | (source (origin
|
| 660 | (method url-fetch)
|
| 661 | (uri (string-append "https://bitbucket.org/pypy/pypy/downloads/" |
| 662 | "pypy3.6-v" version "-src.tar.bz2"))
|
| 663 | (sha256
|
| 664 | (base32
|
| 665 | "10zsk8jby8j6visk5mzikpb1cidvz27qq4pfpa26jv53klic6b0c"))
|
| 666 | (patches (search-patches "pypy3-7.3.1-fix-tests.patch"))))
|
| 667 | (build-system gnu-build-system)
|
| 668 | (native-inputs
|
| 669 | `(("python-2" ,python-2)
|
| 670 | ("pkg-config" ,pkg-config)
|
| 671 | ("tar" ,tar) |
| 672 | ("python2-pycparser" ,python2-pycparser)
|
| 673 | ("python2-hypothesis" ,python2-hypothesis)
|
| 674 | ("nss-certs" ,nss-certs) |
| 675 | ("gzip" ,gzip)))
|
| 676 | (inputs
|
| 677 | `(("libffi" ,libffi)
|
| 678 | ("zlib" ,zlib)
|
| 679 | ("ncurses" ,ncurses)
|
| 680 | ("openssl" ,openssl)
|
| 681 | ("expat" ,expat)
|
| 682 | ("bzip2" ,bzip2)
|
| 683 | ("sqlite" ,sqlite)
|
| 684 | ("gdbm" ,gdbm)
|
| 685 | ("tcl" ,tcl)
|
| 686 | ("tk" ,tk)
|
| 687 | ("glibc" ,glibc)
|
| 688 | ("bash-minimal" ,bash-minimal) |
| 689 | ("xz" ,xz))) |
| 690 | (arguments
|
| 691 | `(#:tests? #f |
| 692 | #:modules ((ice-9 ftw) (ice-9 match)
|
| 693 | (guix build utils) (guix build gnu-build-system))
|
| 694 | #:phases (modify-phases %standard-phases
|
| 695 | (delete 'configure)
|
| 696 | (add-after 'unpack 'patch-source
|
| 697 | (lambda* (#:key inputs outputs #:allow-other-keys)
|
| 698 | (substitute* '("rpython/rlib/clibffi.py")
|
| 699 | |
| 700 | (("ctypes\\.util\\.find_library\\('c'\\)") "'libc.so'"))
|
| 701 | (substitute* '("lib_pypy/cffi/_pycparser/ply/cpp.py")
|
| 702 | |
| 703 | (("time\\.localtime\\(\\)") "time.gmtime(0)"))
|
| 704 | (substitute* '("pypy/module/sys/version.py")
|
| 705 | |
| 706 | (("t\\.gmtime\\(\\)") "t.gmtime(0)"))
|
| 707 | (substitute* '("lib_pypy/_tkinter/tklib_build.py")
|
| 708 | |
| 709 | (("linklibs = \\['tcl', 'tk'\\]")
|
| 710 | "linklibs = ['tcl8.6', 'tk8.6']")
|
| 711 | (("incdirs = \\[\\]")
|
| 712 | (string-append "incdirs = ['"
|
| 713 | (assoc-ref inputs "tcl")
|
| 714 | "/include', '"
|
| 715 | (assoc-ref inputs "tk")
|
| 716 | "/include']")))
|
| 717 | (substitute* '("lib_pypy/_curses_build.py")
|
| 718 | |
| 719 | (("/usr/local") (assoc-ref inputs "ncurses")))
|
| 720 | (substitute* '("lib_pypy/_sqlite3_build.py")
|
| 721 | |
| 722 | (("sys\\.platform\\.startswith\\('freebsd'\\)") "True")
|
| 723 | |
| 724 | (("/usr/local") (assoc-ref inputs "sqlite"))
|
| 725 | (("libname = 'sqlite3'")
|
| 726 | (string-append "libname = '"
|
| 727 | (assoc-ref inputs "sqlite")
|
| 728 | "/lib/libsqlite3.so.0'")))
|
| 729 | (substitute* '("lib-python/3/subprocess.py")
|
| 730 | |
| 731 | (("/bin/sh")
|
| 732 | (string-append (assoc-ref inputs "bash-minimal") "/bin/sh")))
|
| 733 | (substitute* '("lib-python/3/distutils/unixccompiler.py")
|
| 734 | |
| 735 | (("\"cc\"") "\"gcc\""))
|
| 736 | #t))
|
| 737 | (add-after
|
| 738 | 'unpack 'set-source-file-times-to-1980
|
| 739 | |
| 740 | (lambda _
|
| 741 | (let ((circa-1980 (* 10 366 24 60 60)))
|
| 742 | (ftw "." (lambda (file stat flag)
|
| 743 | (utime file circa-1980 circa-1980)
|
| 744 | #t))
|
| 745 | #t)))
|
| 746 | (replace 'build
|
| 747 | (lambda* (#:key inputs #:allow-other-keys)
|
| 748 | (with-directory-excursion "pypy/goal"
|
| 749 | |
| 750 | (invoke "python2"
|
| 751 | "../../rpython/bin/rpython"
|
| 752 | (string-append "--make-jobs="
|
| 753 | (number->string (parallel-job-count)))
|
| 754 | "-Ojit"
|
| 755 | "targetpypystandalone"))
|
| 756 | |
| 757 | (with-directory-excursion "pypy/tool/release"
|
| 758 | (unsetenv "PYTHONPATH") |
| 759 | |
| 760 | |
| 761 | (invoke "python2" "package.py"
|
| 762 | "--archive-name" "pypy-dist"
|
| 763 | "--builddir" (getcwd)))))
|
| 764 | (replace 'check
|
| 765 | (lambda* (#:key tests? #:allow-other-keys)
|
| 766 | (if tests?
|
| 767 | (begin
|
| 768 | (setenv "HOME" "/tmp") |
| 769 | |
| 770 | |
| 771 | |
| 772 | (invoke
|
| 773 | "python2"
|
| 774 | "pypy/test_all.py"
|
| 775 | "--pypy=pypy/tool/release/pypy-dist/bin/pypy3"
|
| 776 | "lib-python"))
|
| 777 | (format #t "test suite not run~%"))
|
| 778 | #t))
|
| 779 | (replace 'install
|
| 780 | (lambda* (#:key inputs outputs #:allow-other-keys)
|
| 781 | (with-directory-excursion "pypy/tool/release"
|
| 782 | |
| 783 | (for-each
|
| 784 | (lambda (x)
|
| 785 | (delete-file-recursively (string-append
|
| 786 | "pypy-dist/lib-python/3/" x)))
|
| 787 | '("tkinter/test"
|
| 788 | "test"
|
| 789 | "sqlite3/test"
|
| 790 | "lib2to3/tests"
|
| 791 | "idlelib/idle_test"
|
| 792 | "distutils/tests"
|
| 793 | "ctypes/test"
|
| 794 | "unittest/test"))
|
| 795 | |
| 796 | (substitute* '("pypy-dist/lib-python/3/cgi.py"
|
| 797 | "pypy-dist/lib-python/3/encodings/rot_13.py")
|
| 798 | (("#!.+/bin/python")
|
| 799 | (string-append "#!" (assoc-ref outputs "out") "/bin/pypy3")))
|
| 800 | (with-fluids ((%default-port-encoding "ISO-8859-1"))
|
| 801 | (substitute* '("pypy-dist/lib_pypy/_md5.py"
|
| 802 | "pypy-dist/lib_pypy/_sha1.py")
|
| 803 | (("#!.+/bin/python")
|
| 804 | (string-append "#!" (assoc-ref outputs "out") "/bin/pypy3"))))
|
| 805 | (copy-recursively "pypy-dist" (assoc-ref outputs "out")))
|
| 806 | #t)))))
|
| 807 | (home-page "https://www.pypy.org/")
|
| 808 | (synopsis "Python implementation with just-in-time compilation")
|
| 809 | (description "PyPy is a faster, alternative implementation of the Python
|
| 810 | programming language employing a just-in-time compiler. It supports most
|
| 811 | Python code natively, including C extensions.")
|
| 812 | (license (list license:expat |
| 813 | license:psfl |
| 814 | license:asl2.0 |
| 815 | license:gpl3+ |
| 816 | license:bsd-3 |
| 817 | (license:non-copyleft
|
| 818 | "http://www.unicode.org/copyright.html")))))
|
| 819 |
|