Solved question about pkg default compilation options for python

hello,
i'm using qgis on a freebsd release 14.3 and one of the plugins cannot work because it cannot create a sqlite-db.
i noticed that the extension _sqlite3 is disabled by default in the makefile and as far as i understand this is how the official pkg is created.
is there a reason (security?) that this is the case?

in any case, short of compiling from the ports, do i have a solution for that? this would undoubtedly be costly to recompile via poudriere on a "normal" laptop, wouldn't it?

anyways, thanks for the work in maintaining the port to those who do!
all the best,
a-

ps: i send this as an email but was asked to join the mailing list, it seems overkill to me and decided to post it here, if i broke many convention by doing it i apologize and will make penance by going in the forest and stroll under the rain for a while. if i *again* posted in the wrong topic, i'll do likewise. thanks :)
 
What does prevent you from installing the sqlite3 extension?
pkg install py311-sqlite3
when i read that i almost facepalmed myself... but actually this is not the issue :) for a moment i thought i was really silly. sqlite3 module is installed on my machine (i use it in other programs).
however, here is the error i got from qgis when attempting to use the plugin i need:

Code:
search_dialog.py", line 370, in checkMajicContent
              connector = CadastreCommon.getConnectorFromUri(self.connectionParams)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              File "/home/hern42/.local/share/QGIS/QGIS3/profiles/default/python/plugins/cadastre/cadastre_common_base.py", line 234, in getConnectorFromUri
              connector = SpatiaLiteDBConnector(uri)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
              File "/usr/local/share/qgis/python/plugins/db_manager/db_plugins/spatialite/connector.py", line 52, in __init__
              self.connection = spatialite_connect(self._connectionInfo())
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              File "/usr/local/share/qgis/python/qgis/utils.py", line 940, in spatialite_connect
              con.enable_load_extension(True)
              ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'sqlite3.Connection' object has no attribute 'enable_load_extension'

when looking at the makefile of /ports/lang/python311 there is the following line: DISABLED_EXTENSIONS= _sqlite3 _tkinter _gdbm which lets me think that i'd need to use a version of python311 with _sqlite3 not in the list of disabled extensions.
am i correct?
 
when looking at the makefile of /ports/lang/python311 there is the following line: DISABLED_EXTENSIONS= _sqlite3 _tkinter _gdbm which lets me think that i'd need to use a version of python311 with _sqlite3 not in the list of disabled extensions.
It may be disabled in python311 for the same reason it is disabled in python314:

Commit "lang/python314: split out _sqlite3 again."
Rich (BB code):
to avoid a dependency loop through ICU.

You can still try to compile from the ports tree (not poudriere) with the flag removed from the Makefile. To prevent building dependency ports use packages instead ("install-missing-packages"). There are quite a lot dependencies to build:
Code:
ports/lang/python311 ~ % make all-depends-list | wc -l
     908
The packages list should be shorter.
 
You can still try to compile from the ports tree (not poudriere) with the flag removed from the Makefile. To prevent building dependency ports use packages instead ("install-missing-packages"). There are quite a lot dependencies to build:
Code:
ports/graphics/qgis ~ % make all-depends-list | wc -l
    1270
The packages list should be shorter.
thanks for the answer...
will it not conflict with the pkg or should i delete it before?
 
will it not conflict with the pkg or should i delete it before?
Yes, it will conflict, but there is code to prevent the installation in this case and the user will be notified. But you don't need to de-install first, the "reinstall" target takes care of de-installation of the old package and installation of the new one ( ports(7) ).

But lets see if you get that far. There must be a reason the flag was set.

After you are done testing, you can remove the installed build dependencies executing pkg-autoremove(8).
 
Yes, it will conflict, but there is code to prevent the installation in this case and the user will be notified. But you don't need to de-install first, the "reinstall" target takes care of de-installation of the old package and installation of the new one ( ports(7) ).

But lets see if you get that far. There must be a reason the flag was set.

After you are done testing, you can remove the installed build dependencies executing pkg-autoremove(8).

some feedback about this affair :)

so i did that... recompile python with the flag set off.
i worked fine and was not really long.
then i reinstalled py-sqlite3
and it did not solve the issue with said qgis plugin...
i still need to see if installing py-sqlite-utils will change anything. then i'll email the plugin author and investigate that trail.

i'll keep you posted!
 
Code:
% sqlite3
SQLite version 3.50.4 2025-07-30 19:33:53
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .dbconfig
...
     load_extension on
...
sqlite> .quit


pkg info sqlite3



python3.11
Python 3.11.14 (main, Nov 14 2025, 07:59:58) [Clang 19.1.7 (https://github.com/llvm/llvm-project.git llvmorg-19.1.7-0-gcd7080 on freebsd14
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> conn = sqlite3.connect(":memory:")
>>> conn.execute("create table users(id, name)")
<sqlite3.Cursor object at 0x330877e3f2c0>
>>> conn.close()
>>> quit()
 
Code:
% sqlite3
SQLite version 3.50.4 2025-07-30 19:33:53
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .dbconfig
...
     load_extension on
...
sqlite> .quit


pkg info sqlite3


i have exactly the same output as you...
so that means the plugin is buggy? this one -> https://docs.3liz.org/QgisCadastrePlugin/ or https://github.com/3liz/QgisCadastrePlugin
 
I don't know which version of qgis you have in "/home/hern42/.local/share/QGIS/QGIS3/" You can try the 3.44.4 version from the ports /usr/ports/graphics/qgis

qgis->Plugins -> Manage and install Plugins... -> install from ZIP

1763474802801.png
 
I don't know which version of qgis you have in "/home/hern42/.local/share/QGIS/QGIS3/" You can try the 3.44.4 version from the ports /usr/ports/graphics/qgis


qgis->Plugins -> Manage and install Plugins... -> install from ZIP
the bug happens when trying to create a new spatialite database. cf screenshot. it creates a file but it's empty.
my qgis version is 3.44.4 and the plugin is 2.2.3
 

Attachments

  • 20251118_1922-screenshot_000.jpg
    20251118_1922-screenshot_000.jpg
    231.3 KB · Views: 30
Try to build python311 from the ports and add --enable-loadable-sqlite-extensions in configure_args in makefile

Code:
DISABLED_EXTENSIONS=    _tkinter _gdbm
CONFIGURE_ARGS+=        --enable-loadable-sqlite-extensions --enable-shared --without-ensurepip \
                        --with-system-ffi

1763535762001.png

1763536642761.png
 
alright, we're getting somewhere! thanks very much for your help VladiBG...
i managed to have the blank db created and to use the plugin tool to download a set of data. but then at the very end of the import procedure it fails.
here is the message:
Code:
An error has occurred while executing Python code:

UnboundLocalError: cannot access local variable 'sql' where it is not associated with a value
Traceback (most recent call last):
  File "/home/hern42/.local/share/QGIS/QGIS3/profiles/default/python/plugins/cadastre/cadastre_import.py", line 1679, in importEdigeoVecToDatabase
    c.executemany(query, [(item[0], item[1], item[2]) for item in l])
sqlite3.OperationalError: no such table: edigeo_rel

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/hern42/.local/share/QGIS/QGIS3/profiles/default/python/plugins/cadastre/dialogs/import_dialog.py", line 337, in processImport
    qi.importEdigeo()
  File "/home/hern42/.local/share/QGIS/QGIS3/profiles/default/python/plugins/cadastre/cadastre_import.py", line 830, in importEdigeo
    self.importAllEdigeoToDatabase()
  File "/home/hern42/.local/share/QGIS/QGIS3/profiles/default/python/plugins/cadastre/cadastre_import.py", line 1472, in importAllEdigeoToDatabase
    self.importEdigeoVecToDatabase(vec)
  File "/home/hern42/.local/share/QGIS/QGIS3/profiles/default/python/plugins/cadastre/cadastre_import.py", line 1682, in importEdigeoVecToDatabase
    self.qc.updateLog('Erreurs pendant la requête : %s' % sql)
                                                                 ^^^
UnboundLocalError: cannot access local variable 'sql' where it is not associated with a value


Python version: 3.11.13 (main, Nov 25 2025, 17:32:08) [Clang 19.1.7 (https://github.com/llvm/llvm-project.git llvmorg-19.1.7-0-gcd7080
QGIS version: 3.44.5-Solothurn Solothurn, exported

Python Path:
/usr/local/share/qgis/python
/home/hern42/.local/share/QGIS/QGIS3/profiles/default/python
/home/hern42/.local/share/QGIS/QGIS3/profiles/default/python/plugins
/usr/local/share/qgis/python/plugins
/usr/local/lib/python311.zip
/usr/local/lib/python3.11
/usr/local/lib/python3.11/lib-dynload
/home/hern42/.local/lib/python3.11/site-packages
/usr/local/lib/python3.11/site-packages
/home/hern42/.local/share/QGIS/QGIS3/profiles/default/python
/home/hern42/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qfieldsync/libqfieldsync_62853968a3cc98953ff7f41f8770a7f9d1b6a80e.whl
/home/hern42/Documents/Qgis perso/Mailly-la-Ville(89270)

it seems to me that this time it's coming from them.
i relayed the issue. we'll see what happens.
fingers crossed.
a-

ps: of course there are other ways to import this data but it's cumbersome when there is a lot of different sets to import recursively
 

Attachments

  • 20251125_1753-screenshot_selection.jpg
    20251125_1753-screenshot_selection.jpg
    293.3 KB · Views: 10
it's the same data. i get it town by town instead of by "département" from https://cadastre.data.gouv.fr/datasets/plan-cadastral-informatise (there is a tool at the bottom that let's you choose data granularity and type (edigeo is supported amongst others).
besides, the cadastre plugin comes with a nifty tool that let's you get the same directly from qgis, and it works fine.
did you also update to the newest version of the tool (25/11/2025)?
 
my bad!
i got the entire departement89 archive and then used the plugin with only one commune. and it worked! i have no idea why... i'll investigate.
many many thanks!
a-
ps: if BG is for bulgaria, how comes you are using a french cadastre GIS tool?? :)
 
Back
Top