TD PIP

Get dynamic python modules.

Tested on Windows TD 2023.12000

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.

For backwardscompatibility reasons the Automount Environment parametrs is enabled for now. This will be disabled in the future!
If Automount Environment is enabled, TD_PIP will polute the global space which can create issues with other means of importing modules.
If this is the case, use PrepareModule.
op("td_pip").PrepareModule("PIL", packagePipName = "pillow) 
import PIL

If not, you will need to mount the ENV explicitly.
with op("td_pip").MountModule(
		"pip_install_test", 
		pipPackageName = "pip-install-test"):
	import pip_install_test

or using PrepareModule
with op("td_pip").Mount():
    op("td_pip").PrepareModule("PIL", packagePipName = "pillow) 
    import PIL

Adding the lib-path to your vscode-settings gives you code compleation!
{
    "python.analysis.extraPaths": ["TDImportCache/Lib"]
}

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: 4584

Created at: 5.12.2020

Uploaded: 3.2.2025
Added Mount feature and disabled paramer usage by default.
Download