Bug 1141993 - python3-pyenchant fails on Tumbleweed
python3-pyenchant fails on Tumbleweed
Status: RESOLVED FIXED
Classification: openSUSE
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Other
Current
Other Other
: P5 - None : Normal (vote)
: ---
Assigned To: Antonio Larrosa
E-mail List
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2019-07-18 09:34 UTC by Mike FABIAN
Modified: 2020-12-17 03:38 UTC (History)
4 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike FABIAN 2019-07-18 09:34:23 UTC
mfabian@linux-v8we:~> rpm -qa | grep enchant
enchant-1-backend-voikko-1.6.1-1.7.x86_64
libenchant-2-2-2.2.3-4.3.x86_64
python3-pyenchant-2.0.0-2.4.noarch
libenchant1-1.6.1-1.7.x86_64
enchant-2-backend-hunspell-2.2.3-4.3.x86_64
enchant-data-2.2.3-4.3.x86_64
mfabian@linux-v8we:~> rpm -ql myspell-es_AR
/usr/share/hunspell/es_AR.aff
/usr/share/hunspell/es_AR.dic
/usr/share/hyphen/hyph_es_AR.dic
/usr/share/myspell/es_AR.aff
/usr/share/myspell/es_AR.dic
/usr/share/myspell/hyph_es_AR.dic
/usr/share/myspell/th_es_AR_v2.dat
/usr/share/myspell/th_es_AR_v2.idx
/usr/share/mythes/th_es_AR_v2.dat
/usr/share/mythes/th_es_AR_v2.idx
mfabian@linux-v8we:~> 
mfabian@linux-v8we:~> python3
Python 3.7.3 (default, Apr 09 2019, 05:18:21) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import enchant
>>> enchant.Dict('es_AR')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/site-packages/enchant/__init__.py", line 562, in __init__
    _EnchantObject.__init__(self)
  File "/usr/lib/python3.7/site-packages/enchant/__init__.py", line 168, in __init__
    self._init_this()
  File "/usr/lib/python3.7/site-packages/enchant/__init__.py", line 569, in _init_this
    this = self._broker._request_dict_data(self.tag)
  File "/usr/lib/python3.7/site-packages/enchant/__init__.py", line 310, in _request_dict_data
    self._raise_error(eStr % (tag,),DictNotFoundError)
  File "/usr/lib/python3.7/site-packages/enchant/__init__.py", line 258, in _raise_error
    raise eclass(default)
enchant.errors.DictNotFoundError: Dictionary for language 'es_AR' could not be found
>>> 

I.e., even though /usr/share/hunspell/es_AR.dic and /usr/share/hunspell/es_AR.aff are there, initializing enchant for 'es_AR' fails.
Comment 2 Tomáš Chvátal 2019-07-18 09:50:21 UTC
Works here:

scarabeus@bugaboo: ~ $ rpm -qa |grep enchant
enchant-1-tools-1.6.1-1.8.x86_64
python3-pyenchant-2.0.0-2.4.noarch
enchant-2-backend-hunspell-2.2.3-4.4.x86_64
enchant-data-2.2.3-4.4.x86_64
enchant-2-backend-voikko-2.2.3-4.4.x86_64
python2-pyenchant-2.0.0-2.4.noarch
libenchant-2-2-2.2.3-4.4.x86_64
enchant-tools-2.2.3-4.4.x86_64
enchant-1-backends-1.6.1-1.8.x86_64
libenchant1-1.6.1-1.8.x86_64

