Marc-Andre Lemburg added the comment: On 25.03.2014 19:27, Brett Cannon wrote: > > Brett Cannon added the comment: > > OK, so trying to import around the package was definitely why the first > instance didn't work so that's all expected. > > As for the failure when importing psycopg2, my guess is that the freezing of > psycopg2.__init__ is not setting __path__ to anything reasonable to work with > dynamically loading psycopg2._psycopg. That really shouldn't really ever work > anyway since that just doesn't make sense from the perspective of freezing a > package unless you made the extension module a built-in module, but I don't > think submodules are supported in that case right now anyway. > > MAL, do you agree with that assessment?
Using C extensions embedded in Python packages is supported in Python 2's freeze - but not directly: This works because Python2 search for the module in the top level directories in case it cannot find the shared mod in the package dir (which in the case of frozen packages does not exist). So you ship the frozen app together with the .so shared module in the same directory or setup sys.path to point to whatever dir you use for this. I'll have to have a look at how the pyscopg2 package normally imports its C extension. It's likely that they will have to use something like this to make things work for frozen apps as well: try: from psycopg2 import _psycopg except ImportError: # try to find the module at the top-level import _psyocpg or setup the package's .__path__ to include the top-level dir. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue16047> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com