I'm trying to add micropython support to HBMQTT, an MQTT client/broker I've been developing.
One task is to correctly import micropython renamed modules like uasyncio. Therefore, I've added this kind of statements to my python code:
Code: Select all
try:
import uasyncio as asyncio
except:
import asyncio
Problems come with dependencies. For example, HBMQTT uses websockets module which also import asyncio. This fails when importing on microypthon, but I can't fix by modifying this third-party library.
So, i was wondering if there was a way in python to globally replace all "imports asyncio" to import "uasyncio as asyncio". May be byoverriding "__import__". Does anyone know how to do this ?