� ��^i D��@�UdZddlZddlZddlZddlZddlZddlmZddlm Z m Z m Z m Z m Z mZmZmZmZddlmZddlmZmZddlmZddlmZdd lmZdd lmZdd lm Z e r dd lm!Z!dd l"m#Z#dgZ$e ee%e&fZ'e e&gee&effZ(ej)dej*��Z+ej)d��Z,ej)d��Z-ej.ej/ej0ej1ej2ej3ej4ej5ej6ej7ej8ej9ej:ej;gZd<ej?ej@ejAgZBee dej=fe>d<d�eBD��ZCGd�d��ZDGd�d��ZE d8de&dededdeejd eFd!eeDf d"�ZGd#e&d!e'fd$�ZH d9d%eEdeejd!eDfd&�ZI d:d'ede&d(e%deddeejdeed!dfd)�ZJ d:d%eEdeejdeddeed!eeDf d*�ZKGd+�d,��ZLdedd!e(fd-�ZMd%e&d!ee&e&ffd.�ZNGd/�d0eO��ZPd!ejQfd1�ZRd2e'd!e'fd3�ZSd2e'd!e'fd4�ZTd2e'd!e'fd5�ZUd6e&ded!ee&e&ffd7�ZVdS);z Requirements file parsing �N)�Values) � TYPE_CHECKING�Any�Callable�Dict�Iterable�Iterator�List�Optional�Tuple)� cmdoptions)�InstallationError�RequirementsFileParseError)� SearchScope)� PipSession)�raise_for_status)� auto_decode)�get_url_scheme)�NoReturn)� PackageFinder�parse_requirementsz^(http|https|file):z (^|\s+)#.*$z#(?P\$\{(?P[A-Z0-9_]+)\}).�SUPPORTED_OPTIONS�SUPPORTED_OPTIONS_REQc�F�g|]}t|��j����S�)�str�dest)�.0�os ��/builddir/build/BUILDROOT/alt-python311-pip-21.3.1-4.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_internal/req/req_file.py� r!Ns&��K�K�K��c�!�!�#�#�(�m�m�K�K�K�c�`�eZdZ d dededededeeeefdeeddfd �ZdS) �ParsedRequirementN� requirement� is_editable� comes_from� constraint�options� line_source�returnc�Z�||_||_||_||_||_||_dS�N)r%r&r'r)r(r*)�selfr%r&r'r(r)r*s r �__init__zParsedRequirement.__init__Rs7��'���&���$����� �$���&����r")NN) �__name__� __module__� __qualname__r�boolr rrr/rr"r r$r$Qs�������-1�%)�'�'��'��'�� '� � '� �$�s�C�x�.�)� '��c�]�'� �'�'�'�'�'�'r"r$c �.�eZdZdedededededdf d�ZdS) � ParsedLine�filename�lineno�args�optsr(r+Nc���||_||_||_||_|rd|_d|_||_dS|jr"d|_d|_|jd|_dSd|_dS)NTFr)r6r7r9r(�is_requirementr&r%� editables)r.r6r7r8r9r(s r r/zParsedLine.__init__ds���!�� ��� ��� �$��� � (�"&�D� �$�D� �#�D� � � � �^� (�"&�D� �#�D� �#�~�a�0�D� � � �"'�D� � � r")r0r1r2r�intrr3r/rr"r r5r5csb������(��(��(�� (� � (� � (� �(�(�(�(�(�(r"r5Fr6�session�finderrr)r(r+c#�K�t|��}t||��}|�||��D]}t||||���}|�|V��dS)aqParse a requirements file and yield ParsedRequirement instances. :param filename: Path or url of requirements file. :param session: PipSession instance. :param finder: Instance of pip.index.PackageFinder. :param options: cli options. :param constraint: If true, parsing a constraint file rather than requirements file. )r)r?r>N)�get_line_parser�RequirementsFileParser�parse� handle_line) r6r>r?r)r(� line_parser�parser� parsed_line� parsed_reqs r rr~s}���� "�&�)�)�K� #�G�[� 9� 9�F��|�|�H�j�9�9��� � � ���� � � � � � !�� � � �� �r"�contentc��t|���d���}t|��}t|��}t |��}|S)zxSplit, filter, and join lines, and return a line iterator :param content: the content of the requirements file �)�start)� enumerate� splitlines� join_lines�ignore_comments�expand_env_variables)rI� lines_enums r � preprocessrS�sO�� )��);�);�)=�)=�Q�G�G�G�J��J�'�'�J� ��,�,�J�%�j�1�1�J� �r"�linec���d�|jrdnd|j|j��}|jsJ�|jr"t |j|j||j���S|rtj ||j ��i}tD]7}||j j vr'|j j |r|j j |||<�8d|j�d|j��}t |j|j||j||���S)Nz{} {} (line {})z-cz-r)r%r&r'r(�line � of )r%r&r'r(r)r*) �formatr(r6r7r;r&r$r%r �check_install_build_globalr9�SUPPORTED_OPTIONS_REQ_DEST�__dict__)rTr)�line_comes_from� req_optionsrr*s r �handle_requirement_liner^�s.�� (�.�.���)���T� � � � ���O� � ��� � �� �!��(��(�&���  � � � � � F� � 1�'�4�9� E� E� E�� �.� =� =�D��t�y�)�)�)�d�i�.@��.F�)�$(�I�$6�t�$<� �D�!��>�d�k�>�>�t�}�>�>� � ��(��(�&����#�  � � � r"r9r7c����rE|jr |j�_|jr+�j��fd�|jD����|�r�|j}|j}|jr|jg}|jdurg}|jr|�|j��|jr�|jd}tj � tj � |����} tj � | |��} tj � | ��r| }|�|��|r|�|��t!||���} | |_|jr|���|jr|���|r-|jpgD]%} d|�d|��} |�| | ����"dSdSdS)Nc3�.�K�|]}|�jv� |V��dSr-)�features_enabled)r�fr)s �r � z%handle_option_line..�s9�����,�,��A�W�=U�4U�4U��4U�4U�4U�4U�,�,r"Tr)� find_links� index_urlsrVrW)�source)�require_hashesra�extendrdre� index_url�no_index�extra_index_urls�os�path�dirname�abspath�join�exists�append�update_index_urlsr� search_scope�pre�set_allow_all_prereleases� prefer_binary�set_prefer_binary� trusted_hosts�add_trusted_host)r9r6r7r?r)r>rdre�value�req_dir�relative_to_reqs_filert�hostrfs ` r �handle_option_liner�s<����� � � 9�%)�%8�G� "� � � � � $� +� +�,�,�,�,��0�,�,�,� � � � �'>��&� ��&� � �>� *��.�)�J� �=�D� � ��J� � � 5� � � �d�3� 4� 4� 4� �?� %��O�A�&�E��g�o�o�b�g�o�o�h�&?�&?�@�@�G�$&�G�L�L��%�$@�$@� !��w�~�~�3�4�4� .�-�� � � �e� $� $� $� � 2� � %� %�j� 1� 1� 1�"�!�!� � � � �+��� �8� /� � ,� ,� .� .� .� � � '� � $� $� &� &� &� � >��*�0�b� >� >��7��7�7�X�7�7���(�(��f�(�=�=�=�=�O'>�'>�H >� >� >� >r"c�~�|jrt||��}|St|j|j|j|||��dS)aHandle a single parsed requirements line; This can result in creating/yielding requirements, or updating the finder. :param line: The parsed line to be processed. :param options: CLI options. :param finder: The finder - updated by non-requirement lines. :param session: The session - updated by non-requirement lines. Returns a ParsedRequirement object if the line is a requirement line, otherwise returns None. For lines that contain requirements, the only options that have an effect are from SUPPORTED_OPTIONS_REQ, and they are scoped to the requirement. Other options from SUPPORTED_OPTIONS may be present, but are ignored. For lines that do not contain requirements, the only options that have an effect are from SUPPORTED_OPTIONS. Options from SUPPORTED_OPTIONS_REQ may be present, but are ignored. These lines may contain multiple options (although our docs imply only one is supported), and all our parsed and affect the finder. N)r;r^rr9r6r7)rTr)r?r>rHs r rDrDsU��: �� �,�T�7�;�;� ���� �I� �M� �K� � � �  � � ��tr"c��eZdZdededdfd�Zdededee fd�Z dededee fd �Z dededee fd �Z dS) rBr>rEr+Nc�"�||_||_dSr-)�_session� _line_parser)r.r>rEs r r/zRequirementsFileParser.__init__<s��  �� �'����r"r6r(c#�BK�|�||��Ed{V��dS)z*Parse a given file, yielding parsed lines.N)�_parse_and_recurse)r.r6r(s r rCzRequirementsFileParser.parseDs4�����*�*�8�Z�@�@�@�@�@�@�@�@�@�@�@r"c#�PK�|�||��D�] }|js�|jjs |jjr�|jjr|jjd}d}n|jjd}d}t �|��r!tj� ||��}nWt �|��s=tj � tj � |��|��}|�||��Ed{V����|V��� dS)NrFT)� _parse_filer;r9� requirements� constraints� SCHEME_RE�search�urllibrC�urljoinrlrmrprnr�)r.r6r(rT�req_path�nested_constraints r r�z)RequirementsFileParser._parse_and_recurseHs;�����$�$�X�z�:�:� � �D��&� �� �&� �*.�)�*?� ��9�)�-�#�y�5�a�8�H�(-�%�%�#�y�4�Q�7�H�(,�%��#�#�H�-�-� �%�|�3�3�H�h�G�G�H�H�"�)�)�(�3�3��!�w�|�|������1�1� � � �H�  �2�2�8�=N�O�O�O�O�O�O�O�O�O�O�� � � � �5 � r"c#�"K�t||j��\}}t|��}|D]b\}} |�|��\}} n.#t$r!} d|�d| j��} t | ���d} ~ wwxYwt|||| |��V��cdS)NzInvalid requirement: � )�get_file_contentr�rSr��OptionParsingError�msgrr5) r.r6r(�_rIrR� line_numberrT�args_strr9�er�s r r�z"RequirementsFileParser._parse_filegs�����%�h�� �>�>� ��7���(�(� �!+� � � �K�� 6�!%�!2�!2�4�!8�!8���$�$��%� 6� 6� 6�=�d�=�=�a�e�=�=��0��5�5�5����� 6���� ������ �� � � � � � s�A � A6�A1�1A6) r0r1r2r� LineParserr/rr3r r5rCr�r�rr"r rBrB;s�������(��(� �(� � (�(�(�(�A�c�A�t�A���8L�A�A�A�A����)-�� �*� �����>�C��T��h�z�>R������r"rBc�T��dtdtttff�fd� }|S)NrTr+c����t��}|���}d|_�r �j|_t |��\}}|�t j|��|��\}}||fSr-)� build_parser�get_default_valuesri�format_control�break_args_options� parse_args�shlex�split)rTrF�defaultsr�� options_strr9r�r?s �r � parse_linez#get_line_parser..parse_line~sy��������,�,�.�.��!��� � <�&,�&;�H� #� 2�4� 8� 8���+��#�#�E�K� �$<�$<�h�G�G���a���~�r")rr r)r?r�s` r rArA}s@��� �� ��s�F�{�!3� � � � � � � �r"c�N�|�d��}g}|dd�}|D]X}|�d��s|�d��rn+|�|��|�d���Yd�|��d�|��fS)z�Break up the line into an args and options string. We only want to shlex (and then optparse) the options, not the args. args can contain markers which are corrupted by shlex. � N�-z--r)r�� startswithrr�poprp)rT�tokensr8r)�tokens r r�r��s��� �Z�Z��_�_�F� �D��Q�Q�Q�i�G����� � � �C� � � �E�$4�$4�T�$:�$:� � �E� �K�K�� � � � �K�K��N�N�N�N� �8�8�D�>�>�3�8�8�G�,�,� ,�,r"c��eZdZdeddfd�ZdS)r�r�r+Nc��||_dSr-)r��r.r�s r r/zOptionParsingError.__init__�s ������r")r0r1r2rr/rr"r r�r��s6�������C��D������r"r�c���tjd���}ttz}|D]!}|��}|�|���"dt dt ddfd�}||_|S)z7 Return a parser for parsing requirement lines F)�add_help_optionr.r�r+rc� �t|���r-)r�r�s r � parser_exitz!build_parser..parser_exit�s�� ��%�%�%r")�optparse� OptionParserrr� add_optionrr�exit)rF�option_factories�option_factory�optionr�s r r�r��s���� "�5� 9� 9� 9�F�(�+@�@��*�"�"����!�!�����&�!�!�!�!�&�#�&�C�&�J�&�&�&�&� �F�K� �Mr"rRc#��K�d}g}|D]�\}}|�d��rt�|��r]t�|��rd|z}|r5|�|��|�J�|d�|��fV�g}��||fV���|s|}|�|�d������|r|�J�|d�|��fV�dSdS)z�Joins a line ending in '' with the previous line (except when following comments). The joined line takes on the index of the first line. N�\r��)�endswith� COMMENT_RE�matchrrrp�strip)rR�primary_line_number�new_liner�rTs r rOrO�s?�������H�'�.�.�� �T��}�}�T�"�"� .�j�&6�&6�t�&<�&<� .�����%�%� "��T�z��� (�����%�%�%�*�6�6�6�)�2�7�7�8�+<�+<�<�<�<�<����!�4�'�'�'�'�'�� 2�&1�#� �O�O�D�J�J�t�,�,� -� -� -� -��5�"�.�.�.�!�2�7�7�8�#4�#4�4�4�4�4�4�4�5�5r"c#�K�|D]<\}}t�d|��}|���}|r||fV��=dS)z1 Strips comments and filter empty lines. r�N)r��subr�)rRr�rTs r rPrP�s`����(�$�$�� �T��~�~�b�$�'�'���z�z�|�|�� � $��t�#� #� #� #�� $�$r"c#��K�|D]X\}}t�|��D]2\}}tj|��}|s�|�||��}�3||fV��YdS)a�Replace all environment variables that can be retrieved via `os.getenv`. The only allowed format for environment variables defined in the requirement file is `${MY_VARIABLE_1}` to ensure two things: 1. Strings that contain a `$` aren't accidentally (partially) expanded. 2. Ensure consistency across platforms for requirement files. These points are the result of a discussion on the `github pull request #3514 `_. Valid characters in variable names follow the `POSIX standard `_ and are limited to uppercase letter, digits and the `_` (underscore). N)� ENV_VAR_RE�findallrl�getenv�replace)rRr�rT�env_var�var_namer{s r rQrQ�s����� (� � �� �T�!+�!3�!3�D�!9�!9� 0� 0� �G�X��I�h�'�'�E�� ���<�<���/�/�D�D��4������ � r"�urlc�r�t|��}|dvr2|�|��}t|��|j|jfS t |d��5}t |�����}ddd��n #1swxYwYn$#t$r}td|�����d}~wwxYw||fS)aGets the content of a file; it may be a filename, file: URL, or http: URL. Returns (location, content). Content is unicode. Respects # -*- coding: declarations on the retrieved files. :param url: File path or url. :param session: PipSession instance. )�http�https�file�rbNz"Could not open requirements file: ) r�getrr��text�openr�read�OSErrorr)r�r>�scheme�resprbrI�excs r r�r�s ���C� � �F��*�*�*��{�{�3����������x���"�"�L� �#�t�_�_� ,��!�!�&�&�(�(�+�+�G� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,� ,���� ,� ,� ,� ,��� �L�L�L�� J�S� J� J�K�K�K�����L���� ��<�s<�B�"B�9 B�B � B� B � B� B2�B-�-B2)NNFr-)NNN)W�__doc__r�rl�rer�� urllib.parser�r�typingrrrrrr r r r �pip._internal.clir �pip._internal.exceptionsrr�!pip._internal.models.search_scoper�pip._internal.network.sessionr�pip._internal.network.utilsr�pip._internal.utils.encodingr�pip._internal.utils.urlsrr�"pip._internal.index.package_finderr�__all__r=r� ReqFileLinesr��compile�Ir�r�r�ri�extra_index_urlrjr�r��editablerd� no_binary� only_binaryrwrgru� trusted_host�use_new_featurer�Option�__annotations__�install_options�global_options�hashrrZr$r5r3rrSr^rrDrBrAr�� Exceptionr�r�r�rOrPrQr�rr"r �r�s#��������� � � � � � � � � � � � ����������� � � � � � � � � � � � � � � � � � � � � � �)�(�(�(�(�(�R�R�R�R�R�R�R�R�9�9�9�9�9�9�4�4�4�4�4�4�8�8�8�8�8�8�4�4�4�4�4�4�3�3�3�3�3�3��A� ������@�@�@�@�@�@� � ����c�3�h��(� � �s�e�U�3��;�/�/� 0� � �B�J�-�r�t� 4� 4� � �R�Z�� '� '� � �R�Z�>� ?� ?� ������������������������N�����;��4���h�o�!5�6�7����&�����O�?��t�H�S�(�/�%9�:�;����L�K�5J�K�K�K��'�'�'�'�'�'�'�'�$(�(�(�(�(�(�(�(�<)-�)-�� ���� �� �_� %���h�o� &� � � � �� � ����6 �� � � � � � �*.�* �* � �* � �h�o� &�* ��* �* �* �* �b)-�)-�$(� :>�:>� �:>��:>� �:>� �_� %� :>� �h�o� &� :>� �j� !� :>� �:>�:>�:>�:>�~*.�(,�$(� )�)� �)� �h�o� &�)� �_� %�)��j� !� )� �� � )�)�)�)�X?�?�?�?�?�?�?�?�D�H�_�5��*�����&-�S�-�U�3��8�_�-�-�-�-�"��������� �h�+�����.5�<�5�L�5�5�5�5�>$� �$��$�$�$�$� �\� �l� � � � �6�#�� ��u�S�#�X�������r"