octoprint.util.pip#
OUTPUT_ALREADY_INSTALLED = 'Requirement already satisfied'
module-attribute
#
Start of a line indicating some package was already installed in this version
OUTPUT_ERROR = 'ERROR:'
module-attribute
#
Start of error line
OUTPUT_FAILURE = 'Could not install'
module-attribute
#
Start of failure result line
OUTPUT_POTENTIAL_EGG_PROBLEM_POSIX = 'No such file or directory'
module-attribute
#
Line indicating a potential egg problem on Posix
OUTPUT_POTENTIAL_EGG_PROBLEM_WINDOWS = 'The system cannot find the file specified'
module-attribute
#
Line indicating a potential egg problem on Windows
OUTPUT_PYTHON_MISMATCH = 'requires a different Python:'
module-attribute
#
Line segment indicating a mismatch of python_requires version
OUTPUT_PYTHON_SYNTAX = 'SyntaxError: invalid syntax'
module-attribute
#
Line segment indicating a syntax error, could be a python mismatch, e.g. f-strings
OUTPUT_SUCCESS = 'Successfully installed'
module-attribute
#
Start of successful result line
LocalPipCaller
#
PipCaller(configured = None, ignore_cache = False, force_sudo = False, force_user = False)
#
Bases: CommandlineCaller
get_result_line(lines)
#
Returns the success or failure line contained in the output.
pip might generate more lines after the actual result line, which is why we can't just take the final line. So instead we look for the last line starting with either "Successfully installed" or "Could not install". If neither can be found, an empty string will be returned, which should also be considered a failure to install.
Parameters:
-
lines
(
list of str
) –the output to parse, stdout or stderr
Returns:
-
str –
the last result line, or an empty string if none was found, in which case failure should be resumed
is_already_installed(lines)
#
Returns whether the given output lines indicates the packages was already installed or not.
This is currently determined by an empty result line and any line starting with "Requirement already satisfied".
Parameters:
-
lines
(
list of str
) –the output to parse, stdout or stderr
Returns:
-
bool –
True if detected, False otherwise
is_egg_problem(lines)
#
Returns whether the given output lines indicates an occurrence of the "egg-problem".
If something (target or dependency of target) was installed as an egg at an earlier date (e.g. thanks to just running python setup.py install), pip install will throw an error after updating that something to a newer (non-egg) version since it will still have the egg on its sys.path and expect to read data from it.
See commit 8ad0aadb52b9ef354cad1b33bd4882ae2fbdb8d6 for more details.
Parameters:
-
lines
(
list of str
) –the output to parse, stdout or stderr
Returns:
-
bool –
True if detected, False otherwise
is_python_mismatch(lines)
#
Returns whether the given output lines indicates a Python version mismatch.
This is currently determined by either a syntax error or an explicit "requires a different Python" line.
Parameters:
-
lines
(
list of str
) –the output to parse, stdout or stderr
Returns:
-
bool –
True if detected, False otherwise