[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: shebang for python script?
From: |
zimoun |
Subject: |
Re: shebang for python script? |
Date: |
Wed, 25 Jan 2023 10:35:17 +0100 |
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