Skip to content

fix(lm15): support targets (e.g. wasm) without ssl, fcntl, or home directory - #8

Merged
MaximeRivest merged 1 commit into
lm15-dev:mainfrom
cmpnd-ai:wasi-portability
Sep 15, 2026
Merged

MaximeRivest merged 1 commit into
lm15-dev:mainfrom
cmpnd-ai:wasi-portability

Conversation

@adriaanm

Copy link
Copy Markdown
Contributor

Push usage of these unsupported features out of module scope, and into the code paths that need them, so that import lm15 succeeds on CPython for wasm32-wasip2.

Each failure was a platform assumption made at module scope, where nothing can recover from it:

  • _authlock picked its locking primitive with if os.name == "posix": import fcntl. WASI reports posix but does not ship fcntl.

  • auth resolved three credential-path constants with Path("~/...").expanduser(), which raises RuntimeError wherever no home directory can be determined.

  • Both transports imported ssl at module scope, and componentize-py's embedded libpython has no _ssl. TLS moves into _ssl.py, which imports ssl plainly because it cannot work without it, and which nothing imports until a request names an https URL. That placement is also what keeps its except ssl.SSLError clauses ordinary, an except clause being evaluated whenever an exception passes it — plain-HTTP errors included.

…rectory

Push usage of these unsupported features out of module scope, and into the code
paths that need them, so that `import lm15` succeeds on CPython for wasm32-wasip2.

Each failure was a platform assumption made at module scope, where nothing can recover
from it:

- `_authlock` picked its locking primitive with `if os.name == "posix": import fcntl`. WASI
  reports `posix` but does not ship `fcntl`.

- `auth` resolved three credential-path constants with `Path("~/...").expanduser()`, which
  raises RuntimeError wherever no home directory can be determined.

- Both transports imported `ssl` at module scope, and componentize-py's embedded libpython
  has no `_ssl`. TLS moves into `_ssl.py`, which imports `ssl` plainly because it cannot work
  without it, and which nothing imports until a request names an https URL. That placement is
  also what keeps its `except ssl.SSLError` clauses ordinary, an except clause being evaluated
  whenever an exception passes it — plain-HTTP errors included.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
MaximeRivest added a commit that referenced this pull request Sep 15, 2026
…, with tests

The no-fcntl/no-msvcrt branch raised UnsupportedFeatureError, a CapabilityError
that speaks of a provider adapter; lm15-ts raises NotConfiguredError for the
same host limitation, and that is what this is: a fact about the host's setup,
with a way out (LM15_LOCK_DIR, or an explicit credential) the hint names.

The lock directory also resolved ~/.cache with expanduser(), so on a host with
no home directory a bare RuntimeError fired before the branch above was ever
reached. Same error class, same hint, from there.

Tests run each reduced target in a fresh interpreter: no ssl (import, plain
HTTP, and the https refusal naming FetchTransport), no home directory, and no
locking primitive. Changelog entry for #8.

Signed-off-by: Maxime Rivest <mrive052@gmail.com>
MaximeRivest added a commit that referenced this pull request Sep 15, 2026
Signed-off-by: Maxime Rivest <mrive052@gmail.com>
@MaximeRivest
MaximeRivest merged commit 6912455 into lm15-dev:main Sep 15, 2026
@MaximeRivest

Copy link
Copy Markdown
Member

Merged, thanks — exactly the right shape (feature-detect the primitive, and pull ssl in only when https is asked for).

Two follow-ups landed on top in b171d75:

  • The no-locking refusal is now NotConfiguredError, which is what lm15-ts raises for the same host limitation; UnsupportedFeatureError is the provider-adapter bucket. Same hint either way: set LM15_LOCK_DIR or pass an explicit credential.
  • _lock_dir() still resolved ~/.cache with expanduser(), so on a host with no home the bare RuntimeError fired before your branch could. Same error class from there now.

Plus tests that run each reduced target in a fresh interpreter (no ssl, no home, no fcntl/msvcrt) and a changelog entry.

@MaximeRivest
MaximeRivest deleted the wasi-portability branch September 15, 2026 12:13
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