8.4.7. pymodaq_utils.environment module
- class pymodaq_utils.environment.EnvironmentBackupManager[source]
Bases:
objectA class to manage rotating backups of python environments, controlled by entries in [backup] section of the configuration.
Methods
Save the current environment if there is no backup or if it's different from the oldest one.
- class pymodaq_utils.environment.PythonEnvironment(filename=None)[source]
Bases:
objectA class to represent a python environment and creates/delete backups.
- Preferably, it is instanciated using one the following static method:
from_freeze: to perform a pip freeze and allowing to save it
from_file: to read a file and allowing to delete it
Methods
date()Gets the date at which this environment was created from its filename.
extend(packages)Add packages to the environment.
from_file(filename)Loads a PythonEnvironment from a text file in a pip recognized format
Loads a PythonEnvironment by performing a pip freeze
remove()Remove the backup file associated with this environment, if it exists.
save()Save the backup file associated with this environment, if it does not exists.
- static from_file(filename)[source]
Loads a PythonEnvironment from a text file in a pip recognized format
- Parameters:
filename (
str) – A Path to the file to load- Returns:
the PythonEnvironment representation of the file represented by filename
- Return type:
- static from_freeze()[source]
Loads a PythonEnvironment by performing a pip freeze
- Returns:
the PythonEnvironment representation of all installed packages in the current environment
- Return type:
- date()[source]
Gets the date at which this environment was created from its filename. If not possible it fallbacks to its creation/modification date (depending on the OS) If still not possible it fallbacks to now.
It allows to sort them by date, without having to declare comparison operators that aren’t consistant with __eq__.
- Returns:
The date associated with this environment
- Return type:
datetime
- extend(packages)[source]
Add packages to the environment. (This does not install them)
- Parameters:
packages (
[str]) – an iterable containing the different packages, preferably in a “<name>==<version>” format
- DATE_FORMAT = '%Y%m%d%H%M%S'