AeglosGreenleaf
AeglosGreenleaf

Reputation: 45

Python Setuptools Package with Easy "double-click" Entrypoints

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!

Upvotes: 2

Views: 488

Answers (1)

mateuszb
mateuszb

Reputation: 1102

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.

Upvotes: 1

Related Questions