[bug#78828,5/8] build-system/pyproject: Avoid PEP427 substitution on binary files.

Message ID 20250619075859.10878-5-ngraves@ngraves.fr
State New
Headers
Series None |

Commit Message

Nicolas Graves June 19, 2025, 7:58 a.m. UTC
  In some rare cases, the dest-path can be an elf-file, which are
unreadable by substitute*, leading to an error instead of just
continuing which makes more sense in this case.

* guix/build-system/pyproject.scm (check): Guard substitution attempt
with basic readability guarantees.
---
 guix/build/pyproject-build-system.scm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
  

Patch

diff --git a/guix/build/pyproject-build-system.scm b/guix/build/pyproject-build-system.scm
index 1fa610faa9..1ca91701c3 100644
--- a/guix/build/pyproject-build-system.scm
+++ b/guix/build/pyproject-build-system.scm
@@ -218,10 +218,11 @@  (define (expand-data-directory directory)
            (lambda (file)
              (chmod file #o755)
              ;; PEP 427 recommends that installers rewrite
-             ;; this odd shebang.
-             (substitute* file
-               (("#!python")
-                (string-append "#!" python "/bin/python"))))
+             ;; this odd shebang, but avoid the binary case.
+             (unless (elf-file? file)
+               (substitute* file
+                 (("#!python")
+                  (string-append "#!" python "/bin/python")))))
            (find-files destination))))
       ;; Data can be contained in arbitrary directory structures.  Most
       ;; commonly it is used for share/.