summaryrefslogtreecommitdiff
path: root/gnu/packages/python.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/packages/python.scm')
-rw-r--r--gnu/packages/python.scm117
1 files changed, 73 insertions, 44 deletions
diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 57ced499cb..a26a88e6d9 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -3,7 +3,7 @@
;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013, 2014, 2015, 2016 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
-;;; Copyright © 2014, 2017 Eric Bavier <bavier@member.fsf.org>
+;;; Copyright © 2014, 2017, 2019 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2014, 2015 Federico Beffa <beffa@fbengineering.ch>
;;; Copyright © 2015 Omar Radwan <toxemicsquire4@gmail.com>
;;; Copyright © 2015 Pierre-Antoine Rault <par@rigelk.eu>
@@ -26,7 +26,7 @@
;;; Copyright © 2016, 2017 ng0 <ng0@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 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>
@@ -54,7 +54,7 @@
;;; 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>
;;;
@@ -85,6 +85,7 @@
#: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)
@@ -94,8 +95,7 @@
(define-public python-2.7
(package
(name "python2")
- (version "2.7.15")
- (replacement python-2/fixed)
+ (version "2.7.16")
(source
(origin
(method url-fetch)
@@ -103,18 +103,26 @@
version "/Python-" version ".tar.xz"))
(sha256
(base32
- "0x2mvz9dp11wj7p5ccvmk9s0hzjk2fa1m462p395l4r6bfnb3n92"))
+ "1mqfcqp5y8r0bfyr7ppl74n0lig45p9mc4b8adlcpvj74rhfy8pj"))
(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"))
(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
@@ -131,11 +139,22 @@
`(#: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"
(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 (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))
@@ -204,16 +223,35 @@
(scandir testdir
(match-lambda
((or "." "..") #f)
+ ("support" #f)
(file
(not
- ;; FIXME: Add the 'support' directory
- ;; in the next rebuild cycle, since it
- ;; moved in 2.7.14. See also
- ;; python2-futures below.
(string-prefix? "test_support."
file))))))
(call-with-output-file "__init__.py" (const #t))
#t)))))))
+ (add-after 'remove-tests 'rebuild-bytecode
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ ;; Disable hash randomization to ensure the generated .pycs
+ ;; are reproducible.
+ (setenv "PYTHONHASHSEED" "0")
+ (for-each
+ (lambda (opt)
+ (format #t "Compiling with optimization level: ~a\n"
+ (if (null? opt) "none" (car opt)))
+ (for-each (lambda (file)
+ (apply invoke
+ `(,(string-append out "/bin/python")
+ ,@opt
+ "-m" "compileall"
+ "-f" ; force rebuild
+ ;; Don't build lib2to3, because it contains Python 3 code.
+ "-x" "lib2to3/.*"
+ ,file)))
+ (find-files out "\\.py$")))
+ (list '() '("-O") '("-OO")))
+ #t)))
(add-after 'install 'move-tk-inter
(lambda* (#:key outputs #:allow-other-keys)
;; When Tkinter support is built move it to a separate output so
@@ -237,6 +275,7 @@
#t))))))
(inputs
`(("bzip2" ,bzip2)
+ ("expat" ,expat)
("gdbm" ,gdbm)
("libffi" ,libffi) ; for ctypes
("sqlite" ,sqlite) ; for sqlite extension
@@ -266,16 +305,6 @@ data types.")
;; Current 2.x version.
(define-public python-2 python-2.7)
-(define python-2/fixed
- (package
- (inherit python-2)
- (source (origin
- (inherit (package-source python-2))
- (patches (append
- (origin-patches (package-source python-2))
- (search-patches "python2-CVE-2018-14647.patch"
- "python2-CVE-2018-1000802.patch")))))))
-
(define-public python2-called-python
;; Both 2.x and 3.x used to be called "python". In commit
;; a7714d42de2c3082f3609d1e63c83d703fb39cf9 (March 2018), we renamed the
@@ -288,23 +317,27 @@ data types.")
(define-public python-3.7
(package (inherit python-2)
(name "python")
- (version "3.7.0")
- (replacement python-3/fixed)
+ (version "3.7.2")
(source (origin
(method url-fetch)
(uri (string-append "https://www.python.org/ftp/python/"
version "/Python-" version ".tar.xz"))
(patches (search-patches
- "python-fix-tests.patch"
"python-3-fix-tests.patch"
"python-3-deterministic-build-info.patch"
"python-3-search-paths.patch"))
- (patch-flags '("-p0"))
(sha256
(base32
- "0j9mic5c9lbd2b20wka7hily7szz740wy9ilfrczxap63rnrk0h3"))
+ "1fzi9d2gibh0wzwidyckzbywsxcsbckgsl05ryxlifxia77fhgyq"))
+ (modules '((guix build utils)))
(snippet
'(begin
+ ;; Delete the bundled copy of libexpat.
+ (delete-file-recursively "Modules/expat")
+ (substitute* "Modules/Setup.dist"
+ ;; Link Expat instead of embedding the bundled one.
+ (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n"))
+
(for-each delete-file
'(;; This test may hang and eventually run out of
;; memory on some systems:
@@ -318,6 +351,9 @@ data types.")
#t))))
(arguments
(substitute-keyword-arguments (package-arguments python-2)
+ ((#:make-flags _)
+ ;; Strip tests exclusions that have to do with Python 2 only.
+ `(list (format #f "TESTOPTS=-j~d" (parallel-job-count))))
((#:phases phases)
`(modify-phases ,phases
;; Unset SOURCE_DATE_EPOCH while running the test-suite and set it
@@ -326,10 +362,7 @@ data types.")
(lambda _ (unsetenv "SOURCE_DATE_EPOCH") #t))
(add-after 'check 'reset-SOURCE_DATE_EPOCH
(lambda _ (setenv "SOURCE_DATE_EPOCH" "1") #t))
- ;; FIXME: Without this phase we have close to 400 files that
- ;; differ across different builds of this package. With this phase
- ;; there are 44 files left that differ.
- (add-after 'remove-tests 'rebuild-bytecode
+ (replace 'rebuild-bytecode
(lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
;; Disable hash randomization to ensure the generated .pycs
@@ -361,14 +394,6 @@ data types.")
;; Current 3.x version.
(define-public python-3 python-3.7)
-(define python-3/fixed
- (package
- (inherit python-3)
- (source (origin
- (inherit (package-source python-3))
- (patches (append (origin-patches (package-source python-3))
- (search-patches "python-CVE-2018-14647.patch")))))))
-
;; Current major version.
(define-public python python-3)
@@ -382,8 +407,10 @@ data types.")
;; 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
@@ -393,8 +420,10 @@ data types.")
;; 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)))))