Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set EM_PKG_CONFIG_PATH to correctly configure pkg-config #52

Merged
merged 5 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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