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.