Skip to content

Commit

Permalink
Merge pull request #4807 from markusr815/master
Browse files Browse the repository at this point in the history
BLD: setupext.py: let the user set a different pkg-config
  • Loading branch information
tacaswell committed Aug 30, 2015
2 parents 5630a97 + 64d8ac6 commit fb12c7b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
8 changes: 8 additions & 0 deletions INSTALL
Expand Up @@ -135,6 +135,14 @@ the latest *tar.gz* release file from `the download page
to develop matplotlib or just need the latest bugfixed version, grab
the latest git version :ref:`install-from-git`.

The standard environment variables `CC`, `CXX`, `PKG_CONFIG` are respected.
This means you can set them if your toolchain is prefixed. This may be used for
cross compiling.

export CC=x86_64-pc-linux-gnu-gcc
export CXX=x86_64-pc-linux-gnu-g++
export PKG_CONFIG=x86_64-pc-linux-gnu-pkg-config

Once you have satisfied the requirements detailed below (mainly
python, numpy, libpng and freetype), you can build matplotlib::

Expand Down
10 changes: 10 additions & 0 deletions doc/users/whats_new.rst
Expand Up @@ -98,6 +98,16 @@ IPython's ``HTML`` display class::
from IPython.display import HTML
HTML(anim.to_html5_video())

Prefixed pkg-config for building
--------------------------------

Handling of `pkg-config` has been fixed in so far as it is now possible to set
it using the environment variable `PKG_CONFIG`. This is important if your
toolchain is prefixed. This is done in a simpilar way as setting `CC` or `CXX`
before building. An example follows.

export PKG_CONFIG=x86_64-pc-linux-gnu-pkg-config


.. _whats-new-1-4:

Expand Down
11 changes: 8 additions & 3 deletions setupext.py
Expand Up @@ -252,8 +252,13 @@ def __init__(self):
if sys.platform == 'win32':
self.has_pkgconfig = False
else:
try:
self.pkg_config = os.environ['PKG_CONFIG']
except KeyError:
self.pkg_config = 'pkg-config'

self.set_pkgconfig_path()
status, output = getstatusoutput("pkg-config --help")
status, output = getstatusoutput(self.pkg_config + " --help")
self.has_pkgconfig = (status == 0)
if not self.has_pkgconfig:
print("IMPORTANT WARNING:")
Expand Down Expand Up @@ -286,7 +291,7 @@ def setup_extension(self, ext, package, default_include_dirs=[],

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

use_defaults = True

Expand Down Expand Up @@ -330,7 +335,7 @@ def get_version(self, package):
return None

status, output = getstatusoutput(
"pkg-config %s --modversion" % (package))
self.pkg_config + " %s --modversion" % (package))
if status == 0:
return output
return None
Expand Down

0 comments on commit fb12c7b

Please sign in to comment.