Skip to content

fix: declare sniffio as a direct runtime dependency - #111

Open
JunkaiWang-TheoPhy wants to merge 1 commit into
MetaGLM:mainfrom
JunkaiWang-TheoPhy:codex/declare-sniffio-runtime-dependency
Open

JunkaiWang-TheoPhy wants to merge 1 commit into
MetaGLM:mainfrom
JunkaiWang-TheoPhy:codex/declare-sniffio-runtime-dependency

Conversation

@JunkaiWang-TheoPhy

Copy link
Copy Markdown

Description

Fixes #110.

Fresh SDK installations can fail before the first API call: from zhipuai import ZhipuAI raises ModuleNotFoundError: No module named 'sniffio'. The SDK imports sniffio directly in core/_utils/_utils.py but does not declare it as a runtime dependency. Environments using current httpx/anyio releases no longer receive it transitively.

Declare the already-used sniffio dependency explicitly. Add installed-package smoke checks that import and close the public client and exercise async-library detection. They use only the standard library and runtime dependencies, run with python -I against an installed wheel, and perform no API requests. The accompanying instructions keep development extras out of that environment so they cannot conceal missing runtime dependencies.

Validation

Built the original and fixed wheels and installed each with normal dependency resolution in separate, fresh Python3.14.6 environments. Both resolve httpx0.28.1, anyio4.15.1 and Pydantic2.14.2; the fixed wheel additionally installs sniffio1.3.1.

../sdk-before-env/bin/python -I tests/installation/test_installed_sdk.py -v
Ran 2 tests in 0.185s
FAILED (errors=2)

../sdk-after-env/bin/python -I tests/installation/test_installed_sdk.py -v
Ran 2 tests in 0.427s
OK

Both original-wheel errors identify missing sniffio. The fixed wheel also passes the same two checks on Python3.10.20 with Pydantic2.14.2 and Pydantic1.10.27. Wheel dependency consistency, Ruff checks/formatting of the new test, and git diff --check pass.

The full upstream unit/integration suites and live API calls were not run. This change leaves SDK request, parsing, compatibility and authentication code unchanged. It is independent of the historical Python3.14/Pydantic-v1 warning in #107 and the PyJWT work in #109.

  • Followed CONTRIBUTING.md.
  • Title uses Conventional Commits.
  • Packaging regression tests pass; actual Python commands are listed above (the template's Maven command is inapplicable).
  • Added instructions for the installed-package regression.

AI assistance: investigated, implemented and verified with OpenAI Codex assistance.

The SDK already imports sniffio directly, but current httpx/anyio dependencies no longer supply it transitively. Declare the existing runtime requirement and verify real wheel installation without development extras.

Confidence: high
Scope-risk: narrow
Tested: Original clean wheel fails both smoke tests; fixed wheel passes on Python 3.14 and 3.10 with Pydantic 1 and 2
Not-tested: Full upstream test suites and live API requests

This branch has not been deployed

No deployments
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.

Clean wheel installs fail to import SDK when sniffio is not a transitive dependency

1 participant