[Pythonmac-SIG] py2app and PythonCard
bob at redivi.com
Mon Oct 25 20:00:12 CEST 2004
On Oct 25, 2004, at 13:52, Kevin Altis wrote:
> On Oct 25, 2004, at 10:16 AM, Bob Ippolito wrote:
>> On Oct 25, 2004, at 12:44, Chris Barker wrote:
>>> Bob Ippolito wrote:
>>>> On Oct 25, 2004, at 12:21, Chris Barker wrote:
>>>>> Bob Ippolito wrote:
>>>>>> This is sort of a bug in py2app. You are using software that
>>>>>> uses PIL, but you do not have PIL installed.
>>>>> Huh? does py2app use PIL? why?
>>>> No. His software uses PIL (indirectly via PythonCard, it seems),
>>>> py2app detected this and tried to include PIL, but PIL was not
>>>> present. svn trunk has been changed such that now py2app only
>>>> tries to use recipes for packages that are actually present (a
>>>> change to the recipes, not anything in py2app's core).
>>> Ah, I see. So this is really the same problem we can get with
>>> packages that conditionally import stuff. If you're not using it,
>>> Py2app doesn't know that. In fact, PIL is (or was, last I checked),
>>> whenever I've tried to Py2exe an app that uses PIL, I get all if
>>> tkinter too, even though I wasn't using it. It sounds like you're
>>> solving at least half the problem.
>> If you py2exe an app that uses PIL you'll probably have an
>> application that doesn't work. One of the things that makes py2app
>> more generally useful than py2exe is that it includes special
>> exceptions, called recipes, that allow additional things to happen
>> when certain packages are detected. In cases like PIL or docutils,
>> plugins need to be detected and added to the zip, or else they won't
>> work. py2app includes recipes that do these things. Also, in PIL,
>> it eliminates the implicit dependency on Tkinter (by means of FixTk),
>> so if you don't use Tkinter elsewhere, then it won't be included.
>> py2app includes everything it sees, even if you don't think you're
>> using it. If you know you're not using a particular module or
>> package, and you see that it is getting included anyway, then simply
>> exclude it explicitly. It's not very hard to do. I would say that a
>> whole lot more than half the problem is solved by py2app.
> Sorry, I'm late to the the party. I was at the Seattle coding sprint
> last weekend and I'm just now catching up on email. I haven't tried
> py2app yet as last week I was wrapping up the PythonCard 0.8.1
> release. There are bundlebuilder scripts for a variety of samples and
> I'm hoping to convert them to py2app, though I have no idea what is
> involved yet.
Very likely you can just take your py2exe scripts and change
windows=[...] to app=[...] and py2exe to py2app.. you may also be able
to remove some cruft. The scripts will certainly be a lot shorter than
the bundlebuilder versions. If you run into any issues, let me know on
or off list and I'll help you.
> Both PythonCard/graphic.py and PythonCard/components/bitmapcanvas.py
> have conditional imports for PIL, and bitmapcanvas.py has one for
> Numeric as well.
<conditional import example>
> In the short term, you could just comment out the imports and force
> the FOUND constants to False and that will avoid the conditional
> import. The readme.txt gives the py2exe option to exclude libraries
> you don't want included in your standalone.
> Use the following command-line to build the minimal.exe file.
> python setup.py py2exe --excludes=Image
> I don't know if py2app has something similar, but it would be nice for
> the apps that know they aren't using particular libraries like PIL
> which are imported optionally. The reason the imports are there in the
> first place, is that PythonCard supports drawing and converting PIL
> and Numeric arrays.
py2app supports identical syntax for the excludes hook... though it may
not work for PIL with py2app 0.1.4 due to the bug in the recipe. SVN
trunk (or 0.2.0, when I release it) should work fine.
More information about the Pythonmac-SIG