pip_importer.py helps you to import python packages for your addon.
This works only for addons with their own folder
Drop pip_importer.py into you addon folder
You need to adjust your init.py file accordingly:
from . import (
pip_importer,
)
def register():
# First startup the pip importer
pip_importer.register()
Then you add as many pip_importer.add_package() calls as necessary. Yes, you can manage as many pip packages as you desire.
# then add the required packages
if platform.system() == "Windows":
pip_importer.add_package(pip_importer.Package("SpoutGL", version="==0.0.4"))
if platform.system() == "Darwin":
pip_importer.add_package(pip_importer.Package("syphonpy", version="==0.0.2"))
pip_importer.Package("SpoutGL")
pip_importer.Package("SpoutGL", version=">=0.0.3")
pip_importer.Package("SpoutGL", version="==0.0.4")
pip_importer.Package("SpoutGL", "SpoutGL", version="==0.0.4")
# pip_importer.auto_install_packages()
# Check required modules availability
try:
pip_importer.check_modules()
from . import operators, ui
operators.register()
ui.register()
except ModuleNotFoundError:
print("Spout addon isn't available!")
def unregister():
try:
operators.unregister()
ui.unregister()
except Exception:
pass
pip_importer.unregister()
if __name__ == "__main__":
register()
When the addon is enabled for the first time, the user will be asked to install the required packages:
once the packages are successfully installed, the user will get the follwing
once the addon is restarted, the addon is ready to use:
created by IASpace, Zürich University of the Arts, Switzerland.
CAD_Sketcher got me started. Hurray to Opensource!
Python support by Florian Bruggisser