chtd / psycopg2cffi

Port to cffi with some speed improvements
Other
177 stars 43 forks source link

__pycache__ Error #41

Closed camux closed 9 years ago

camux commented 9 years ago

When I try to enter first time to app client (tryton), after to restart server, client fail with next error:

ERROR:tryton.common.common:Traceback (most recent call last): File "/trytond/protocols/jsonrpc.py", line 162, in _marshaled_dispatch response['result'] = dispatch_method(method, params) File "/trytond/protocols/jsonrpc.py", line 191, in _dispatch res = dispatch(args) File "/trytond/protocols/dispatcher.py", line 31, in dispatch Database = backend.get('Database') File "/trytond/backend/init.py", line 18, in get import(modname) File "/trytond/backend/postgresql/init.py", line 4, in from .database import File "/trytond/backend/postgresql/database.py", line 12, in from psycopg2cffi import compat File "/psycopg2cffi/init.py", line 4, in from psycopg2cffi import extensions File "/psycopg2cffi/extensions.py", line 39, in from psycopg2cffi._impl import connection as _connection File "/psycopg2cffi/_impl/connection.py", line 10, in from psycopg2cffi._impl import exceptions File "/psycopg2cffi/_impl/exceptions.py", line 12, in from psycopg2cffi._impl.libpq import libpq, ffi File "/psycopg2cffi/_impl/libpq.py", line 257, in ext_package='psycopg2cffi') File "/cffi/api.py", line 367, in verify lib = self.verifier.load_library() File "/cffi/verifier.py", line 95, in load_library self._write_source() File "/cffi/verifier.py", line 183, in _write_source with open(self.sourcefilename, "w") as fp: IOError: [Errno 2] No such file or directory: '/psycopg2cffi/_impl/pycache/_cffi__x97b0ad0cxb201248a.c'

[Errno 2] No such file or directory: '/usr/local/lib/python2.7/dist-packages/psycopg2cffi/_impl/pycache/_cffi__x97b0ad0cxb201248a.c'

But the second tries not fail and client enter fine, on Xubuntu 15.04.

Version: 2.6.1

faide commented 9 years ago

I had the same issue while running latest odoo8 under pypy 2.5.1 and psycopg2cffi-2.6.1

I used pip unzip psycopg2cffi to solve the issue since the egg was installed in a zipped form. And I saw doing this that the unzip option of pip is deprecated.

But since the code is trying to write a new c file (source code) at run time it should either use a proper temp dir (not inside the installed modules, because not all users have write perms to the installation dirs) or at least install an unzipped version using the zip_safe=False flag in setup.py (and pray the user has a virtualenv and it is write enabled for him)

I have only looked really quickly to my /usr/lib/pypy/lib_pypy/cffi/verifier.py _write_source definition and I am wondering if there is a way to generate this c code at install time instead of runtime...

cffi seems to be partially the culprit here instead of psycopg2cffi...

lopuhin commented 9 years ago

I think the proper fix here is to start using cffi 1.0, which is almost ready and gives more control over compilation step - I hope I will soon have time to do it, sorry for being unresponsive.

faide commented 9 years ago

3 days to answer a ticket on an opensource project is what I would call fairly responsive :)

cffi latest release is 0.9.2, do you mean that we should use cffi trunk version from here: https://bitbucket.org/cffi/cffi ?

I see they are in release 1.0.0b2 so we should have a pip installable 1.0 "soon" :p

lopuhin commented 9 years ago

I mean I should use new cffi 1.0 features that make installation more robust)

lopuhin commented 9 years ago

I think this is the duplicate of #35, I will rename it, and close this one