manolomartinez / greg

A command-line podcast aggregator
GNU General Public License v3.0
298 stars 37 forks source link

pypi 0.4.3: "#!/usr/bin/env python3" gets changed to "#!/bin/python" on install #29

Closed ghost closed 9 years ago

ghost commented 9 years ago

Thanks for pushing the update to pypi, However I encounter the following problem:

When I run greg I'll see the following:

bash: /usr/local/bin/greg: /bin/python3: bad interpreter: No such file or directory

manolomartinez commented 9 years ago

Huh. I'm not seeing any problems here. You install by running pip install greg, don't you? What happens next?

Narrat commented 9 years ago

I would ask additionally for: What distro? Got /bin and /usr/bin merged? What result for "whereis python3?

At least the bad interpreter error looks like /bin and /usr/bin are separate things

manolomartinez commented 9 years ago

Yep, what Narrat said :)

ghost commented 9 years ago

Oops sorry. Yes, installed via pip install greg and I encounter the problems in first post: https://github.com/manolomartinez/greg/issues/29#issue-85822787

However, if I fully remove greg and then install from here on git, it works just fine!

python3: /usr/bin/python3.4-config /usr/bin/python3.4m-config /usr/bin/python3.4 /usr/bin/python3 /usr/bin/python3.4m /etc/python3.4 /etc/python3 /usr/lib/python3.4 /usr/lib/python3 /usr/bin/X11/python3.4-config /usr/bin/X11/python3.4m-config /usr/bin/X11/python3.4 /usr/bin/X11/python3 /usr/bin/X11/python3.4m /usr/local/lib/python3.4 /usr/include/python3.4 /usr/include/python3.4m /usr/share/python3 /usr/share/man/man1/python3.1.gz

If I install using python2.7 with pip2 install greg then I get this error:

File "/usr/local/bin/greg", line 2
SyntaxError: Non-ASCII character '\xc3' in file /usr/local/bin/greg on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

So then if I edit /usr/local/bin/greg to change first line to #!/usr/bin/python3 it then gives me this error

Traceback (most recent call last):
  File "/usr/local/bin/greg", line 17, in <module>
    from greg.gregparser import main 
ImportError: No module named 'greg'
Narrat commented 9 years ago

How do I determine if /bin and /usr/bin are merged? (I don't think they are...)

If /bin is a link to /usr/bin for example

One point of notice. iirc greg doesn't run under python2 (hence the encoding issue). Changing in the python2 environment the interpreter to py3 causes the problem, that it searches for the py3 module and cannot find it.

If running the correctly py3 pip version producing the error for file not found. hm Wonderous why the /usr/bin/env check returns the wrong path, as your python3 interpreter is installed in /usr/bin (and if /bin isn't a link to /usr/bin this will fail). Something is setting the wrong env (or at least looks like that) You could see what happens if you change

!/usr/bin/env python3

to

!/usr/bin/python3

ghost commented 9 years ago

Ok, my /bin and /usr/bin are separate directory.

I just did a fresh install of greg from pypi using pip install greg again receive the following error upon run: bash: /usr/local/bin/greg: /bin/python: bad interpreter: No such file or directory

So I looked in the file of /usr/local/bin/greg and see on first line: #!/bin/python and NOT #!/usr/bin/env python3 If I change it back to #!/usr/bin/env python3 or even #!/usr/bin/python3 everythign works fine!!

So this is a problem because I do not have /bin/python at all on my Ubuntu. So why on installation does that first line get changed to #!/bin/python ???

ghost commented 9 years ago

Ok when I do a build from git using pip install git+https://github.com/manolomartinez/greg the shebang line in /usr/local/bin/greg is set correctly to #!/usr/bin/python3 but when I install 0.4.3 from pypi the shebang is set to #!/bin/python - super odd, I have no idea why.

I think setuptools or distutils might be mangling the shebang line?

I wonder if my environment is messed up somehow. At any rate I'll stay with the git build for now instead of using pypi.

manolomartinez commented 9 years ago

Thanks for the report, I will try to understand what's going on and get back to you.

manolomartinez commented 9 years ago

All right, I've uploaded a test package to testpypi in which I only use setuptools. If you can, please install it with

pip install --index-url https://testpypi.python.org/pypi/ greg

and let me know if this behaves.

ghost commented 9 years ago

Yes! That works well for me, it installs correctly, and launches correctly. And the shebang of /usr/local/bin/greg is set correctly to #!/usr/bin/python3

Thanks again for making greg and for fixing the problems as they come up!!

ghost commented 9 years ago

Is there anything you need from me to help close this issue or help push the test version live?

Thanks again.

manolomartinez commented 9 years ago

Is there anything you need from me to help close this issue or help push the test version live?

Nudging me from time to time works fine ;) Done! M

ghost commented 9 years ago

Awesome, thanks again! I updated and everything is working well.