Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 851741 - dev-python/apsw-3.38.5_p1: Breaks app-text/calibre-5.43.0
Summary: dev-python/apsw-3.38.5_p1: Breaks app-text/calibre-5.43.0
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords: PATCH
: 859892 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-06-13 17:21 UTC by Bernd Feige
Modified: 2022-09-25 07:57 UTC (History)
7 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Ebuild patch to restore --enable=load_extension (apsw-load_extension.patch,495 bytes, patch)
2022-06-20 07:25 UTC, Bernard Cafarelli
Details | Diff
Output of emerge --info dev-python/apsw (apsw-emerge--info.txt,6.77 KB, text/plain)
2022-07-23 00:58 UTC, David Suarez
Details
Output of equery f dev-python/apsw (apsw-equery_f.txt,884 bytes, text/plain)
2022-07-23 00:59 UTC, David Suarez
Details
apsw-3.39.2.1-enable-more-extensions.patch (file_851741.txt,1.10 KB, patch)
2022-09-06 05:34 UTC, Sam James
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bernd Feige 2022-06-13 17:21:02 UTC
File "/usr/lib64/calibre/calibre/constants.py", line 325, in load_apsw_extension
    conn.enableloadextension(True)
AttributeError: 'Connection' object has no attribute 'enableloadextension'

Calibre works with dev-python/apsw-3.38.1_p1. Recompiling calibre after dev-python/apsw-3.38.5_p1 does not help.

Reproducible: Always
Comment 1 Matthias Schwarzott gentoo-dev 2022-06-15 08:43:25 UTC
According to https://bugs.launchpad.net/calibre/+bug/1935747, "sqlite extension loading" need to be enabled.

Comparing good and bad ebuild:
--- dev-python/apsw/apsw-3.38.1_p1.ebuild       2022-06-01 11:51:42.989165532 +0200
+++ dev-python/apsw/apsw-3.38.5_p1.ebuild       2022-06-10 15:28:53.683234235 +0200
@@ -4,7 +4,7 @@
 EAPI=8
 
 DISTUTILS_USE_PEP517=setuptools
-PYTHON_COMPAT=( python3_{8..10} )
+PYTHON_COMPAT=( python3_{8..11} )
 
 inherit distutils-r1
 
@@ -24,7 +24,7 @@
 
 LICENSE="ZLIB"
 SLOT="0"
-KEYWORDS="amd64 ~arm ~ppc64 x86"
+KEYWORDS="~amd64 ~arm ~ppc64 ~x86"
 IUSE="doc"
 
 DEPEND="
@@ -38,12 +38,6 @@
        "${FILESDIR}/${PN}-3.6.20.1-fix_tests.patch"
 )
 
