From 03fd94c43731e8acf60b28ebf705adeedcc25061 Mon Sep 17 00:00:00 2001 From: Giacomo Leidi Date: Sat, 3 Jan 2026 01:59:09 +0100 Subject: [PATCH] gnu: python-pyinotify: Reduce package closure size. This Python package can be used both as a library and as a standalone command line application. It does so by adding a shebang to the library code. Dropping this shebang prevents the build system from adding python-wrapper as an input, reducing package closure size from ~200 MiB to ~0.2 MiB. A new python-pyinotify-cli package is added to allow users who desire so to use the CLI application. * gnu/packages/python-xyz.scm (python-pyinotify)[phases]{drop-shebang}: New phase. (python-pyinotify-cli): New variable. Change-Id: Ifb796d26fc6a7bedec69093f7c9bd43ada8bebac Signed-off-by: Sharlatan Hellseher Signed-off-by: Rutherther --- gnu/packages/python-xyz.scm | 42 ++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm index 4a2851ea2e7ea507588ad0b514d042465d7cac52..5b763e23090f0c4f175d1799b09fb301ae46912f 100644 --- a/gnu/packages/python-xyz.scm +++ b/gnu/packages/python-xyz.scm @@ -64,7 +64,7 @@ ;;; Copyright © 2019, 2020 Alex Griffin ;;; Copyright © 2019, 2020, 2021, 2022, 2023 Pierre Langlois ;;; Copyright © 2019 Jacob MacDonald -;;; Copyright © 2019-2021, 2023, 2024 Giacomo Leidi +;;; Copyright © 2019-2021, 2023, 2024, 2026 Giacomo Leidi ;;; Copyright © 2019 Wiktor Żelazny ;;; Copyright © 2019, 2020, 2021, 2022 Tanguy Le Carrour ;;; Copyright © 2019, 2021-2023 Mădălin Ionel Patrașcu @@ -26693,8 +26693,20 @@ interpreter. bpython's main features are (sha256 (base32 "0qfvs1sfvlpfb10rxlivwa96mg0ibczis554s2rx32s11nynzvbk")))) (build-system pyproject-build-system) - (arguments (list #:tests? #f)) ;no tests - (native-inputs (list python-setuptools)) + (arguments + (list + #:tests? #f ;no tests + #:phases + #~(modify-phases %standard-phases + (add-after 'unpack 'drop-shebang + (lambda _ + ;; Dropping this shebang prevents the build system from adding + ;; python-wrapper as an input, reducing package closure size from + ;; ~200 MiB to ~0.2 MiB. + (substitute* "python3/pyinotify.py" + (("#!/usr/bin/env python") ""))))))) + (native-inputs + (list python-setuptools)) (home-page "https://github.com/seb-m/pyinotify") (synopsis "Python library for monitoring inotify events") (description @@ -26702,6 +26714,30 @@ interpreter. bpython's main features are events on Linux.") (license license:expat))) +(define-public python-pyinotify-cli + (package + (inherit python-pyinotify) + (name "python-pyinotify-cli") + (arguments + (substitute-keyword-arguments (package-arguments python-pyinotify) + ((#:phases phases #~%standard-phases) + #~(modify-phases #$phases + (delete 'drop-shebang) + (add-after 'install 'install-entrypoint + (lambda _ + (let ((entrypoint + (string-append #$output "/lib/python" + (python-version (which "python")) + "/site-packages/pyinotify.py")) + (bin (string-append #$output "/bin"))) + (mkdir-p bin) + (invoke "chmod" "+x" entrypoint) + (symlink + entrypoint (string-append #$output "/bin/pyinotify"))))))))) + (description + "This package provides, in addition to the @code{pyinotify} Python library, +a command line application exposing the same functionality."))) + (define-public python-more-itertools (package (name "python-more-itertools")