Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Assuming that you have all the dependencies installed (on Ubuntu that would be bunch of things like <code>sudo apt-get install libdb4.8-dev</code> and various other -dev packages, then this is how I build Python.</p> <pre><code>tar zxvf Python-2.7.1.tgz cd Python-2.7.1 # 64 bit self-contained build in /opt export TARG=/opt/python272 export CC="gcc -m64" export LDFLAGS='-Wl,-rpath,\$${ORIGIN}/../lib -Wl,-rpath-link,\$${ORIGIN}/../lib -Wl,--enable-new-dtags' ./configure --prefix=$TARG --with-dbmliborder=bdb:gdbm --enable-shared --enable-ipv6 make make install </code></pre> <p>The only modules that don't build during make are:</p> <pre><code>_tkinter - I don't do GUI apps and would use wxWindows if I did bsddb185 - horribly obsolete version of bdb dl - deprecated in 2.6 imageop - deprecated in 2.6 sunaudiodev - obsolete interface to some SparcStation device I think </code></pre> <p>Next I collect any .so files that are not already in the Python install directories and copy them over:</p> <pre><code># collect binary libraries ##REDO THIS IF YOU ADD ANY ADDITIONAL MODULES## cd /opt/python272 find . -name '*.so' | sed 's/^/ldd -v /' &gt;elffiles echo "ldd -v bin/python" &gt;&gt;elffiles chmod +x elffiles ./elffiles | sed 's/.*=&gt; //;s/ .*//;/:$/d;s/^ *//' | sort -u | sed 's/.*/cp -L &amp; lib/' &gt;lddinfo # mkdir lib chmod +x lddinfo ./lddinfo </code></pre> <p>And then add setuptools for good measure</p> <pre><code>#set the path export PATH=/opt/python272/bin:$PATH #install setuptools ./setuptools-0.6c11-py2.7.egg </code></pre> <p>At this point I can make a tarball of /opt/python272 and run it on any 64-bit Linux distro, even a stripped down one that has none of the dependencies installed, or a older distro that has old obsolete versions of the dependencies.</p> <p>I also get <code>pip</code> installed but at this point there is a gap in my notes due to some failed struggles with virtualenv. Basically virtualenv does not support this scenario. Presumably I did <code>easy_install pip</code> and then:</p> <pre><code>export LD_RUN_PATH=\$${ORIGIN}/../lib pip install cython pip install {a whole bunch of other libraries that I expect to use} </code></pre> <p>After I'm done installing modules, I go back and rerun the commands to collect .so files, and make a new tarball. There were a couple of packages where I had to muck around with <code>LDFLAGS</code> to get them to install correctly, and I haven't done enough thorough testing yet, but so far it works and I'm using this Python build to run production applications on machines that don't have all the support libraries preinstalled.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload