Creating plugins for standalone python executables

how to create a good plugin engine for standalone executable files created using pyInstaller, py2exe or similar tools?

I have no experience with py2exe, but pyInstaller uses import capture to import packages from it into a compressed repository. Of course, I can dynamically import another compressed repository created using pyInstaller and execute the code - it can be a simple plugin engine.

Problems arise when a plug-in (this is something that is imported dynamically) uses a library that is missing from the original repository (never imported). This is because the import hook is for the original application and is looking for packages in the original repository - not the one that was imported later (plugin package repository).

Is there an easy way to solve this problem? Maybe there is such an engine?

+5
source share
2 answers

When compiling in exe you will have this problem.

The only option I can imagine to allow users to access their plugins to use any python library is to include all the libraries in the exe package.

, . .

py2exe.

py2exe , setup.py.

:

from distutils.core import setup
import py2exe

setup (name = "script2compile",
       console=['script2compile.pyw'],
       version = "1.4",
       author = "me",
       author_email="somemail@me.com",
       url="myurl.com",
       windows = [{
                    "script":"script2compile.pyw",
                    "icon_resources":[(1,"./ICONS/app.ico")]  # Icon file to use for display
                 }],
       # put packages/libraries to include in the "packages" list
       options = {"py2exe":{"packages": [   "pickle",
                                            "csv",
                                            "Tkconstants",
                                            "Tkinter",
                                            "tkFileDialog",
                                            "pyexpat",
                                            "xml.dom.minidom",
                                            "win32pdh",
                                            "win32pdhutil",
                                            "win32api",
                                            "win32con",
                                            "subprocess", 
                                        ]}} 

       )

import win32pdh
import win32pdhutil
import win32api
+3

PyInstaller . . - (http://www.pyinstaller.org), :

PyInstaller - . , PyInstaller PyInstaller, . . SupportedPackages.

+1

All Articles