[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/03: gnu: python-2.7: Byte compile files with a single optimization le
From: |
guix-commits |
Subject: |
03/03: gnu: python-2.7: Byte compile files with a single optimization level. |
Date: |
Tue, 20 Oct 2020 22:42:28 -0400 (EDT) |
apteryx pushed a commit to branch core-updates
in repository guix.
commit 6731fc6ab891c3d6c4f762d54a45e79a4ae40dad
Author: Maxim Cournoyer <maxim.cournoyer@gmail.com>
AuthorDate: Tue Oct 20 21:32:05 2020 -0400
gnu: python-2.7: Byte compile files with a single optimization level.
* gnu/packages/python.scm (python-2.7)[phases]{rebuild-bytecode}: Byte
compile
using optimization level, -OO. Provide the output directory as the source
argument to 'compileall', instead of looping over each individual source
file.
---
gnu/packages/python.scm | 33 ++++++++++++++++-----------------
1 file changed, 16 insertions(+), 17 deletions(-)
diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 2e057a7..3414ad9 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -229,14 +229,12 @@
"--with-system-ffi"
""))))
#t))
- (add-before
- 'check 'pre-check
+ (add-before 'check 'pre-check
(lambda _
;; 'Lib/test/test_site.py' needs a valid $HOME
(setenv "HOME" (getcwd))
#t))
- (add-after
- 'unpack 'set-source-file-times-to-1980
+ (add-after 'unpack 'set-source-file-times-to-1980
;; XXX One of the tests uses a ZIP library to pack up some of the
;; source tree, and fails with "ZIP does not support timestamps
;; before 1980". Work around this by setting the file times in the
@@ -280,19 +278,20 @@
(lambda (opt)
(format #t "Compiling with optimization level: ~a\n"
(if (null? opt) "none" (car opt)))
- (for-each (lambda (file)
- (apply invoke
- `(,,(if (%current-target-system)
- "python2"
- '(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")))
+ (apply invoke
+ `(,,(if (%current-target-system)
+ "python2"
+ '(string-append out "/bin/python"))
+ ,@opt
+ "-m" "compileall"
+ "-f" ; force rebuild
+ ;; Don't build lib2to3, because it contains Python
3 code.
+ "-x" "lib2to3/.*"
+ ,out)))
+ ;; Python 2 has a single file extension (.pyo) for the chosen
+ ;; level of optimization, so it doesn't make sense to byte
+ ;; compile with more than one level.
+ (list '() '("-OO")))
#t)))
(add-after 'install 'move-tk-inter
(lambda* (#:key outputs #:allow-other-keys)