diff --git a/pyodide_build/buildpkg.py b/pyodide_build/buildpkg.py index 22d227b..6ad323b 100755 --- a/pyodide_build/buildpkg.py +++ b/pyodide_build/buildpkg.py @@ -549,7 +549,11 @@ def _get_helper_vars(self) -> dict[str, str]: "DISTDIR": str(self.src_dist_dir), # TODO: rename this to something more compatible with Makefile or CMake conventions "WASM_LIBRARY_DIR": str(self.library_install_prefix), - # Using PKG_CONFIG_LIBDIR instead of PKG_CONFIG_PATH, + # Emscripten will use this variable to configure pkg-config in emconfigure + "EM_PKG_CONFIG_PATH": str(self.library_install_prefix / "lib/pkgconfig"), + # This variable is usually overwritten by emconfigure + # The value below will only be used if pkg-config is called without emconfigure + # We use PKG_CONFIG_LIBDIR instead of PKG_CONFIG_PATH, # so pkg-config will not look in the default system directories "PKG_CONFIG_LIBDIR": str(self.library_install_prefix / "lib/pkgconfig"), } diff --git a/pyodide_build/tests/test_buildpkg.py b/pyodide_build/tests/test_buildpkg.py index c320c20..33b8a8f 100644 --- a/pyodide_build/tests/test_buildpkg.py +++ b/pyodide_build/tests/test_buildpkg.py @@ -126,6 +126,9 @@ def test_get_helper_vars(tmp_path): tmp_path / "pkg_1" / "build" / "pkg_1-1.0.0" / "dist" ) assert helper_vars["WASM_LIBRARY_DIR"] == str(tmp_path / ".libs") + assert helper_vars["EM_PKG_CONFIG_PATH"] == str( + tmp_path / ".libs" / "lib" / "pkgconfig" + ) assert helper_vars["PKG_CONFIG_LIBDIR"] == str( tmp_path / ".libs" / "lib" / "pkgconfig" )