Skip to content
Merged
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
70 changes: 70 additions & 0 deletions .github/workflows/test-system-uchardet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Test (system uchardet)

# Exercises the `system-uchardet` feature option (see meson.options): build
# cChardet against a system uchardet built from git and confirm the resulting
# extension links the shared library instead of the bundled sources. The
# regular Tests workflow only covers the bundled default.
on:
pull_request:
push:
branches:
- master

jobs:
system-uchardet:
name: Build against system uchardet (from git)
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
# meson's files() validates the vendored uchardet sources exist at
# configure time even for a system build, so the submodule still has
# to be checked out.
submodules: recursive

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Build and install uchardet from git
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends cmake ninja-build pkg-config
git clone --depth 1 \
https://gitlab.freedesktop.org/uchardet/uchardet.git /tmp/uchardet-src
cmake -S /tmp/uchardet-src -B /tmp/uchardet-build \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DBUILD_BINARY=OFF
sudo cmake --build /tmp/uchardet-build --target install
sudo ldconfig

- name: Confirm the system uchardet exposes the candidate API
run: |
pkg-config --exists uchardet
echo "system uchardet version: $(pkg-config --modversion uchardet)"
# `enabled`/`auto` reject a uchardet without this symbol; the last
# tagged release still reports 0.0.8 but only the git build ships it.
grep -q uchardet_get_n_candidates /usr/include/uchardet/uchardet.h

- name: Build cChardet against the system uchardet
run: |
python -m pip install --upgrade pip
python -m pip install pytest
python -m pip install . \
--config-settings=setup-args=-Dsystem-uchardet=enabled

- name: Verify the extension links the system libuchardet
run: |
so=$(python -c "import cchardet._cchardet as m; print(m.__file__)")
echo "built extension: $so"
ldd "$so"
# Fail if it did not link the shared system library -- i.e. it
# silently fell back to compiling the bundled sources.
ldd "$so" | grep -q libuchardet

- name: Run tests
run: python -m pytest src/tests
Loading