Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Pull Request Suggestion for #4062 #4094

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions readme_4062.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
The objective of this Pull Request is to make installation more robust on mac's regarding freetype paths
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is useful information, but should not go into the repo as a tracked file. This seems better suited as a commit message or comments in the code.


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
14 changes: 14 additions & 0 deletions setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit : no spaces around =

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean like this, for example?
'sources = []' => 'sources=[]'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly

edit: just for include_dirs in line 945

Numpy().add_flags(ext)
return ext


class FT2Font(SetupPackage):
name = 'ft2font'

Expand Down
29 changes: 29 additions & 0 deletions test_4062.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import setupext
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please put this in the testing directory with the rest of the tests? We use nose every where else instead of unit test.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See http://matplotlib.org/devel/testing.html and all of the existing tests.

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())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only actual test in this as far as I can tell...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was planning to add more lines to the test_*() methods below.


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()