scarabeus@bugaboo: ~ $ rpm -ql myspell-cs_CZ
/usr/share/doc/packages/myspell-cs_CZ
/usr/share/doc/packages/myspell-cs_CZ/README_cs.txt
/usr/share/doc/packages/myspell-cs_CZ/README_en.txt
/usr/share/doc/packages/myspell-cs_CZ/description.xml
/usr/share/doc/packages/myspell-cs_CZ/dictionaries.xcu
/usr/share/hunspell/cs_CZ.aff
/usr/share/hunspell/cs_CZ.dic
/usr/share/hyphen/hyph_cs_CZ.dic
/usr/share/myspell/cs_CZ.aff
/usr/share/myspell/cs_CZ.dic
/usr/share/myspell/hyph_cs_CZ.dic
/usr/share/myspell/th_cs_CZ_v2.dat
/usr/share/myspell/th_cs_CZ_v2.idx
/usr/share/myspell/thes_cs_CZ.dat
/usr/share/myspell/thes_cs_CZ.idx
/usr/share/mythes/th_cs_CZ_v2.dat
/usr/share/mythes/th_cs_CZ_v2.idx
/usr/share/mythes/thes_cs_CZ.dat
/usr/share/mythes/thes_cs_CZ.idx


scarabeus@bugaboo: ~ $ python3
Python 3.7.3 (default, Apr 09 2019, 05:18:21) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import enchant
>>> enchant.Dict('cs_CZ')
<enchant.Dict object at 0x7f5861a57f60>
>>> enchant.Dict('es_AR')
<enchant.Dict object at 0x7f5861a61358>

Try installing package enchant-1-backends
Comment 3 Mike FABIAN 2019-07-18 09:54:51 UTC
(In reply to Tomáš Chvátal from comment #2)

> Try installing package enchant-1-backends

Yes, if that is installed it works.

Then this should be required by python3-pyenchant, right?
Comment 4 Tomáš Chvátal 2019-07-18 09:59:59 UTC
Good question, it should've worked with enchant2 only so it is a bug.
But upstream recently archived the project and stopped the development so dunno if the requires on the old version would not be better indeed.
Comment 5 Antonio Larrosa 2019-07-19 06:29:25 UTC
I just installed a new vm with Tumbleweed 20190716, installed python3-pyenchant and some myspell dictionaries on it and did a test:

antonio@linux-sywh:~> rpm -qa | grep enchant
enchant-data-2.2.3-4.4.x86_64
enchant-2-backend-hunspell-2.2.3-4.4.x86_64
libenchant-2-2-2.2.3-4.4.x86_64
python3-pyenchant-2.0.0-2.4.noarch

antonio@linux-sywh:~> rpm -qa |grep myspell
myspell-dictionaries-20190423-1.3.x86_64
myspell-es-20190423-1.3.noarch
myspell-en_US-20190423-1.3.noarch
myspell-es_ES-20190423-1.3.noarch
myspell-lightproof-en-20190423-1.3.x86_64
myspell-cs_CZ-20190423-1.3.noarch
myspell-en-20190423-1.3.noarch

antonio@linux-sywh:~> python3
Python 3.7.3 (default, Apr 09 2019, 05:18:21) [GCC] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import enchant
>>> enchant.Dict('es_ES')
<enchant.Dict object at 0x7f7b7bea8240>
>>> enchant.Dict('cs_CZ')
<enchant.Dict object at 0x7f7b7bea8940>
>>> enchant.Dict('en_US')
<enchant.Dict object at 0x7f7b7bea8240>

So it works fine here without enchant-1-backends.

I then installed enchant-1-backend-voikko and ...


>>> enchant.Dict('es_ES')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/site-packages/enchant/__init__.py", line 562, in __init__
    _EnchantObject.__init__(self)
  File "/usr/lib/python3.7/site-packages/enchant/__init__.py", line 168, in __init__
    self._init_this()
  File "/usr/lib/python3.7/site-packages/enchant/__init__.py", line 569, in _init_this
    this = self._broker._request_dict_data(self.tag)
  File "/usr/lib/python3.7/site-packages/enchant/__init__.py", line 310, in _request_dict_data
    self._raise_error(eStr % (tag,),DictNotFoundError)
  File "/usr/lib/python3.7/site-packages/enchant/__init__.py", line 258, in _raise_error
    raise eclass(default)
enchant.errors.DictNotFoundError: Dictionary for language 'es_ES' could not be found

So it seems that for some reason, enchant is preferring to use enchant-1-backend-voikko (which seems to need enchant-1-backends) instead of enchant-2-backend-hunspell (which works fine).
Comment 6 Antonio Larrosa 2019-07-19 06:42:01 UTC
Definitely, it's preferring libenchant 1 to enchant 2

  def _e_path_possibilities():
      """Generator yielding possible locations of the enchant library."""
      # Allow it to be overridden using an environment variable.
      yield os.environ.get("PYENCHANT_LIBRARY_PATH")
      # For linuxish systems, allow default soname lookup a chance to succeed.
      if sys.platform not in ("win32", "darwin"):
          yield "libenchant.so.1.6.0"
          yield "libenchant.so.1"
          yield "libenchant.so"
      # See if ctypes can find the library for us, under various names.
      yield find_library("enchant-2")
      yield find_library("enchant")
      yield find_library("libenchant")
      yield find_library("libenchant-1")
      # Special-case handling for enchant installed by macports.
      if sys.platform == 'darwin':
           yield "/opt/local/lib/libenchant.dylib"

We currently have libenchant.so.1.6.1, so basically, if PYENCHANT_LIBRARY_PATH is not set, that gives valid results first for "libenchant.so.1" (if libenchant1 is installed, and it's installed by enchant-1-backend-voikko) and for find_library("enchant-2") (which is the one that was used in my first successfull test), and then find_library("enchant"), gives a reference to "libenchant.so.1" again.

So I'd say our options are:
1) Remove the special case of preferring libenchant 1 on "linuxish systems"
2) Make enchant-1-backend-voikko require enchant-1-backends
3) All of the above

