Skip to content

Instantly share code, notes, and snippets.

@bebosudo
Created April 15, 2018 14:57
Show Gist options
  • Save bebosudo/7b1c0650e2f94d26afe830530764de65 to your computer and use it in GitHub Desktop.
Save bebosudo/7b1c0650e2f94d26afe830530764de65 to your computer and use it in GitHub Desktop.
Compile python 3.6 locally, with openssl and sqlite3 support
Create a dir to build things into:
$ mkdir ~/stack && cd ~/stack
Download the sources (sqlite 3230100 was broken, 3220000 was used instead):
$ wget https://www.openssl.org/source/openssl-1.1.0h.tar.gz
$ wget https://sqlite.org/2018/sqlite-src-3220000.zip
$ wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
Add paths in your ~/.bashrc so that when you'll compile python below, it'll find the just compiled programs:
export PATH=$HOME/.local/bin:$PATH
export LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH
export MANPATH=$HOME/.local/share/man:$MANPATH
export PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig:$PKG_CONFIG_PATH
Then enter into a computing node (!), and load the most recent gnu compiler:
$ module load gnu
Sometimes, doing things too much in parallel (-j8) breaks tests. Try reducing it (-j4).
Compile openssl:
$ tar xf openssl-1.1.0h.tar.gz && cd openssl-1.1.0h
$ ./config --prefix=$HOME/.local/
$ make -j8
$ make -j8 test
$ make -j8 install
Compile sqlite3 (tcl needs to be disabled, otherwise it tries to install things in /usr; tests cannot be done, since they use tcl):
$ unzip sqlite-src-3220000.zip
$ mkdir sqlite-src-3220000_build && cd sqlite-src-3220000_build/
$ ../sqlite-src-3220000/configure --prefix=$HOME/.local/ --disable-tcl
$ make -j8
$ make -j8 install
Compile python (tests are already performed during compile time; try adding --with-lto to configure, it should improve things):
$ tar xf Python-3.6.5.tar.xz && cd Python-3.6.5/
$ ./configure --prefix=$HOME/.local/ --enable-optimizations
$ make -j8
$ make -j8 install
Before doing the make install of python, make sure that it found both ssl and sqlite libraries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment