[Image-SIG] importing plugins in PIL-1.1.1
Christopher Lee
clee@v1.wustl.edu
Mon, 23 Oct 2000 13:49:43 -0500
Hello again,
I just compiled Imaging-1.1.1 and tried using PIL as a package again
(without PIL being in sys.path). The Image.py does not import the
ImagingPlugins in the PIL directory with the code as written.
The problem appears to be that the __path__ variable is not working as
expected. On my system (Linux, python 1.5.2), the __path__ variable is not
defined when init() is being called, so the code reverts back to using
sys.path which doesn't contain PIL. I can fix it with my previous method
using the __file__ variable. Here's what I have now:
try:
directories = __path__[:]
except NameError:
directories = sys.path[:]
(thisdir, thisfile) = os.path.split(__file__)
if not thisdir in directories:
directories.append(thisdir)
# only check directories (including current, if present in the path)
for path in filter(os.path.isdir, directories):
I continue to be confused about the use of __path__. Perhaps someone has
some enlightenment to offer?
-chris
p.s. Here's a diff -c between the two files
*** /usr/local/src/Python/Extensions/Imaging-1.1.1/PIL/Image.py Mon Oct 23 05:47:25 2000
--- Image.py Mon Oct 23 13:46:07 2000
***************
*** 192,200 ****
import os, sys
try:
! directories = __path__
except NameError:
! directories = sys.path
# only check directories (including current, if present in the path)
for path in filter(os.path.isdir, directories):
--- 192,204 ----
import os, sys
try:
! directories = __path__[:]
except NameError:
! directories = sys.path[:]
!
! (thisdir, thisfile) = os.path.split(__file__)
! if not thisdir in directories:
! directories.append(thisdir)
# only check directories (including current, if present in the path)
for path in filter(os.path.isdir, directories):