-python_compile() {
-       distutils-r1_python_compile --enable=load_extension
-       mv "${BUILD_DIR}/install${EPREFIX}/usr/apsw.pyi" \
-               "${BUILD_DIR}/install$(python_get_sitedir)" || die
-}
-
 python_test() {
        esetup.py build_test_extension
        "${EPYTHON}" tests.py -v || die "Tests failed under ${EPYTHON}"
Comment 2 krloom 2022-06-18 09:37:27 UTC
I have same error using stable dev-python/apsw-3.38.1_p1
Comment 3 Bernard Cafarelli gentoo-dev 2022-06-20 07:25:04 UTC
Created attachment 786389 [details, diff]
Ebuild patch to restore --enable=load_extension

This restores the --enable=load_extension part and calibre opens properly from quick test
Comment 4 krloom 2022-06-21 05:03:59 UTC
I patched apsw-3.38.5_p1 and installed it. 
Still not working.(As I said it did not work with apsw-3.38.1_p1 too).
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-06-21 05:07:20 UTC
(In reply to krloom from comment #4)
> I patched apsw-3.38.5_p1 and installed it. 
> Still not working.(As I said it did not work with apsw-3.38.1_p1 too).

I would expect the patched version to work. Are you sure you installed the right one? You'll need to patch the ebuild itself.
Comment 6 Guillaume Castagnino 2022-06-21 05:31:09 UTC
On my side, downgrade worked, and patch works for me.
Thank’s!
Comment 7 krloom 2022-06-21 15:21:47 UTC
Hi!

(In reply to Sam James from comment #5)
> (In reply to krloom from comment #4)
> > I patched apsw-3.38.5_p1 and installed it. 
> > Still not working.(As I said it did not work with apsw-3.38.1_p1 too).
> 
> I would expect the patched version to work. Are you sure you installed the
> right one? You'll need to patch the ebuild itself.

Yeah, I installed right one.
(I used commands like "ebuild apsw-3.38.5_p1.ebuild digest" and "ACCEPT_KEYWORDS="~amd64" emerge apsw -v" )

But one more thing: my environment is PYTHON_SINGLE_TARGET="python3_10" PYTHON_TARGETS="python3_10" so  maybe I have some kind of python-10 problem. As I already said stable apsw is broken too.
Comment 8 Bernd Feige 2022-06-21 16:00:12 UTC
The patched ebuild fixes the problem for me too, thanks!
Comment 9 Larry the Git Cow gentoo-dev 2022-06-23 05:41:47 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=da975336a864f624adb8931df83fdf0a4e64bd1c

commit da975336a864f624adb8931df83fdf0a4e64bd1c
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2022-06-23 05:41:38 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-06-23 05:41:38 +0000

    dev-python/apsw: restore extension to fix Calibre
    
    Closes: https://bugs.gentoo.org/851741
    Signed-off-by: Sam James <sam@gentoo.org>

 dev-python/apsw/apsw-3.38.5_p1-r1.ebuild | 54 ++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
Comment 10 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-07-22 16:57:53 UTC
*** Bug 859892 has been marked as a duplicate of this bug. ***
Comment 11 David Suarez 2022-07-22 23:36:59 UTC
Hello, I tried to solve this problem by syncing and updating world, but I still have the same problem, even when I upgraded apsw to version 3.38.5_p1-r1:

$ ipython
Python 3.10.5 (main, Jul 22 2022, 11:55:31) [GCC 11.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import apsw

In [2]: connection=apsw.Connection(":memory:")

In [3]: connection.enableloadextension(True)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 connection.enableloadextension(True)

AttributeError: 'apsw.Connection' object has no attribute 'enableloadextension'

In [4]: apsw.apswversion()
Out[4]: '3.38.5-r1'
Comment 12 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-07-23 00:37:34 UTC
(In reply to David Suarez from comment #11)
> Hello, I tried to solve this problem by syncing and updating world, but I
> still have the same problem, even when I upgraded apsw to version
> 3.38.5_p1-r1:
> 
> $ ipython
>[...]
> AttributeError: 'apsw.Connection' object has no attribute
> 'enableloadextension'
> 
> In [4]: apsw.apswversion()
> Out[4]: '3.38.5-r1'

Thanks for sharing a reproducer.

$ python3.10
>>> import apsw
>>> connection=apsw.Connection(":memory:")
>>> connection.enableloadextension(True)
>>> apsw.apswversion()
'3.38.5-r1'

This works okay for me.

Could you share:
1. emerge --info dev-python/apsw
2. equery f dev-python/apsw (use an attachment for that)?
Comment 13 David Suarez 2022-07-23 00:58:20 UTC
Created attachment 793238 [details]
Output of emerge --info dev-python/apsw
Comment 14 David Suarez 2022-07-23 00:59:15 UTC
Created attachment 793241 [details]
Output of equery f dev-python/apsw
Comment 15 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-07-23 01:02:02 UTC
(In reply to David Suarez from comment #14)
> Created attachment 793241 [details]
> Output of equery f dev-python/apsw

Huh. Our lists are the same and the extension is installed... (/usr/lib/python3.10/site-packages/apsw/__init__.cpython-310-x86_64-linux-gnu.so).
Comment 16 David Suarez 2022-07-23 02:15:50 UTC
(In reply to Sam James from comment #15)
> (In reply to David Suarez from comment #14)
> > Created attachment 793241 [details]
> > Output of equery f dev-python/apsw
> 
> Huh. Our lists are the same and the extension is installed...
> (/usr/lib/python3.10/site-packages/apsw/__init__.cpython-310-x86_64-linux-
> gnu.so).

Yes, I don't know what is wrong, but I am afraid it is related to how apsw is built by portage, since when I build it from source it doesn't throw the error:

(apsw)$ python
Python 3.10.5 (main, Jul 22 2022, 11:55:31) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import apsw
>>> apsw.apswversion()
'3.38.5-r1'
>>> apsw.__file__
'/tmp/apsw/lib/python3.10/site-packages/apsw-3.38.5.post1-py3.10-linux-x86_64.egg/apsw/__init__.cpython-310-x86_64-linux-gnu.so'
>>> connection=apsw.Connection(":memory:")
>>> connection.enableloadextension(True)

While the system version does:

$ python
Python 3.10.5 (main, Jul 22 2022, 11:55:31) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import apsw
>>> apsw.apswversion()
'3.38.5-r1'
>>> apsw.__file__
'/usr/lib/python3.10/site-packages/apsw/__init__.cpython-310-x86_64-linux-gnu.so'
>>> connection=apsw.Connection(":memory:")
>>> connection.enableloadextension(True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'apsw.Connection' object has no attribute 'enableloadextension'
Comment 17 krloom 2022-09-04 09:58:23 UTC
I used following dirty hack to get dev-python/apsw-3.39.2.0::gentoo working:
1. # FEATURES="keepwork" emerge apsw -v
2. Calibre does not work
3. Edit file /tmp/portage/dev-python/apsw-3.39.2.0/work/apsw-3.39.2.0/src/connection.c
remove line "#if !defined(SQLITE_OMIT_LOAD_EXTENSION)" and "#endif" in lines 3668 and 3673
4. rm /tmp/portage/dev-python/apsw-3.39.2.0/.compiled
5. # FEATURES="keepwork" emerge apsw -v
6. Calibre is ok :)
Comment 18 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-09-06 05:34:38 UTC
Created attachment 803356 [details, diff]
apsw-3.39.2.1-enable-more-extensions.patch

Could someone try apsw-3.39.2.1-enable-more-extensions.patch I've attached?

I still have no idea why I can't repro this.

I'm wondering if there's some orphaned file on your system?

Could someone still hitting this run: qfile -o /usr/lib/python3.*/*/*
Comment 19 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2022-09-06 07:21:12 UTC
(In reply to Sam James from comment #18)
> Created attachment 803356 [details, diff] [details, diff]
> apsw-3.39.2.1-enable-more-extensions.patch
> 
> Could someone try apsw-3.39.2.1-enable-more-extensions.patch I've attached?
> 
> I still have no idea why I can't repro this.
> 
> I'm wondering if there's some orphaned file on your system?
> 
> Could someone still hitting this run: qfile -o /usr/lib/python3.*/*/*

FYI, upstream is working on making apsw autodetect build options from sqlite3, and it'll probably be in the next release.
Comment 20 Matthias Schwarzott gentoo-dev 2022-09-06 09:42:25 UTC
It seems dev-python/apsw-3.39.2.1 breaks this again.

It seems handling multiple --enable= arguments is not supported in the way the ebuild tries it.
So this change is needed:
--- a/dev-python/apsw/apsw-3.39.2.1.ebuild
+++ b/dev-python/apsw/apsw-3.39.2.1.ebuild
@@ -33,7 +33,7 @@ RDEPEND="
 python_compile() {
        # Needed for e.g. bug #851741
        # Enable column-metadata to match dev-db/sqlite
-       distutils-r1_python_compile --enable=load_extension --enable=column_metadata
+       distutils-r1_python_compile --enable=load_extension,column_metadata
 }
 
 python_test() {
Comment 21 krloom 2022-09-06 16:51:33 UTC

Hi!

I patched both apsw-3.39.2.0.ebuild and apsw-3.39.2.1.ebuild  with "distutils-r1_python_compile --enable=load_extension,column_metadata" line.
But Calibre did not work with that.

I got Calibre again working with " krloom@gmail.com 2022-09-04 09:58:23 UTC " hack.


I think maybe bug is here (from emerge -v output):
x86_64-pc-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -march=native -O2 -pipe -flto=3 -fuse-linker-plugin -fPIC -DNDEBUG=1 -DAPSW_FORK_CHECKER=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -Isrc -I/usr/include/python3.10 -c src/apsw.c -o build/temp.linux-x86_64-cpython-310/src/apsw.o
Look at this "-DSQLITE_OMIT_LOAD_EXTENSION=1"  compiler switch. I do not know where it comes.....
Comment 22 Larry the Git Cow gentoo-dev 2022-09-06 21:54:58 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6f184c3a08706e44f848ef7428adf3315a4e2999

commit 6f184c3a08706e44f848ef7428adf3315a4e2999
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2022-09-06 21:54:45 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-09-06 21:54:45 +0000

    dev-python/apsw: fix --enable for extensions syntax
    
    Needs to be comma separated. Not adding the whole list right now as upstream are
    working on autodetection?
    
    Bug: https://bugs.gentoo.org/851741
    Signed-off-by: Sam James <sam@gentoo.org>

 dev-python/apsw/{apsw-3.39.2.1.ebuild => apsw-3.39.2.1-r1.ebuild} | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 23 Bernd Feige 2022-09-24 18:56:05 UTC
Really sorry to say that dev-python/apsw-3.39.3.0 got me the same calibre error again:

calibre, version 5.44.0
[Invalid database location...]

Traceback (most recent call last):
  File "/usr/lib64/calibre/calibre/gui2/main.py", line 330, in initialize_db
    db = LibraryDatabase(self.library_path)
  File "/usr/lib64/calibre/calibre/db/legacy.py", line 187, in __init__
    backend = self.backend = create_backend(library_path, default_prefs=default_prefs,
  File "/usr/lib64/calibre/calibre/db/legacy.py", line 44, in create_backend
    return DB(library_path, default_prefs=default_prefs,
  File "/usr/lib64/calibre/calibre/db/backend.py", line 460, in __init__
    if self.user_version == 0:
  File "/usr/lib64/calibre/calibre/db/backend.py", line 1212, in user_version
    return self.conn.get('pragma user_version;', all=False)
  File "/usr/lib64/calibre/calibre/db/backend.py", line 925, in conn
    self._conn = Connection(self.dbpath)
  File "/usr/lib64/calibre/calibre/db/backend.py", line 339, in __init__
    plugins.load_apsw_extension(self, 'sqlite_extension')
  File "/usr/lib64/calibre/calibre/constants.py", line 329, in load_apsw_extension
    conn.enableloadextension(True)
AttributeError: 'Connection' object has no attribute 'enableloadextension'

Now, I guess this version of dev-python/apsw should have the autodetection discussed in https://github.com/rogerbinns/apsw/issues/363 ? There no longer are --enable options at all to tinker with, only use_system_sqlite_config=True...

Again, recompiling calibre, or recompiling apsw without ccache etc, did not help. Using dev-python/apsw-3.39.2.1-r1 did.

BTW: qfile -o /usr/lib/python3.*/*/* for me gives:
/usr/lib/python3.10/site-packages/include_server-3.4-py3.10.egg-info.backup.0000
/usr/lib/python3.10/site-packages/tre-0.8.0-py3.10.egg-info.backup.0000
Comment 24 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2022-09-24 19:37:16 UTC
I'm sorry about that.  I guess load_extension is not something that is enabled through autodetection -- I guess it's special.
Comment 25 Larry the Git Cow gentoo-dev 2022-09-24 19:38:03 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cb01a1c377bb2bf0ffec4bc8f47da12f61f23cbb

commit cb01a1c377bb2bf0ffec4bc8f47da12f61f23cbb
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: 2022-09-24 19:36:27 +0000
Commit:     Michał Górny <mgorny@gentoo.org>
CommitDate: 2022-09-24 19:38:00 +0000

    dev-python/apsw: Reenable load_extension, again
    
    Closes: https://bugs.gentoo.org/851741
    Signed-off-by: Michał Górny <mgorny@gentoo.org>

 dev-python/apsw/{apsw-3.39.3.0.ebuild => apsw-3.39.3.0-r1.ebuild} | 1 +
 1 file changed, 1 insertion(+)
Comment 26 Bernd Feige 2022-09-25 07:57:57 UTC
Thanks Michał - that worked :-)