unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Hartmut Goebel <h.goebel@crazy-compilers.com>
Cc: guix-devel <guix-devel@gnu.org>
Subject: Re: avoid wrapper scripts when possible
Date: Sun, 05 Nov 2017 18:06:17 +0100	[thread overview]
Message-ID: <87po8wpsdy.fsf@gnu.org> (raw)
In-Reply-To: <65968230-bd78-dfe7-2767-c1b7b89ad748@crazy-compilers.com> (Hartmut Goebel's message of "Sun, 5 Nov 2017 12:00:17 +0100")

Hi!

Hartmut Goebel <h.goebel@crazy-compilers.com> skribis:

> answering on a mail which Ricardo CCed to me and which did not make it
> to the list yet. Thus I full-quote.
>
> Am 04.11.2017 um 23:30 schrieb Ricardo Wurmus:
>> How about this:
>>
>> --8<---------------cut here---------------start------------->8---
>> #!/home/rekado/.guix-profile/bin/guile --no-auto-compile
>> #!# (let (($0 (car (command-line)))) (execl "/home/rekado/.guix-profile/bin/python3" $0 $0))
>> #!/home/rekado/.guix-profile/bin/python3
>> import sys; print("hello from python: "+sys.argv[0])
>> --8<---------------cut here---------------end--------------->8---
>>
>> The first two lines are Guile code, but they are also line comments in
>> shell, Perl, Python, Ruby, and R.  The Guile code in this example calls
>> the script again as a Python script.  Before doing that it can set
>> environment variables, like so:
>>
>> --8<---------------cut here---------------start------------->8---
>> #!/home/rekado/.guix-profile/bin/guile --no-auto-compile
>> #!#
>> #\- (setenv "PYTHONPATH" (string-append "/gnu/store/foo:/gnu/store/bar:" (getenv "PYTHONPATH")))
>> #\- (let (($0 (car (command-line)))) (execl "/home/rekado/.guix-profile/bin/python3" $0 $0))
>> #!/home/rekado/.guix-profile/bin/python3
>> import sys; print("hello from python: "+sys.argv[0])
>> print(sys.path)
>> --8<---------------cut here---------------end--------------->8---
>>
>> Did I overlook something?  Or could we use this hack to remove separate
>> wrapper scripts for Perl, Python, Ruby, and R?

Overall this looks good to me (with the adjustments Hartmut mentions).

Now, we should have a white list of languages for which this can be
done.  ‘wrap-program’ would grab the shebang and check if the
basename of the interpreter is in that white list.

Thoughts?

Ludo’.

  reply	other threads:[~2017-11-05 17:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-02 21:31 avoid wrapper scripts when possible Ricardo Wurmus
2017-11-03 18:54 ` Christopher Baines
2017-11-03 19:22   ` Jan Nieuwenhuizen
2017-11-03 21:17   ` Ricardo Wurmus
     [not found]     ` <874lqbghlz.fsf@elephly.net>
2017-11-03 22:41       ` Ricardo Wurmus
2017-11-05 11:10     ` Hartmut Goebel
2017-11-04 21:42   ` Eric Bavier
2017-11-04 10:12 ` Hartmut Goebel
     [not found]   ` <87tvy9ptge.fsf@elephly.net>
2017-11-05 11:00     ` Hartmut Goebel
2017-11-05 17:06       ` Ludovic Courtès [this message]
2017-11-06 15:53 ` Dave Love
  -- strict thread matches above, loose matches on Subject: below --
2021-09-07 18:52 Attila Lendvai
2021-09-07 20:41 ` Maxime Devos
2021-09-08  9:20   ` Attila Lendvai
2021-09-08 10:39     ` Maxime Devos
2021-09-24 21:38 John Kehayias

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87po8wpsdy.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guix-devel@gnu.org \
    --cc=h.goebel@crazy-compilers.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).