Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
ExternallyManagedEnvironment Class Reference
Inheritance diagram for ExternallyManagedEnvironment:
Collaboration diagram for ExternallyManagedEnvironment:

Public Member Functions

None __init__ (self, Optional[str] error)
 
"ExternallyManagedEnvironment" from_config (cls, Union[pathlib.Path, str] config)
 
- Public Member Functions inherited from DiagnosticPipError
str __repr__ (self)
 
RenderResult __rich_console__ (self, Console console, ConsoleOptions options)
 

Static Public Attributes

str reference = "externally-managed-environment"
 
- Static Public Attributes inherited from DiagnosticPipError
str reference
 

Static Protected Member Functions

Iterator[str] _iter_externally_managed_error_keys ()
 

Additional Inherited Members

- Data Fields inherited from DiagnosticPipError
 kind
 
 reference
 
 message
 
 context
 
 note_stmt
 
 hint_stmt
 
 link
 

Detailed Description

The current environment is externally managed.

This is raised when the current environment is externally managed, as
defined by `PEP 668`_. The ``EXTERNALLY-MANAGED`` configuration is checked
and displayed when the error is bubbled up to the user.

:param error: The error message read from ``EXTERNALLY-MANAGED``.

Definition at line 663 of file exceptions.py.

Constructor & Destructor Documentation

◆ __init__()

None __init__ (   self,
Optional[str]  error 
)

Reimplemented from DiagnosticPipError.

Definition at line 675 of file exceptions.py.

675 def __init__(self, error: Optional[str]) -> None:
676 if error is None:
677 context = Text(_DEFAULT_EXTERNALLY_MANAGED_ERROR)
678 else:
679 context = Text(error)
680 super().__init__(
681 message="This environment is externally managed",
682 context=context,
683 note_stmt=(
684 "If you believe this is a mistake, please contact your "
685 "Python installation or OS distribution provider. "
686 "You can override this, at the risk of breaking your Python "
687 "installation or OS, by passing --break-system-packages."
688 ),
689 hint_stmt=Text("See PEP 668 for the detailed specification."),
690 )
691
for i

Referenced by Protocol.__init_subclass__().

Here is the caller graph for this function:

Member Function Documentation

◆ _iter_externally_managed_error_keys()

Iterator[str] _iter_externally_managed_error_keys ( )
staticprotected

Definition at line 693 of file exceptions.py.

693 def _iter_externally_managed_error_keys() -> Iterator[str]:
694 # LC_MESSAGES is in POSIX, but not the C standard. The most common
695 # platform that does not implement this category is Windows, where
696 # using other categories for console message localization is equally
697 # unreliable, so we fall back to the locale-less vendor message. This
698 # can always be re-evaluated when a vendor proposes a new alternative.
699 try:
700 category = locale.LC_MESSAGES
701 except AttributeError:
702 lang: Optional[str] = None
703 else:
704 lang, _ = locale.getlocale(category)
705 if lang is not None:
706 yield f"Error-{lang}"
707 for sep in ("-", "_"):
708 before, found, _ = lang.partition(sep)
709 if not found:
710 continue
711 yield f"Error-{before}"
712 yield "Error"
713

◆ from_config()

"ExternallyManagedEnvironment" from_config (   cls,
Union[pathlib.Path, str]  config 
)

Definition at line 715 of file exceptions.py.

718 ) -> "ExternallyManagedEnvironment":
719 parser = configparser.ConfigParser(interpolation=None)
720 try:
721 parser.read(config, encoding="utf-8")
722 section = parser["externally-managed"]
723 for key in cls._iter_externally_managed_error_keys():
724 with contextlib.suppress(KeyError):
725 return cls(section[key])
726 except KeyError:
727 pass
728 except (OSError, UnicodeDecodeError, configparser.ParsingError):
729 from pip._internal.utils._log import VERBOSE
730
731 exc_info = logger.isEnabledFor(VERBOSE)
732 logger.warning("Failed to read %s", config, exc_info=exc_info)
733 return cls(None)

Field Documentation

◆ reference

str reference = "externally-managed-environment"
static

Definition at line 673 of file exceptions.py.

Referenced by DiagnosticPipError.__init__().


The documentation for this class was generated from the following file: