Skip to content

Instantly share code, notes, and snippets.

@jamescarr
Last active May 25, 2016 07:08
Show Gist options
  • Save jamescarr/97d3c85bfa8f0f4b95878a81d3ec111e to your computer and use it in GitHub Desktop.
Save jamescarr/97d3c85bfa8f0f4b95878a81d3ec111e to your computer and use it in GitHub Desktop.

Building a stand alone deb for a recent python

I needed a more recent python for one of our projects but you can't update the system python on ubuntu 14.04 without breaking some core mechanics. Here's the steps I went through!

Install required tools

sudo apt-get install -y \
autotools-dev      \
blt-dev            \
bzip2              \
dpkg-dev           \
g++-multilib       \
gcc-multilib       \
libbluetooth-dev   \
libbz2-dev         \
libexpat1-dev      \
libffi-dev         \
libffi6            \
libffi6-dbg        \
libgdbm-dev        \
libgpm2            \
libncursesw5-dev   \
libreadline-dev    \
libsqlite3-dev     \
libssl-dev         \
libtinfo-dev       \
mime-support       \
net-tools          \
netbase            \
python-crypto      \
python-mox3        \
python-pil         \
python-ply         \
quilt              \
tk-dev             \
zlib1g-dev

Get and Compile Python

wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz
tar xfz Python-2.7.11.tgz
cd Python-2.7.11/
./configure --prefix /usr/local/lib/python2.7.11 --enable-ipv6
make
sudo make install

Now we do a rough test to make sure all is good:

/usr/local/lib/python2.7.11/bin/python -V
Python 2.7.11

Create a Package with FPM

Finally, we want to create a package so we can redistribute this.

The first step is to install ruby and fpm

apt-get install -y ruby-dev gcc
gem install fpm

Then build a package with fpm. Be careful not to name it the same as an existing package out there (e.g. python) or it will conflict with it and force you to do apt-get install -f to fix missing, which will leave you with a broken system and tears of disbelief.

export ORGNAME=yourorgname
export [email protected]
fpm -s dir -t deb -m $MAINTAINER_EMAIL -n $ORGNAME-python -v 2.7.11 /usr/local/lib/python2.7.11

That's it! Now it is ready for distribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment