pypi#

Reads PyPI packages in a conda prefix that have been installed with non-conda tools.

Classes#

PrefixGraph

A directed graph structure used for sorting packages (prefix_records) in prefixes and

CondaPrefixDataLoader

Define new loaders to expose non-conda packages in a given prefix

Functions#

get_python_site_packages_short_path(python_version)

win_path_ok(path)

rm_rf(→ bool)

Completely delete path

get_site_packages_anchor_files(site_packages_path, ...)

Get all the anchor files for the site packages directory.

read_python_record(prefix_path, anchor_file, ...)

Convert a python package defined by an anchor file (Metadata information)

load_site_packages(→ dict[str, ...)

Load non-conda-installed python packages in the site-packages of the prefix.

get_conda_anchor_files_and_records(...)

Return the anchor files for the conda records of python packages.

conda_prefix_data_loaders()

Attributes#

hookimpl

Decorator used to mark plugin hook implementations

exception ValidationError(key, value=None, valid_types=None, msg=None)#

Bases: AuxlibError, TypeError

Mixin to identify exceptions associated with the auxlib package.

Initialize self. See help(type(self)) for accurate signature.

get_python_site_packages_short_path(python_version)#
win_path_ok(path)#
rm_rf(path: str | os.PathLike, clean_empty_parents: bool = False) bool#

Completely delete path max_retries is the number of times to retry on failure. The default is 5. This only applies to deleting a directory. If removing path fails and trash is True, files will be moved to the trash directory.

class PrefixGraph(records, specs=())#

A directed graph structure used for sorting packages (prefix_records) in prefixes and manipulating packages within prefixes (e.g. removing and pruning).

The terminology used for edge direction is "parents" and "children" rather than "successors" and "predecessors". The parent nodes of a record are those records in the graph that match the record's "depends" field. E.g. NodeA depends on NodeB, then NodeA is a child of NodeB, and NodeB is a parent of NodeA. Nodes can have zero parents, or more than two parents.

Most public methods mutate the graph.

property records#
remove_spec(spec)#

Remove all matching nodes, and any associated child nodes.

Parameters:

spec (MatchSpec)

Returns:

The removed nodes.

Return type:

tuple[PrefixRecord]

remove_youngest_descendant_nodes_with_specs()#

A specialized method used to determine only dependencies of requested specs.

Returns:

The removed nodes.

Return type:

tuple[PrefixRecord]

prune()#

Prune back all packages until all child nodes are anchored by a spec.

Returns:

The pruned nodes.

Return type:

tuple[PrefixRecord]

get_node_by_name(name)#
all_descendants(node)#
all_ancestors(node)#
_remove_node(node)#

Removes this node and all edges referencing it.

_toposort()#
classmethod _toposort_raise_on_cycles(graph)#
classmethod _topo_sort_handle_cycles(graph)#
static _toposort_pop_key(graph)#

Pop an item from the graph that has the fewest parents. In the case of a tie, use the node with the alphabetically-first package name.

static _toposort_prepare_graph(graph)#
hookimpl#

Decorator used to mark plugin hook implementations

class CondaPrefixDataLoader#

Define new loaders to expose non-conda packages in a given prefix as PrefixRecord objects.

Parameters:
  • name -- name of the loader

  • loader -- a function that takes a prefix and a dictionary that maps package names to PrefixRecord objects. The newly loaded packages must be inserted in the passed dictionary accordingly, and also returned as a separate dictionary.

name: str#
loader: CondaPrefixDataLoaderCallable#
get_site_packages_anchor_files(site_packages_path, site_packages_dir)#

Get all the anchor files for the site packages directory.

read_python_record(prefix_path, anchor_file, python_version)#

Convert a python package defined by an anchor file (Metadata information) into a conda prefix record object.

load_site_packages(prefix: conda.common.path.PathType, records: dict[str, conda.models.records.PrefixRecord]) dict[str, conda.models.records.PrefixRecord]#

Load non-conda-installed python packages in the site-packages of the prefix.

Python packages not handled by conda are installed via other means, like using pip or using python setup.py develop for local development.

Packages found that are not handled by conda are converted into a prefix record and handled in memory.

Packages clobbering conda packages (i.e. the conda-meta record) are removed from the in memory representation.

get_conda_anchor_files_and_records(site_packages_short_path, python_records)#

Return the anchor files for the conda records of python packages.

conda_prefix_data_loaders()#