From cdabe7a75ea14f14ca8d4cd3bf9ac36cb1817531 Mon Sep 17 00:00:00 2001 From: neodarz Date: Fri, 28 Apr 2017 19:05:18 +0200 Subject: Delete some usless file --- ...python-with-sqlite-in-nonstandard-location.html | 68 ---------------------- 1 file changed, 68 deletions(-) delete mode 100644 build/blog/2016-10-26-pyenv-compiling-python-with-sqlite-in-nonstandard-location.html (limited to 'build/blog/2016-10-26-pyenv-compiling-python-with-sqlite-in-nonstandard-location.html') diff --git a/build/blog/2016-10-26-pyenv-compiling-python-with-sqlite-in-nonstandard-location.html b/build/blog/2016-10-26-pyenv-compiling-python-with-sqlite-in-nonstandard-location.html deleted file mode 100644 index 0a1fab47..00000000 --- a/build/blog/2016-10-26-pyenv-compiling-python-with-sqlite-in-nonstandard-location.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - -pyenv: compiling Python with SQLite in nonstandard location - - - - - - - - - -
This blog has been archived.
Visit my home page at zhimingwang.org.
- -
-
-

pyenv: compiling Python with SQLite in nonstandard location

- -
-

This is a quick post sharing a workaround that I needed just now.

-

I was trying to compile Pythons with pyenv on a RHEL 6.8 cluster. Unfortunately sqlite-devel is not installed and I doubt I can convince my sysadmin to install a package for me. The lack of SQLite headers resulted in Pythons without _sqlite3 which is essential for me. Hinting at SQLite headers from Linuxbrew with CPATH did not help either.

-

Digging into CPython source code, turns out that CPython only looks into a fixed set of paths:

-
sqlite_inc_paths = [ '/usr/include',
-                     '/usr/include/sqlite',
-                     '/usr/include/sqlite3',
-                     '/usr/local/include',
-                     '/usr/local/include/sqlite',
-                     '/usr/local/include/sqlite3',
-                     ]
-if cross_compiling:
-    sqlite_inc_paths = []
-

Well that's unfortunate. Luckily pyenv makes it really easy to patch Python source code; take a look at plugins/python-build/share/python-build/patches and you'll get the idea. Therefore, in the case of Linuxbrew'ed pyenv and SQLite, say we want to build Python 3.5.2 with SQLite support, we simply put the following patch at ~/.linuxbrew/opt/pyenv/plugins/python-build/share/python-build/patches/3.5.2/Python-3.5.2/linuxbrew-sqlite3.patch:

-
diff --git a/setup.py b/setup.py
-index 174ce72..774fd65 100644
---- a/setup.py
-+++ b/setup.py
-@@ -1108,6 +1108,7 @@ class PyBuildExt(build_ext):
-                              '/usr/local/include',
-                              '/usr/local/include/sqlite',
-                              '/usr/local/include/sqlite3',
-+                             os.path.expanduser('~/.linuxbrew/opt/sqlite/include/'),
-                              ]
-         if cross_compiling:
-             sqlite_inc_paths = []
-

That's it. Now

-
$ pyenv install 3.5.2
-

and enjoy.

-
-
- - - -- cgit v1.2.1