# ParaView 5.9.0-RC1 superbuild package configuration issue affecting matplotlib's detection of freetype and zlib

**URL:** https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831
**Category:** Development
**Created:** [November 17, 2020, 10:10pm UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831 "2020-11-17T22:10:37Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![joeh](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@joeh](https://discourse.paraview.org/u/joeh)
#### Post date: [November 17, 2020, 10:10pm UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831/1 "2020-11-17T22:10:37Z")

</div>

The ParaView 5.9.0-RC1 superbuild does not seem to add the package config directory to it PKG\_CONFIG\_PATH unless you add it yourself

setenv PKG\_CONFIG\_PATH Build\_dir/install}/lib/pkgconfig

without this the matplotlib section can not find the freetype2.pc file

also the superbuild zlib build fails to put its zlib.pc configuration file into the Build\_dir/install}/lib/pkgconfig

so one must manually copy it

cp Build\_dir/superbuild/zlib/build/zlib.pc to Build\_dir/install/lib/pkgconfig

for matplotlib to dectect and use it.

Thanks,

Joe Hennessey

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [November 17, 2020, 11:53pm UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831/2 "2020-11-17T23:53:49Z")

</div>

We do set it up (`superbuild/cmake/SuperbuildMacros.cmake` line 1192 and it is built up in `superbuild/cmake/SuperbuildUtils.cmake` line 129). Is there something going wrong with these? You can see the effects of it in the relevant `superbuild/sb-*-configure.cmake` scripts). `zlib` seems to put it into `install/share/pkgconfig/zlib.pc` instead (which is wrong, but is also a place that should be searched).

---

<div class="post-metadata">

### Author: ![joeh](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@joeh](https://discourse.paraview.org/u/joeh)
#### Post date: [November 18, 2020, 4:17am UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831/3 "2020-11-18T04:17:01Z")

</div>

Ben,

I am not sure what is going wrong with the superbuild script but it seems to just affect matplotlib and nothing else it seems that there is a file in matplotlib

Build\_dir/superbuild/matplotlib/src/setupext.py

which has a function get\_pkg\_config() lines 232-252 in the file

I suspect it must be causing the issue somehow.

a workaround could still be to set

setenv PKG\_CONFIG\_PATH Build\_dir/install/lib/pkgconfig:Build\_dir/install/share/pkgconfig

where Build\_dir is your build directory. This would allow matplotlib to find freetype2 and zlib.pc then.

Thanks,

Joe

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [November 18, 2020, 8:30pm UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831/4 "2020-11-18T20:30:11Z")

</div>

`PKG_CONFIG_PATH` should already get set as part of the superbuild though. Could you provide the information from the `sb-matplotlib-build.cmake` file? When I configure (without setting `PKG_CONFIG_PATH` manually), I see `PKG_CONFIG_PATH;/home/boeckb/misc/builds/paraview/build-sb/install/lib/pkgconfig:/home/boeckb/misc/builds/paraview/build-sb/install/share/pkgconfig` in it which should be doing what you’re trying to do manually. Is it there? If so, is it correct? If not, we need to figure out what is missing.

---

<div class="post-metadata">

### Author: ![joeh](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@joeh](https://discourse.paraview.org/u/joeh)
#### Post date: [November 19, 2020, 2:20am UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831/5 "2020-11-19T02:20:23Z")

</div>

Ben,

Here is the information you requested.

```
# Handle the environment when running a primary step (configure, build,
# install) of a project.

set(environment "PKG_CONFIG;LDFLAGS; ;CPPFLAGS; ;CXXFLAGS;-fPIC ;CFLAGS;-fPIC ;PATH;/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/bin;LD_LIBRARY_PATH;/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/lib:/p/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/lib:/app/DAAC/build/Qt/5.12.10/lib:/app/DAAC/build/libpthread-stubs/0.3/lib:/app/DAAC/build/libtool/2.4.6/lib:/app/DAAC/build/glproto/1.4.17/lib:/p/app/hpe/mpt-2.17/lib:/p/app/gnu/6.3.0/lib64:/usr/lib64:/usr/lib;PKG_CONFIG_PATH;/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/lib/pkgconfig:/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/share/pkgconfig:/app/DAAC/build/Qt/5.12.10/lib/pkgconfig;PYTHONPATH;/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/lib/python3.8/site-packages")
set(list_separator "-+-")
set(command "/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/bin/python3;setup.py;build")

set(env_separator ":")
# These environment variables are prepended to using `env_separator`.
set(prepend_envvars
PATH CMAKE_PREFIX_PATH PKG_CONFIG_PATH)
if (WIN32)
  set(env_separator ";")
elseif (APPLE)
  list(APPEND prepend_envvars
  DYLD_LIBRARY_PATH)
elseif (UNIX)
  list(APPEND prepend_envvars
  LD_LIBRARY_PATH)
endif ()

set(key)
foreach (arg IN LISTS environment)
  if (NOT key)
    set(key "${arg}")
  else ()
    list(FIND prepend_envvars "${key}" index)
    if (index EQUAL "-1")
      set(value "${arg}")
    else ()
      set(value "${arg}${env_separator}$ENV{${key}}")
    endif ()
    string(REPLACE "${list_separator}" ";" value "${value}")
    set("ENV{${key}}" "${value}")

    unset(key)
  endif ()
endforeach ()

string(REPLACE "${list_separator}" "\;" command "${command}")

execute_process(
COMMAND ${command}
RESULT_VARIABLE rv)

if (rv)
  message(FATAL_ERROR "Failed with exit code ${rv}")
endif ()

```

Thanks,

Joe

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [November 19, 2020, 3:39am UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831/6 "2020-11-19T03:39:43Z")

</div>

It looks like it has the right `PKG_CONFIG_PATH` setting. Maybe `matplotlib` needs some love for its pkg-config support? I’ll try and look into it tomorrow, though I suspect I’ll need some debugging info from your environment for details.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [November 19, 2020, 1:40pm UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831/7 "2020-11-19T13:40:00Z")

</div>

I added some debugging output (diff below) to `setupext.py`. I have no `PKG_CONFIG_PATH` set up in my environment outside of the superbuild. During the build, this output is available:

```auto
old PKG_CONFIG_PATH: /home/boeckb/misc/builds/paraview/build-sb/install/lib/pkgconfig:/home/boeckb/misc/builds/paraview/build-sb/install/share/pkgconfig:
new PKG_CONFIG_PATH: /home/boeckb/misc/builds/paraview/build-sb/install/lib/pkgconfig:/home/boeckb/misc/builds/paraview/build-sb/install/share/pkgconfig::/home/boeckb/misc/builds/paraview/build-sb/install/lib/pkgconfig
pkg_config: pkg-config
cmd for freetype2 : ['pkg-config', 'freetype2']
cflags: ['-I/home/boeckb/misc/builds/paraview/build-sb/install/include/freetype2', '-I/home/boeckb/misc/builds/paraview/build-sb/install/include', '-I/home/boeckb/misc/builds/paraview/build-sb/install/include/libpng16']
libs: ['-L/home/boeckb/misc/builds/paraview/build-sb/install/lib', '-lfreetype']
cmd for libpng : ['pkg-config', 'libpng']
cflags: ['-I/home/boeckb/misc/builds/paraview/build-sb/install/include/libpng16', '-I/home/boeckb/misc/builds/paraview/build-sb/install/include']
libs: ['-L/home/boeckb/misc/builds/paraview/build-sb/install/lib', '-lpng16', '-lz']
cmd for freetype2 : ['pkg-config', 'freetype2']
cflags: ['-I/home/boeckb/misc/builds/paraview/build-sb/install/include/freetype2', '-I/home/boeckb/misc/builds/paraview/build-sb/install/include', '-I/home/boeckb/misc/builds/paraview/build-sb/install/include/libpng16']
libs: ['-L/home/boeckb/misc/builds/paraview/build-sb/install/lib', '-lfreetype']

```

which all looks fine to me.

```diff
--- setupext.py 2020-11-19 08:37:21.987610337 -0500
+++ setupext.py 2020-11-19 08:37:01.977991294 -0500
@@ -241,16 +241,19 @@
             "IMPORTANT WARNING:\n"
             " pkg-config is not installed.\n"
             " Matplotlib may not be able to find some of its dependencies.")
         return None
     pkg_config_path = sysconfig.get_config_var('LIBDIR')
+ print('old PKG_CONFIG_PATH:', os.environ['PKG_CONFIG_PATH'])
     if pkg_config_path is not None:
         pkg_config_path = os.path.join(pkg_config_path, 'pkgconfig')
         try:
             os.environ['PKG_CONFIG_PATH'] += ':' + pkg_config_path
         except KeyError:
             os.environ['PKG_CONFIG_PATH'] = pkg_config_path
+ print('new PKG_CONFIG_PATH:', os.environ['PKG_CONFIG_PATH'])
+ print('pkg_config:', pkg_config)
     return pkg_config
 
 
 def pkg_config_setup_extension(
         ext, package,
@@ -259,10 +262,11 @@
 
     # First, try to get the flags from pkg-config.
 
     pkg_config = get_pkg_config()
     cmd = [pkg_config, package] if pkg_config else alt_exec
+ print('cmd for', package, ':', cmd)
     if cmd is not None:
         try:
             if pkg_config and atleast_version:
                 subprocess.check_call(
                     [*cmd, f"--atleast-version={atleast_version}"])
@@ -275,10 +279,12 @@
             libs = shlex.split(
                 os.fsdecode(subprocess.check_output([*cmd, "--libs"])))
         except (OSError, subprocess.CalledProcessError):
             pass
         else:
+ print('cflags:', cflags)
+ print('libs:', libs)
             ext.extra_compile_args.extend(cflags)
             ext.extra_link_args.extend(libs)
             return
 
     # If that fails, fall back on the defaults.

```

---

<div class="post-metadata">

### Author: ![joeh](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@joeh](https://discourse.paraview.org/u/joeh)
#### Post date: [November 19, 2020, 4:31pm UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831/8 "2020-11-19T16:31:27Z")

</div>

Ben,

Here is the output

```
Edit setup.cfg to change the build options; suppress output with --quiet.

BUILDING MATPLOTLIB
  matplotlib: yes [3.2.1]
      python: yes [3.8.6 (default, Nov 18 2020, 21:00:58) [GCC 6.3.0]]
    platform: yes [linux]
 sample_data: yes [installing]
       tests: no [skipping due to configuration]
         agg: yes [installing]
       tkagg: yes [installing; run-time loading from Python Tcl/Tk]
      macosx: no [Mac OS-X only]

running build
running build_py
copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.linux-x86_64-3.8/matplotlib/mpl-data
UPDATING build/lib.linux-x86_64-3.8/matplotlib/_version.py
set build/lib.linux-x86_64-3.8/matplotlib/_version.py to '3.2.1'
running build_ext
IMPORTANT WARNING:
    pkg-config is not installed.
    Matplotlib may not be able to find some of its dependencies.
pkg_config: None
cflags: []
cflags: []
pkg_config: None
cflags: ['-L/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/lib', '-lpng16', '-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/libpng16']
cflags: ['-L/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/lib', '-lpng16', '-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/libpng16']
pkg_config: None
cflags: []
cflags: []
building 'matplotlib.ft2font' extension
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -fPIC -fPIC -DFREETYPE_BUILD_TYPE=system -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_ft2font_ARRAY_API -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -D__STDC_FORMAT_MACROS=1 -Iextern/agg24-svn/include -I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/lib/python3.8/site-packages/numpy/core/include -I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/python3.8 -c src/checkdep_freetype2.c -o build/temp.linux-x86_64-3.8/src/checkdep_freetype2.o
```

---

<div class="post-metadata">

### Author: ![joeh](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@joeh](https://discourse.paraview.org/u/joeh)
#### Post date: [November 19, 2020, 4:37pm UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831/9 "2020-11-19T16:37:21Z")

</div>

Ben,

And here is the output if I set the PKG\_CONFIG\_PATH environment variable to

`setenv PKG_CONFIG_PATH ${INSTALLPATH}/lib/pkgconfig:${INSTALLPATH}/share/pkgconfig`

