unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* shebang for python script?
@ 2023-01-25  6:09 jgart
  2023-01-25  6:12 ` jgart
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: jgart @ 2023-01-25  6:09 UTC (permalink / raw)
  To: help-guix

Hi Guixers,

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)}")


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: shebang for python script?
  2023-01-25  6:09 shebang for python script? jgart
@ 2023-01-25  6:12 ` jgart
  2023-01-25  9:35 ` zimoun
  2023-01-27  6:10 ` jgart
  2 siblings, 0 replies; 6+ messages in thread
From: jgart @ 2023-01-25  6:12 UTC (permalink / raw)
  To: help-guix

or this shebang pinned to a particular commit?

#!/usr/bin/env nix-shell
#!nix-shell -i python3 -p "python3.withPackages(ps: [ ps.numpy ])"
#!nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/d373d80b1207d52621961b16aa4a3438e4f98167.tar.gz
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)}")

https://ryantm.github.io/nixpkgs/languages-frameworks/python/


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: shebang for python script?
  2023-01-25  6:09 shebang for python script? jgart
  2023-01-25  6:12 ` jgart
@ 2023-01-25  9:35 ` zimoun
  2023-01-27  6:10 ` jgart
  2 siblings, 0 replies; 6+ messages in thread
From: zimoun @ 2023-01-25  9:35 UTC (permalink / raw)
  To: jgart, help-guix

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: shebang for python script?
  2023-01-25  6:09 shebang for python script? jgart
  2023-01-25  6:12 ` jgart
  2023-01-25  9:35 ` zimoun
@ 2023-01-27  6:10 ` jgart
  2023-01-27 11:15   ` Simon Tournier
  2023-01-27 15:42   ` jgart
  2 siblings, 2 replies; 6+ messages in thread
From: jgart @ 2023-01-27  6:10 UTC (permalink / raw)
  To: zimoun, help-guix

Hi, thanks!! 

Should we document this approach in the manual somewhere? 

If so, where would be a good place to mention how to do this?


> --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---
> 

> 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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: shebang for python script?
  2023-01-27  6:10 ` jgart
@ 2023-01-27 11:15   ` Simon Tournier
  2023-01-27 15:42   ` jgart
  1 sibling, 0 replies; 6+ messages in thread
From: Simon Tournier @ 2023-01-27 11:15 UTC (permalink / raw)
  To: jgart, help-guix

Hi,

On ven., 27 janv. 2023 at 06:10, "jgart" <jgart@dismail.de> wrote:

> Should we document this approach in the manual somewhere? 

An attempt here: <https://issues.guix.gnu.org/61094>

Cheers,
simon


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: shebang for python script?
  2023-01-27  6:10 ` jgart
  2023-01-27 11:15   ` Simon Tournier
@ 2023-01-27 15:42   ` jgart
  1 sibling, 0 replies; 6+ messages in thread
From: jgart @ 2023-01-27 15:42 UTC (permalink / raw)
  To: Simon Tournier, help-guix

> An attempt here: <https://issues.guix.gnu.org/61094>

Awesome!

Thanks for sending that. Much appreciated!

all best,

jgart


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-01-27 15:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-25  6:09 shebang for python script? jgart
2023-01-25  6:12 ` jgart
2023-01-25  9:35 ` zimoun
2023-01-27  6:10 ` jgart
2023-01-27 11:15   ` Simon Tournier
2023-01-27 15:42   ` jgart

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).