emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#29856: closed ([PATCH core-updates] guix: python-b


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#29856: closed ([PATCH core-updates] guix: python-build-system: Modify ".py" files in-place.)
Date: Mon, 04 Feb 2019 07:59:02 +0000

Your message dated Mon, 04 Feb 2019 08:58:21 +0100
with message-id <address@hidden>
and subject line Re: [bug#29856] [PATCH core-updates] guix: 
python-build-system:, Modify ".py" files in-place.
has caused the debbugs.gnu.org bug report #29856,
regarding [PATCH core-updates] guix: python-build-system: Modify ".py" files 
in-place.
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
29856: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=29856
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: [PATCH core-updates] guix: python-build-system: Modify ".py" files in-place. Date: Tue, 26 Dec 2017 13:21:05 +0100
* guix/build/python-build-system.scm (wrap-python-program): New variable.
(wrap-program*): New variable.
(wrap): Use wrap-program*.
---
 guix/build/python-build-system.scm | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/guix/build/python-build-system.scm 
b/guix/build/python-build-system.scm
index dd07986b9..f5f6b07f8 100644
--- a/guix/build/python-build-system.scm
+++ b/guix/build/python-build-system.scm
@@ -25,6 +25,7 @@
   #:use-module (guix build utils)
   #:use-module (ice-9 match)
   #:use-module (ice-9 ftw)
+  #:use-module (ice-9 rdelim)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
   #:export (%standard-phases
@@ -184,6 +185,32 @@ when running checks after installing the package."
                          configure-flags)))
     (call-setuppy "install" params use-setuptools?)))
 
+(define (wrap-python-program file-name vars)
+  "Wrap the given program as a Python script (in-place)"
+  (match vars
+    (("PYTHONPATH" 'prefix python-path)
+     (let ((pythonish-path (string-join python-path "', '")))
+       (with-atomic-file-replacement file-name
+         (lambda (in out)
+           (display (format #f "#!~a
+import sys
+sys.path = ['~a'] + sys.path
+" (which "python") pythonish-path) out)
+           (let loop ((line (read-line in 'concat)))
+             (if (eof-object? line)
+               #t
+               (begin
+                 (display line out)
+                 (loop (read-line in 'concat)))))))))))
+
+(define (wrap-program* file-name vars)
+  "Wrap the given program.
+   If FILE-NAME is ending in '.py', wraps it in a Python way.
+   Otherwise wraps it in a Bash way."
+  (if (string-suffix? ".py" file-name)
+    (wrap-python-program file-name vars)
+    (wrap-program file-name vars)))
+
 (define* (wrap #:key inputs outputs #:allow-other-keys)
   (define (list-of-files dir)
     (map (cut string-append dir "/" <>)
@@ -209,7 +236,7 @@ when running checks after installing the package."
                         (or (getenv "PYTHONPATH") ""))))))
     (for-each (lambda (dir)
                 (let ((files (list-of-files dir)))
-                  (for-each (cut wrap-program <> var)
+                  (for-each (cut wrap-program* <> var)
                             files)))
               bindirs)))
 



--- End Message ---
--- Begin Message --- Subject: Re: [bug#29856] [PATCH core-updates] guix: python-build-system:, Modify ".py" files in-place. Date: Mon, 04 Feb 2019 08:58:21 +0100 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Danny Milosavljevic <address@hidden> writes:
>
> On Tue, 2 Jan 2018 17:13:15 +0100
> Hartmut Goebel <address@hidden> wrote:
>
>>   * it kills "from __future__ import", which must be the first import
>>     statement (or even the first statement after any doc-string) to work.
>
> ... oops.
>
>> Thus I suggest aiming to implement the solution discussed in that thread
>> (see esp.
>> <https://lists.gnu.org/archive/html/guix-devel/2017-11/msg00041.html>.
>
> I like that approach. Nice...
>
>> Beside of this, the patch suffers from some more issues. Sorry to say :-(
>> 
>>   * When converting PYTHONPATH into a list of python strings, these need
>>     to be quoted properly.
>
> I agree.
>
>>   * The description (commit-message) of the patch is much to terse. It
>>     should describe the the reason and implications. Esp. it should
>>     describe the case this is fixing.
>
> Sure.

I’m closing this in favour of #29951.

Thanks!



--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]