;;; Copyright © 2016 Daniel Pimentel <d4n1@d4n1.org>
;;; Copyright © 2016 Sou Bunnbu <iyzsong@gmail.com>
;;; Copyright © 2016, 2017 Troy Sankey <sankeytms@gmail.com>
-;;; Copyright © 2016, 2017 Nils Gillmann <ng0@n0.is>
+;;; Copyright © 2016, 2017 Nikita <nikita@n0.is>
;;; Copyright © 2016 Dylan Jeffers <sapientech@sapientech@openmailbox.org>
;;; Copyright © 2016 David Craven <david@craven.ch>
-;;; Copyright © 2016, 2017, 2018 Marius Bakke <mbakke@fastmail.com>
+;;; Copyright © 2016, 2017, 2018, 2019, 2020 Marius Bakke <mbakke@fastmail.com>
;;; Copyright © 2016, 2017 Stefan Reichör <stefan@xsteve.at>
;;; Copyright © 2016 Dylan Jeffers <sapientech@sapientech@openmailbox.org>
;;; Copyright © 2016, 2017 Alex Vong <alexvong1995@gmail.com>
;;; Copyright © 2017 Frederick M. Muriithi <fredmanglis@gmail.com>
;;; Copyright © 2017, 2018 Adriano Peluso <catonano@gmail.com>
;;; Copyright © 2017 Ben Sturmfels <ben@sturm.com.au>
-;;; Copyright © 2017, 2018 Mathieu Othacehe <m.othacehe@gmail.com>
+;;; Copyright © 2017, 2018, 2019 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2017 José Miguel Sánchez García <jmi2k@openmailbox.org>
;;; Copyright © 2017 Roel Janssen <roel@gnu.org>
;;; Copyright © 2017, 2018 Kei Kebreau <kkebreau@posteo.net>
;;; Copyright © 2017 Rutger Helling <rhelling@mykolab.com>
;;; Copyright © 2017 Muriithi Frederick Muriuki <fredmanglis@gmail.com>
-;;; Copyright © 2017 Brendan Tildesley <brendan.tildesley@openmailbox.org>
+;;; Copyright © 2017 Brendan Tildesley <mail@brendan.scot>
;;; Copyright © 2018 Ethan R. Jones <ethanrjones97@gmail.com
;;; Copyright © 2018 Fis Trivial <ybbs.daans@hotmail.com>
;;; Copyright © 2018 Vijayalakshmi Vedantham <vijimay12@gmail.com>
;;; Copyright © 2018 Nicolas Goaziou <mail@nicolasgoaziou.fr>
;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
-;;; Copyright © 2018 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2018, 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2018 Luther Thompson <lutheroto@gmail.com>
;;; Copyright © 2018 Vagrant Cascadian <vagrant@debian.org>
+;;; Copyright © 2019 Tanguy Le Carrour <tanguy@bioneland.org>
+;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
(define-module (gnu packages python)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (gnu packages)
+ #:use-module (gnu packages base)
#:use-module (gnu packages bash)
#:use-module (gnu packages compression)
#:use-module (gnu packages dbm)
+ #:use-module (gnu packages hurd)
#:use-module (gnu packages libffi)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages readline)
#:use-module (gnu packages sqlite)
#:use-module (gnu packages tcl)
#:use-module (gnu packages tls)
+ #:use-module (gnu packages xml)
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu)
- #:use-module (guix build-system trivial))
+ #:use-module (guix build-system trivial)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-26))
(define-public python-2.7
(package
(name "python2")
- (version "2.7.15")
+ (version "2.7.17")
(source
(origin
(method url-fetch)
version "/Python-" version ".tar.xz"))
(sha256
(base32
- "0x2mvz9dp11wj7p5ccvmk9s0hzjk2fa1m462p395l4r6bfnb3n92"))
+ "0hds28cg226m8j8sr394nm9yc4gxhvlv109w0avsf2mxrlrz0hsd"))
(patches (search-patches "python-2.7-search-paths.patch"
"python-2-deterministic-build-info.patch"
"python-2.7-site-prefixes.patch"
"python-2.7-source-date-epoch.patch"
"python-2.7-adjust-tests.patch"
- "python2-CVE-2018-14647.patch"
- "python2-CVE-2018-1000802.patch"))
+ "python-cross-compile.patch"))
(modules '((guix build utils)))
- ;; suboptimal to delete failing tests here, but if we delete them in the
- ;; arguments then we need to make sure to strip out that phase when it
- ;; gets inherited by python and python-minimal.
(snippet
'(begin
+ ;; Ensure the bundled copies of these libraries are not used.
+ (for-each delete-file-recursively
+ '("Modules/_ctypes/libffi" "Modules/expat" "Modules/zlib"))
+
+ (substitute* "Modules/Setup.dist"
+ ;; Link Expat instead of embedding the bundled one.
+ (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n"))
+
+ ;; Suboptimal to delete failing tests here, but if we delete them in
+ ;; the arguments then we need to make sure to strip out that phase
+ ;; when it gets inherited by python and python-minimal.
(for-each delete-file
'("Lib/test/test_compileall.py"
"Lib/test/test_ctypes.py" ; fails on mips64el
`(#:test-target "test"
#:configure-flags
(list "--enable-shared" ;allow embedding
+ "--with-system-expat" ;for XML support
"--with-system-ffi" ;build ctypes
"--with-ensurepip=install" ;install pip and setuptools
"--enable-unicode=ucs4"
+
+ ;; Prevent the installed _sysconfigdata.py from retaining a reference
+ ;; to coreutils.
+ "INSTALL=install -c"
+ "MKDIR_P=mkdir -p"
+
+ ;; Disable runtime check failing if cross-compiling, see:
+ ;; https://lists.yoctoproject.org/pipermail/poky/2013-June/008997.html
+ ,@(if (%current-target-system)
+ '("ac_cv_buggy_getaddrinfo=no"
+ "ac_cv_file__dev_ptmx=no"
+ "ac_cv_file__dev_ptc=no")
+ '())
(string-append "LDFLAGS=-Wl,-rpath="
(assoc-ref %outputs "out") "/lib"))
;; With no -j argument tests use all available cpus, so provide one.
#:make-flags
- (list (format #f "TESTOPTS=-j~d" (parallel-job-count)))
+ (list (string-append
+ (format #f "TESTOPTS=-j~d" (parallel-job-count))
+ ;; Exclude the following tests as they fail
+ ;; non-deterministically with "error: [Errno 104] Connection
+ ;; reset by peer." Python 3 seems unaffected. A potential fix,
+ ;; yet to be backported to Python 2, is available at:
+ ;; https://github.com/python/cpython/commit/529525fb5a8fd9b96ab4021311a598c77588b918.
+ " --exclude test_urllib2_localnet test_httplib"))
#:modules ((ice-9 ftw) (ice-9 match)
(guix build utils) (guix build gnu-build-system))
(add-before
'configure 'patch-lib-shells
(lambda _
+ ;; This variable is used in setup.py to enable cross compilation
+ ;; specific switches. As it is not set properly by configure
+ ;; script, set it manually.
+ ,@(if (%current-target-system)
+ '((setenv "_PYTHON_HOST_PLATFORM" ""))
+ '())
;; Filter for existing files, since some may not exist in all
;; versions of python that are built with this recipe.
(substitute* (filter file-exists?
"Lib/test/test_subprocess.py"))
(("/bin/sh") (which "sh")))
#t))
+ ,@(if (hurd-system?)
+ `((add-before 'build 'patch-regen-for-hurd
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let ((libc (assoc-ref inputs "libc")))
+ (substitute* "Lib/plat-generic/regen"
+ (("/usr/include/") (string-append libc "/include/")))
+ #t))))
+ '())
(add-before 'configure 'do-not-record-configure-flags
(lambda* (#:key configure-flags #:allow-other-keys)
;; Remove configure flags from the installed '_sysconfigdata.py'
(if (null? opt) "none" (car opt)))
(for-each (lambda (file)
(apply invoke
- `(,(string-append out "/bin/python")
+ `(,,(if (%current-target-system)
+ "python2"
+ '(string-append out "/bin/python"))
,@opt
"-m" "compileall"
"-f" ; force rebuild
#t))))))
(inputs
`(("bzip2" ,bzip2)
+ ("expat" ,expat)
("gdbm" ,gdbm)
("libffi" ,libffi) ; for ctypes
("sqlite" ,sqlite) ; for sqlite extension
("tcl" ,tcl)
("tk" ,tk))) ; for tkinter
(native-inputs
- `(("pkg-config" ,pkg-config)))
+ `(("pkg-config" ,pkg-config)
+ ;; When cross-compiling, a native version of Python itself is needed.
+ ,@(if (%current-target-system)
+ `(("python2" ,this-package)
+ ("which" ,which))
+ '())))
(native-search-paths
(list (search-path-specification
(variable "PYTHONPATH")
expression of procedural code; full modularity, supporting hierarchical
packages; exception-based error handling; and very high level dynamic
data types.")
+ (properties '((cpe-name . "python")))
(license license:psfl)))
;; Current 2.x version.
(name "python")
(properties `((superseded . ,python-2)))))
-(define-public python-3.7
+(define-public python-3.8
(package (inherit python-2)
(name "python")
- (version "3.7.2")
+ (version "3.8.2")
(source (origin
(method url-fetch)
(uri (string-append "https://www.python.org/ftp/python/"
version "/Python-" version ".tar.xz"))
(patches (search-patches
"python-3-fix-tests.patch"
+ "python-3.8-fix-tests.patch"
"python-3-deterministic-build-info.patch"
"python-3-search-paths.patch"))
(sha256
(base32
- "1fzi9d2gibh0wzwidyckzbywsxcsbckgsl05ryxlifxia77fhgyq"))
+ "1ps5v323cp5czfshqjmbsqw7nvrdpcbk06f62jbzaqik4gfffii6"))
+ (modules '((guix build utils)))
(snippet
'(begin
- (for-each delete-file
- '(;; This test may hang and eventually run out of
- ;; memory on some systems:
- ;; <https://bugs.python.org/issue34587>
- "Lib/test/test_socket.py"
-
- ;; These tests fail on AArch64.
- "Lib/ctypes/test/test_win32.py"
- "Lib/test/test_fcntl.py"
- "Lib/test/test_posix.py"))
+ ;; Delete the bundled copy of libexpat.
+ (delete-file-recursively "Modules/expat")
+ (substitute* "Modules/Setup"
+ ;; Link Expat instead of embedding the bundled one.
+ (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n"))
#t))))
(arguments
(substitute-keyword-arguments (package-arguments python-2)
+ ((#:make-flags _)
+ `(list (string-append
+ (format #f "TESTOPTS=-j~d" (parallel-job-count))
+ ;; test_mmap fails on low-memory systems.
+ " --exclude test_mmap"
+ ;; test_socket may hang and eventually run out of memory
+ ;; on some systems: <https://bugs.python.org/issue34587>.
+ " test_socket")))
((#:phases phases)
`(modify-phases ,phases
+ ,@(if (hurd-system?)
+ `((delete 'patch-regen-for-hurd)) ;regen was removed after 3.5.9
+ '())
+ (add-before 'check 'set-TZDIR
+ (lambda* (#:key inputs native-inputs #:allow-other-keys)
+ ;; test_email requires the Olson time zone database.
+ (setenv "TZDIR"
+ (string-append (assoc-ref
+ (or native-inputs inputs) "tzdata")
+ "/share/zoneinfo"))
+ #t))
;; Unset SOURCE_DATE_EPOCH while running the test-suite and set it
;; again afterwards. See <https://bugs.python.org/issue34022>.
(add-before 'check 'unset-SOURCE_DATE_EPOCH
(if (null? opt) "none" (car opt)))
(for-each (lambda (file)
(apply invoke
- `(,(string-append out "/bin/python3")
- ,@opt
- "-m" "compileall"
- "-f" ; force rebuild
- ;; Don't build lib2to3, because it's Python 2 code.
- "-x" "lib2to3/.*"
- ,file)))
+ `(,,(if (%current-target-system)
+ "python3"
+ '(string-append out
+ "/bin/python3"))
+ ,@opt
+ "-m" "compileall"
+ "-f" ; force rebuild
+ ;; Don't build lib2to3, because it's Python 2 code.
+ "-x" "lib2to3/.*"
+ ,file)))
(find-files out "\\.py$")))
(list '() '("-O") '("-OO")))
- #t)))))))
+ #t)))
+ ;; XXX: Apply patch on ARM platforms only to avoid a full rebuild.
+ ;; Remove this phase in the next rebuild cycle.
+ ,@(let ((system (or (%current-target-system)
+ (%current-system))))
+ (if (any (cute string-prefix? <> system)
+ '("arm" "aarch64"))
+ '((add-after 'unpack 'apply-alignment-patch
+ (lambda* (#:key native-inputs inputs #:allow-other-keys)
+ (invoke "patch" "-p1" "--force" "--input"
+ (assoc-ref (or native-inputs inputs)
+ "arm-alignment.patch")))))
+ '()))))))
+ (native-inputs
+ `(("tzdata" ,tzdata-for-tests)
+
+ ;; Disable unaligned accesses in the sha3 module on ARM as
+ ;; it causes a test failure when building 32-bit Python on a
+ ;; 64-bit kernel. See <https://bugs.python.org/issue36515>.
+ ;; TODO: make this a regular patch in the next rebuild cycle.
+ ,@(let ((system (or (%current-target-system)
+ (%current-system))))
+ (if (any (cute string-prefix? <> system)
+ '("arm" "aarch64"))
+ `(("arm-alignment.patch" ,(search-patch "python-3-arm-alignment.patch")))
+ '()))
+
+ ,@(if (%current-target-system)
+ `(("python3" ,this-package))
+ '())
+ ,@(package-native-inputs python-2)))
(native-search-paths
(list (search-path-specification
(variable "PYTHONPATH")
"/site-packages"))))))))
;; Current 3.x version.
-(define-public python-3 python-3.7)
+(define-public python-3 python-3.8)
;; Current major version.
(define-public python python-3)
;; Keep zlib, which is used by 'pip' (via the 'zipimport' module), which
;; is invoked upon 'make install'. 'pip' also expects 'ctypes' and thus
- ;; libffi.
- (inputs `(("libffi" ,libffi)
+ ;; libffi. Expat is needed for XML support which is expected by a lot
+ ;; of libraries out there.
+ (inputs `(("expat" ,expat)
+ ("libffi" ,libffi)
("zlib" ,zlib)))))
(define-public python-minimal
;; Build fails due to missing ctypes without libffi.
;; OpenSSL is a mandatory dependency of Python 3.x, for urllib;
- ;; zlib is required by 'zipimport', used by pip.
- (inputs `(("libffi" ,libffi)
+ ;; zlib is required by 'zipimport', used by pip. Expat is needed
+ ;; for XML support, which is generally expected to be available.
+ (inputs `(("expat" ,expat)
+ ("libffi" ,libffi)
("openssl" ,openssl)
("zlib" ,zlib)))))
(define-public micropython
(package
(name "micropython")
- (version "1.10")
+ (version "1.11")
(source
(origin
(method url-fetch)
"/micropython-" version ".tar.gz"))
(sha256
(base32
- "1g1zjip3rkx6bp16qi1bag72wivnbh56fcsl3nffanrx4j5f4z90"))
+ "0px3xhw16rl0l7qifq7jw1gq92wzlnhd17dmszv9m2c3wbzs9p9f"))
(modules '((guix build utils)))
(snippet
'(begin
(arguments
`(#:phases
(modify-phases %standard-phases
- (add-before 'build 'preprare-build
+ (add-before 'build 'prepare-build
(lambda _
(chdir "ports/unix")
;; see: https://github.com/micropython/micropython/pull/4246