From: Jelle Licht <jlicht@fsfe.org>
To: help-guix <help-guix@gnu.org>
Subject: python to support SQLite extensions
Date: Mon, 10 May 2021 23:31:33 +0200 [thread overview]
Message-ID: <86tunagtsa.fsf@fsfe.org> (raw)
Hello folks,
I want to enable support for loadable extensions in python's sqlite3
module. This should be enabled by passing
`--enable-loadable-sqlite-extensions' to `./configure'.
I've spend an embarassing amount of time on this, so perhaps someone out
there understands python better than I do and can elucidate me.
This does depend on our SQLite package needing support for loadable
extensions, but it seems it does.
I've tried the following custom package definition:
--8<---------------cut here---------------start------------->8---
(define-public python/sqlite-extensions
(package
(inherit python)
(arguments
(substitute-keyword-arguments (package-arguments python)
((#:configure-flags flags '())
`(cons "--enable-loadable-sqlite-extensions" ,flags))))))
--8<---------------cut here---------------end--------------->8---
... which seems to 'work', according to the build log:
--8<---------------cut here---------------start------------->8---
[snip]
checking for --enable-loadable-sqlite-extensions... yes
[snip]
--8<---------------cut here---------------end--------------->8---
Sadly, even with my freshly built python3, I get the following:
--8<---------------cut here---------------start------------->8---
#> import sqlite3
#> conn=sqlite3.connect("/tmp/some-db.sqlite")
#> conn.enable_load_extension(True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'sqlite3.Connection' object has no attribute 'enable_load_extension'
--8<---------------cut here---------------end--------------->8---
Does anybody perhaps know why my python is correctly receiving (and
subsequently ignoring) this configure flag? It seems that *something*
happens between the 'configure' script receiving the flag, and the file
in `Modules/_sqlite/connection.c' being built, it seems
SQLITE_OMIT_LOAD_EXTENSION is set to "1".
This (seemingly) happens in setup.py, lines 1432 and on:
--8<---------------cut here---------------start------------->8---
if '--enable-loadable-sqlite-extensions' not in sysconfig.get_config_var("CONFIG_ARGS"):
sqlite_defines.append(("SQLITE_OMIT_LOAD_EXTENSION", "1"))
--8<---------------cut here---------------end--------------->8---
Indeed, in *any* python3 I can find on my Guix System, I see:
--8<---------------cut here---------------start------------->8---
#> import sysconfig
#> sysconfig.get_config_var("CONFIG_ARGS")
'--with-system-ffi'
--8<---------------cut here---------------end--------------->8---
Something weird is going on!
I have no clue how to continue finding why this happens, but for my
personal problem I can just patch python's setup.py file.
Thanks for any pointers,
- Jelle
NB, this configure option happens to be enabled by default in many other
distro's (among which Nix [1]), so it might actually make sense to also
set things up in such a way on our next core-updates cycle, once the
flag actually does something.
[1] https://github.com/NixOS/nixpkgs/pull/67472/files
next reply other threads:[~2021-05-10 21:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-10 21:31 Jelle Licht [this message]
2021-05-16 17:56 ` python to support SQLite extensions Felix Gruber
2021-05-31 19:22 ` Jelle Licht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86tunagtsa.fsf@fsfe.org \
--to=jlicht@fsfe.org \
--cc=help-guix@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).