Python: module VirtualEnvOnDemand.GlobalEnv

VirtualEnvOnDemand.GlobalEnv | index

`GlobalEnv - Methods/Classes related to the "global" env,
i.e. the environment used for on-demand imports`

Modules
`` |  |
imp | sys | tempfile |

Classes
`` |  | __builtin__.object VirtualEnvOnDemandImporter
class VirtualEnvOnDemandImporter(__builtin__.object)
`` | `VirtualEnvOnDemandImporter - The workhouse of auto-importing. Upon an import that wouldn't resolve, it will try to install the leading package name using pip. Failure will still cause a "cannot import" error, but otherwise things will be installed on-demand.`
| Methods defined here: find_module(self, fullname, path=None) Data descriptors defined here: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)`

Functions
`` |  | enableOnDemandImporter(tmpDir=None, deferSetup=True, noRetryFailedPackages=True) `enableOnDemandImporter - Calling this method turns on the "on demand" importer. A temporary global env is created, and all failed imports will attempt an installation. @param tmpDir <str/None> - Temporary directory to use. A subdirectory will be created within this. Defaults to tempfile.gettempdir() @param deferSetup <bool> - If True (default), defers setup (which can take a couple seconds) until the first failed import or attempted install. Setup takes a couple seconds. Use this to always enable on-demand importer, but give advantage if all modules are present. If False, the ondemand virtualenv will be setup right-away. If you are using this in a multi-threaded environment, this should be set to False. @param noRetryFailedPackages <bool> - If True (default), a package which fails to download will not be retried. This is a performance savings. This should generally always be True, unless you are using VirtualEnvOnDemand to have a running process written to work with an unreleased module to prevent a restart or something similar.` ensureImportGlobal(importName, packageName=None, stdout=None, stderr=None) `ensureImportGlobal - Try to import a module, and upon failure to import try to install package into global virtualenv. This assumes that enableOnDemandImporter has already been called. @param importName <str> - The name of the module to import @param packageName <str/None> - If the package name differs from the import name (like biopython package provides "Bio" module), install this package if import fails. This may contain version info (like AdvancedHTMLParser>6.0) @param stdout <stream/None> - Stream to use for stdout as package info, or None to silence. Default None. NOTE: This differs from elsewhere where sys.stdout is default. @param stderr <stream/None> - Stream to use for stderr as package info, or None to silence. Default None. NOTE: This differs from elsewhere where sys.stderr is default. @return - The imported module @raises - ImportError if cannot import. NOTE: With this method, PipInstallFailed will be intercepted and ImportError thrown instead, as this is intended to be a drop-in replacement for "import" when the package name differs.` getGlobalVirtualEnvInfo() `getGlobalVirtualEnvInfo - Returns the VirtualEnvInfo object representing the global environment, or None if not setup. If not setup, call enableOnDemandImporter() to add the hook and create the "global" env. @return VirtualEnvInfo representing global env, or None if enableOnDemandImporter has not been called.` toggleDebug(isDebug) `toggleDebug - Toggle debug messages. Default disabled. @param isDebug <bool> - Whether to enable debug messages or disable them. @return <bool> - The old state of debug` toggleOnDemandImporter(isActive) `toggleOnDemandImporter - Toggle whether the on demand importer (import hook) is active. If enableOnDemandImporter was not ever called, this has no effect. Otherwise, calling toggleOnDemandImporter(False) will temporarily disable the import hook, until toggleOnDemandImporter(True) is called. @param isActive <bool> - To temporarily enable/disable the on-demand importer. @return <bool> - True if a toggle occured, False if no state has changed. @raises ValueError - If no global virtualenv has been set, either by enableOnDemandImporter or setGlobalVirtualEnv`

Data
`` |  | __all__ = ('globalOnDemandVirtualEnv', 'isOnDemandImporterEnabled', 'getGlobalVirtualEnvInfo', 'enableOnDemandImporter', 'ensureImportGlobal', 'VirtualEnvOnDemandImporter', 'toggleOnDemandImporter', 'toggleDebug') globalOnDemandVirtualEnv = None isOnDemandImporterEnabled = False