Skip to content

Commit fb12c7b

Browse files
committed
Merge pull request matplotlib#4807 from markusr815/master
BLD: setupext.py: let the user set a different pkg-config
2 parents 5630a97 + 64d8ac6 commit fb12c7b

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

INSTALL

+8
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ the latest *tar.gz* release file from `the download page
135135
to develop matplotlib or just need the latest bugfixed version, grab
136136
the latest git version :ref:`install-from-git`.
137137

138+
The standard environment variables `CC`, `CXX`, `PKG_CONFIG` are respected.
139+
This means you can set them if your toolchain is prefixed. This may be used for
140+
cross compiling.
141+
142+
export CC=x86_64-pc-linux-gnu-gcc
143+
export CXX=x86_64-pc-linux-gnu-g++
144+
export PKG_CONFIG=x86_64-pc-linux-gnu-pkg-config
145+
138146
Once you have satisfied the requirements detailed below (mainly
139147
python, numpy, libpng and freetype), you can build matplotlib::
140148

doc/users/whats_new.rst

+10
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ IPython's ``HTML`` display class::
9898
from IPython.display import HTML
9999
HTML(anim.to_html5_video())
100100

101+
Prefixed pkg-config for building
102+
--------------------------------
103+
104+
Handling of `pkg-config` has been fixed in so far as it is now possible to set
105+
it using the environment variable `PKG_CONFIG`. This is important if your
106+
toolchain is prefixed. This is done in a simpilar way as setting `CC` or `CXX`
107+
before building. An example follows.
108+
109+
export PKG_CONFIG=x86_64-pc-linux-gnu-pkg-config
110+
101111

102112
.. _whats-new-1-4:
103113

setupext.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,13 @@ def __init__(self):
252252
if sys.platform == 'win32':
253253
self.has_pkgconfig = False
254254
else:
255+
try:
256+
self.pkg_config = os.environ['PKG_CONFIG']
257+
except KeyError:
258+
self.pkg_config = 'pkg-config'
259+
255260
self.set_pkgconfig_path()
256-
status, output = getstatusoutput("pkg-config --help")
261+
status, output = getstatusoutput(self.pkg_config + " --help")
257262
self.has_pkgconfig = (status == 0)
258263
if not self.has_pkgconfig:
259264
print("IMPORTANT WARNING:")
@@ -286,7 +291,7 @@ def setup_extension(self, ext, package, default_include_dirs=[],
286291

287292
executable = alt_exec
288293
if self.has_pkgconfig:
289-
executable = 'pkg-config {0}'.format(package)
294+
executable = (self.pkg_config + ' {0}').format(package)
290295

291296
use_defaults = True
292297

@@ -330,7 +335,7 @@ def get_version(self, package):
330335
return None
331336

332337
status, output = getstatusoutput(
333-
"pkg-config %s --modversion" % (package))
338+
self.pkg_config + " %s --modversion" % (package))
334339
if status == 0:
335340
return output
336341
return None

0 commit comments

Comments
 (0)