� !A?h=3��v� ddlZddlZddlmZddlmZddlmZddlm Z ddd�Z Gd �d e��Z d d �Z dS) �N)�Command)�DistutilsExecError)�customize_compiler)�logz.cz.cxx)�czc++c��eZdZdZgd�Zd�Zd�Zd�Zd�Zd�Z d�Z d �Z d �Z d �Z dd�Z dd�Zdd�Z dd�Z dd�Z dd�Zd d d gfd�Z dd�Zd S)�configzprepare to build) )z compiler=Nzspecify the compiler type)zcc=Nzspecify the compiler executable)z include-dirs=�Iz.list of directories to search for header files)zdefine=�DzC preprocessor macros to define)zundef=�Uz!C preprocessor macros to undefine)z libraries=�lz!external C libraries to link with)z library-dirs=�Lz.directories to search for external C libraries)�noisyNz1show every action (compile, link, run, ...) taken)z dump-sourceNz=dump generated source files before attempting to compile themc�v�d|_d|_d|_d|_d|_d|_d|_g|_dS)N�)�compiler�cc� include_dirs� libraries� library_dirsr� dump_source� temp_files��selfs �E/opt/alt/python-internal/lib64/python3.11/distutils/command/config.py�initialize_optionszconfig.initialize_options3sE���� ���� ������ ����� ���������c���|j�|jjpg|_nCt|jt��r)|j�t j��|_|j�g|_n't|jt��r |jg|_|j� g|_dSt|jt��r+|j�t j��|_dSdS�N) r� distribution� isinstance�str�split�os�pathseprrrs r�finalize_optionszconfig.finalize_optionsBs��� � � $� $� 1� >� D�"�D� � � ��)�3� /� /� D� $� 1� 7� 7�� � C� C�D� � �>� !��D�N�N� ���� ,� ,� .�"�n�-�D�N� � � $� "�D� � � � ��)�3� /� /� D� $� 1� 7� 7�� � C� C�D� � � � D� Drc��dSr�rs r�runz config.runRs�� �rc�� ddlm}m}t|j|��s�||j|jd���|_t |j��|jr|j�|j��|j r|j� |j ��|j r#|j� |j ��dSdSdS)Nr)� CCompiler� new_compilerr)r�dry_run�force) �distutils.ccompilerr+r,r!rr-rr�set_include_dirsr� set_librariesr�set_library_dirs)rr+r,s r�_check_compilerzconfig._check_compilerYs��� � @�?�?�?�?�?�?�?��$�-��3�3� B�(�L�$�-�15��Q�H�H�H�D�M� �t�}� -� -� -�� � B�� �.�.�t�/@�A�A�A��~� <�� �+�+�D�N�;�;�;�� � B�� �.�.�t�/@�A�A�A�A�A� B� B� B� Brc�J�dt|z}t|d��5}|r2|D]}|�d|z���|�d��|�|��|ddkr|�d��ddd��n #1swxYwY|S)N� _configtest�wz#include <%s> � �����)�LANG_EXT�open�write)r�body�headers�lang�filename�file�headers r�_gen_temp_sourcefilezconfig._gen_temp_sourcefileks��� �8�D�>�1�� �(�C� � � !�D�� !�%�;�;�F��J�J�0�6�9�:�:�:�:�� � �4� � � � �J�J�t� � � ��B�x�4���� � �4� � � � !� !� !� !� !� !� !� !� !� !� !���� !� !� !� !��s�A+B�B�Bc��|�|||��}d}|j�||g��|j�|||���||fS)Nz _configtest.i�r)rBr�extendr� preprocess)rr<r=rr>�src�outs r� _preprocesszconfig._preprocessws_���'�'��g�t�<�<���� �����S�z�*�*�*� � � � ��c� � �E�E�E��S�z�rc��|�|||��}|jrt|d|z��|j�|g��\}|j�||g��|j�|g|���||fS)Nzcompiling '%s':rD)rBr� dump_filer�object_filenamesrrE�compile)rr<r=rr>rG�objs r�_compilezconfig._compile~s����'�'��g�t�<�<�� � � 4� �c�,�s�2� 3� 3� 3���/�/���6�6��� �����S�z�*�*�*� � ���s�e�,��?�?�?��S�z�rc�p�|�||||��\}}tj�tj�|����d} |j�|g| |||���|jj�| |jjz} |j� | ��||| fS)Nr)rr� target_lang) rOr$�path�splitext�basenamer�link_executable� exe_extensionr�append) rr<r=rrrr>rGrN�progs r�_linkz config._link�s����]�]�4��,��E�E� ��c��w����� 0� 0�� 5� 5�6�6�q�9�� � �%�%�s�e�T�09�3?�26� &� 8� 8� 8� �=� &� 2��$�-�5�5�D� ����t�$�$�$��S�$��rc���|s|j}g|_tjdd�|����|D]'} t j|���#t $rY�$wxYwdS)Nz removing: %s� )rr�info�joinr$�remove�OSError)r� filenamesr?s r�_cleanz config._clean�s���� !���I� �D�O� ������)�!4�!4�5�5�5�!� � �H� �� �(�#�#�#�#��� � � ��� ���� � s�A� A �A Nrc�� ddlm}|���d} |�||||��n #|$rd}YnwxYw|���|S)Nr�� CompileErrorTF)r/rdr3rIra�rr<r=rr>rd�oks r�try_cppzconfig.try_cpp�s��� � 5�4�4�4�4�4� ������ �� � � � �T�7�L�$� ?� ?� ?� ?��� � � ��B�B�B� ���� � � � � � �� s�8�A�Ac�� |���|�||||��\}}t|t��rt j|��}t |��5}d} |���} | dkrn|�| ��rd} n�4ddd��n #1swxYwY|� ��| S)NFT�) r3rIr!r"�rerMr:�readline�searchra) r�patternr<r=rr>rGrHr@�match�lines r� search_cppzconfig.search_cpp�s�� � �������#�#�D�'�<��F�F���S� �g�s� #� #� *��j��)�)�G� �#�Y�Y� �$��E� ��}�}�����2�:�:���>�>�$�'�'�� �E��  � � � � � � � � � � � ���� � � � � � � � � � �� s�)8B-�-B1�4B1c��� ddlm}|��� |�||||��d}n #|$rd}YnwxYwt j|rdpd��|���|S)NrrcTF�success!�failure.)r/rdr3rOrr\rares r� try_compilezconfig.try_compile�s��� � 5�4�4�4�4�4� ������ � �M�M�$���t� <� <� <��B�B��� � � ��B�B�B� ���� ���"� �0�j�1�1�1� � � � � � �� s�8�A�Ac��� ddlm}m}|��� |�||||||��d} n#||f$rd} YnwxYwt j| rdpd��|���| S�Nr)rd� LinkErrorTFrrrs)r/rdrwr3rYrr\ra) rr<r=rrrr>rdrwrfs r�try_linkzconfig.try_link�s��� � @�?�?�?�?�?�?�?� ������ � �J�J�t�W�l� �,�� 6� 6� 6��B�B���i�(� � � ��B�B�B� ���� ���"� �0�j�1�1�1� � � � � � �� s�<� A�Ac�2� ddlm}m}|��� |�||||||��\} } } |�| g��d} n#||t f$rd} YnwxYwtj| rdpd��|� ��| Srv) r/rdrwr3rY�spawnrrr\ra) rr<r=rrrr>rdrwrGrN�exerfs r�try_runzconfig.try_run�s��� � @�?�?�?�?�?�?�?� ������ � �J�J�t�W�l�'0�,��F�F�M�C��c� �J�J��u� � � ��B�B���i�);�<� � � ��B�B�B� ���� ���"� �0�j�1�1�1� � � � � � �� s�6A�A(�'A(rc�� |���g}|r|�d|z��|�d��|r|�d|z��n|�d|z��|�d��d�|��dz}|�|||||��S)Nz int %s ();z int main () {z %s();z %s;�}r7)r3rWr]rx) r�funcr=rrr�decl�callr<s r� check_funczconfig.check_funcs��� � �������� � -� �K�K� �t�+� ,� ,� ,� � � �O�$�$�$� � (� �K�K� �D�(� )� )� )� )� �K�K��$�� '� '� '� � � �C�����y�y�����%���}�}�T�7�L�&� �6�6� 6rc�f� |���|�d|||g|z|��S)Nzint main (void) { })r3rx)r�libraryrr=r�other_librariess r� check_libzconfig.check_lib4sG�� � �������}�}�2�G�\�%�Y��8�,�H�H� Hrc�6� |�d|g|���S)Nz /* No body */)r<r=r)rg)rrArrr>s r� check_headerzconfig.check_headerBs-�� ��|�|��6�(�)5��7�7� 7r)NNNr)NNr)NNNNr)NNNNrr)�__name__� __module__� __qualname__� description� user_optionsrr&r)r3rBrIrOrYrargrprtrxr|r�r�r�r(rrr r s�������$�K� � � �L�4 � � �D�D�D�  � � �B�B�B�$ � � �������  �  �  � � � �,����$IM������8���� IM�),�����&HL�(+�����2;?�CD�6�6�6�6�</3�D�#�R� H� H� H� H�DH��7�7�7�7�7�7rr c�&� |�tjd|��ntj|��t|��} tj|�����|���dS#|���wxYw)Nz%s)rr\r:�read�close)r?�headr@s rrKrKKs{��� �|� ���x� � � � � ������ ��>�>�D�� ���������� � � � � � � � ��� � � � � � ���s �&A:�:Br) r$rj�distutils.corer�distutils.errorsr�distutils.sysconfigr� distutilsrr9r rKr(rr�r�s��� �� � � � � � � �"�"�"�"�"�"�/�/�/�/�/�/�2�2�2�2�2�2��������f� %� %��t7�t7�t7�t7�t7�W�t7�t7�t7�l � � � � � r