2

How can I add "double-click" shortcuts to my python application with setuptools?

I actively develop a program that is used in our lab by myself and a handful of less tech savvy people. I distribute the app via PyPI/setuptools packages, and currently a "gui_scripts" entry point which launches a Qt GUI. I'm aware of freezing options like py2exe/app, but prefer setuptools since it allows for faster testing and deployment within the lab.

I'm looking for a way to add some kind of application shortcut or start-menu entry for my program to make it simpler to access for those not used to a command line.

On windows python creates an exe file in the python bin, is there a way to automatically create a shortcut to this on the desktop upon install? Perhaps with a custom icon? Do I have any similar options for mac/linux as far as appearing in the launchpad?

Thank you for the help!

1
  • Funny, I would have expected there to be an answer to this already. I only found these two though: batch files for windows and .desktop files for ubuntu. I don't think it's a good idea to create the icon during each install by running some platform specific code in the setup.py. The icon should just point to the latest installation and execute it. Commented Jun 21, 2019 at 6:47

1 Answer 1

1

Whereas it is not a setuptools feature, you might want to look into pyshortcuts package that creates shortcuts across the different operating systems:

from pyshortcuts import make_shortcut

make_shortcut('/home/user/bin/myapp.py', name='MyApp',
                        icon='/home/user/icons/myicon.ico')

https://pypi.org/project/pyshortcuts/

This library could be in turn combined with setuptools by running the script after the installation, as shown here:

Another option is to use the distutils which can create an installation file. Specifically setup.py bdist feature which allows for using a post-installation script which can make use of create_shortcut function.

https://docs.python.org/3/distutils/builtdist.html

Here is someone using it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.