Re: [Pythonmac-SIG] Py2app PIL recipe

2009-11-26 Thread Ronald Oussoren

On 24 Nov, 2009, at 23:08, Christopher Barker wrote:

 
 
 Ronald Oussoren wrote:
 
 No harm in having both ways, though.
 I'm not 100% sure about that though, users may now end up with two copies of 
 PIL unless they remove the .pth file as well. That wouldn't be a disaster, 
 but I'd prefer to avoid that.
 
 hmm -- I suppose we should check that. I agree that it's probably not a good 
 idea to have the contents of the package also in sys.path, but that's how PIL 
 is installed now. It seems that users could have it imported in two different 
 ways in their own code, regardless of how py2app imports it.
 
 I guess the question is whether modulegraph is smart enough to realize that 
 they are the same thing!

The aren't according to the python rules: if you import both PIL.Image and 
Image you get two distinct modules in sys.modules (that is, 
sys.modules['Image'] is not sys.modules['PIL.Image']).  PIL isn't too large, 
adding it twice won't really be a problem but it would be nice to avoid this 
issue.

Ronald



smime.p7s
Description: S/MIME cryptographic signature
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Py2app PIL recipe

2009-11-24 Thread Ronald Oussoren

On 2 Nov, 2009, at 20:10, Christopher Barker wrote:

 Hi folks,
 
 For a while now, PIL has provided a proper package, so that you can do:
 
 from PIL import Image
 
 rather than relying on a pth file and:
 
 import Image
 
 
 I'm such a fanatic about proper use of packages and namespaces that I 
 removed the PIL.pth file from my system.
 
 Then I tried to use py2app on a program that uses PIL. It turns out that the 
 PIL py2app recipe has a prescript.py file that gets put into the bundle, and 
 it uses the old import Image form.
 
 I've hacked it to use:
 
try:
import Image
except ImportError:
from PIL import Image # note: the newer way to import PIL
import sys

I will commit this patch once py2apps repository gets back (I have connectivity 
problems to the repo at the moment)

 
 instead, which works fine for me.
 
 I'd really rather simple use the package form:
 
   from PIL import Image # note: the newer way to import PIL
 
 all by itself, but there is some chance that that would break older PIL 
 installations -- or is there? when was the PIL directory made a package?

I don't know, I don't even know which name is the preferred one. The PIL 
Handbook (http://www.pythonware.com/library/pil/handbook/index.htm) uses 
'import Image' throughout.

Ronald

smime.p7s
Description: S/MIME cryptographic signature
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Py2app PIL recipe

2009-11-24 Thread Christopher Barker

Ronald Oussoren wrote:

I will commit this patch once py2apps repository gets back (I have connectivity 
problems to the repo at the moment)


great, thanks.


I don't know, I don't even know which name is the preferred one.


I'm clear on that -- every package has moved to using namespaces over 
the years.


The PIL Handbook 
(http://www.pythonware.com/library/pil/handbook/index.htm) uses 
'import Image' throughout.


That's a pretty old document. I don't know what Fredrik thinks, but 
given that those are the docs, it's best to support it. However, my 
suggested change only effects how py2app finds PIL, I don't think it 
would break any user code.


No harm in having both ways, though.

-Chris




--
Christopher Barker, Ph.D.
Oceanographer

NOAA/ORR/HAZMAT (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Py2app PIL recipe

2009-11-24 Thread Bill Janssen
Ronald Oussoren ronaldousso...@mac.com wrote:

 I don't know, I don't even know which name is the preferred one. The
 PIL Handbook
 (http://www.pythonware.com/library/pil/handbook/index.htm) uses
 'import Image' throughout.

Note that the on-line PIL handbook is from 4.5 years ago.

Bill
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Py2app PIL recipe

2009-11-24 Thread Ronald Oussoren

On 24 Nov, 2009, at 20:27, Bill Janssen wrote:

 Ronald Oussoren ronaldousso...@mac.com wrote:
 
 I don't know, I don't even know which name is the preferred one. The
 PIL Handbook
 (http://www.pythonware.com/library/pil/handbook/index.htm) uses
 'import Image' throughout.
 
 Note that the on-line PIL handbook is from 4.5 years ago.

Is there more recent documentation? Even the version at effbot's site 
http://effbot.org/imagingbook/ says 'import Image'. 

Some of the examples in the 1.1.6 distribution seem to have been converted to 
'from PIL import Image', but I haven't found a definite source that says which 
is the prefered style.

Ronald



smime.p7s
Description: S/MIME cryptographic signature
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Py2app PIL recipe

2009-11-24 Thread Ronald Oussoren

On 24 Nov, 2009, at 20:06, Christopher Barker wrote:

 Ronald Oussoren wrote:
 I will commit this patch once py2apps repository gets back (I have 
 connectivity problems to the repo at the moment)
 
 great, thanks.

The patch is in the repo.

 
 I don't know, I don't even know which name is the preferred one.
 
 I'm clear on that -- every package has moved to using namespaces over the 
 years.
 
 The PIL Handbook (http://www.pythonware.com/library/pil/handbook/index.htm) 
 uses 'import Image' throughout.
 
 That's a pretty old document. I don't know what Fredrik thinks, but given 
 that those are the docs, it's best to support it. However, my suggested 
 change only effects how py2app finds PIL, I don't think it would break any 
 user code.
 
 No harm in having both ways, though.

I'm not 100% sure about that though, users may now end up with two copies of 
PIL unless they remove the .pth file as well. That wouldn't be a disaster, but 
I'd prefer to avoid that.

Ronald



smime.p7s
Description: S/MIME cryptographic signature
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Py2app PIL recipe

2009-11-24 Thread Christopher Barker



Ronald Oussoren wrote:


No harm in having both ways, though.


I'm not 100% sure about that though, users may now end up with two copies of 
PIL unless they remove the .pth file as well. That wouldn't be a disaster, but 
I'd prefer to avoid that.


hmm -- I suppose we should check that. I agree that it's probably not a 
good idea to have the contents of the package also in sys.path, but 
that's how PIL is installed now. It seems that users could have it 
imported in two different ways in their own code, regardless of how 
py2app imports it.


I guess the question is whether modulegraph is smart enough to realize 
that they are the same thing!


-Chris






--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/ORR(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] Py2app PIL recipe

2009-11-02 Thread Christopher Barker

Hi folks,

For a while now, PIL has provided a proper package, so that you can do:

from PIL import Image

rather than relying on a pth file and:

import Image


I'm such a fanatic about proper use of packages and namespaces that I 
removed the PIL.pth file from my system.


Then I tried to use py2app on a program that uses PIL. It turns out that 
the PIL py2app recipe has a prescript.py file that gets put into the 
bundle, and it uses the old import Image form.


I've hacked it to use:

try:
import Image
except ImportError:
from PIL import Image # note: the newer way to import PIL
import sys

instead, which works fine for me.

I'd really rather simple use the package form:

   from PIL import Image # note: the newer way to import PIL

all by itself, but there is some chance that that would break older PIL 
installations -- or is there? when was the PIL directory made a package?


Anyway, could someone with SVN access to py2app please make this small 
patch. (I've enclosed the whole file, to make it easy).


It belongs in:

py2app/recipes/PIL/prescript.py


Thanks,
-Chris





--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/ORR(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov


prescript.py
Description: application/python
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig