TD PIP

Get dynamic python modules.

Tested on Windows TD 2023.11880

Having to handle external python libraries is a thing of the past. This component installs PIP directly in your project and dynamicly downloads and import the libraries in your project.

Note: Using PrepareModule is the suggested best way!
op("td_pip").PrepareModule("PIL", packagePipName = "pillow) 
import PIL


Even though you can use CustomParameters, I do advice to use the pythonAPI instead, with the following functions: 

    def RemoveCachedPackage(self, packagePipName: str):
        """
            Removes a cached package from the cache-repository.
        """
        pass

    def CachePackage(self, packagePipName: str, additional_settings: List[str]=[]):
        """
            Saves the package and all its dependencies in to the cache-component defined as a custom-parameter.
        """
        pass

    def Freeze(self, requirementsFilepath='', additional_settings: List[str]=[]):
        """
            Save all installed modules in to the given filepath or the file defined by the custom-parameter.
        """
        pass

    def InstallRequirements(self, requirementsFilepath='', additional_settings: List[str]=[]):
        """
            Installs all modules, either from the filepath given as argument or the customparameter.
        """
        pass

    def InstallPackages(self, packagePipNames: Union[List[str], str], additionalSettings: List[str]=[]):
        """
            Installs the given packages, either as a list of package names or space delimited list.
        """
        pass

    def InstallPackage(self, packagePipName: str, additional_settings: List[str]=[]):
        """
            Install the defined package from PIP, even if it is already installed. So handle with care.
        """
        pass

    def UpgradePackage(self, packagePipName: str):
        """
            Forces the given package to be upgraded.
        """
        pass

    def UninstallPackage(self, packagePipName: str):
        """
            Not implemented.
        """
        pass

    def TestModule(self, module: str, silent: bool=False):
        """
            Check if a given moduel is alread installed. 
            Note, this does not test for a package but the module itself.
        """
        pass

    def ImportModule(self, moduleName: str, pipPackageName: str='', additionalSettings: List[str]=[]):
        """
            Installs the module if not already installed and returns the module.
            Use instead of the default import method.
            Deprecatd. use PrepareModule instead for proper code completion.
        """
        pass

    def PrepareModule(self, moduleName: str, pipPackageName: str='', additionalSettings: List[str]=[]):
        """
            Installed the package of the modul if not already, otherwise does nothing.
        """
        pass

Downloads: 4159

Created at: 5.12.2020

Uploaded: 2.9.2024
Added PreapreModule and InstallPackages (with an s).
Download