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

Skip to content

Commit 5dfded1

Browse files
committed
Restore pkg-config version checks.
1 parent b73f541 commit 5dfded1

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

setupext.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,19 @@ def set_pkgconfig_path(self):
161161
except KeyError:
162162
os.environ['PKG_CONFIG_PATH'] = pkgconfig_path
163163

164-
def setup_extension(self, ext, package,
165-
alt_exec=None, default_libraries=()):
164+
def setup_extension(
165+
self, ext, package,
166+
atleast_version=None, alt_exec=None, default_libraries=()):
166167
"""Add parameters to the given *ext* for the given *package*."""
167168

168169
# First, try to get the flags from pkg-config.
169170

170171
cmd = ([self.pkg_config, package] if self.pkg_config else alt_exec)
171172
if cmd is not None:
172173
try:
174+
if self.pkg_config and atleast_version:
175+
subprocess.check_call(
176+
[*cmd, f"--atleast-version={atleast_version}"])
173177
flags = shlex.split(subprocess.check_output(
174178
[*cmd, "--cflags", "--libs"], universal_newlines=True))
175179
except (OSError, subprocess.CalledProcessError):
@@ -200,19 +204,6 @@ def setup_extension(self, ext, package,
200204
# Default linked libs.
201205
ext.libraries.extend(default_libraries)
202206

203-
def get_version(self, package):
204-
"""
205-
Get the version of the package from pkg-config.
206-
"""
207-
if not self.has_pkgconfig:
208-
return None
209-
210-
status, output = subprocess.getstatusoutput(
211-
self.pkg_config + " %s --modversion" % (package))
212-
if status == 0:
213-
return output
214-
return None
215-
216207

217208
# The PkgConfig class should be used through this singleton
218209
pkg_config = PkgConfig()
@@ -630,7 +621,11 @@ def add_flags(self, ext):
630621
ext.define_macros.append(('FREETYPE_BUILD_TYPE', 'local'))
631622
else:
632623
pkg_config.setup_extension(
624+
# FreeType 2.3 has libtool version 9.11.3 as can be checked
625+
# from the tarball. For FreeType>=2.4, there is a conversion
626+
# table in docs/VERSIONS.txt in the FreeType source tree.
633627
ext, 'freetype2',
628+
atleast_version='9.11.3',
634629
alt_exec=['freetype-config', '--cflags', '--libs'],
635630
default_libraries=['freetype', 'z'])
636631
ext.define_macros.append(('FREETYPE_BUILD_TYPE', 'system'))
@@ -799,6 +794,7 @@ def get_extension(self):
799794
ext = Extension('matplotlib._png', sources)
800795
pkg_config.setup_extension(
801796
ext, 'libpng',
797+
atleast_version='1.2',
802798
alt_exec=['libpng-config', '--cflags', '--ldflags'],
803799
default_libraries=['png', 'z'])
804800
Numpy().add_flags(ext)

0 commit comments

Comments
 (0)