diff --git a/readme_4062.txt b/readme_4062.txt new file mode 100644 index 000000000000..e723d77729d8 --- /dev/null +++ b/readme_4062.txt @@ -0,0 +1,37 @@ +The objective of this Pull Request is to make installation more robust on mac's regarding freetype paths + +Analysis on existing commit(master 8f10470): ++ Setup.py has a list of pre-requisit packages "mpl_packages." ++ A for loop after "__main__" check goes through this list. ++ If package.check() returns a value other than None, setup recognizes that package. + ++ Setupext.py has a class for Freetype incluidng check(). ++ FreeType check() method searches for a header file name "ft2build.h." + ++ On mac, FreeType check() method works as follows. +++ Using "freetype-config --ftversion" command, check version. +++ check() returns the return value from _check_for_pkg_config(). + ++++ _check_for_pkg_config() belongs to superclass SetupPackage of setupext.py ++++ _check_for_pkg_config() calls self.get_extension() to obtain ext object + Here, because FreeType doesn't overload get_extension() method, + calls SetupPackage.get_extension() returning None ++++ Then, _check_for_pkg_config() calls make_extension('test', []) for ext object + whose include_dirs covers + ['/usr/local/include', '/usr/include', '/usr/X11/include', '/opt/X11/include', '.'] ++++ _check_for_pkg_config() returns result from check_include_file() + +++++ check_include_file() searches for include files within paths in ext.include_dirs +++++ check_include_file() calls has_include_file(include_dirs, filename) ++++++ has_include_file(include_dirs, filename) searches for following files + /usr/local/include/ft2build.h + /usr/include/ft2build.h + /usr/X11/include/ft2build.h + /opt/X11/include/ft2build.h + ./ft2build.h ++++++ possible locations are + /opt/X11/include/freetype2 + /usr/local/include/freetype2 + +++ Hence, it could be more desirable if FreeType get_extension() could return + an ext object with include_dirs information about paths above diff --git a/setupext.py b/setupext.py index 780a21f0ee3a..25ae221d1e1f 100755 --- a/setupext.py +++ b/setupext.py @@ -933,6 +933,20 @@ def add_flags(self, ext): default_libraries=['freetype', 'z']) + def get_extension(self): + sources = [] + include_dirs = ['include/freetype2', 'freetype2', + 'lib/freetype2/include', + 'lib/freetype2/include/freetype2', + '/opt/X11/include/freetype2', # mac osx X window installation + '/usr/local/include/freetype2' # ref : http://stackoverflow.com/questions/4092994/unable-to-install-matplotlib-on-mac-os-x + ] + ext = make_extension('matplotlib.freetype', sources, + include_dirs = include_dirs) + Numpy().add_flags(ext) + return ext + + class FT2Font(SetupPackage): name = 'ft2font' diff --git a/test_4062.py b/test_4062.py new file mode 100644 index 000000000000..5c71c0fc83c0 --- /dev/null +++ b/test_4062.py @@ -0,0 +1,29 @@ +import setupext +import unittest +from pprint import pprint +reload(setupext) + +class testFreetypeRobustInstallation (unittest.TestCase): + def setUp(self): + self.ft = setupext.FreeType() + + def test_check(self): + self.assertEqual(r"version 2.5.5", self.ft.check()) + + def test_get_extension(self): + '''test FreeType get_extension() for returnedn .include_dirs''' + print "test_get_extension ".ljust(60, '+') + ext = self.ft.get_extension() + print "ext.include_dirs ".ljust(30, '+') + pprint (ext.include_dirs) + + def test_make_extension(self): + ext = setupext.make_extension('test', []) + print "test_make_extension ".ljust(60, '*') + print ext.include_dirs + + def tearDown(self): + del self.ft + +if "__main__" == __name__: + unittest.main()