```
Edit setup.cfg to change the build options; suppress output with --quiet.

BUILDING MATPLOTLIB
  matplotlib: yes [3.2.1]
      python: yes [3.8.6 (default, Nov 18 2020, 21:00:58) [GCC 6.3.0]]
    platform: yes [linux]
 sample_data: yes [installing]
       tests: no [skipping due to configuration]
         agg: yes [installing]
       tkagg: yes [installing; run-time loading from Python Tcl/Tk]
      macosx: no [Mac OS-X only]

running build
running build_py
copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.linux-x86_64-3.8/matplotlib/mpl-data
UPDATING build/lib.linux-x86_64-3.8/matplotlib/_version.py
set build/lib.linux-x86_64-3.8/matplotlib/_version.py to '3.2.1'
running build_ext
IMPORTANT WARNING:
    pkg-config is not installed.
    Matplotlib may not be able to find some of its dependencies.
pkg_config: None
cflags: ['-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/freetype2', '-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/libpng16', '-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include']
cflags: ['-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/freetype2', '-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/libpng16', '-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include']
pkg_config: None
cflags: ['-L/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/lib', '-lpng16', '-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/libpng16']
cflags: ['-L/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/lib', '-lpng16', '-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/libpng16']
pkg_config: None
cflags: ['-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/freetype2', '-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/libpng16', '-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include']
cflags: ['-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/freetype2', '-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/libpng16', '-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include']
building 'matplotlib.ft2font' extension
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -fPIC -fPIC -DFREETYPE_BUILD_TYPE=system -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_ft2font_ARRAY_API -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -D__STDC_FORMAT_MACROS=1 -Iextern/agg24-svn/include -I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/lib/python3.8/site-packages/numpy/core/include -I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/python3.8 -c src/checkdep_freetype2.c -o build/temp.linux-x86_64-3.8/src/checkdep_freetype2.o -I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/freetype2 -I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/libpng16 -I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include

```

… etc it builds fine from this point on

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [November 19, 2020, 5:18pm UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831/10 "2020-11-19T17:18:58Z")

</div>

It appears as though the fallback works, but this output seems indicative of the core problem:

