Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd1060a8

Browse files
authored
Merge pull request#11983 from anntzer/builddepchecks
BLD: Simplify version checks for freetype and libpng.
2 parents879b7f0 +923ce72 commitd1060a8

File tree

3 files changed

+28
-73
lines changed

3 files changed

+28
-73
lines changed

‎setupext.py

Lines changed: 10 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,13 @@ def add_flags(self, ext, add_sources=True):
814814
forxinagg_sources)
815815

816816

817+
# For FreeType2 and libpng, we add a separate checkdep_foo.c source to at the
818+
# top of the extension sources. This file is compiled first and immediately
819+
# aborts the compilation either with "foo.h: No such file or directory" if the
820+
# header is not found, or an appropriate error message if the header indicates
821+
# a too-old version.
822+
823+
817824
classFreeType(SetupPackage):
818825
name="freetype"
819826
pkg_names= {
@@ -825,59 +832,8 @@ class FreeType(SetupPackage):
825832
"windows_url":"http://gnuwin32.sourceforge.net/packages/freetype.htm"
826833
}
827834

828-
defcheck(self):
829-
ifoptions.get('local_freetype'):
830-
return"Using local version for testing"
831-
832-
ifsys.platform=='win32':
833-
try:
834-
check_include_file(get_include_dirs(),'ft2build.h','freetype')
835-
exceptCheckFailed:
836-
check_include_file(get_include_dirs(),os.path.join('freetype2','ft2build.h'),'freetype')
837-
return'Using unknown version found on system.'
838-
839-
status,output=subprocess.getstatusoutput(
840-
"freetype-config --ftversion")
841-
ifstatus==0:
842-
version=output
843-
else:
844-
version=None
845-
846-
# Early versions of freetype grep badly inside freetype-config,
847-
# so catch those cases. (tested with 2.5.3).
848-
ifversionisNoneor'No such file or directory\ngrep:'inversion:
849-
version=self.version_from_header()
850-
851-
# pkg_config returns the libtool version rather than the
852-
# freetype version so we need to explicitly pass the version
853-
# to _check_for_pkg_config
854-
returnself._check_for_pkg_config(
855-
'freetype2','ft2build.h',
856-
min_version='2.3',version=version)
857-
858-
defversion_from_header(self):
859-
version='unknown'
860-
ext=self.get_extension()
861-
ifextisNone:
862-
returnversion
863-
# Return the first version found in the include dirs.
864-
forinclude_dirinext.include_dirs:
865-
header_fname=os.path.join(include_dir,'freetype.h')
866-
ifos.path.exists(header_fname):
867-
major,minor,patch=0,0,0
868-
withopen(header_fname,'r')asfh:
869-
forlineinfh:
870-
ifline.startswith('#define FREETYPE_'):
871-
value=line.rsplit(' ',1)[1].strip()
872-
if'MAJOR'inline:
873-
major=value
874-
elif'MINOR'inline:
875-
minor=value
876-
else:
877-
patch=value
878-
return'.'.join([major,minor,patch])
879-
880835
defadd_flags(self,ext):
836+
ext.sources.insert(0,'src/checkdep_freetype2.c')
881837
ifoptions.get('local_freetype'):
882838
src_path=os.path.join(
883839
'build','freetype-{0}'.format(LOCAL_FREETYPE_VERSION))
@@ -1058,30 +1014,11 @@ class Png(SetupPackage):
10581014
"windows_url":"http://gnuwin32.sourceforge.net/packages/libpng.htm"
10591015
}
10601016

1061-
defcheck(self):
1062-
ifsys.platform=='win32':
1063-
check_include_file(get_include_dirs(),'png.h','png')
1064-
return'Using unknown version found on system.'
1065-
1066-
status,output=subprocess.getstatusoutput("libpng-config --version")
1067-
ifstatus==0:
1068-
version=output
1069-
else:
1070-
version=None
1071-
1072-
try:
1073-
returnself._check_for_pkg_config(
1074-
'libpng','png.h',
1075-
min_version='1.2',version=version)
1076-
exceptCheckFailedase:
1077-
ifhas_include_file(get_include_dirs(),'png.h'):
1078-
returnstr(e)+' Using unknown version found on system.'
1079-
raise
1080-
10811017
defget_extension(self):
10821018
sources= [
1019+
'src/checkdep_libpng.c',
10831020
'src/_png.cpp',
1084-
'src/mplutils.cpp'
1021+
'src/mplutils.cpp',
10851022
]
10861023
ext=make_extension('matplotlib._png',sources)
10871024
pkg_config.setup_extension(

‎src/checkdep_freetype2.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include<ft2build.h>
2+
#includeFT_FREETYPE_H
3+
4+
#defineXSTR(x) STR(x)
5+
#defineSTR(x) #x
6+
7+
#pragma message("Compiling with FreeType version " \
8+
XSTR(FREETYPE_MAJOR) "." XSTR(FREETYPE_MINOR) "." XSTR(FREETYPE_PATCH) ".")
9+
#ifFREETYPE_MAJOR <<16+FREETYPE_MINOR <<8+FREETYPE_PATCH<0x020300
10+
#error "FreeType version 2.3 or higher is required." \
11+
"Consider setting the MPLLOCALFREETYPE environment variable to 1."
12+
#error
13+
#endif

‎src/checkdep_libpng.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include<png.h>
2+
#pragma message("Compiling with libpng version " PNG_LIBPNG_VER_STRING ".")
3+
#ifPNG_LIBPNG_VER<10200
4+
#error "libpng version 1.2 or higher is required."
5+
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp