0

I've written a python application and I use cx_freeze to freeze the scripts and create the executable. Then I'm making it into a single executable bin package using shell scripts.

Recently I developed a context menu extension using nautilus-python and would like to include the same with my application bundle. Obviously I can't place the .py file under under ~/.local/share/nautilus-python/extensions. I tried with just placing the .pyc file alone with executable bit enabled for the script which didn't work.

Any pointers reg this would be greatly helpful.

TFA
  • 81
  • 10

1 Answers1

0

cx_Freeze is fine for Windows or Mac but on Linux systems, applications are expected to be installed with package manager. Usually, distributions have designated people who will create the packages. Alternatively, you can choose distributions you want to support and create the packages for them yourself, or you can use service like OBS.

If you really want to provide a single executable for people to drop into a directory they have on PATH, you will need to provide the extension separately.

Please do not make the application install the extension on start-up, user should retain control over their computer. Or if you do that, please add a setup.py flag, so that distributions can easily disable it.

Jan Tojnar
  • 5,306
  • 3
  • 29
  • 49
  • If disabling the extensions is the concern every application provides an option internally to show/hide Shell Extensions(ex., Win32 COM extensions) to register/un-register at user's wish. We are planning to provide the same too. – TFA Nov 30 '18 at 10:05
  • Your suggestion is very generic. But my question here is how can we bundle it with the application(For example in C we can have so file)? – TFA Nov 30 '18 at 10:09
  • Also we are aware of separate packaging system in different linux flavors. Our application required providing a single bin package which is why we went with the above option. – TFA Nov 30 '18 at 10:14
  • 1
    nautilus-python only supports loading scripts from [predefined directories](https://gitlab.gnome.org/GNOME/nautilus-python/blob/44224fac32d2d5284956b55ecd884fdfcb1bec4e/src/nautilus-python.c#L231-266). As fair as I can tell, there is no API for loading a script at run-time, without installing it into one of the paths. – Jan Tojnar Nov 30 '18 at 14:15
  • You could make your program copy the script there on start-up but it is a big no-no for Linux distributions, since the package manager will not know about it. – Jan Tojnar Nov 30 '18 at 14:16
  • Ok Thanks. One more query. If I use cx_freeze to freeze my scripts and if I want to run my program in another machine, is it necessary to have nautilus-python installed in that machine? – TFA Dec 03 '18 at 14:29
  • Nautilus will not load the python scripts without nautilus-python installed. If you want to make users install `nautilus-python`, you can use [PackageKit](https://www.freedesktop.org/software/PackageKit), which is supported by many modern distros. – Jan Tojnar Dec 03 '18 at 19:01