aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2023-03-09 22:33:05 +0100
committerLudovic Courtès <ludo@gnu.org>2023-03-09 22:33:05 +0100
commitaf916f3f8b5e1191cdcc95dded1e376f51ad9e9b (patch)
treecd790b92c722f220ca373bfa07fcd025c65ec21d
parentef893df92ae40b9572a2be093c75762fa752fbbb (diff)
downloadguix-af916f3f8b5e1191cdcc95dded1e376f51ad9e9b.tar
guix-af916f3f8b5e1191cdcc95dded1e376f51ad9e9b.tar.gz
gnu: python-wrapper: Refer to the target Python when cross-compiling.
Previously, "guix build python-wrapper --target=aarch64-linux-gnu" would return a wrapper that symlinks the native programs (e.g., 'python3' for x86_64-linux) instead of the target programs. * gnu/packages/python.scm (wrap-python3)[arguments]: Use gexps. Use 'this-package-input' to refer to Python when cross-compiling.
-rw-r--r--gnu/packages/python.scm46
1 files changed, 27 insertions, 19 deletions
diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 6abc5cdd88..3e3074d5d8 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -635,30 +635,38 @@ for more information.")))
(inputs `(("bash" ,bash)))
(propagated-inputs `(("python" ,python)))
(arguments
- `(#:modules ((guix build utils))
- #:builder
- (begin
- (use-modules (guix build utils))
- (let ((bin (string-append (assoc-ref %outputs "out") "/bin"))
- (python (string-append (assoc-ref %build-inputs "python") "/bin/")))
- (mkdir-p bin)
- (for-each
+ (list #:modules '((guix build utils))
+ #:builder
+ #~(begin
+ (use-modules (guix build utils))
+
+ ;; TODO: Remove 'assoc-ref' uses on next rebuild cycle.
+ (let ((bin (string-append (assoc-ref %outputs "out") "/bin"))
+ (python (string-append
+ ;; XXX: '%build-inputs' contains the native
+ ;; Python when cross-compiling.
+ #$(if (%current-target-system)
+ (this-package-input "python")
+ #~(assoc-ref %build-inputs "python"))
+ "/bin/")))
+ (mkdir-p bin)
+ (for-each
(lambda (old new)
(symlink (string-append python old)
(string-append bin "/" new)))
`("python3" ,"pydoc3" ,"pip3")
`("python" ,"pydoc" ,"pip"))
- ;; python-config outputs search paths based upon its location,
- ;; use a bash wrapper to avoid changing its outputs.
- (let ((bash (string-append (assoc-ref %build-inputs "bash")
- "/bin/bash"))
- (old (string-append python "python3-config"))
- (new (string-append bin "/python-config")))
- (with-output-to-file new
- (lambda ()
- (format #t "#!~a~%" bash)
- (format #t "exec \"~a\" \"$@\"~%" old)
- (chmod new #o755))))))))
+ ;; python-config outputs search paths based upon its location,
+ ;; use a bash wrapper to avoid changing its outputs.
+ (let ((bash (string-append (assoc-ref %build-inputs "bash")
+ "/bin/bash"))
+ (old (string-append python "python3-config"))
+ (new (string-append bin "/python-config")))
+ (with-output-to-file new
+ (lambda ()
+ (format #t "#!~a~%" bash)
+ (format #t "exec \"~a\" \"$@\"~%" old)
+ (chmod new #o755))))))))
(synopsis "Wrapper for the Python 3 commands")
(description
"This package provides wrappers for the commands of Python@tie{}3.x such