From 20d52562e5c943b30e48e310b58b94054c3a54e5 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Wed, 17 Mar 2021 13:33:22 +0100 Subject: gnu: python: Remove unnecessary files. * gnu/packages/python.scm (python2)[arguments]: Remove files built during the test phase. (python3)[arguments]: Also remove windows binaries shipped with the sources. --- gnu/packages/python.scm | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'gnu/packages/python.scm') diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm index c8129ce46c..9e29733091 100644 --- a/gnu/packages/python.scm +++ b/gnu/packages/python.scm @@ -31,8 +31,8 @@ ;;; Copyright © 2016 Dylan Jeffers ;;; Copyright © 2016, 2017 Alex Vong ;;; Copyright © 2016, 2017, 2018 Arun Isaac -;;; Copyright © 2016, 2017, 2018 Julien Lepiller ;;; Copyright © 2016–2018, 2021 Tobias Geerinckx-Rice +;;; Copyright © 2016, 2017, 2018, 2021 Julien Lepiller ;;; Copyright © 2016, 2017 Thomas Danckaert ;;; Copyright © 2017 Carlo Zancanaro ;;; Copyright © 2017 Frederick M. Muriithi @@ -295,7 +295,16 @@ (not (string-prefix? "test_support." file)))))) - (call-with-output-file "__init__.py" (const #t))))))))) + (call-with-output-file "__init__.py" (const #t)))) + (let ((libdir (string-append out "/lib/" pythonX.Y))) + (for-each + (lambda (directory) + (let ((dir (string-append libdir "/" directory))) + (when (file-exists? dir) + (delete-file-recursively dir)))) + '("email/test" "ctypes/test" "unittest/test" "tkinter/test" + "sqlite3/test" "bsddb/test" "lib-tk/test" "lib2to3/tests" + "json/tests" "distutils/tests")))))))) (add-after 'remove-tests 'rebuild-bytecode (lambda* (#:key outputs #:allow-other-keys) (let ((out (assoc-ref outputs "out"))) @@ -416,6 +425,9 @@ data types.") (substitute* "Modules/Setup" ;; Link Expat instead of embedding the bundled one. (("^#pyexpat.*") "pyexpat pyexpat.c -lexpat\n")) + ;; Delete windows binaries + (for-each delete-file + (find-files "Lib/distutils/command" "\\.exe$")) #t)))) (arguments (substitute-keyword-arguments (package-arguments python-2) @@ -461,6 +473,23 @@ data types.") ,@(if (hurd-system?) `((delete 'patch-regen-for-hurd)) ;regen was removed after 3.5.9 '()) + (add-after 'unpack 'remove-windows-binaries + (lambda _ + ;; Delete .exe from embedded .whl (zip) files + (for-each + (lambda (whl) + (let ((dir "whl-content")) + (mkdir-p dir) + (with-directory-excursion dir + (let ((whl (string-append "../" whl))) + (invoke "unzip" whl) + (for-each delete-file + (find-files "." "\\.exe$")) + (delete-file whl) + (apply invoke "zip" "-X" whl + (find-files "." ".*" #:directories? #t)))) + (delete-file-recursively dir))) + (find-files "Lib/ensurepip" "\\.whl$")))) (add-before 'check 'set-TZDIR (lambda* (#:key inputs native-inputs #:allow-other-keys) ;; test_email requires the Olson time zone database. @@ -495,6 +524,8 @@ data types.") ,(customize-site version)))))) (native-inputs `(("tzdata" ,tzdata-for-tests) + ("unzip" ,unzip) + ("zip" ,(@ (gnu packages compression) zip)) ,@(if (%current-target-system) `(("python3" ,this-package)) '()) -- cgit v1.2.3