我最近从源代码安装了 python,并使用以下命令从源代码安装 SQLite 和从源代码安装 Python 2.7.13。
对于 SQLite3,您可以使用以下命令 $SQLITE_INSTALL_LOCATION
$ curl -O http://www.sqlite.org/sqlite-autoconf-3070603.tar.gz
$ tar xvfz sqlite-autoconf-3070603.tar.gz
$ cd sqlite-autoconf-3070603
$ ./configure --prefix=$SQLITE_INSTALL_LOCATION --disable-static CFLAGS="-g"
$ make && make install
然后,当我编译我的 python 时,我在 Python 源代码的根目录中编辑了 setup.py
$ curl -O https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
$ tar xvfz Python-2.7.13.tgz
Python-2.7.13/setup.py -- 在此处添加 SQLite 安装路径:```
...
# We hunt for #define SQLITE_VERSION "n.n.n"
# We need to find >= sqlite version 3.0.8
sqlite_incdir = sqlite_libdir = None
sqlite_inc_paths = [ '/usr/include',
'/usr/include/sqlite',
'/usr/include/sqlite3',
'/usr/local/include',
'/usr/local/include/sqlite',
'/usr/local/include/sqlite3',
$SQLITE_INSTALL_LOCATION/include,
]
...
一旦你更改了 python 源代码中的 setup.py ,假设安装位置是 $PYTHON_INSTALL_LOCATION,就完成编译和安装 python
$ cd Python-2.7.13
$ LD_RUN_PATH=$SQLITE_INSTALL_LOCATION/lib ./configure --prefix=$PYTHON_INSTALL_LOCATION --enable-shared --enable-unicode=ucs4
$ LD_RUN_PATH=$SQLITE_INSTALL_LOCATION/lib make
$ LD_RUN_PATH=$SQLITE_INSTALL_LOCATION/lib make install
一旦你这样做了,你应该在 $PYTHON_INSTALL_LOCATION/bin/python 安装一个支持 SQLite3 的 Python 版本
希望这可以帮助!