Feature: Python Plugin Importer
ClosedPublic

Authored by rbreu on Mon, Jan 7, 9:08 PM.

Details

Summary

This is a Python plugin that imports Python plugins from zip files into the proper location in the resources directory. The user still needs to restart Krita and activate the imported plugins in the settings, but at least the most technical/complicated aspect of copying the files is automated. (While testing, I noticed that once you have enabled a plugin, you have to restart Krita again to make it show up in the menu. That seems like a bug?)

Since I didn't want to assume a specific directory structure inside the zip, the plugin uses the following strategy to find the correct files:

  1. Find files with the ending .desktop and read the Python module name from them
  2. Find directories that correspond to the Python module names and that contain an __init__.py file
  3. Find files with ending .action that have matching <Action name=...> tags (these files are optional)

Then the found desktop- and action-files and the Python module directories are extracted into the corresponding pykrita and actions folders. This approach is very flexible and doesn't seem too error-prone to me, as long as the zip files aren't too wild. (One could easily make the algorithm more restrictive, though, if needed.) I've tested it with a couple of Python plugins out there, on Linux as well as Windows.

The Plugin can be found under "Tools > Scripts > Import Python Plugin...". It's enabled by default.

(See also the forum post.)

Diff Detail

Repository
R37 Krita
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
rbreu created this revision.Mon, Jan 7, 9:08 PM
Restricted Application added a reviewer: Krita. · View Herald TranscriptMon, Jan 7, 9:08 PM
Restricted Application added a project: Krita. · View Herald Transcript
rbreu requested review of this revision.Mon, Jan 7, 9:08 PM
yurchor added a subscriber: yurchor.Mon, Jan 7, 9:14 PM
yurchor added inline comments.
plugins/python/plugin_importer/manual.html
2

Typo: Importert -> Importer

rbreu updated this revision to Diff 49092.Wed, Jan 9, 6:20 PM

Fix typo

rempt added a subscriber: rempt.Tue, Jan 15, 8:54 AM

I'm all for it, but the patch doesn't apply:

boud@boud-ThinkPad-T470p:~/dev/krita$ git apply ~/D18074.diff
error: plugins/python/plugin_importer/manual.html: No such file or directory

I think that the patch isn't a complete diff against master, but the last of a set of commits?

rbreu updated this revision to Diff 49548.Tue, Jan 15, 5:32 PM

Ooops, I didn't know you need to update a review request with the full patch. Squashed both commits (the original and the typo fix).

rempt accepted this revision.Wed, Jan 16, 9:35 AM
This revision is now accepted and ready to land.Wed, Jan 16, 9:35 AM
This revision was automatically updated to reflect the committed changes.