Skip to content

Conversation

brenordv
Copy link

@brenordv brenordv commented Sep 30, 2025

Problem

When installing lora-sx126x or lora-sx127x packages via mip, users only get the hardware drivers but not the SyncModem/AsyncModem wrapper classes, making the packages unusable.

Also found a problem in the import handling in lora/__init__.py where ImportError would be raised incorrectly when the error message contained lib.lora instead of just lora.

I noticed both problems after installing the lora-sx1262 package via Thonny package manager.

Solution

Added require("lora-sync") and require("lora-async") to the manifest files so these dependencies are automatically installed.

To fix the import problem, I added an extra check to prevent this from happening by checking if the error message contains both "no module named", and "lora". Since the check was the same for all imports, I centralized the check in a function.

Testing

Install the package and verify the modem classes are available:

import mip
mip.install("lora-sx126x")
from lora import SX1262, AsyncSX1262  # Should work now

brenordv and others added 5 commits September 30, 2025 19:04
The lora-sx126x and lora-sx127x packages create SyncModem and AsyncModem classes by importing from lora.sync_modem and lora.async_modem modules, which are provided by the lora-sync and lora-async extension packages respectively.

However, the manifest.py files for these hardware driver packages did not require lora-sync or lora-async as dependencies. This meant that when users installed lora-sx126x or lora-sx127x, they would get the hardware driver but not the modem wrapper classes needed to actually use it.

This commit adds the missing dependencies and increments the patch versions (0.1.5→0.1.6 for sx126x, 0.1.2→0.1.3 for sx127x), so users will receive the fixed packages.

Also fixed error handling in lora/__init__.py where ImportError would be raised incorrectly when the second hardware driver import failed, even if the first one had succeeded.

Signed-off-by: Breno RdV <[email protected]>
…cond hardware driver import failed, because the error message would contain "lib.lora" instead of just "lora.".

Signed-off-by: Breno RdV <[email protected]>
…sync modems.

micropython/lora/lora-sx127x/manifest.py: Add dependencies for sync/async modems.

The lora-sx126x and lora-sx127x packages create SyncModem and AsyncModem classes by importing from lora.sync_modem and lora.async_modem modules, which are provided by
the lora-sync and lora-async extension packages respectively.

However, the manifest.py files for these hardware driver packages did not require lora-sync or lora-async as dependencies. This meant that when users installed
lora-sx126x or lora-sx127x, they would get the hardware driver but not the modem wrapper classes needed to actually use it.

This commit adds the missing dependencies and increments the patch versions (0.1.5→0.1.6 for sx126x, 0.1.2→0.1.3 for sx127x), so users will receive the fixed packages.

Also fixed error handling in lora/__init__.py where ImportError would be raised incorrectly when the second hardware driver import failed, even if the first one had
succeeded.

Signed-off-by: Breno RdV <[email protected]>
…ncorrectly when the second hardware driver import failed,

because the error message would contain "lib.lora" instead of just "lora.".

Signed-off-by: Breno RdV <[email protected]>
Signed-off-by: Breno RdV <[email protected]>
@projectgus
Copy link
Contributor

Hi @brenordv,

Thanks for digging into this and submitting this PR. Not depending on either lora-sync or lora-async is an intentional design choice to save flash size - both these packages are biggish and no one is likely to need both.

We tried to smooth over the usability of this in the installation instructions and by producing a helpful error message if neither package was installed. It seems like your PR also fixes a case where that message wasn't being generated, thanks!

del ok


__version__ = '0.2.1'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is automatically added by mip when the package is installed.

@projectgus projectgus self-assigned this Oct 7, 2025
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