From c731dabdb73974278e392f8b4158b0bb6958919c Mon Sep 17 00:00:00 2001 From: Kangwon Lee Date: Fri, 6 Feb 2015 13:27:32 -0800 Subject: [PATCH 1/7] started readme_4062.txt : described objective of the pull request and early part of current status analysis --- readme_4062.txt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 readme_4062.txt diff --git a/readme_4062.txt b/readme_4062.txt new file mode 100644 index 000000000000..8cd31ad99748 --- /dev/null +++ b/readme_4062.txt @@ -0,0 +1,9 @@ +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." From 444bc5fe5e42d32556798326a939f34cfdbb8418 Mon Sep 17 00:00:00 2001 From: Kangwon Lee Date: Fri, 6 Feb 2015 13:30:06 -0800 Subject: [PATCH 2/7] started test_4062.py : a test setup for FreeType check() and other related methods possibly including superclass methods (not overloaded) --- test_4062.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 test_4062.py diff --git a/test_4062.py b/test_4062.py new file mode 100644 index 000000000000..43ac2191c126 --- /dev/null +++ b/test_4062.py @@ -0,0 +1,9 @@ +import setupext +import unittest + +class testFreetypeRobustInstallation (unittest.TestCase): + def setUp(self): + self.ft = setupext.FreeType() + + def tearDown(self): + del self.ft From 5a8275da83608688db2ffefb517f2f973b1b5160 Mon Sep 17 00:00:00 2001 From: Kangwon Lee Date: Fri, 6 Feb 2015 21:26:22 -0800 Subject: [PATCH 3/7] added analysis on FreeType check(), _check_for_pkg_config(), make_extension(); enabled command line testing; added test for FreeType check(); added call to make_extension() --- readme_4062.txt | 15 +++++++++++++++ test_4062.py | 11 +++++++++++ 2 files changed, 26 insertions(+) diff --git a/readme_4062.txt b/readme_4062.txt index 8cd31ad99748..3a4d2669f913 100644 --- a/readme_4062.txt +++ b/readme_4062.txt @@ -7,3 +7,18 @@ Analysis on existing commit(master 8f10470): + 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 diff --git a/test_4062.py b/test_4062.py index 43ac2191c126..8f14b6b54356 100644 --- a/test_4062.py +++ b/test_4062.py @@ -5,5 +5,16 @@ class testFreetypeRobustInstallation (unittest.TestCase): def setUp(self): self.ft = setupext.FreeType() + def test_check_None(self): + self.assertEqual(r"version 2.5.5", self.ft.check()) + + 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() From f7d4604357bbc18547323c683eaf7de2ab736054 Mon Sep 17 00:00:00 2001 From: Kangwon Lee Date: Fri, 6 Feb 2015 22:15:24 -0800 Subject: [PATCH 4/7] revised analysis : check_include_file(), has_include_file() --- readme_4062.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/readme_4062.txt b/readme_4062.txt index 3a4d2669f913..e723d77729d8 100644 --- a/readme_4062.txt +++ b/readme_4062.txt @@ -22,3 +22,16 @@ Analysis on existing commit(master 8f10470): +++ _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 From e532e97f3dd648f71ddff2b458128d36b0061846 Mon Sep 17 00:00:00 2001 From: Kangwon Lee Date: Sat, 7 Feb 2015 10:07:24 -0800 Subject: [PATCH 5/7] added pprint(); setUp() : reload setupext to make sure newest code is under test renamed test_check_None() -> test_check() : expected return different added test_get_extension() : calls FreeType get_extension() and pprint include_dirs --- test_4062.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test_4062.py b/test_4062.py index 8f14b6b54356..5c71c0fc83c0 100644 --- a/test_4062.py +++ b/test_4062.py @@ -1,13 +1,22 @@ import setupext import unittest +from pprint import pprint +reload(setupext) class testFreetypeRobustInstallation (unittest.TestCase): def setUp(self): self.ft = setupext.FreeType() - def test_check_None(self): + 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, '*') From b252e49de4a5d7806246f294b63465502d5b9aeb Mon Sep 17 00:00:00 2001 From: Kangwon Lee Date: Sat, 7 Feb 2015 10:08:08 -0800 Subject: [PATCH 6/7] FreeType : added get_extension() method --- setupext.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/setupext.py b/setupext.py index 780a21f0ee3a..386afe4f54f6 100755 --- a/setupext.py +++ b/setupext.py @@ -933,6 +933,17 @@ 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'] + ext = make_extension('matplotlib.freetype', sources, + include_dirs = include_dirs) + Numpy().add_flags(ext) + return ext + + class FT2Font(SetupPackage): name = 'ft2font' From b18df2745bae6f92263f7a71f9a6a3b313927277 Mon Sep 17 00:00:00 2001 From: Kangwon Lee Date: Tue, 10 Feb 2015 13:15:07 -0800 Subject: [PATCH 7/7] added possible freetype installation paths for mac osx --- setupext.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/setupext.py b/setupext.py index 386afe4f54f6..25ae221d1e1f 100755 --- a/setupext.py +++ b/setupext.py @@ -937,7 +937,10 @@ def get_extension(self): sources = [] include_dirs = ['include/freetype2', 'freetype2', 'lib/freetype2/include', - 'lib/freetype2/include/freetype2'] + '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)