�
��^i�B � � � d Z ddlZddlZddlZddlmZ ddlmZ ddlm Z m
Z
mZmZ ddl
mZ ddlmZ ddlmZ dd lmZ dd
lmZmZ ddlmZ ddlmZ dd
lmZ ddlmZ ddl m!Z! ddl"m#Z# ddl$m%Z%m&Z&m'Z'm(Z( ddl)m*Z* ddl+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6m7Z7m8Z8 ddl9m:Z: ej; e<� � Z= G d� de� � Z> G d� dee>� � Z?e8j@ e8jA e8jB gZCd$d�ZDd e de fd!�ZE G d"� d#e?� � ZFdS )%a Contains the Command base classes that depend on PipSession.
The classes in this module are in a separate module so the commands not
needing download / PackageFinder capability don't unnecessarily import the
PackageFinder machinery and all its vendored dependencies, etc.
� N)�partial)�Values)�Any�List�Optional�Tuple)�
WheelCache)�
cmdoptions)�Command)�CommandContextMixIn)�CommandError�PreviousBuildDirError)�
LinkCollector)�
PackageFinder)�SelectionPreferences)�TargetPython)�
PipSession)�RequirementPreparer)�install_req_from_editable�install_req_from_line�#install_req_from_parsed_requirement�install_req_from_req_string)�parse_requirements)�InstallRequirement)�RequirementTracker)�BaseResolver)�pip_self_version_check)�
deprecated)�
TempDirectory�TempDirectoryTypeRegistry�
tempdir_kinds)�running_under_virtualenvc � � � e Zd ZdZd� fd�Zededeee fd�� � Z
dedefd�Z ddedee
d ee
defd
�Z� xZS )
�SessionCommandMixinzE
A class mixin for command classes needing _build_session().
�returnNc �V �� t � � � � � d | _ d S �N)�super�__init__�_session)�self� __class__s ���/builddir/build/BUILDROOT/alt-python311-pip-21.3.1-4.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_internal/cli/req_command.pyr) zSessionCommandMixin.__init__6 s$ �� �
��������.2��
�
�
� �optionsc �� � g }t |dd� � s(t |dd� � }|r|� |� � t |dd� � }|r|� |� � |pdS )z7Return a list of index urls from user-provided options.�no_indexF� index_urlN�extra_index_urls)�getattr�append�extend)�clsr/ �
index_urls�url�urlss r- �_get_index_urlsz#SessionCommandMixin._get_index_urls: s� � � �
��w�
�E�2�2� '��'�;��5�5�C��
'��!�!�#�&�&�&��w� 2�D�9�9��� $����d�#�#�#��!�T�!r. c � � | j �6| � | � |� � � � | _ | j �J �| j S )zGet a default-managed session.)r* �
enter_context�_build_session)r+ r/ s r- �get_default_sessionz'SessionCommandMixin.get_default_sessionH sE � ��=� � �.�.�t�/B�/B�7�/K�/K�L�L�D�M� �=�,�,�,��}�r. �retries�timeoutc �� � |j r&t j � |j � � sJ �t |j r%t j � |j d� � nd |�|n|j |j | � |� � �� � }|j r|j |_
|j r|j |_ |j s|r|�|n|j |_ |j
r|j
|j
d�|_ |j |j _ |S )N�http)�cacher@ �
trusted_hostsr8 )rC �https)� cache_dir�os�path�isabsr �joinr@ rE r; �cert�verify�client_certrA �proxy�proxies�no_input�auth� prompting)r+ r/ r@ rA �sessions r- r> z"SessionCommandMixin._build_sessionR s � � �$�H���
�
�g�6G�(H�(H�H�H�H��;B�;L�V�����W�.��7�7�7�RV�&�2�G�G���!�/��+�+�G�4�4�
�
�
�� �<� *�$�\�G�N� �� /�"�.�G�L� �?� R�g� R�)0�)<�g�g�'�/�G�O� �=� ��
� ��� �G�O� &-�%5�!5�����r. �r% N�NN)�__name__�
__module__�__qualname__�__doc__r) �classmethodr r r �strr; r r? �intr> �
__classcell__�r, s @r- r$ r$ 0 s� �� � � � � �� �3� 3� 3� 3� 3� 3� �"�f� "��$�s�)�1D� "� "� "� �[�"��6� �j� � � � � "&�!%� &� &��&� �#��&� �#�� &�
�&� &� &� &� &� &� &� &r. r$ c �" � e Zd ZdZdeddfd�ZdS )�IndexGroupCommandz�
Abstract base class for commands with the index_group options.
This also corresponds to the commands that permit the pip version check.
r/ r% Nc �� � t |d� � sJ �|j s|j rdS | � |dt d|j � � �� � }|5 t
||� � ddd� � dS # 1 swxY w Y dS )z�
Do the pip version check if not disabled.
This overrides the default behavior of not doing the check.
r1 Nr � )r@ rA )�hasattr�disable_pip_version_checkr1 r> �minrA r )r+ r/ rT s r- �handle_pip_version_checkz*IndexGroupCommand.handle_pip_version_check� s� � � �w�
�+�+�+�+�+��,� ��0@� ��F� �%�%��Q��A�w��(?�(?� &�
�
�� � 5� 5�"�7�G�4�4�4� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5� 5���� 5� 5� 5� 5� 5� 5s �A.�.A2�5A2)rW rX rY rZ r rg � r. r- ra ra { s@ � � � � � �� �5�� 5�4� 5� 5� 5� 5� 5� 5r. ra r% c �� � t � � rdS t t d� � sdS t j dk st j dk rdS t j � � dk rdS t � d� � dS )z�Output a warning for sudo users on Unix.
In a virtual environment, sudo pip still writes to virtualenv.
On Windows, users may run pip as Administrator without issues.
This warning only applies to Unix root users outside of virtualenv.
N�getuid�win32�cygwinr z�Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv)r" rd rH �sys�platformrj �logger�warningrh r. r- �warn_if_run_as_rootrq � s� � � �!�!� ����2�x� � � ��� �|�w���#�,�(�":�":��� �y�{�{�a�����
�N�N� ,�� � � � r. �funcc � � �� dt ddfd��dt dt dt t dt
t f�� fd�}|S ) zNDecorator for common logic related to managing temporary
directories.
�registryr% Nc �F � t D ]}| � |d� � �d S )NF)�KEEPABLE_TEMPDIR_TYPES�
set_delete)rt �ts r- �configure_tempdir_registryz0with_cleanup.