Commits

Ronald Oussoren committed 2674c2b

Two recipe updates

1) Disable the 'email' recipe for python 3, the recipe is used
for backward compatible imports and those aren't present there.

2) Add a recipe for lxml <http://lxml.de/>;, needed because of
a number of imports from extensions.

  • Participants
  • Parent commits a23a7f0
  • Branches branch-0.7

Comments (0)

Files changed (4)

File doc/changelog.rst

 py2app 0.7.4
 ------------
 
-- ...
+- Disabled the 'email' recipe for python 3.x as it isn't needed there.
+
+- Issue #91: Added a recipe for `lxml <http://lxml.de/>`, needed because 
+  lxml performs a number of imports from an extension and those cannot
+  be detected automaticly by modulegraph.
+
 
 py2app 0.7.3
 ------------

File py2app/recipes/__init__.py

 from . import numpy
 from . import scipy
 from . import matplotlib
+from . import lxml
 
 from . import virtualenv
 from . import pyside

File py2app/recipes/email.py

     if sys.version_info[:2] < (2, 5):
         return None
 
+    if sys.version_info[0] >= 3:
+        # The older names are not present in Python 3.x, 
+        # and therefore the workaround isn't needed there.
+        return None
+
     m = mf.findNode('email')
     if m is None or m.filename is None:
         return None

File py2app/recipes/lxml.py

+#
+# LXML uses imports from C code (or actually Cython code)
+# and those cannot be detected by modulegraph. 
+# The check function adds the hidden imports to the graph
+#
+# The dependency list was extracted from lxml 3.0.2
+import sys
+
+def check(cmd, mf):
+    m = mf.findNode('lxml.etree')
+    if m is not None and m.filename is not None:
+        mf.import_hook('lxml._elementpath', m)
+        mf.import_hook('os.path', m)
+        mf.import_hook('re', m)
+        mf.import_hook('gzip', m)
+
+        if sys.version_info[0] == 2:
+            mf.import_hook('StringIO', m)
+        else:
+            mf.import_hook('io', m)
+
+    m = mf.findNode('lxml.objectify')
+    if m is not None and m.filename is not None:
+        if sys.version_info[0] == 2:
+            mf.import_hook('copy_reg', m)
+        else:
+            mf.import_hook('copyreg', m)
+
+    return {}
+