hot-reload for python packages
Project description
HOW TO USE?
STEP 1
Import hot_import
into your python file with import hot_import
or from hot_import import HotImport
STEP 2
Import the desired module as following import module_name
or from module_name import function
STEP 3
Create an object HotImport that you will use to manage your modules
# main.py
from hot_import import HotImport
import module
from module2 import function
mods = HotImport([module, function], auto_update=True)
module = mods.get_module(module)
STEP 4
Check if it's working, to proceed, you have to edit module.py
while your code is running
# module.py
def hello():
return "Hello world!"
# module2.py
def function():
return "This is a function!"
# main.py
from hot_import import HotImport
import time
import module
from module2 import function
mods = EasyImport([module, function], auto_update=True)
module = mods.get_module(module)
while True:
print(module.hello())
print(function2())
time.sleep(1)
STEP 5 (optional)
You can add an event on_update to help you debugging
# main.py
from hot_import import EasyImport
import time
import module
mods = EasyImport([module], auto_update=True)
module = mods.get_module(module)
@mods.on_update()
def on_update(module):
print(f"The module {module.__name__} has been updated!")
while True:
print(module.hello())
time.sleep(1)
DISCLAIMER
This library is new and may contain some errors
Otherwise, have fun with it as long as you declare my work
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hot-import-2.0.0.tar.gz
(4.1 kB
view hashes)
Built Distribution
Close
Hashes for hot_import-2.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e2d0831c68742951644e96711e0cf599d30d929e04a3ef03bafaa360c0c1da4 |
|
MD5 | 87523fb4e03fede0abe08a4b7cb9f45f |
|
BLAKE2b-256 | eb358d5bae96301b259992306b5a1a5ab05727ed0e76f245abd0c17359adb68b |