I have setup a Python environnement in nix
that contains the several Python modules. The python
executable is a wrapper around the python
interpreter:
% less /Users/smaret/.nix-profile/bin/python
#! /nix/store/cblfnvb5rmhd2z231mqasn0brzh1hhv4-bash-4.4-p23/bin/bash -e
export PYTHONHOME='/nix/store/avqvqqqsrbrcpja4avvw9sfff2bfwm8c-python-2.7.15-env'
export PYTHONNOUSERSITE='true'
exec "/nix/store/s9mj8zzg7b0zj7s0k4rx3hdsiayr3ckn-python-2.7.15/bin/python" "${extraFlagsArray[@]}" "$@"
I would like to use this wrapper in a script shebang to make sure that this Python environnement is used when running the script:
% cat test.py
#!/Users/smaret/.nix-profile/bin/python
print("hello world")
However it seems that the shebang does not launch Python:
% ./test.py
./test.py: line 2: syntax error near unexpected token `"hello world"'
./test.py: line 2: `print("hello world")'
% /Users/smaret/.nix-profile/bin/python test.py
hello world
Is there a way to make the wrapper work in a shebang?