shiv
shiv copied to clipboard
shiv generates invalid shebang line in git bash (windows/mingw)
Hi, I'm having a strange issue where the interpreter that ends up in the shiv zipapp is different from what I give it with the -p
option. I can't figure out where this translation is happening. I do this on Windows with "git bash", which is a mingw environment that ships with the standard git installer. Here are my steps, after setting up a venv and installing shiv:
/c/source/shiv$./env/Scripts/python --version
Python 3.6.8
/c/source/shiv$./env/Scripts/shiv --version
shiv, version 0.4.0
/c/source/shiv$uname -a
MINGW64_NT-10.0-14393 DEVHOST31 3.1.4-340.x86_64 2020-05-19 12:55 UTC x86_64 Msys
/c/source/shiv$./env/Scripts/shiv -e script:main -p '/usr/bin/env python' -r /dev/null -o out.pyz
/c/source/shiv$head -1 out.pyz
#!C:/Program Files/Git/usr/bin/env python
/c/source/shiv$./out.pyz
bash: ./out.pyz: C:/Program: bad interpreter: No such file or directory
Something is prefixing "C:/Program Files/Git/" to my provided interpreter, causing it to become invalid. Any help would be much appreciated!
Hi @aboulart,
That's pretty strange, I'm not familiar with mingw or your environment, the error indicates that having a space in your shebang is what's causing the error.
Can you try the following for me,
./env/Scripts/python
from shiv.builder import write_file_prefix
with open("test_file", "wb") as f:
write_file_prefix(f, "/usr/bin/env python")
And then tell me the contents of "test_file"? It should be simply: #!/usr/bin/env python
. Just trying to isolate where this could've gone wrong. Thanks!
That seems to work ok:
$ cat test_file
#!/usr/bin/env python
I'm not sure how git bash
behaves with regard to single quotes vs double quotes, but that's the only hunch I have as to how this could happen :/