Skip to content

Instantly share code, notes, and snippets.

@jphalip
Last active December 11, 2015 14:29
Show Gist options
  • Save jphalip/4614527 to your computer and use it in GitHub Desktop.
Save jphalip/4614527 to your computer and use it in GitHub Desktop.
Bash script for a Chef recipe to install PIL with Zlib and Freetype support in a Vagrant Ubuntu 32bit box. I wish PIL offered a cleaner way of doing this other than having to modify its setup.py.
%w{libjpeg-dev libfreetype6-dev}.each do |pkg|
package pkg do
action :install
end
end
bash "Install PIL from source" do
user vagrant
group vagrant
code <<-EOH
. #{virtualenv_path}/bin/activate
pip install --no-install PIL==1.1.7
sed 's/ZLIB_ROOT = None/ZLIB_ROOT = ("\\/usr\\/lib\\/i386-linux-gnu", "\\/usr\\/include")/' #{virtualenv_path}/build/PIL/setup.py > #{virtualenv_path}/build/PIL/setup-modified.py ; mv #{virtualenv_path}/build/PIL/setup-modified.py #{virtualenv_path}/build/PIL/setup.py
sed 's/FREETYPE_ROOT = None/FREETYPE_ROOT = ("\\/usr\\/lib\\/i386-linux-gnu", "\\/usr\\/include\\/freetype2\\/freetype")/' #{virtualenv_path}/build/PIL/setup.py > #{virtualenv_path}/build/PIL/setup-modified.py ; mv #{virtualenv_path}/build/PIL/setup-modified.py #{virtualenv_path}/build/PIL/setup.py
python #{virtualenv_path}/build/PIL/setup.py install
EOH
not_if "test -d #{virtualenv_path}/lib/python2.7/site-packages/PIL"
end
@jphalip
Copy link
Author

jphalip commented Jan 23, 2013

The symlink approach is quite neat, thanks. Also yes, the code above is only for a 32bit Ubuntu distro. The recipe could be improved by leveraging Chef's distro detection logic.

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