fix(deps): exclude nltk 3.10.1 from the extras that pull rouge-score - #6576
Open
wuliang229 wants to merge 2 commits into
Open
fix(deps): exclude nltk 3.10.1 from the extras that pull rouge-score#6576wuliang229 wants to merge 2 commits into
wuliang229 wants to merge 2 commits into
Conversation
nltk 3.10.1 added nltk/inisec.py, an import hook that breaks CI and any
in-project virtualenv. It reaches ADK transitively through rouge-score,
which the eval and test extras pull in.
The hook does two independently harmful things:
1. find_spec refuses any import whose origin resolves under the CWD. For
the standard in-project venv layout (uv, in-project Poetry, plain
`python -m venv .venv`) site-packages *is* under the CWD, so nltk
blocks its own dependency and `import regex` raises.
2. _install() calls os.environ.setdefault("PYTHONSAFEPATH", "1"), which
mutates the importing process's environment. Every subprocess later
spawned with os.environ.copy() inherits -P semantics it never opted
into. This fires even when the nltk import itself fails, is invisible
in the child's traceback, and only manifests on Python 3.11+ because
PYTHONSAFEPATH is a no-op on 3.10.
Together these account for all 28 unit-test failures currently on main:
the evaluation/CLI collection errors from (1), and the subprocess
import-isolation failures from (2), which is why the latter reproduce on
3.11-3.14 but not on 3.10.
Upstream tracked in nltk/nltk#3730. The maintainers' preferred fix,
nltk/nltk#3732, removes inisec.py entirely and therefore clears both
problems; `!=` rather than an upper bound so the fixed release is picked
up automatically once it ships.
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.
Summary
Excludes
nltk3.10.1 from the two extras that pullrouge-score(evalandtest), and adds a guard test totests/unittests/test_release_dependencies.py.This fixes all 28 unit-test failures currently on
main(and the equivalent 13 onv1).Root cause
nltk3.10.1 (released 2026-08-01) addednltk/inisec.py, an import hook. It reaches ADK transitively viarouge-score. The hook does two independently harmful things:1.
find_specrefuses imports whose origin resolves under the CWD. For the standard in-project virtualenv layout — uv's default, in-project Poetry, plainpython -m venv .venv—site-packagesis under the CWD, so NLTK blocks its own dependency:This produces the
evaluation/*collection errors,test_list_metrics_info, and thecli_evalfailures.2.
_install()callsos.environ.setdefault("PYTHONSAFEPATH", "1"), mutating the importing process's environment. Every subprocess later spawned withos.environ.copy()inherits-Psemantics it never opted into. This produces the subprocess import-isolation failures (test_import_loading,test_litellm_import,test_auth_config,test_adk_web_server_import_isolation,test_managed_agent), which fail with a bareModuleNotFoundError: No module named 'google.adk'in the child.Three properties made (2) hard to attribute: it fires even when the nltk import itself fails with (1); nothing in the child's traceback mentions nltk; and it only manifests on Python 3.11+, because
PYTHONSAFEPATHis a no-op on 3.10.That version split is the tell — on
main, Python 3.10 fails 15 tests (cause 1 only) while 3.11–3.14 fail 28 (causes 1 and 2).Why a pin rather than a CI-only workaround
rouge-scoredepends onnltkwith no upper bound, so the exclusion must be declared by each extra that pulls it. A[tool.uv]constraint would fix CI but would not protect users — anyone installinggoogle-adk[eval]into an in-project venv currently cannot import the eval stack, and picks up thePYTHONSAFEPATHmutation in their own application. Basepip install google-adkis unaffected;rouge-scoreis only inevalandtest.!=rather than an upper bound so a fixed release is picked up automatically.Upstream
Tracked in nltk/nltk#3730. nltk/nltk#3731 (harden the hook) was closed in favour of nltk/nltk#3732 (remove
inisec.pyentirely), which is the maintainers' stated preference and clears both problems. This pin can be dropped once that ships.Worth noting: #3731 would have kept
_install(), so it would have fixed cause 1 and left cause 2 in place. Theos.environside effect is not yet documented upstream.Test plan
pytest tests/unittests/test_release_dependencies.py— 7 passed; the two new cases fail if thepyproject.tomlchange is reverted (verified).pyproject-fmt2.24.0 reports no change.uv pip compileonrouge-score+ the new constraint resolves tonltk==3.10.0.