penberg / limbo

Limbo is a work-in-progress, in-process OLTP database management system, compatible with SQLite.
MIT License
1.04k stars 66 forks source link

CPython support #128

Open penberg opened 4 months ago

penberg commented 4 months ago

This is going to be a huge task, but the goal is to be able to build CPython using Limbo's SQLite compatibility library.

You can build Python with Limbo as follows:

git clone --depth 1 https://github.com/python/cpython.git
cd python
export LIBSQLITE3_LIBS=<LIMBO SOURCES>/target/debug/liblimbo_sqlite3.a
./configure
make -j8

I already added bunch of stubs to make it link, but there's tons of stuff to implement:

https://github.com/penberg/limbo/commit/17137ec458a9eed0eddc16d21e7ea457b057be36

penberg commented 4 months ago

After pull request #176, CPython no builds. The next step is to make it actually work:

penberg@turing:~/src/penberg/cpython$ ./python 
Python 3.14.0a0 (heads/main:e8c91d9, Jul 17 2024, 13:04:45) [GCC 13.2.1 20231205 (Red Hat 13.2.1-6)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> con = sqlite3.connect("tutorial.db")
thread '<unnamed>' panicked at sqlite3/src/lib.rs:339:5:
not yet implemented
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
Aborted (core dumped)
lietu commented 3 months ago

It seems unlikely people would want a custom build of Python to use a library, is there work in progress on a pylimbo -library that would specifically wrap this library and get published on PyPI?

penberg commented 3 months ago

@lietu Right, the main reason to do CPython support like this is more about ensuring SQLite compatibility. A pylimbo package makes sense when we have some more of the functionality covered. It should be pretty easy to build with something like https://github.com/PyO3/maturin