Opinions?
Comment 7 Tomáš Chvátal 2019-07-19 08:01:43 UTC
(In reply to Antonio Larrosa from comment #6)
> 
> So I'd say our options are:
> 1) Remove the special case of preferring libenchant 1 on "linuxish systems"
> 2) Make enchant-1-backend-voikko require enchant-1-backends
> 3) All of the above
> 
> Opinions?

I agree with option 3 the voikko should pull the backends on its own, yet pyenchant should really properly use enchant2 only first. I took the patch from upstream and just briefly tested it in docker and it worked... :)

For the record on TW it seems inkscape and pidgin are the 'evil' pullers of the old enchant:

Bude ODSTRANĚNO 23 balíčků:
  enchant-1-backends enchant-1-tools gtkspell-lang inkscape
  inkscape-extensions-dia inkscape-extensions-extra inkscape-extensions-gimp
  inkscape-lang libayatana-appindicator1 libayatana-indicator7 libdbusmenu-gtk4
  libenchant1 libgtkmm-2_4-1 libgtkspell0 libMagick++-7_Q16HDRI4 libplotter2
  libpotrace0 pidgin pidgin-plugin-indicator pidgin-plugin-indicator-lang
  pstoedit python2-scour yudit
Comment 8 Stefan Dirsch 2019-09-24 10:26:28 UTC
Seems Antonio already implemented option 2, if I understand his changelog and patch in python-pyenchant correctly.

-------------------------------------------------------------------
Fri Jul 19 10:11:23 UTC 2019 - Antonio Larrosa <alarrosa@suse.com>

- Modified enchant2.patch so the enchant-2 library is used when both
  enchant 1 and enchant 2 are installed on the system (boo#1141993).

From ed02ae493ade4ca749462d041ce83261783fa1a1 Mon Sep 17 00:00:00 2001
From: Raphael Michel <mail@raphaelmichel.de>
Date: Thu, 8 Mar 2018 10:40:00 +0100
Subject: [PATCH] Auto-detect enchant2

After support for enchant2 is already merged, the only thing missing is to detect the library :)
---
 enchant/_enchant.py | 1 +
 1 file changed, 1 insertion(+)

