From: zimoun <zimon.toutoune@gmail.com>
To: jgart <jgart@dismail.de>, help-guix@gnu.org
Subject: Re: shebang for python script?
Date: Wed, 25 Jan 2023 10:35:17 +0100 [thread overview]
Message-ID: <86zga7554a.fsf@gmail.com> (raw)
In-Reply-To: <b689e8c713beda5b748c9817c58c5fd5@dismail.de>
Hi,
On Wed, 25 Jan 2023 at 06:09, "jgart" <jgart@dismail.de> wrote:
> What's the current recommended way to do this in Guix?
>
> #!/usr/bin/env nix-shell
> #!nix-shell -i python3 -p "python3.withPackages(ps: [ ps.numpy ])"
> import numpy as np
> a = np.array([1,2])
> b = np.array([3,4])
> print(f"The dot product of {a} and {b} is: {np.dot(a, b)}")
Something like:
--8<---------------cut here---------------start------------->8---
#!/usr/bin/env -S guix shell python -- python3
import numpy as np
a = np.array([1,2])
b = np.array([3,4])
print(f"The dot product of {a} and {b} is: {np.dot(a, b)}")
--8<---------------cut here---------------end--------------->8---
works for me.
And to answer your other question about specific revision, I would do:
--8<---------------cut here---------------start------------->8---
#!/usr/bin/env -S guix time-machine --commit=29efa27 -- shell python -- python3
import numpy as np
a = np.array([1,2])
b = np.array([3,4])
print(f"The dot product of {a} and {b} is: {np.dot(a, b)}")
--8<---------------cut here---------------end--------------->8---
Cheers,
simon
next prev parent reply other threads:[~2023-01-25 10:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-25 6:09 shebang for python script? jgart
2023-01-25 6:12 ` jgart
2023-01-25 9:35 ` zimoun [this message]
2023-01-27 6:10 ` jgart
2023-01-27 11:15 ` Simon Tournier
2023-01-27 15:42 ` jgart
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=86zga7554a.fsf@gmail.com \
--to=zimon.toutoune@gmail.com \
--cc=help-guix@gnu.org \
--cc=jgart@dismail.de \
/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.
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).