[Product-Developers] z3c.autoinclude and ImportError for PIL-1

Giacomo Spettoli giacomo.spettoli at gmail.com
Fri Dec 9 02:12:21 UTC 2011


Hi all,
    I would like to continue this discussion:
http://lists.plone.org/pipermail/plone-product-developers/2011-January/009956.html

cause I'm facing a similar issue. I've made some debug about that and I 
think that this is a bug in z3c.autoinclude. This is the process of 
z3c.autoinclude that generates this error:

1. z3c.autoinclude lists your product's dependencies (ref: 
z3c.autoinclude.dependency.py#L24)
2. for every dependency, it checks if exists a file 
namespace_packages.txt  in its egg-info dir  (ref: 
z3c.autoinclude.utils.py#L123)
3. if that file doesn't exists , it searches for other packages in the 
same path of the dependency (why?! this doesn't make sense and it's 
dangerous if that product is anywhere in the python path) (ref: 
z3c.autoinclude.utils.py#L26)
4. the fact that the final error is "ImportError: No module named PIL-1" 
is simply because the PIL package has a file __init__.py in its root 
directory but it could be any other package. (ref: 
z3c.autoinclude.utils.py#L61)

(I've omitted some jumps for briefness but you can easily follow every 
step from the point 1.)

The solution suggested by Ross will probably work but IMHO it's not a 
definitive solution. The error in point 3 still remains: any time you 
have a dependency in "lib/python2.6/site-packages" you are likely to hit 
this issue.

With this simple patch everything works smoothly:

-- z3c/autoinclude/utils.py    2011-12-09 01:55:28.826464670 +0100
+++ z3c/autoinclude/utils.py    2011-12-09 02:51:04.964813156 +0100
@@ -23,7 +23,7 @@
          dist_path = self.context.location
          ns_dottednames = self.namespaceDottedNames()
          if not ns_dottednames:
-            return subpackageDottedNames(dist_path)
+            return []
          result = []
          for ns_dottedname in ns_dottednames:
              path = os.path.join(dist_path, *ns_dottedname.split('.'))

What do you think? Am I wrong?

-- 
Giacomo Spettoli

T: http://twitter.com/giacomospettoli
S: http://careers.stackoverflow.com/giacomospettoli
L: http://linkedin.com/in/giacomospettoli
Company site: http://redomino.com
Blog: http://www.spettoli.com



More information about the Product-Developers mailing list