Index: pyenchant-2.0.0/enchant/_enchant.py
===================================================================
--- pyenchant-2.0.0.orig/enchant/_enchant.py
+++ pyenchant-2.0.0/enchant/_enchant.py
@@ -65,6 +65,7 @@ def _e_path_possibilities():
     """Generator yielding possible locations of the enchant library."""
     # Allow it to be overridden using an environment variable.
     yield os.environ.get("PYENCHANT_LIBRARY_PATH")
+    yield find_library("enchant-2")
     # For linuxish systems, allow default soname lookup a chance to succeed.
     if sys.platform not in ("win32", "darwin"):
         yield "libenchant.so.1.6.0"

I'm not sure about option 2 since I couldn't find our sources for enchant-1-backend-voikko.

Antonio, I'm reassigning this to you since the assignee appears to be a random reassignment. I don't see how Robert is related to this at all.
Comment 9 Stefan Dirsch 2019-09-24 10:31:17 UTC
Ok. Found  the sources for enchant-1-backend-voikko: enchant-1. Will do a submit request.
Comment 10 Stefan Dirsch 2019-09-24 10:38:11 UTC
(In reply to Stefan Dirsch from comment #8)
> Seems Antonio already implemented option 2, if I understand his changelog
> and patch in python-pyenchant correctly.

I meant option 1 of course.
Comment 11 Stefan Dirsch 2019-09-24 10:38:42 UTC
(In reply to Stefan Dirsch from comment #9)
> Ok. Found  the sources for enchant-1-backend-voikko: enchant-1. Will do a
> submit request.

Which is option 2.
Comment 12 Stefan Dirsch 2019-09-24 10:41:39 UTC
(In reply to Stefan Dirsch from comment #11)
> (In reply to Stefan Dirsch from comment #9)
> > Ok. Found  the sources for enchant-1-backend-voikko: enchant-1. Will do a
> > submit request.
> 
> Which is option 2.

done --> https://build.opensuse.org/request/show/732910

Closing as fixed.
Comment 13 Swamp Workflow Management 2019-09-26 07:50:07 UTC
This is an autogenerated message for OBS integration:
This bug (1141993) was mentioned in
https://build.opensuse.org/request/show/733326 Factory / enchant-1
Comment 14 OBSbugzilla Bot 2020-09-15 15:40:06 UTC
This is an autogenerated message for OBS integration:
This bug (1141993) was mentioned in
https://build.opensuse.org/request/show/834686 15.2 / python-pyenchant
Comment 15 Swamp Workflow Management 2020-10-18 16:15:29 UTC
openSUSE-RU-2020:1691-1: An update that has 5 recommended fixes can now be installed.

Category: recommended (moderate)
Bug References: 1082318,1141993,1166965,1171573,1172650
CVE References: 
JIRA References: 
Sources used:
openSUSE Leap 15.2 (src):    python-amqp-2.6.1-lp152.2.3.1, python-billiard-3.6.3.0-lp152.3.5.1, python-django-allauth-0.42.0-lp152.2.3.1, python-django-filter-2.3.0-lp152.2.3.1, python-jaraco.text-3.2.0-lp152.2.1, python-kombu-4.6.11-lp152.2.3.1, python-moto-1.3.14-lp152.2.1, python-pycairo-1.19.1-lp152.2.1, python-python-redis-lock-3.6.0-lp152.2.1, python-rq-1.4.3-lp152.2.1, python-sentry-sdk-0.14.4-lp152.2.1, python-social-auth-app-django-4.0.0-lp152.5.3.1, python-sphinx-jsonschema-1.15-lp152.2.1, python-sshpubkeys-3.1.0-lp152.2.1, python-toml-0.10.1-lp152.3.3.1, python-toml-test-0.10.1-lp152.3.3.6, python-translation-finder-2.1-lp152.2.3.1, python-weblate-schemas-0.4-lp152.2.1