Launching a Script on the Linux Platform
Wildman
best_lay at yahoo.com
Tue Nov 12 15:24:25 EST 2019
On Tue, 12 Nov 2019 18:39:38 +0000, Rhodri James wrote:
> On 12/11/2019 18:25, Rob Gaddi wrote:
>> On 11/12/19 10:06 AM, Wildman wrote:
>>> What is the best approach for launching a Python GUI program
>>> on a Linux platform. The program will be distributed in .deb
>>> format. So the .deb will contain a menu file as well as a
>>> .desktop file. The post install script will update the system
>>> menu.
>>>
>>> My question is how should the program be executed? Here are
>>> two choices for the "command=" entry in the menu file...
>>>
>>> command="/path/to/program.py"
>>>
>>> In this case the hash-bang would have to be included in the
>>> program script... #!/usr/bin/env python3
>>>
>>> The other choice is this...
>>>
>>> command="python3 /path/to/program.py"
>>>
>>> (Of course, the Exec command in the .desktop file should match.)
>>>
>>> Is one method better than the other or does it acutally matter?
>>>
>>
>> I will note that without the shebang (and setting the execute bit), the
>> program is only executable from the GUI menu, not the command prompt. I
>> personally start even GUI programs far more often from a prompt.
>>
>> To follow Linux conventions you'd put the shebang, make the file
>> executable, and put the executable somewhere on the PATH. I'd stick to
>> those conventions barring a particular reason not to.
>
> Wildman is talking about launching his program from a menu, so putting
> it on the PATH is unnecessary. It may even be a bad idea, depending on
> exactly what he's done :-)
Yes, that is correct. My program would be installed using
a deb package manager such as apt and an entry placed in the
desktop menu to launch the program.
Thank you for the reply Rob.
> As to the original question, there shouldn't really be much of a
> difference. The original idea of the shebang line invoking env, as far
> I recall, was that you'd get the "proper" system python3 wherever it had
> been put rather than something random and possibly malicious. I guess
> that means to go for your first option.
Shebang! Yea, that is the correct term. All I could think
of was hashbang. I knew that wasn't quite right.
Yes, I prefer to envoke env in the shebang line instead of
depending on the path. Paths can change especially in a
multi-user system but env will always know where to find
the executable.
Thank you for your input. Shebang is the logical answer
with all else being equal.
--
<Wildman> GNU/Linux user #557453
"Setting a good example is a far better way
to spread ideals than through force of arms."
-Ron Paul
More information about the Python-list
mailing list