-
-
Notifications
You must be signed in to change notification settings - Fork 221
Installing menu shortcuts via setup.py rather than on first run #82
Comments
Thanks. your code snippet looks good. I had tried other stuff on the setup.py before, but most of them didn't end up in the wheel (the python binary distribution), because, the wheel marking follows a complicated procedure within itself. However, the current code snippet looks really genuine to me, and I guess it will work. I will test it shortly and let you know. For Linux, here is what I think can be done:
I have to still do this on the first run because
all the above binaries, do not use the thanks for your analysis. I would surely take this into account and give you appropriate credit of it works out well. (I hope adding the above snippet won't cause any FileNotFoundError on Windows 😂) thanks again |
OK. Sounds reasonable. BTW, the snippet comes from the SO post I linked to, so you should actually credit the author of the post. But, honestly, only a single line is relevant and you'll need to modify it anyway so if I were the author I wouldn't be upset about not being credited for something like this :) |
I would add the SO link to the setup.py if I use it. I haven't tested on WIndows yet. Will let you know soon. :) |
@cameel Fixed it; releasing v3.9 (stable) in a few hours |
I originally mentioned the shortcuts in #80 but they were only tangentially related to that issue (a crash) so I'm creating a new one. By the way, I'm posting it mainly because I see an easy and elegant solution but please don't bother with it if it turns out to be more complicated than this. The shortcuts are not really all that important.
Shortcuts
Currently the application on Linux creates two
.desktop
files: one on user's desktop (desktop shortcut) and the other inshare/applications/
(menu shortcut).Menu shortcut
When the application runs, it's already too late for creating a menu shortcut because the it may not have enough privileges to put it in the right place. E.g. the menu shortcut should be placed in
/usr/share/applications/
if the app was installed globally, for all users, not in~/.local/share/applications/
. Fortunatelysetuptools
provides a way to deal with that insetup.py
.The solution is nicely described in this SO answer: Install .desktop file with setup.py. Basically, if you add the shortcut to
data_files
in yoursetup.py
and use a relative path toshare/applications
, the script will put it in the right place, depending on whether the installation is local or global.Here's the relevant example from that post:
Desktop shortcut
I think that the "right" solution that follows conventions of each platform would be to create such a shortcut only on Windows. I don't think that users expect a desktop shortcut on Linux and there's no standard mechanism in
setup.py
or package installers to create one. But if some users were confused and asked for it even on Linux then, well, one shortcut is not a big deal. Better to have happy users than to be too strict and lose them :) Also, it would require creating an actual Windows installer, which is a big effort just for a shortcut.So for desktop shortcut I'd say that creating it on first run is fine. If user does not want it, it can be easily deleted. Or you could provide a command-line flag (e.g.
--no-desktop-shortcut
) and/or an option in configuration file for those who really hate desktop shortcuts with a passion :)The text was updated successfully, but these errors were encountered: