Working with external libraries can be super cumbersome. You first have to install python with pip, download the library import it into your project and append the project folder. All very unconvinient. And what happens when you move the project? Are all the dependancies still there?
I present: TD PIP, the easy to implement Module manager for your project: Place TD PIP in your project and it will generate a Lib folder in your project and make it accesable for all your python scripts. You can drop the libraries into that folder by hand or use the actual PIP-Functionality.
To install a package just call
op('td_pip').InstallPackage( package_name )


and marvel as PIP opens and downloads the package right into your project.


But this can make problems when the package is refferenced before you had the chance to download the packe. Fear not, the Import_Module function is saving you. The Import_Module function checks first if the module is importable, and if not will just start PIP to download the module and import it afterwards. It is only neccesarry to change the syntax a little bit. From (using qrcode as en example)

import qrcode

you will need to write

qrcode = op('td_pip').Import_Module("qrcode")

If you come arround a package that has a differrent name to the module, use the pip_name optional argument.

socket_io = op('td_pip').Import_Module("socketio", pip_name = "python-socketio")

Best used as an attribute in your extensions.


You can download TD PIP from the Alpha Moonbase OLIB




Asset Downloads