Skip to content

Make system-uchardet a Meson feature option (auto/enabled/disabled)#64

Open
wbarnha wants to merge 2 commits into
masterfrom
claude/mode-pr-81-review-xe6yhe
Open

Make system-uchardet a Meson feature option (auto/enabled/disabled)#64
wbarnha wants to merge 2 commits into
masterfrom
claude/mode-pr-81-review-xe6yhe

Conversation

@wbarnha

@wbarnha wbarnha commented Jul 24, 2026

Copy link
Copy Markdown
Member

Implements the feature-flag suggestion from the review of #56 (#56 (comment)).

Builds on top of @mgorny's #56 (that commit is included here, unchanged) and refines the system-uchardet switch from a hard boolean into a Meson feature option, so one switch serves more environments.

What changed

  • meson.optionstype: 'boolean'type: 'feature', value: falsevalue: 'disabled'. Also fixes the description typo (chardetuchardet).

  • src/cchardet/meson.build — three-way selection:

    -Dsystem-uchardet= Behaviour
    disabled (default) Always build the bundled copy — unchanged behaviour for the published wheels.
    enabled Require the system library; hard fail if missing or too old. What distro packaging wants.
    auto Use the system library if new enough, else fall back to the bundled copy. Handy for source installs.

    Passing the feature to dependency('uchardet', required: system_uchardet) gives the enabled (hard-fail) vs auto (quiet fallback) distinction for free. The existing has_function('uchardet_get_n_candidates') probe still rejects a found-but-too-old system library, and now only error()s under enabledauto falls through to bundled.

  • README.md — a "Building against a system uchardet" section for packagers: the three states, the pip install . --config-settings=setup-args=-Dsystem-uchardet=enabled invocation, and the git-uchardet requirement. The # TODO to swap has_function() for a version: constraint once upstream tags a release is kept.

Verification (local)

meson setup exercised for every state (submodule checked out, no system uchardet present):

  • disabled (default) and auto → configure the bundled copy; full build + test suite pass: 125 passed, 1 skipped.
  • enabled with no system library → configuration fails (exit 1) as intended: ERROR: Dependency "uchardet" not found.

The whole meson.build parses (so the too-old-error() branch is syntax-checked), and the bundled extension compiles and links cleanly.

Not included

  • CI coverage for the system path (suggestion Add linux aarch64 wheel support #2 in the review): a Linux job that builds uchardet from git, installs it, then builds with -Dsystem-uchardet=enabled and runs the tests. I left it out to keep this PR focused and locally-verifiable — happy to add it as a follow-up commit here or a separate PR, whichever you prefer.

Credit to @mgorny for the original declare_dependency refactor and system-uchardet support in #56; this supersedes that PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BnTZQEXqpedyrFAgwRnbsA


Generated by Claude Code

mgorny and others added 2 commits July 21, 2026 11:55
Add a `system-uchardet` option to build against the system installed
`uchardet` library instead of building a bundled copy.  This requires
a git version of `uchardet` right now, and upstream did not increment
the version yet, so the code is explicitly checking whether
`uchardet_get_n_candidates` is available.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
Refine the system-uchardet switch from a hard boolean into a Meson
`feature` option so one switch serves more environments:

- enabled  -> require the system library; hard fail if missing or too
              old (what distro packaging wants).
- disabled -> always build the bundled copy (the default; unchanged
              behaviour for the published wheels).
- auto     -> use the system library when it is new enough, else fall
              back to the bundled copy (handy for source installs on a
              box that happens to have a recent-enough uchardet).

Passing the feature to dependency(..., required: system_uchardet) gives
the enabled/auto hard-fail-vs-fallback distinction for free. The existing
has_function('uchardet_get_n_candidates') probe still rejects a
found-but-too-old system library, and now only errors out under
`enabled` -- `auto` falls through to the bundled copy.

Also document the option for packagers in the README (the three states,
the --config-settings invocation, and the git-uchardet requirement), and
fix the option description ("chardet" -> "uchardet").

Validated with meson setup for all three states: disabled and auto (no
system lib) configure the bundled copy and the full test suite passes
(125 passed, 1 skipped); enabled with no system lib fails configuration
as intended.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BnTZQEXqpedyrFAgwRnbsA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants