Archived
1
0
Fork 0

gnu: python-2.7: Fix indentation.

* gnu/packages/python.scm (python-2.7): Fix indentation.
This commit is contained in:
Maxim Cournoyer 2020-10-20 21:25:20 -04:00
parent dd4a4603be
commit fbb74c82e1
No known key found for this signature in database
GPG key ID: 1260E46482E63562

View file

@ -110,51 +110,51 @@
(version "2.7.17") (version "2.7.17")
(source (source
(origin (origin
(method url-fetch) (method url-fetch)
(uri (string-append "https://www.python.org/ftp/python/" (uri (string-append "https://www.python.org/ftp/python/"
version "/Python-" version ".tar.xz")) version "/Python-" version ".tar.xz"))
(sha256 (sha256
(base32 (base32
"0hds28cg226m8j8sr394nm9yc4gxhvlv109w0avsf2mxrlrz0hsd")) "0hds28cg226m8j8sr394nm9yc4gxhvlv109w0avsf2mxrlrz0hsd"))
(patches (search-patches "python-2.7-search-paths.patch" (patches (search-patches "python-2.7-search-paths.patch"
"python-2-deterministic-build-info.patch" "python-2-deterministic-build-info.patch"
"python-2.7-site-prefixes.patch" "python-2.7-site-prefixes.patch"
"python-2.7-source-date-epoch.patch" "python-2.7-source-date-epoch.patch"
"python-2.7-adjust-tests.patch" "python-2.7-adjust-tests.patch"
"python-cross-compile.patch")) "python-cross-compile.patch"))
(modules '((guix build utils))) (modules '((guix build utils)))
(snippet (snippet
'(begin '(begin
;; Ensure the bundled copies of these libraries are not used. ;; Ensure the bundled copies of these libraries are not used.
(for-each delete-file-recursively (for-each delete-file-recursively
'("Modules/_ctypes/libffi" "Modules/expat" "Modules/zlib")) '("Modules/_ctypes/libffi" "Modules/expat" "Modules/zlib"))
(substitute* "Modules/Setup.dist" (substitute* "Modules/Setup.dist"
;; Link Expat instead of embedding the bundled one. ;; Link Expat instead of embedding the bundled one.
(("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n")) (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n"))
;; Suboptimal to delete failing tests here, but if we delete them in ;; 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 ;; the arguments then we need to make sure to strip out that phase
;; when it gets inherited by python and python-minimal. ;; when it gets inherited by python and python-minimal.
(for-each delete-file (for-each delete-file
'("Lib/test/test_compileall.py" '("Lib/test/test_compileall.py"
"Lib/test/test_ctypes.py" ; fails on mips64el "Lib/test/test_ctypes.py" ; fails on mips64el
"Lib/test/test_distutils.py" "Lib/test/test_distutils.py"
"Lib/test/test_import.py" "Lib/test/test_import.py"
"Lib/test/test_shutil.py" "Lib/test/test_shutil.py"
"Lib/test/test_socket.py" "Lib/test/test_socket.py"
"Lib/test/test_subprocess.py")) "Lib/test/test_subprocess.py"))
#t)))) #t))))
(outputs '("out" (outputs '("out"
"tk")) ;tkinter; adds 50 MiB to the closure "tk")) ;tkinter; adds 50 MiB to the closure
(build-system gnu-build-system) (build-system gnu-build-system)
(arguments (arguments
`(#:test-target "test" `(#:test-target "test"
#:configure-flags #:configure-flags
(list "--enable-shared" ;allow embedding (list "--enable-shared" ;allow embedding
"--with-system-expat" ;for XML support "--with-system-expat" ;for XML support
"--with-system-ffi" ;build ctypes "--with-system-ffi" ;build ctypes
"--with-ensurepip=install" ;install pip and setuptools "--with-ensurepip=install" ;install pip and setuptools
"--enable-unicode=ucs4" "--enable-unicode=ucs4"
;; Prevent the installed _sysconfigdata.py from retaining a reference ;; Prevent the installed _sysconfigdata.py from retaining a reference
@ -182,12 +182,12 @@
;; https://github.com/python/cpython/commit/529525fb5a8fd9b96ab4021311a598c77588b918. ;; https://github.com/python/cpython/commit/529525fb5a8fd9b96ab4021311a598c77588b918.
" --exclude test_urllib2_localnet test_httplib")) " --exclude test_urllib2_localnet test_httplib"))
#:modules ((ice-9 ftw) (ice-9 match) #:modules ((ice-9 ftw) (ice-9 match)
(guix build utils) (guix build gnu-build-system)) (guix build utils) (guix build gnu-build-system))
#:phases #:phases
(modify-phases %standard-phases (modify-phases %standard-phases
(add-before (add-before
'configure 'patch-lib-shells 'configure 'patch-lib-shells
(lambda _ (lambda _
;; This variable is used in setup.py to enable cross compilation ;; This variable is used in setup.py to enable cross compilation
;; specific switches. As it is not set properly by configure ;; specific switches. As it is not set properly by configure
@ -205,38 +205,38 @@
"Lib/test/test_subprocess.py")) "Lib/test/test_subprocess.py"))
(("/bin/sh") (which "sh"))) (("/bin/sh") (which "sh")))
#t)) #t))
,@(if (hurd-system?) ,@(if (hurd-system?)
`((add-before 'build 'patch-regen-for-hurd `((add-before 'build 'patch-regen-for-hurd
(lambda* (#:key inputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
(let ((libc (assoc-ref inputs "libc"))) (let ((libc (assoc-ref inputs "libc")))
(substitute* "Lib/plat-generic/regen" (substitute* "Lib/plat-generic/regen"
(("/usr/include/") (string-append libc "/include/"))) (("/usr/include/") (string-append libc "/include/")))
#t)))) #t))))
'()) '())
(add-before 'configure 'do-not-record-configure-flags (add-before 'configure 'do-not-record-configure-flags
(lambda* (#:key configure-flags #:allow-other-keys) (lambda* (#:key configure-flags #:allow-other-keys)
;; Remove configure flags from the installed '_sysconfigdata.py' ;; Remove configure flags from the installed '_sysconfigdata.py'
;; and 'Makefile' so we don't end up keeping references to the ;; and 'Makefile' so we don't end up keeping references to the
;; build tools. ;; build tools.
;; ;;
;; Preserve at least '--with-system-ffi' since otherwise the ;; Preserve at least '--with-system-ffi' since otherwise the
;; thing tries to build libffi, fails, and we end up with a ;; thing tries to build libffi, fails, and we end up with a
;; Python that lacks ctypes. ;; Python that lacks ctypes.
(substitute* "configure" (substitute* "configure"
(("^CONFIG_ARGS=.*$") (("^CONFIG_ARGS=.*$")
(format #f "CONFIG_ARGS='~a'\n" (format #f "CONFIG_ARGS='~a'\n"
(if (member "--with-system-ffi" configure-flags) (if (member "--with-system-ffi" configure-flags)
"--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
@ -247,85 +247,85 @@
(utime file circa-1980 circa-1980) (utime file circa-1980 circa-1980)
#t)) #t))
#t))) #t)))
(add-after 'install 'remove-tests (add-after 'install 'remove-tests
;; Remove 25 MiB of unneeded unit tests. Keep test_support.* ;; Remove 25 MiB of unneeded unit tests. Keep test_support.*
;; because these files are used by some libraries out there. ;; because these files are used by some libraries out there.
(lambda* (#:key outputs #:allow-other-keys) (lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out"))) (let ((out (assoc-ref outputs "out")))
(match (scandir (string-append out "/lib") (match (scandir (string-append out "/lib")
(lambda (name) (lambda (name)
(string-prefix? "python" name))) (string-prefix? "python" name)))
((pythonX.Y) ((pythonX.Y)
(let ((testdir (string-append out "/lib/" pythonX.Y (let ((testdir (string-append out "/lib/" pythonX.Y
"/test"))) "/test")))
(with-directory-excursion testdir (with-directory-excursion testdir
(for-each delete-file-recursively (for-each delete-file-recursively
(scandir testdir (scandir testdir
(match-lambda (match-lambda
((or "." "..") #f) ((or "." "..") #f)
("support" #f) ("support" #f)
(file (file
(not (not
(string-prefix? "test_support." (string-prefix? "test_support."
file)))))) file))))))
(call-with-output-file "__init__.py" (const #t)) (call-with-output-file "__init__.py" (const #t))
#t))))))) #t)))))))
(add-after 'remove-tests 'rebuild-bytecode (add-after 'remove-tests 'rebuild-bytecode
(lambda* (#:key outputs #:allow-other-keys) (lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out"))) (let ((out (assoc-ref outputs "out")))
;; Disable hash randomization to ensure the generated .pycs ;; Disable hash randomization to ensure the generated .pycs
;; are reproducible. ;; are reproducible.
(setenv "PYTHONHASHSEED" "0") (setenv "PYTHONHASHSEED" "0")
(for-each (for-each
(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) (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/.*"
,file))) ,file)))
(find-files out "\\.py$"))) (find-files out "\\.py$")))
(list '() '("-O") '("-OO"))) (list '() '("-O") '("-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)
;; When Tkinter support is built move it to a separate output so ;; When Tkinter support is built move it to a separate output so
;; that the main output doesn't contain a reference to Tcl/Tk. ;; that the main output doesn't contain a reference to Tcl/Tk.
(let ((out (assoc-ref outputs "out")) (let ((out (assoc-ref outputs "out"))
(tk (assoc-ref outputs "tk"))) (tk (assoc-ref outputs "tk")))
(when tk (when tk
(match (find-files out "tkinter.*\\.so") (match (find-files out "tkinter.*\\.so")
((tkinter.so) ((tkinter.so)
;; The .so is in OUT/lib/pythonX.Y/lib-dynload, but we ;; The .so is in OUT/lib/pythonX.Y/lib-dynload, but we
;; want it under TK/lib/pythonX.Y/site-packages. ;; want it under TK/lib/pythonX.Y/site-packages.
(let* ((len (string-length out)) (let* ((len (string-length out))
(target (string-append (target (string-append
tk "/" tk "/"
(string-drop (string-drop
(dirname (dirname tkinter.so)) (dirname (dirname tkinter.so))
len) len)
"/site-packages"))) "/site-packages")))
(install-file tkinter.so target) (install-file tkinter.so target)
(delete-file tkinter.so))))) (delete-file tkinter.so)))))
#t)))))) #t))))))
(inputs (inputs
`(("bzip2" ,bzip2) `(("bzip2" ,bzip2)
("expat" ,expat) ("expat" ,expat)
("gdbm" ,gdbm) ("gdbm" ,gdbm)
("libffi" ,libffi) ; for ctypes ("libffi" ,libffi) ; for ctypes
("sqlite" ,sqlite) ; for sqlite extension ("sqlite" ,sqlite) ; for sqlite extension
("openssl" ,openssl) ("openssl" ,openssl)
("readline" ,readline) ("readline" ,readline)
("zlib" ,zlib) ("zlib" ,zlib)
("tcl" ,tcl) ("tcl" ,tcl)
("tk" ,tk))) ; for tkinter ("tk" ,tk))) ; for tkinter
(native-inputs (native-inputs
`(("pkg-config" ,pkg-config) `(("pkg-config" ,pkg-config)
;; When cross-compiling, a native version of Python itself is needed. ;; When cross-compiling, a native version of Python itself is needed.