Make system-uchardet a Meson feature option (auto/enabled/disabled)#64
Open
wbarnha wants to merge 2 commits into
Open
Make system-uchardet a Meson feature option (auto/enabled/disabled)#64wbarnha wants to merge 2 commits into
wbarnha wants to merge 2 commits into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-uchardetswitch from a hard boolean into a Mesonfeatureoption, so one switch serves more environments.What changed
meson.options—type: 'boolean'→type: 'feature',value: false→value: 'disabled'. Also fixes the description typo (chardet→uchardet).src/cchardet/meson.build— three-way selection:-Dsystem-uchardet=disabled(default)enabledautoPassing the feature to
dependency('uchardet', required: system_uchardet)gives theenabled(hard-fail) vsauto(quiet fallback) distinction for free. The existinghas_function('uchardet_get_n_candidates')probe still rejects a found-but-too-old system library, and now onlyerror()s underenabled—autofalls through to bundled.README.md— a "Building against a systemuchardet" section for packagers: the three states, thepip install . --config-settings=setup-args=-Dsystem-uchardet=enabledinvocation, and the git-uchardet requirement. The# TODOto swaphas_function()for aversion:constraint once upstream tags a release is kept.Verification (local)
meson setupexercised for every state (submodule checked out, no system uchardet present):disabled(default) andauto→ configure the bundled copy; full build + test suite pass: 125 passed, 1 skipped.enabledwith no system library → configuration fails (exit 1) as intended:ERROR: Dependency "uchardet" not found.The whole
meson.buildparses (so the too-old-error()branch is syntax-checked), and the bundled extension compiles and links cleanly.Not included
-Dsystem-uchardet=enabledand 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_dependencyrefactor and system-uchardet support in #56; this supersedes that PR.🤖 Generated with Claude Code
https://claude.ai/code/session_01BnTZQEXqpedyrFAgwRnbsA
Generated by Claude Code