Merge pull request #656 from jacknagel/ft

Adjust Homebrew freetype detection logic
This commit is contained in:
Alex Clark ☺ 2014-05-10 10:28:55 -07:00
commit e85114ae73

View File

@ -206,22 +206,28 @@ class pil_build_ext(build_ext):
_add_directory(library_dirs, "/opt/local/lib") _add_directory(library_dirs, "/opt/local/lib")
_add_directory(include_dirs, "/opt/local/include") _add_directory(include_dirs, "/opt/local/include")
# if homebrew is installed, use its lib and include directories # if Homebrew is installed, use its lib and include directories
import subprocess import subprocess
try: try:
prefix = subprocess.check_output(['brew', '--prefix']) prefix = subprocess.check_output(['brew', '--prefix']).strip()
except:
# Homebrew not installed
prefix = None
ft_prefix = None
if prefix: if prefix:
prefix = prefix.strip() # add Homebrew's include and lib directories
_add_directory(library_dirs, os.path.join(prefix, 'lib')) _add_directory(library_dirs, os.path.join(prefix, 'lib'))
_add_directory(include_dirs, os.path.join(prefix, 'include')) _add_directory(include_dirs, os.path.join(prefix, 'include'))
ft_prefix = os.path.join(prefix, 'opt', 'freetype')
# freetype2 is a key-only brew under opt/ if ft_prefix and os.path.isdir(ft_prefix):
_add_directory(library_dirs, os.path.join(prefix, 'opt', 'freetype', 'lib')) # freetype might not be linked into Homebrew's prefix
_add_directory(include_dirs, os.path.join(prefix, 'opt', 'freetype', 'include')) _add_directory(library_dirs, os.path.join(ft_prefix, 'lib'))
except: _add_directory(include_dirs, os.path.join(ft_prefix, 'include'))
pass # homebrew not installed else:
# fall back to freetype from XQuartz if Homebrew's freetype is missing
# freetype2 ships with X11 (after homebrew, so that homebrew freetype is preferred)
_add_directory(library_dirs, "/usr/X11/lib") _add_directory(library_dirs, "/usr/X11/lib")
_add_directory(include_dirs, "/usr/X11/include") _add_directory(include_dirs, "/usr/X11/include")