"python exe" and "py plugins"
theller at python.net
Thu Nov 20 21:29:52 CET 2003
Thomas Heller <theller at python.net> writes:
> Ahmad Baitalmal <ahmad at bitbuilder.com> writes:
>> Thomas Heller wrote:
>>>>That works fine in linux or uncompiled on windows, but with py2exe, it
>>>>can't find the "services" folder.
>>> You should be a bit more specific here - what do you mean by "it
>>> find the services folder" ?
>> I figured out that's what is happening. py2exe used to package my
>> "services" package because it was imported normally. But now I do a
>> folder lookup to find all subfolders in my sys.executable +
>> '/services' folder and
>> exec("import %s" % foldername )
>> each subfolder. That's why py2exe can't package those packages when
>> its building.
>> And I'm doing it that way because the set of plugins are not known
>> ofcourse, that's why I do this dynamic discovery at runtime.
>> This will work, but it feels a bit patchy to me, is there a way in
>> python to say "here is the path to folder x, recursevily import all
>> packages you find in there"? py, pyc, pyd also?
> No, but it's easy to do that yourself.
That wasn't a good answer, you already discovered that.
But, you may want to organize your plugins somewhat differently.
Maybe you can create a plugin package (a directory plugin, which
contains an __init__.py file). And then you (or your users) write the
plugins as modules contained in this directory. Or someting like that.
It may be useful to look into sources which do something like this, PIL
comes to mind, but there are most certainly more.
More information about the Python-list