PipShellProxy
Shell proxy for managing Pipenv virtual environments.
This class manages Python virtual environments using Pipenv, which uses Pipfile and Pipfile.lock for dependency management. It provides:
- Automatic Pipenv environment creation from Pipfile
- Command execution within the Pipenv environment
- Environment cleanup and management
The virtual environment is created in the project directory (.venv subdirectory) using the PIPENV_VENV_IN_PROJECT setting.
CONFIG_FILE_NAME: strenv_file_path: strenv_hash: strenv_name: strworking_dir: strInitialize a BaseEnvShell instance.
pathlib.Path | strstr | Nonestr | Nonegws_core.core.classes.observer.message_dispatcher.MessageDispatcher | NoneAttach a custom observer to the shell proxy.
The logs of the proxy will be dispatched to the observer.
MessageObserverAttach a progress bar to the shell proxy.
The logs of the proxy will be dispatched to the progress bar logs.
ProgressBarRun a command in a shell and return the output. There logs of the command are ignored.
list | strdict | NoneShellProxyEnvVariableMode - ShellProxyEnvVariableMode.MERGEbool | Nonebool - TrueAnyDelete the working directory and all its contents.
Create the environment directory if it doesn't exist.
PathForce the message dispatcher to send all buffered messages immediately.
Check if the virtual environment is installed.
boolFormat the user command to run within the Pipenv environment.
Prepends pipenv run to the user command to ensure it executes within
the virtual environment context.
list | strlist | strGet the path to the Pipfile configuration file.
strGet default environment variables for Pipenv execution.
Sets PIPENV_PIPFILE to point to the Pipfile location and enables PIPENV_VENV_IN_PROJECT to create the virtual environment in the project directory.
dictGet the absolute path for the environment directory.
All environments are stored in the global env directory, with subdirectories named by their environment hash.
strGet the message dispatcher instance.
MessageDispatcherGet the path to the Pipfile.
strInstall the virtual env. Return True if the env was installed, False if it was already installed, or an error occured.
boolList all installed packages with their versions in the virtual environment.
Returns a dictionary where keys are package names and values are version strings. Only works if the environment is installed.
dictLog an error message using the dispatcher.
strLog an info message using the dispatcher.
strLog a warning message using the dispatcher.
strRead the environment configuration file and return its content.
strRun a command in a shell. The logs of the command will be dispatched to the message dispatcher during the execution.
list | strdict | NoneShellProxyEnvVariableMode - ShellProxyEnvVariableMode.MERGEbool | Nonebool - Falsebool - TrueintRun a command in a shell without blocking the thread. There logs of the command are ignored.
list | strdict | NoneShellProxyEnvVariableMode - ShellProxyEnvVariableMode.MERGEbool | NoneSysProcConvert the ShellProxy instance to a data transfer object.
ShellProxyDTOUninstall the virtual env. Return true if the env was uninstalled, False if it was already uninstalled or an error occured.
boolReturns the name of the class
bool - Falsebool - Falsebool - FalsestrCheck if a folder is a valid Pipenv environment folder.
Validates that the folder contains a Pipfile, Pipfile.lock, and .venv directory.
strboolCreate a virtual environment from a string containing the environment definition.
The environment directory name is generated from a hash of the env_str, so identical environment strings will share the same environment directory.
strgws_core.core.classes.observer.message_dispatcher.MessageDispatcher | NoneBaseEnvShellTypeReturns the full name of the class
bool - Falsebool - FalsestrstrVersionGet the environment creation information from the metadata file.
strVEnvCreationInfoGet the environment type identifier.
LiteralGet the human name of the object
strGet the short description of the object
strGet the style of the object
TypingStyleGet the typing name of the object Ex: 'RESOURCE.gws_core.Table'
strTypingNameObjCreate an MD5 hash from the environment string.
Removes whitespace and newlines before hashing to ensure consistent hashes for equivalent environment definitions.
strstrGet all the classes that inherit this class
list