git-imerge icon indicating copy to clipboard operation
git-imerge copied to clipboard

Add Python3 shebang

Open abitrolly opened this issue 4 years ago • 9 comments
trafficstars

abitrolly avatar Mar 31 '21 12:03 abitrolly

My understanding was that python setup.py install would somehow arrange for this to be invoked as a module by the correct python interpreter. @jdufresne do you have an opinion about whether a shebang line would be beneficial?

mhagger avatar Apr 26 '21 15:04 mhagger

Not sure if that's true for Linux. I just run it from source with my dirty hacks and system interpreter.

abitrolly avatar Apr 26 '21 15:04 abitrolly

My understanding was that python setup.py install would somehow arrange for this to be invoked as a module by the correct python interpreter. @jdufresne do you have an opinion about whether a shebang line would be beneficial?

Yes, that is correct. Hard coding the Python path is unnecessary and discouraged with modern setuptools entry points.

@abitrolly If you want to run if from source, do python3 gitimerge.py or use your preferred Python path.

If you want it to be self executing, please install it using pip or setuptools.

jdufresne avatar Apr 26 '21 20:04 jdufresne

Yes, that is correct. Hard coding the Python path is unnecessary and discouraged with modern setuptools entry points.

It is not hardcoding, because it uses /usr/bin/env. And I would be interested to see a proof link where shebangs are discouraged in favor of setuptools installation process. If I remember correctly setuptools writes its own launcher script for entrypoints without relying on shebang in imported file.

If you want it to be self executing, please install it using pip or setuptools.

What is the benefit of installing it if it works without installing?

abitrolly avatar Apr 27 '21 06:04 abitrolly

@jdufresne so can you provide a reference explaining why shebangs are discouraged?

abitrolly avatar May 31 '21 01:05 abitrolly

The shebang is added by setuptools, there is no need to hardcode it. Setuptools handles Python running from any environment, be it system, virtualenv, or an unusual custom installation.

jdufresne avatar May 31 '21 14:05 jdufresne

@jdufresne setuptools doesn't modify source code. It creates its own launcher scripts, which use Python import mechanism, which means that this change doesn't conflict with setuptools.

abitrolly avatar May 31 '21 14:05 abitrolly

It creates its own launcher scripts

Correct. Please use the setuptools CLI entry point or python -m gitimerge to run the program after installation.

jdufresne avatar May 31 '21 16:05 jdufresne

@jdufresne why are you insist on installation? The package runs fine from sources, allows to easily modify it without setuptools, virtualenv and entrypoints. I understand that maybe you've had some traumatic experience without setuptools, but so do I when I am forced to install scripts that work perfectly fine without installation. It should be sufficient that shebang doesn't break anything.

abitrolly avatar May 31 '21 18:05 abitrolly