tbird20d / grabserial

Grabserial - python-based serial dump and timing program - good for embedded Linux development
GNU General Public License v2.0
195 stars 77 forks source link

Shebang Python location could cause not find the interpreter #60

Closed J-Rios closed 2 years ago

J-Rios commented 3 years ago

Context

Current shebang line in grabserial/putserial/setup.py files, that specify where to search by default for the Python interpreter, points to /usr/bin/python, but there is systems where the python binary could be in other path or could be multiple python versions, and can cause the scripts to not be executed directly:

./grabserial
-bash: ./grabserial: /usr/bin/python: bad interpreter: No such file or directory

Change Recomendation

Modify current shebang:

#!/usr/bin/python

To use env, that search in PATH enviroment variable fro the interpreter and is a best way for portability (find the interpreter in most systems):

#!/usr/bin/env python3

What do you think about it?

Regards.

tbird20d commented 3 years ago

I actually used "#!/usr/bin/env python2" a long time ago, and I had problems. I don't recall what they were, and unfortunately, the commit that changes that line (3bddb068) is silent on why the change back was made.

Given this history, I'm hesitant to change it. I suppose we could try it and see what breaks. I'd rather not switch to python3, though. Although I test with both python2 and python3, I still do development on grabserial with python2 as the primary language.

J-Rios commented 3 years ago

Maybe that problem just was related to thread creation order (maybe due closing exiting main thread before stein thread) and not to the shebang line. I agree to just try change it and see if there is any problem (I test it in current commit and didn't find any problem).

Regarding python2 vs python3... Due python2 is deprecated, it is recommended to move on into python3, however due you did a good work maintaining both version support, it could be ok to keep that way, supporting both, just we need to make sure to don't use/introduce some python2 specific code that could break python3 support or otherwise. But maybe we could use "python" in the shebang line, instead "python2" or "python3", and that can allow the user decide which version to use by just creating a Symlink for that:

#!/usr/bin/env python
github-actions[bot] commented 2 years ago

Stale issue message