On Tue, 30 Aug 2016 22:45:34 +0200
Antonio Ospite <[email protected]> wrote:

[...]
> OK, python-axolotl_0.1.35-1, which is available in unstable, fixes this
> issue, so now the latest python-protobuf package can be used in case you
> downgraded it as I suggested in the previous message.
> 
> However the recent update of the python-setuptools and
> python-pkg-resources packages breaks some gajim plugins (namely the OMEMO
> plugin) in another way:
> 
> $ gajim
> Traceback (most recent call last):
[...]
>   File "/usr/lib/python2.7/dist-packages/pkg_resources/_vendor/pyparsing.py", 
> line 1496, in ParserElement
>     packrat_cache_lock = RLock()
>   File "/usr/share/gajim/src/common/demandimport.py", line 82, in __call__
>     raise TypeError("%s object is not callable" % repr(self))
> TypeError: <unloaded module 'RLock'> object is not callable
> 
> 
> A workaround is to downgrade the offending packages:
> http://ftp.debian.org/debian/pool/main/p/python-setuptools/python-setuptools_25.2.0-1_all.deb
> http://ftp.debian.org/debian/pool/main/p/python-setuptools/python-pkg-resources_25.2.0-1_all.deb
> 
> I don't know if the issue is in these packages or in the
> demandimport.py code, or rather in how the OMEMO plugin uses it.
> 
> Does anyone have any insight?
> 

The issue seems to be related to the interaction between demandimport
(even the one from mercurial) and pkg_resources, this is the
first minimal script which triggers the same issue seen when running
gjim with the OMEMO plugin:

----------------------------------------------------------------------
#!/usr/bin/env python2

from mercurial import demandimport

demandimport.enable()

# Recent versions of pyhton-pkg-resources break programs using
# mercurial.demandimport which import modules doing this:
#   __import__('pkg_resources').declare_namespace(__name__)
#
# Just FTR one of such packages is google.protobufs
#
__import__('pkg_resources')
----------------------------------------------------------------------

I bisected the regression in setuptools and I tracked it down to this
commit:
https://github.com/pypa/setuptools/commit/84aec138dc4311c3f23ff78e9916e00b457a1896

In that commit setuptools upgraded the pyparsing module to version 2.1.8
but the offending change is that RLock is imported:

  try:
      from _thread import RLock
  except ImportError:
      from threading import RLock

The first import succeeds, to that's the one to look into, this is
another minimal script to reproduce the issue:

----------------------------------------------------------------------
#!/usr/bin/env python2

from mercurial import demandimport

demandimport.enable()

# demandimport does not play nice with the _thread module
from _thread import RLock

lock = RLock()
----------------------------------------------------------------------

Ignoring the _thread module in demandimport and adding back the
try/except logic when importing RLock seems to fix the issue, so for
now I am using this local patch for the gajim OMEMO plugin:

----------------------------------------------------------------------
diff --git omemo.orig/__init__.py omemo/__init__.py
index 50dd68f..04987f2 100644
--- omemo.orig/__init__.py
+++ omemo/__init__.py
@@ -40,7 +40,7 @@ from .xmpp import (

 from common import demandimport
 demandimport.enable()
-demandimport.ignore += ['_imp']
+demandimport.ignore += ['_imp', '_thread']


 IQ_CALLBACK = {}
----------------------------------------------------------------------

However this is a temporary workaround, the issue is about demandimport
and we should report the issue to the gajim and mercurial/demandimport
developers.

I'll post an update when I have some news.

Ciao ciao,
   Antonio

-- 
Antonio Ospite
http://ao2.it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?

Reply via email to