Skip to content

Conversation

@dicej
Copy link
Collaborator

@dicej dicej commented Jun 26, 2024

When building a component intended for composition with other components, it may make sense to target the spin-imports world defined in the src/spin_sdk/wit/spin.wit file in this repo. However, that currently won't work because spin_sdk.http unconditionally imports spin_sdk.wit.exports, which won't exist when targeting spin-imports.

The solution is to catch the ImportError if importing the exports submodule (or its IncomingHandler class) fails and just skip defining spin_sdk.http.IncomingHandler when that happens.

Fixes #110

When building a component intended for composition with other components, it may
make sense to target the `spin-imports` world defined in the
`src/spin_sdk/wit/spin.wit` file in this repo.  However, that currently won't
work because `spin_sdk.http` unconditionally imports `spin_sdk.wit.exports`,
which won't exist when targeting `spin-imports`.

The solution is to catch the `ImportError` if importing the `exports` submodule
(or its `IncomingHandler` class) fails and just skip defining
`spin_sdk.http.IncomingHandler` when that happens.

Fixes #110

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
@dicej dicej merged commit 503aa76 into main Nov 27, 2024
@dicej dicej deleted the optional-incoming-handler branch November 27, 2024 21:38
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.

Support targeting the spin-imports world

3 participants