Re: [wxPython-users] Re: wxPython 2.8.11.0 Pubsub not found by py2exe

36 views
Skip to first unread message

oliver

unread,
Jun 14, 2010, 11:18:26 PM6/14/10
to wxpytho...@googlegroups.com, PyPubSub
So the py2exe freezing problem occurs only when using the legacy API. Two problems: 
  1. the "imp" module from Python core library does not seem to work within zip files, so autosetuppubsubv1 is not found, eventhough it is in the .zip created by py2exe. Solution (hack): import setupv1 explicitly in your application's startup module. 
  2. legacy API setup requires the wx/lib/pubsub/pubsub1 folder, which for a reason that I don't yet understand, py2exe does not copy into the library.zip. Solution (another hack): put an empty __init__.py in that folder. 
The much preferable alternative (ie no hacks!) if you can hack it (sorry!) is to use the same messaging protocol as v1 but in latest API, this is called "arg1": 

from wx.lib.pubsub import setuparg1             # only in app's startup module
from wx.lib.pubsub import pub as Publisher # in all modules that use pubsub

and replace any occurence of "Publisher()." by "Publisher."

Oliver

On Mon, Jun 14, 2010 at 1:21 PM, Mike Driscoll <kyos...@gmail.com> wrote:


On Jun 14, 11:59 am, oliver <oliver.schoenb...@gmail.com> wrote:
> This was discussed not long ago in another thread on this list and it was a
> simple matter of adding the extra setup attribute for package. I haven't
> looked at how the use of autopubusbv1 changes this, but the solution of
> implicitely importing setupv1 should take care of any gotchas (if there are
> any -- there is no reason there would be).
>
> Note that the error message indicates that you are in fact NOT using the
> version 1 API. The setupv1 (automatically imported for you if autopubsubv1
> is found) is *exacty* the old API (in fact, it's even the same module file
> put inside the package, with some special import handling for now).
>
> I'll try to look more closely later, if you any of you make any progress
> please post.
> Oliver
>

So I'm using the new API and didn't even know it? I'm pretty sure I
was basing my code on old examples, and I think I've been using this
code since at least wx 2.8.9.x so I don't know how this works...

I've tried it with

from wx.lib.pubsub import setupv2
from wx.lib.pubsub import Publisher

The above doesn't work at all from source (probably for some obvious
reason). The following doesn't work when frozen:

from wx.lib.pubsub import Publisher

or

from wx.lib.pubsub import setupv1
from wx.lib.pubsub import Publisher

The solution is simple! Downgrade to 2.8.10.1. I guess I need to
figure out whatever the new accepted way is and just do it that way...

-------------------
Mike Driscoll

Blog:   http://blog.pythonlibrary.org

--
To unsubscribe, send email to wxPython-user...@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Reply all
Reply to author
Forward
0 new messages