> [@joeh](#):
>
> ```auto
> IMPORTANT WARNING:
> pkg-config is not installed.
> Matplotlib may not be able to find some of its dependencies.
> 
> ```

---

<div class="post-metadata">

### Author: ![joeh](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@joeh](https://discourse.paraview.org/u/joeh)
#### Post date: [November 19, 2020, 5:25pm UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831/11 "2020-11-19T17:25:12Z")

</div>

Ben,

pkg-config is installed on my system

```
pkg-config --version
0.29.1

```

Thanks,

Joe

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [November 19, 2020, 5:37pm UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831/12 "2020-11-19T17:37:06Z")

</div>

Then `matplotlib` package isn’t finding it though. I don’t know why that might be. It is using `shutil.which`. Do you happen to have the `PKG_CONFIG` environment variable set?

---

<div class="post-metadata">

### Author: ![joeh](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@joeh](https://discourse.paraview.org/u/joeh)
#### Post date: [November 19, 2020, 6:03pm UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831/13 "2020-11-19T18:03:07Z")

</div>

Ben,

I do not have the environment variable PKG\_CONFIG set. I tried setting it, but it did not help.  
If I set the PKG\_CONFIG\_PATH environment variable to

`setenv PKG_CONFIG_PATH ${INSTALLPATH}/lib/pkgconfig:${INSTALLPATH}/share/pkgconfig`

Then it works fine but still complains about pkg-config not being installed, even though it is.

Thanks,

Joe

---

<div class="post-metadata">

### Author: ![joeh](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@joeh](https://discourse.paraview.org/u/joeh)
#### Post date: [November 19, 2020, 6:18pm UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831/14 "2020-11-19T18:18:49Z")

</div>

Ben,

I believe I have figured out why this is failing. The system has python 2.7.5 installed, while shutil.which was not added until python 3.3

```
[joeh@gaffney01 PV]$ which python
/usr/bin/python
[joeh@gaffney01 PV]$ python
Python 2.7.5 (default, Sep 26 2019, 13:23:47)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import shutil
>>> shutil.which('pkg-config')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'which'
>>>

```

So that command cannot work, I think what you mean to be doing is accessing the python 3.8 version that paraview superbuild builds, but it is instead using the system version of 2.7.5 for some reason here.

Thanks,

Joe

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [November 19, 2020, 8:55pm UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831/15 "2020-11-19T20:55:56Z")

</div>

That’s not it. First, we’d get an exception like the `AttributeError`, not `None`. Second, you can see that we’re using the superbuild’s python binary to build matplotlib:

> [@joeh](#):
>
> ```auto
> set(command "/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/bin/python3;setup.py;build")
> 
> ```

> [@joeh](#):
>
> ```auto
> BUILDING MATPLOTLIB
> matplotlib: yes [3.2.1]
> python: yes [3.8.6 (default, Nov 18 2020, 21:00:58) [GCC 6.3.0]]
> 
> ```

Something else is up here. Digging into why `shutil.which` is failing on your machine may be necessary. Adding `strace;-e;file;-o;/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/strace.log;` in front of that quoted `command` variable’s value can get a log of it. If we can see where it looks for `pkg-config`, that might help. Dumping out `os.environ['PATH']` can’t hurt either. Once editing that, make sure that the superbuild does _not_ rerun cmake (as it will clobber the edit) and run just `ninja superbuild/matplotlib/stamp/matplotlib-build` to do the minimum amount of work around it.

---

<div class="post-metadata">

### Author: ![joeh](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@joeh](https://discourse.paraview.org/u/joeh)
#### Post date: [November 19, 2020, 9:57pm UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831/16 "2020-11-19T21:57:33Z")

</div>

Ben,

I have dug further,

I added theses print statements

```
def get_pkg_config():
    """
    Get path to pkg-config and set up the PKG_CONFIG environment variable.
    """
    if sys.platform == 'win32':
        return None
    path_value = os.environ.get('PATH')
    print("path_value = ", path_value)
    pkg_config = os.environ.get('PKG_CONFIG', 'pkg-config')
    print("pkg_config = ", pkg_config)
    pkg_config = 'pkg-config'
    print("pkg_config = ", pkg_config)
    pkg_config_loc = shutil.which(pkg_config)
    print("pkg_config_loc = ", pkg_config_loc)
    if shutil.which(pkg_config) is None:
        print(
            "IMPORTANT WARNING:\n"
            " pkg-config is not installed.\n"
            " Matplotlib may not be able to find some of its dependencies.")
        return None
    print("old PKG_CONFIG_PATH = ", os.environ['PKG_CONFIG_PATH'] )
    pkg_config_path = sysconfig.get_config_var('LIBDIR')
    print("pkg_config_path = ", pkg_config_path)
    if pkg_config_path is not None:
        pkg_config_path = os.path.join(pkg_config_path, 'pkgconfig')
        try:
            os.environ['PKG_CONFIG_PATH'] += ':' + pkg_config_path
        except KeyError:
            os.environ['PKG_CONFIG_PATH'] = pkg_config_path
    print("new PKG_CONFIG_PATH = ", os.environ['PKG_CONFIG_PATH'] )
    return pkg_config

```

and these as well

```
def pkg_config_setup_extension(
        ext, package,
        atleast_version=None, alt_exec=None, default_libraries=()):
    """Add parameters to the given *ext* for the given *package*."""

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

    pkg_config = get_pkg_config()
    print("pkg_config = ", pkg_config)
    print("atleast_version = ", atleast_version)
    print("package = ", package)
    cmd = [pkg_config, package] if pkg_config else alt_exec
    print("cmd = ", cmd)
    if cmd is not None:
        try:
            if pkg_config and atleast_version:
                subprocess.check_call(
                    [*cmd, f"--atleast-version={atleast_version}"])
            # Use sys.getfilesystemencoding() to allow round-tripping
            # when passed back to later subprocess calls; do not use
            # locale.getpreferredencoding() which universal_newlines=True
            # would do.
            cflags = shlex.split(
                os.fsdecode(subprocess.check_output([*cmd, "--cflags"])))
            libs = shlex.split(
                os.fsdecode(subprocess.check_output([*cmd, "--libs"])))
            print("cflags = ", cflags)
            print("libs = ", libs)
        except (OSError, subprocess.CalledProcessError):
            pass
        else:
            ext.extra_compile_args.extend(cflags)
            ext.extra_link_args.extend(libs)
            return

    # If that fails, fall back on the defaults.

    # conda Windows header and library paths.
    # https://github.com/conda/conda/issues/2312 re: getting the env dir.
    if sys.platform == 'win32':
        conda_env_path = (os.getenv('CONDA_PREFIX') # conda >= 4.1
                          or os.getenv('CONDA_DEFAULT_ENV')) # conda < 4.1
        if conda_env_path and os.path.isdir(conda_env_path):
            ext.include_dirs.append(os.fspath(
                pathlib.Path(conda_env_path, "Library/include")))
            ext.library_dirs.append(os.fspath(
                pathlib.Path(conda_env_path, "Library/lib")))

    # Default linked libs.
    ext.libraries.extend(default_libraries)

```

And got this result,

after doing 2 things

First I forced pkg\_config = ‘pkg-config’ because I noticed that its value was being set to LDFLAGS  
which was why that shutil.which(pkg\_config) was failing in that it was incorrectly looking for LDFLAGS instead of pkg-config this must mean that for some reason  
`pkg_config = os.environ.get('PKG_CONFIG', 'pkg-config')`  
is incorrectly returning LDFLAGS once I made this change then shutil.which(pkg\_config) succeeded in correctly returning the location for pkg-config.

Second I copied zlib.pc into /app/DAAC/build/PV/Build\_5.9.0-RC1\_mesa\_test/install/lib/pkgconfig  
from /app/DAAC/build/PV/Build\_5.9.0-RC1\_mesa\_test/install/share/pkgconfig  
since I noticed that /app/DAAC/build/PV/Build\_5.9.0-RC1\_mesa\_test/install/share/pkgconfig was not in the PKG\_CONFIG\_PATH but /app/DAAC/build/PV/Build\_5.9.0-RC1\_mesa\_test/install/lib/pkgconfig  
and freetype will fail without it.

```
Edit setup.cfg to change the build options; suppress output with --quiet.

BUILDING MATPLOTLIB
  matplotlib: yes [3.2.1]
      python: yes [3.8.6 (default, Nov 18 2020, 21:00:58) [GCC 6.3.0]]
    platform: yes [linux]
 sample_data: yes [installing]
       tests: no [skipping due to configuration]
         agg: yes [installing]
       tkagg: yes [installing; run-time loading from Python Tcl/Tk]
      macosx: no [Mac OS-X only]

running build
running build_py
copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.linux-x86_64-3.8/matplotlib/mpl-data
UPDATING build/lib.linux-x86_64-3.8/matplotlib/_version.py
set build/lib.linux-x86_64-3.8/matplotlib/_version.py to '3.2.1'
running build_ext
path_value = /p/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/bin:/app/DAAC/build/Qt/5.12.10/bin:/app/DAAC/build/pkg-config/0.29/1/bin:/app/DAAC/build/m4/1.4.18/bin:/app/DAAC/build/libtool/2.4.6/bin:/app/DAAC/build/automake/1.15/bin:/app/DAAC/build/autoconf/2.69/bin:/app/DAAC/build/git/2.5.0/bin:/app/DAAC/build/cmake/3.17.4/bin:/p/app/hpe/mpt-2.17/bin:/p/app/gnu/6.3.0/bin:/usr/local/bin:/opt/sgi/sbin:/opt/sgi/bin:/app/DAAC/build/pkg-config/0.29.1/bin:/usr/local/bin:/opt/sgi/sbin:/opt/sgi/bin:/usr/lib64/qt-3.3/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/openssh-7.5p1.RedHatEL/bin:/usr/local/bin:/usr/local/sbin:/opt/c3/bin:/opt/pbs_19.2.4/bin:/sbin:/bin:/p/app/BCT/bin:/p/app/SLB:/p/home/joeh/.local/bin:/p/home/joeh/bin:/opt/c3/bin:/opt/pbs_19.2.4/bin:/sbin:/bin:/p/app/BCT/bin:/p/app/SLB
pkg_config = LDFLAGS
pkg_config = pkg-config
pkg_config_loc = /app/DAAC/build/pkg-config/0.29.1/bin/pkg-config
old PKG_CONFIG_PATH = /app/DAAC/build/Qt/5.12.10/lib/pkgconfig:/app/DAAC/build/pkg-config/0.29/1/lib/pkgconfig
pkg_config_path = /app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/lib
new PKG_CONFIG_PATH = /app/DAAC/build/Qt/5.12.10/lib/pkgconfig:/app/DAAC/build/pkg-config/0.29/1/lib/pkgconfig:/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/lib/pkgconfig
pkg_config = pkg-config
atleast_version = 9.11.3
package = freetype2
cmd = ['pkg-config', 'freetype2']
cflags = ['-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/freetype2', '-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/libpng16', '-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include']
libs = ['-L/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/lib', '-lfreetype']
pkg_config = pkg-config
atleast_version = 1.2
package = libpng
cmd = ['pkg-config', 'libpng']
cflags = ['-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/libpng16', '-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include']
libs = ['-L/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/lib', '-lpng16', '-lz']
pkg_config = pkg-config
atleast_version = 9.11.3
package = freetype2
cmd = ['pkg-config', 'freetype2']
cflags = ['-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/freetype2', '-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/libpng16', '-I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include']
libs = ['-L/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/lib', '-lfreetype']
building 'matplotlib.ft2font' extension
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -fPIC -fPIC -DFREETYPE_BUILD_TYPE=system -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_ft2font_ARRAY_API -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -D__STDC_FORMAT_MACROS=1 -Iextern/agg24-svn/include -I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/lib/python3.8/site-packages/numpy/core/include -I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/python3.8 -c src/checkdep_freetype2.c -o build/temp.linux-x86_64-3.8/src/checkdep_freetype2.o -I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/freetype2 -I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include/libpng16 -I/app/DAAC/build/PV/Build_5.9.0-RC1_mesa_test/install/include

```

with these 2 changes compilation succeeded.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [November 20, 2020, 7:16pm UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831/17 "2020-11-20T19:16:33Z")

</div>

Ah ha! Your `sb-matplotlib-build.cmake` has this entry:

```auto
PKG_CONFIG;LDFLAGS

```

which is a parity problem. This is why it has a bogus value. Let me see if I can’t figure out where this is coming from…

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [November 20, 2020, 7:20pm UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831/18 "2020-11-20T19:20:10Z")

</div>

So we have this code:

```auto
  if (pkgconf_enabled)
    list(APPEND matplotlib_process_environment
      PKG_CONFIG "${superbuild_pkgconf}")
  endif ()

```

For some reason, this ends up as an empty entry. There are two places this is set in the superbuild:

- `projects/apple-unix/pkgconf.cmake`
- `projects/apple-unix/pkgconf.system.cmake`

I’m not sure which is being used on your machine, but…I see now. There’s a mismatch in logic. I’ll have a fix up shortly.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [November 20, 2020, 7:23pm UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831/19 "2020-11-20T19:23:09Z")

</div>

Could you please apply this diff to your build to verify that it does what is necessary? [https://gitlab.kitware.com/paraview/common-superbuild/-/merge\_requests/376](https://gitlab.kitware.com/paraview/common-superbuild/-/merge_requests/376)

---

<div class="post-metadata">

### Author: ![joeh](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/j/ce7236/32.png) [@joeh](https://discourse.paraview.org/u/joeh)
#### Post date: [November 20, 2020, 8:05pm UTC](https://discourse.paraview.org/t/paraview-5-9-0-rc1-superbuild-package-configuration-issue-affecting-matplotlibs-detection-of-freetype-and-zlib/5831/20 "2020-11-20T20:05:49Z")

</div>

Ben,

It worked!

Thanks for your help in tracking this down.

Joe
