Building Python 2.5 with full Sqlite3 as a user on linux

[亡魂溺海] 提交于 2021-02-07 18:15:13

问题


This is a bit of a complex problem, at least for me. Here it goes:

I'm working as a user on linux server and it's safe to assume that installing any package not already installed is simply impossible.

Also I need to set up working Python 2.5 (not installed) with working SQLite3 library (Sqlite in any form not installed).

What I can do is: 1. Compile Python 2.5 and make it work 2. Compile amalgamation of SQLite3

Anyway - Python 2.5 is supposed to have interaction with Sqlite3 built-in (pysqlite). It seems true enough, however importing sqlite3: import sqlite3 fails because - in the end - it is impossible to import _sqlite3

Some googling lead me to understand that while pysqlite may be built-in, the sqlite is not. Therefore I assumed that I need to built in locally sqlite and somehow make these two pieces of software interact.

Fair enough.

I'm able to - I hope so - compile amalgamation to shared object but it seems messy. Should I rename sqlite3.so to _sqlite3 and throw it somewhere? It seems fishy a bit, I tried it anyway and get an error: dynamic module does not define init function (init_sqlite3)

At this point I'm a bit stuck. I'm not too familiar with building/compiling stuff - I admit that sudo apt-get / sudo yum made me lazy but for some reason it is not an option at the moment.

Help appreciated!


回答1:


First download, build and install sqlite3 with a --prefix. Then build python with same prefix , it will find sqlite installation and will build _sqlite3 module.

$ mkdir -p ~/applications/src
$ cd ~/applications/src
$ wget http://www.sqlite.org/sqlite-autoconf-3070900.tar.gz
$ tar xvvf sqlite-autoconf-3070900.tar.gz
$ cd sqlite-autoconf-3070900
$ ./configure --prefix=~/applications
$ make
$ make install

$ cd ~/applications/src
$ wget http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tgz
$ tar xvvf Python-2.5.2.tgz
$ cd Python-2.5.2
$ ./configure --prefix=~/applications
$ make
$ make install

$ ~/applications/bin/python
>>> import sqlite3
>>> # no error!


来源:https://stackoverflow.com/questions/8656158/building-python-2-5-with-full-sqlite3-as-a-user-on-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!