Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nix-shell command example in python docs #31197

Merged
merged 1 commit into from Nov 3, 2017
Merged

Fix nix-shell command example in python docs #31197

merged 1 commit into from Nov 3, 2017

Conversation

joncfoo
Copy link

@joncfoo joncfoo commented Nov 3, 2017

The nix-shell command here is incorrect AFAICT. -i is supposed to specify the interpreter and -p specifies the packages.

Fixes #31196

Motivation for this change

Incorrect example in documentation.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

The nix-shell command here is incorrect AFAICT.  `-i` is supposed to specify the interpreter and `-p` specifies the packages.
@joncfoo joncfoo requested a review from FRidh as a code owner November 3, 2017 15:30
@@ -165,7 +165,7 @@ run the script in the `python3` shell.

```py
#! /usr/bin/env nix-shell
#! nix-shell -i 'python3.withPackages(ps: [ps.numpy])'
#! nix-shell -i python3 -p 'python3.withPackages(ps: [ps.numpy])'
Copy link
Member

@Mic92 Mic92 Nov 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python3.withPackages(ps: [ps.numpy]) is a bit different here from pythonPackages. It will return something like a wrapped python interpreter, that includes all python packages gives as argument.
But you are right, the example does seem to work here. Maybe ! nix-shell -i python3 -p python3Packages.numpy is better then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Mic92 I think we shouldn't advertise anymore -p python3 -p python3.numpy because that works because of the shell hook which, in my opinion, is something for nix-shell development, and not for just creating an environment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well. but this approach does not work either:

$ cat ./test
#! /usr/bin/env nix-shell
#! nix-shell -i python3 -p 'python3.withPackages(ps: [ps.numpy])'
import numpy
$ ./test
error: syntax error, unexpected $undefined, at (string):1:94

Copy link
Member

@FRidh FRidh Nov 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, indeed. The quotes are incorrect. Need to be "

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nix-shell command example in python docs is wrong
5 participants