Feature: Python Plugin Importer
ClosedPublic

Authored by rbreu on Jan 7 2019, 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.Jan 7 2019, 9:08 PM
Restricted Application added a reviewer: Krita. · View Herald TranscriptJan 7 2019, 9:08 PM
Restricted Application added a project: Krita. · View Herald Transcript
rbreu requested review of this revision.Jan 7 2019, 9:08 PM
yurchor added a subscriber: yurchor.Jan 7 2019, 9:14 PM
yurchor added inline comments.
plugins/python/plugin_importer/manual.html
2

Typo: Importert -> Importer

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

Fix typo

rempt added a subscriber: rempt.Jan 15 2019, 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.Jan 15 2019, 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.Jan 16 2019, 9:35 AM
This revision is now accepted and ready to land.Jan 16 2019, 9:35 AM
This revision was automatically updated to reflect the committed changes.