Is it possible to install icons and launchers using a setup.py
file, setuptools and PyPI? Like, I'm talking about including .desktop
launcher files for Python scripts included in the package and .svg
icons for those launchers. Usually the .desktop
files would be installed at /usr/share/applications
and the icons would be installed at /usr/share/icons
.
Asked
Active
Viewed 968 times
3

BlandCorporation
- 1,324
- 1
- 15
- 33
-
Did you see [this](https://stackoverflow.com/questions/501597/how-to-distribute-desktop-files-and-icons-for-a-python-package-in-gnome-with)?Seems to provide some type of solution. However it's a very old answer. Maybe it gives you a starting point to search for more up-to-date approaches? – idjaw Jan 29 '18 at 14:07
1 Answers
2
It's possible with data_files
but not recommended. Think about a package installed into a separate environment created with virtualenv
— users will be surprised if such a package installs files outside that separate environment.
Hence advice: distinguish pip-installable package that must be self-contained and must not install anything beyond python code and files required for the code (could be installed with package_data
) from full-blown installable package created with installer builders like RPM or DEB.

phd
- 82,685
- 13
- 120
- 165
-
shouldn't `MANIFEST.in` be enough for [adding any non-code file](https://python-packaging.readthedocs.io/en/latest/non-code-files.html)? – jar Nov 20 '18 at 04:08
-
You couldn't install `.desktop` with `MANIFEST.in` or `package_data` into `/usr` or `$HOME`. `MANIFEST.in` and `package_data` are for installing into `site-packages`. `data_files` can be used to install anywhere, but it's not recommended. – phd Nov 20 '18 at 12:57
-
So the idea is that, if you have non code files like some icons or images for a GUI app, then you can keep those files in `site-packages` using `MANIFEST.in`. And if your package itself installs other things while installing itself, then MANIFEST.in is useless? Is this understanding correct ? – jar Nov 20 '18 at 13:08
-
It's not useless, it's for a different purpose. `MANIFEST.in` and `package_data` are for installing into `site-packages`, `data_files` is to install anywhere. – phd Nov 20 '18 at 13:11
-
Pardon me for asking this as I started with packaging just a couple of days ago, but if something is part of a library, then shouldn't it also be installed in `site-packages` ? Could you give me some cases in which installing it elsewhere would be desirable? – jar Nov 20 '18 at 13:17
-
The question mentions `.desktop` files and icons. Those belong to the desktop directories in `/usr` or `$HOME`, not to `site-packages`. – phd Nov 20 '18 at 13:19
-
Okay, so now I understand this. You want to have some file and an icon in `.desktop` so as to have a shortcut in the launcher or make it appear like any other program you install in linux? So in this case it is imperative that you install these files in `.desktop` directory? Is this interpretation correct? – jar Nov 20 '18 at 13:24
-