Author lemburg
Recipients Arfrever, Trundle, barry, brett.cannon, chba, eric.smith, eric.snow, jcea, jkloth, lemburg, loewis, meador.inge, r.david.murray
Date 2014-03-25.18:41:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <5331CDE0.9030405@egenix.com>
In-reply-to <1395772039.55.0.794267908362.issue16047@psf.upfronthosting.co.za>
Content
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.
History
Date User Action Args
2014-03-25 18:41:41lemburgsetrecipients: + lemburg, loewis, barry, brett.cannon, jcea, eric.smith, jkloth, Arfrever, r.david.murray, Trundle, meador.inge, eric.snow, chba
2014-03-25 18:41:41lemburglinkissue16047 messages
2014-03-25 18:41:41lemburgcreate