me
/
guix
Archived
1
0
Fork 0

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.
master
Maxim Cournoyer 2020-10-20 21:32:05 -04:00
parent 4e0b3d7f9f
commit 6731fc6ab8
No known key found for this signature in database
GPG Key ID: 1260E46482E63562
1 changed files with 16 additions and 17 deletions

View File

@ -229,14 +229,12 @@
"--with-system-ffi" "--with-system-ffi"
"")))) ""))))
#t)) #t))
(add-before (add-before 'check 'pre-check
'check 'pre-check
(lambda _ (lambda _
;; 'Lib/test/test_site.py' needs a valid $HOME ;; 'Lib/test/test_site.py' needs a valid $HOME
(setenv "HOME" (getcwd)) (setenv "HOME" (getcwd))
#t)) #t))
(add-after (add-after 'unpack 'set-source-file-times-to-1980
'unpack 'set-source-file-times-to-1980
;; XXX One of the tests uses a ZIP library to pack up some of the ;; 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 ;; source tree, and fails with "ZIP does not support timestamps
;; before 1980". Work around this by setting the file times in the ;; before 1980". Work around this by setting the file times in the
@ -280,19 +278,20 @@
(lambda (opt) (lambda (opt)
(format #t "Compiling with optimization level: ~a\n" (format #t "Compiling with optimization level: ~a\n"
(if (null? opt) "none" (car opt))) (if (null? opt) "none" (car opt)))
(for-each (lambda (file) (apply invoke
(apply invoke `(,,(if (%current-target-system)
`(,,(if (%current-target-system) "python2"
"python2" '(string-append out "/bin/python"))
'(string-append out "/bin/python")) ,@opt
,@opt "-m" "compileall"
"-m" "compileall" "-f" ; force rebuild
"-f" ; force rebuild ;; Don't build lib2to3, because it contains Python 3 code.
;; Don't build lib2to3, because it contains Python 3 code. "-x" "lib2to3/.*"
"-x" "lib2to3/.*" ,out)))
,file))) ;; Python 2 has a single file extension (.pyo) for the chosen
(find-files out "\\.py$"))) ;; level of optimization, so it doesn't make sense to byte
(list '() '("-O") '("-OO"))) ;; compile with more than one level.
(list '() '("-OO")))
#t))) #t)))
(add-after 'install 'move-tk-inter (add-after 'install 'move-tk-inter
(lambda* (#:key outputs #:allow-other-keys) (lambda* (#:key outputs #:allow-other-keys)