|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
Py2app PIL recipeHi 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/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker@... _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@... http://mail.python.org/mailman/listinfo/pythonmac-sig |
|
|
Re: Py2app PIL recipeOn 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 > > 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 _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@... http://mail.python.org/mailman/listinfo/pythonmac-sig |
|
|
Re: Py2app PIL recipeRonald 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/OR&R/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@... http://mail.python.org/mailman/listinfo/pythonmac-sig |
|
|
Re: Py2app PIL recipeRonald Oussoren <ronaldoussoren@...> 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@... http://mail.python.org/mailman/listinfo/pythonmac-sig |
|
|
Re: Py2app PIL recipeOn 24 Nov, 2009, at 20:27, Bill Janssen wrote: > Ronald Oussoren <ronaldoussoren@...> 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 _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@... http://mail.python.org/mailman/listinfo/pythonmac-sig |
|
|
Re: Py2app PIL recipeOn 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. Ronald _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@... http://mail.python.org/mailman/listinfo/pythonmac-sig |
|
|
Re: Py2app PIL recipeRonald 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/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker@... _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@... http://mail.python.org/mailman/listinfo/pythonmac-sig |
|
|
Re: Py2app PIL recipeOn 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! Ronald _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@... http://mail.python.org/mailman/listinfo/pythonmac-sig |
| Free embeddable forum powered by Nabble | Forum Help |