Skip to content
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

Identification of freetype when 'freetype-config --ftversion' fails. #3363

Merged
merged 1 commit into from Aug 15, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions setupext.py
Expand Up @@ -935,10 +935,37 @@ def check(self):
else:
version = None

# Early versions of freetype grep badly inside freetype-config,
# so catch those cases. (tested with 2.5.3).
if 'No such file or directory\ngrep:' in version:
version = self.version_from_header()

return self._check_for_pkg_config(
'freetype2', 'ft2build.h',
min_version='2.4', version=version)

def version_from_header(self):
version = 'Failed to identify version.'
ext = self.get_extension()
if ext is None:
return version
# Return the first version found in the include dirs.
for include_dir in ext.include_dirs:
header_fname = os.path.join(include_dir, 'freetype.h')
if os.path.exists(header_fname):
major, minor, patch = 0, 0, 0
with open(header_fname, 'r') as fh:
for line in fh:
if line.startswith('#define FREETYPE_'):
value = line.rsplit(' ', 1)[1].strip()
if 'MAJOR' in line:
major = value
elif 'MINOR' in line:
minor = value
else:
patch = value
return '.'.join([major, minor, patch])

def add_flags(self, ext):
pkg_config.setup_extension(
ext, 'freetype2',
Expand Down