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

Public Member Functions

"BaseEnvironment" default (cls)
 
"BaseEnvironment" from_paths (cls, Optional[List[str]] paths)
 
Optional["BaseDistribution"] get_distribution (self, str name)
 
Iterator[BaseDistributioniter_all_distributions (self)
 
Iterator[BaseDistributioniter_installed_distributions (self, bool local_only=True, Container[str] skip=stdlib_pkgs, bool include_editables=True, bool editables_only=False, bool user_only=False)
 

Protected Member Functions

Iterator["BaseDistribution"] _iter_distributions (self)
 

Detailed Description

An environment containing distributions to introspect.

Definition at line 582 of file base.py.

Member Function Documentation

◆ _iter_distributions()

Iterator["BaseDistribution"] _iter_distributions (   self)
protected
Iterate through installed distributions.

This function should be implemented by subclass, but never called
directly. Use the public ``iter_distribution()`` instead, which
implements additional logic to make sure the distributions are valid.

Reimplemented in Environment, and Environment.

Definition at line 601 of file base.py.

601 def _iter_distributions(self) -> Iterator["BaseDistribution"]:
602 """Iterate through installed distributions.
603
604 This function should be implemented by subclass, but never called
605 directly. Use the public ``iter_distribution()`` instead, which
606 implements additional logic to make sure the distributions are valid.
607 """
608 raise NotImplementedError()
609
for i

References i.

Referenced by BaseEnvironment.iter_all_distributions().

Here is the caller graph for this function:

◆ default()

"BaseEnvironment" default (   cls)

Reimplemented in Environment, and Environment.

Definition at line 586 of file base.py.

586 def default(cls) -> "BaseEnvironment":
587 raise NotImplementedError()
588

References i.

◆ from_paths()

"BaseEnvironment" from_paths (   cls,
Optional[List[str]]  paths 
)

Reimplemented in Environment, and Environment.

Definition at line 590 of file base.py.

590 def from_paths(cls, paths: Optional[List[str]]) -> "BaseEnvironment":
591 raise NotImplementedError()
592

References i.

◆ get_distribution()

Optional["BaseDistribution"] get_distribution (   self,
str  name 
)
Given a requirement name, return the installed distributions.

The name may not be normalized. The implementation must canonicalize
it for lookup.

Reimplemented in Environment, and Environment.

Definition at line 593 of file base.py.

593 def get_distribution(self, name: str) -> Optional["BaseDistribution"]:
594 """Given a requirement name, return the installed distributions.
595
596 The name may not be normalized. The implementation must canonicalize
597 it for lookup.
598 """
599 raise NotImplementedError()
600

References i.

Referenced by DistributionPath.get_file_path().

Here is the caller graph for this function:

◆ iter_all_distributions()

Iterator[BaseDistribution] iter_all_distributions (   self)
Iterate through all installed distributions without any filtering.

Definition at line 610 of file base.py.

610 def iter_all_distributions(self) -> Iterator[BaseDistribution]:
611 """Iterate through all installed distributions without any filtering."""
612 for dist in self._iter_distributions():
613 # Make sure the distribution actually comes from a valid Python
614 # packaging distribution. Pip's AdjacentTempDirectory leaves folders
615 # e.g. ``~atplotlib.dist-info`` if cleanup was interrupted. The
616 # valid project name pattern is taken from PEP 508.
617 project_name_valid = re.match(
618 r"^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$",
620 flags=re.IGNORECASE,
621 )
622 if not project_name_valid:
624 "Ignoring invalid distribution %s (%s)",
627 )
628 continue
629 yield dist
630

References BaseEnvironment._iter_distributions(), Environment._iter_distributions(), and i.

Referenced by Environment._search_distribution(), Environment.get_distribution(), and BaseEnvironment.iter_installed_distributions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iter_installed_distributions()

Iterator[BaseDistribution] iter_installed_distributions (   self,
bool   local_only = True,
Container[str]   skip = stdlib_pkgs,
bool   include_editables = True,
bool   editables_only = False,
bool   user_only = False 
)
Return a list of installed distributions.

This is based on ``iter_all_distributions()`` with additional filtering
options. Note that ``iter_installed_distributions()`` without arguments
is *not* equal to ``iter_all_distributions()``, since some of the
configurations exclude packages by default.

:param local_only: If True (default), only return installations
local to the current virtualenv, if in a virtualenv.
:param skip: An iterable of canonicalized project names to ignore;
    defaults to ``stdlib_pkgs``.
:param include_editables: If False, don't report editables.
:param editables_only: If True, only report editables.
:param user_only: If True, only report installations in the user
site directory.

Definition at line 631 of file base.py.

638 ) -> Iterator[BaseDistribution]:
639 """Return a list of installed distributions.
640
641 This is based on ``iter_all_distributions()`` with additional filtering
642 options. Note that ``iter_installed_distributions()`` without arguments
643 is *not* equal to ``iter_all_distributions()``, since some of the
644 configurations exclude packages by default.
645
646 :param local_only: If True (default), only return installations
647 local to the current virtualenv, if in a virtualenv.
648 :param skip: An iterable of canonicalized project names to ignore;
649 defaults to ``stdlib_pkgs``.
650 :param include_editables: If False, don't report editables.
651 :param editables_only: If True, only report editables.
652 :param user_only: If True, only report installations in the user
653 site directory.
654 """
655 it = self.iter_all_distributions()
656 if local_only:
657 it = (d for d in it if d.local)
658 if not include_editables:
659 it = (d for d in it if not d.editable)
660 if editables_only:
661 it = (d for d in it if d.editable)
662 if user_only:
663 it = (d for d in it if d.in_usersite)
664 return (d for d in it if d.canonical_name not in skip)
665
666

References i, and BaseEnvironment.iter_all_distributions().

Here is the call graph for this function:

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