Skip to content

Commit

Permalink
Set EM_PKG_CONFIG_PATH to correctly configure pkg-config (#52)
Browse files Browse the repository at this point in the history
Closes #51

---------
  • Loading branch information
swnf authored Nov 27, 2024
1 parent c47be62 commit 4a82b7f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.29.1]

### Added

- Add `skip_emscripten_version_check` flag and SKIP_EMSCRIPTEN_VERSION_CHECK environment
variable to skip emscripten version check.
[#53](https://github.com/pyodide/pyodide-build/pull/53)
- Set the `EM_PKG_CONFIG_PATH` environment variable used by emscripten/`pkg-config` to discover dependencies
[#52](https://github.com/pyodide/pyodide-build/pull/52)

### Changed

- Source tar files are now extracted with python's [data filter](https://docs.python.org/3/library/tarfile.html#tarfile.data_filter)
[#52](https://github.com/pyodide/pyodide-build/pull/52)

- The `pyodide build` command will now raise an error if the local Python version has been changed,
after the cross-build environment has been set up.
Expand Down
25 changes: 17 additions & 8 deletions pyodide_build/buildpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import shutil
import subprocess
import sys
import warnings
from collections.abc import Iterator
from datetime import datetime
from email.message import Message
Expand Down Expand Up @@ -356,12 +355,18 @@ def _download_and_extract(self) -> None:
shutil.copy(tarballpath, self.src_dist_dir)
return

with warnings.catch_warnings():
# Python 3.12-3.13 emits a DeprecationWarning when using shutil.unpack_archive without a filter,
# but filter doesn't work well for zip files, so we suppress the warning until we find a better solution.
# https://github.com/python/cpython/issues/112760
warnings.simplefilter("ignore")
shutil.unpack_archive(tarballpath, self.build_dir)
# Use a Python 3.14-like filter (see https://github.com/python/cpython/issues/112760)
# Can be removed once we use Python 3.14
# The "data" filter will reset ownership but preserve permissions and modification times
# Without it, permissions and modification times will be silently skipped if the uid/git
# is too large for the chown() call. This behavior can lead to "Permission denied" errors
# (missing x bit) or random strange `make` behavior (due to wrong mtime order) in the CI
# pipeline.
shutil.unpack_archive(
tarballpath,
self.build_dir,
filter=None if tarballpath.suffix == ".zip" else "data",
)

extract_dir_name = self.source_metadata.extract_dir
if extract_dir_name is None:
Expand Down Expand Up @@ -556,7 +561,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"),
}
Expand Down
3 changes: 3 additions & 0 deletions pyodide_build/tests/test_buildpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down

0 comments on commit 4a82b7f

Please sign in to comment.