:py:mod:`pypi` ============== .. py:module:: conda.plugins.prefix_data_loaders.pypi .. autoapi-nested-parse:: Reads PyPI packages in a conda prefix that have been installed with non-conda tools. .. toctree:: :hidden: :titlesonly: :maxdepth: 3 pkg_format/index.rst Classes ------- .. autoapisummary:: conda.plugins.prefix_data_loaders.pypi.PrefixGraph conda.plugins.prefix_data_loaders.pypi.CondaPrefixDataLoader Functions --------- .. autoapisummary:: conda.plugins.prefix_data_loaders.pypi.get_python_site_packages_short_path conda.plugins.prefix_data_loaders.pypi.win_path_ok conda.plugins.prefix_data_loaders.pypi.rm_rf conda.plugins.prefix_data_loaders.pypi.get_site_packages_anchor_files conda.plugins.prefix_data_loaders.pypi.read_python_record conda.plugins.prefix_data_loaders.pypi.load_site_packages conda.plugins.prefix_data_loaders.pypi.get_conda_anchor_files_and_records conda.plugins.prefix_data_loaders.pypi.conda_prefix_data_loaders Attributes ---------- .. autoapisummary:: conda.plugins.prefix_data_loaders.pypi.hookimpl .. py:exception:: ValidationError(key, value=None, valid_types=None, msg=None) Bases: :py:obj:`AuxlibError`, :py:obj:`TypeError` Mixin to identify exceptions associated with the auxlib package. Initialize self. See help(type(self)) for accurate signature. .. py:function:: get_python_site_packages_short_path(python_version) .. py:function:: win_path_ok(path) .. py:function:: 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. .. py: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. .. py:property:: records .. py:method:: remove_spec(spec) Remove all matching nodes, and any associated child nodes. :param spec: :type spec: MatchSpec :returns: The removed nodes. :rtype: tuple[PrefixRecord] .. py:method:: remove_youngest_descendant_nodes_with_specs() A specialized method used to determine only dependencies of requested specs. :returns: The removed nodes. :rtype: tuple[PrefixRecord] .. py:method:: prune() Prune back all packages until all child nodes are anchored by a spec. :returns: The pruned nodes. :rtype: tuple[PrefixRecord] .. py:method:: get_node_by_name(name) .. py:method:: all_descendants(node) .. py:method:: all_ancestors(node) .. py:method:: _remove_node(node) Removes this node and all edges referencing it. .. py:method:: _toposort() .. py:method:: _toposort_raise_on_cycles(graph) :classmethod: .. py:method:: _topo_sort_handle_cycles(graph) :classmethod: .. py:method:: _toposort_pop_key(graph) :staticmethod: 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. .. py:method:: _toposort_prepare_graph(graph) :staticmethod: .. py:data:: hookimpl Decorator to mark plugin hook implementations, used to register plugins. .. py:class:: CondaPrefixDataLoader Bases: :py:obj:`CondaPlugin` Define new loaders to expose non-conda packages in a given prefix as ``PrefixRecord`` objects. :param name: name of the loader :param 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. .. py:attribute:: name :type: str .. py:attribute:: loader :type: CondaPrefixDataLoaderCallable .. py:function:: get_site_packages_anchor_files(site_packages_path, site_packages_dir) Get all the anchor files for the site packages directory. .. py:function:: 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. .. py:function:: 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. .. py:function:: get_conda_anchor_files_and_records(site_packages_short_path, python_records) Return the anchor files for the conda records of python packages. .. py:function:: conda_prefix_data_loaders()