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.scm85
1 files changed, 77 insertions, 8 deletions
diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 05d3390604..51cc1cf5f0 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -138,7 +138,7 @@
(define-public python-2.7
(package
- (name "python")
+ (name "python2")
(version "2.7.14")
(source
(origin
@@ -338,7 +338,8 @@ data types.")
(define-public python-3.6
(package (inherit python-2)
- (version "3.6.3")
+ (name "python")
+ (version "3.6.4")
(source (origin
(method url-fetch)
(uri (string-append "https://www.python.org/ftp/python/"
@@ -351,7 +352,7 @@ data types.")
(patch-flags '("-p0"))
(sha256
(base32
- "1nl1raaagr4car787a2hmjv2dw6gqny53xfd6wisbgx4r5kxk9yd"))
+ "1fna7g8jxzl4kd2pqmmqhva5724c5m920x3fsrpsgskaylmr76qm"))
(snippet
'(begin
(for-each delete-file
@@ -359,8 +360,75 @@ data types.")
"Lib/ctypes/test/test_win32.py" ; fails on aarch64
"Lib/test/test_fcntl.py")) ; fails on aarch64
#t))))
- (arguments (substitute-keyword-arguments (package-arguments python-2)
- ((#:tests? _) #t)))
+ (arguments
+ (substitute-keyword-arguments (package-arguments python-2)
+ ((#:tests? _) #t)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ (add-after 'unpack 'patch-timestamp-for-pyc-files
+ (lambda _
+ ;; We set DETERMINISTIC_BUILD to only override the mtime when
+ ;; building with Guix, lest we break auto-compilation in
+ ;; environments.
+ (setenv "DETERMINISTIC_BUILD" "1")
+ (substitute* "Lib/py_compile.py"
+ (("source_stats\\['mtime'\\]")
+ "(1 if 'DETERMINISTIC_BUILD' in os.environ else source_stats['mtime'])"))
+
+ ;; Use deterministic hashes for strings, bytes, and datetime
+ ;; objects.
+ (setenv "PYTHONHASHSEED" "0")
+
+ ;; Reset mtime when validating bytecode header.
+ (substitute* "Lib/importlib/_bootstrap_external.py"
+ (("source_mtime = int\\(source_stats\\['mtime'\\]\\)")
+ "source_mtime = 1"))
+ #t))
+ ;; These tests fail because of our change to the bytecode
+ ;; validation. They fail because expected exceptions do not get
+ ;; thrown. This seems to be no problem.
+ (add-after 'unpack 'disable-broken-bytecode-tests
+ (lambda _
+ (substitute* "Lib/test/test_importlib/source/test_file_loader.py"
+ (("test_bad_marshal")
+ "disable_test_bad_marshal")
+ (("test_no_marshal")
+ "disable_test_no_marshal")
+ (("test_non_code_marshal")
+ "disable_test_non_code_marshal"))
+ #t))
+ ;; Unset DETERMINISTIC_BUILD to allow for tests that check that
+ ;; stale pyc files are rebuilt.
+ (add-before 'check 'allow-non-deterministic-compilation
+ (lambda _ (unsetenv "DETERMINISTIC_BUILD") #t))
+ ;; We need to rebuild all pyc files for three different
+ ;; optimization levels to replace all files that were not built
+ ;; deterministically.
+
+ ;; FIXME: Without this phase we have close to 2000 files that
+ ;; differ across different builds of this package. With this phase
+ ;; there are about 500 files left that differ.
+ (add-after 'install 'rebuild-bytecode
+ (lambda* (#:key outputs #:allow-other-keys)
+ (setenv "DETERMINISTIC_BUILD" "1")
+ (let ((out (assoc-ref outputs "out")))
+ (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/python3")
+ ,@opt
+ "-m" "compileall"
+ "-f" ; force rebuild
+ ;; Don't build lib2to3, because it's Python 2 code.
+ ;; Also don't build obviously broken test code.
+ "-x" "(lib2to3|test/bad.*)"
+ ,file)))
+ (find-files out "\\.py$")))
+ (list '() '("-O") '("-OO")))
+ #t)))))))
(native-search-paths
(list (search-path-specification
(variable "PYTHONPATH")
@@ -379,7 +447,7 @@ data types.")
(define-public python2-minimal
(package (inherit python-2)
- (name "python-minimal")
+ (name "python2-minimal")
(outputs '("out"))
;; Keep zlib, which is used by 'pip' (via the 'zipimport' module), which
@@ -1026,7 +1094,7 @@ from the Python interpreter, or as a small part of a larger application.")
(modify-phases %standard-phases
(replace 'check
(lambda _
- (zero? (system* "py.test" "-v")))))))
+ (invoke "py.test" "-v"))))))
(native-inputs
`(("python-py" ,python-py)
("python-pytest" ,python-pytest-bootstrap)))
@@ -3187,7 +3255,8 @@ that client code uses to construct the grammar directly in Python code.")
;; input since it would create a circular dependency: Extend the
;; test for Python 3, where it is already dropped, to Python 2.
(substitute* "numpydoc/tests/test_plot_directive.py"
- (("3") "2"))))))
+ (("3") "2"))
+ #t))))
(build-system python-build-system)
(propagated-inputs
`(("python-sphinx" ,python-sphinx)))