� !A?h�{���� ddlZddlZddlZddlZddlmZddlTddlmZm Z ddlm Z ddl m Z ddl mZddlmZdd lmZdd lmZejd ��Zd �ZGd �de��ZdS)�N)�Command)�*)�customize_compiler�get_python_version)�get_config_h_filename)� newer_group)� Extension)� get_platform)�log)� USER_BASEz3^[a-zA-Z_][a-zA-Z_0-9]*(\.[a-zA-Z_][a-zA-Z_0-9]*)*$c�&�ddlm}|��dS)Nr��show_compilers)�distutils.ccompilerrrs �H/opt/alt/python-internal/lib64/python3.11/distutils/command/build_ext.pyrrs(��2�2�2�2�2�2��N������c� �eZdZdZdejzZddddde��zfdd d d ezfd d ddddezfddddddddddgZgd�Z ddde fgZ d �Z d!�Z d"�Zd#�Zd$�Zd%�Zd&�Zd'�Zd(�Zejd)���Zd*�Zd+�Zd,�Zd-�Zd.�Zd/�Zd0�Zd1�ZdS)2� build_extz8build C/C++ extensions (compile/link to build directory)z (separated by '%s'))z build-lib=�bz(directory for compiled extension modules)z build-temp=�tz1directory for temporary files (build by-products)z plat-name=�pz>platform name to cross-compile for, if supported (default: %s))�inplace�iziignore build-lib and put compiled extensions into the source directory alongside your pure Python modulesz 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 withz library-dirs=�Lz.directories to search for external C libraries)zrpath=�Rz7directories to search for shared C libraries at runtime)z link-objects=�Oz2extra explicit link objects to include in the link)�debug�gz'compile/link with debugging information)�force�fz2forcibly build everything (ignore file timestamps))z compiler=�czspecify the compiler type)z parallel=�jznumber of parallel build jobs)�swig-cppNz)make SWIG create C++ files (default is C))z swig-opts=Nz!list of SWIG command line options)zswig=Nzpath to the SWIG executable)�userNz#add user include, library and rpath)rr!r#r'r(z help-compilerNzlist available compilersc�,�d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ d|_ d|_d|_d|_d|_d|_d|_d|_dS)Nr)� extensions� build_lib� plat_name� build_tempr�package� include_dirs�define�undef� libraries� library_dirs�rpath� link_objectsr!r#�compiler�swig�swig_cpp� swig_optsr(�parallel��selfs r�initialize_optionszbuild_ext.initialize_optionsjs����������������� ��� � ����� ��� ���� ����� � ����� ��� ��� ��� ��� ������ ��� � � rc ���ddlm}|�ddddddd d ��|j�|jj|_|jj|_|���}|�d � ��}|j �|jj pg|_ t|j t��r)|j � tj��|_ tjtjkrB|j �tj�tjd ����|j �|� tjj����||kr<|j �|� tjj����|�d��|�d��|j�g|_|j�g|_nCt|jt��r)|j� tj��|_|j�g|_nCt|jt��r)|j� tj��|_tjdk�r�|j�tj�tjd����tjtjkrB|j�tj�tjd����|jr+tj�|jd��|_n*tj�|jd��|_|j �tj�t?������tAtdd��}|r|j�|��|j!dkrd}n|j!dd�}tj�tjd��}|r tj�||��}|j�|��tj"dd�dkr�tj#�$tj�tjd����rT|j�tj�tjddtK��zd����n|j�d��|�&d��rO|j's.|j�|�&d ����n|j�d��|j(r+|j(� d!��}d"�|D��|_(|j)r|j)� d!��|_)|j*�g|_*n|j*� d#��|_*|j+r�tj�tXd ��}tj�tXd��} tj�-|��r|j �|��tj�-| ��r4|j�| ��|j�| ��t|j.t��r9 t_|j.��|_.dS#t`$rtcd$���wxYwdS)%Nr)� sysconfig�build)r+r+)r-r-)r6r6)r!r!)r#r#)r:r:)r,r,�)� plat_specific�includer2r5�nt�libs�Debug�Release�_home�win32��PCbuild��cygwin�bin�lib�python�config�.�Py_ENABLE_SHARED�LIBDIR�,c��g|]}|df��S)�1�)�.0�symbols r� z.build_ext.finalize_options..�s��?�?�?�V�F�C�=�?�?�?r� zparallel should be an integer)2� distutilsr?�set_undefined_optionsr.� distribution� ext_package� ext_modulesr*�get_python_incr/� isinstance�str�split�os�pathsep�sys� exec_prefix�base_exec_prefix�append�path�join�extend�ensure_string_listr2r3r4�name�prefixr!r-�dirnamer�getattrr,�platform� executable� startswithr�get_config_var� python_buildr0r1r9r(r �isdirr:�int� ValueError�DistutilsOptionError) r<r?� py_include�plat_py_include� _sys_home�suffix�new_lib�defines� user_include�user_libs r�finalize_optionszbuild_ext.finalize_options�s`��'�'�'�'�'�'� �"�"�7�#=�#?�#;�#5�#5�#;�#=� %� %� %� �<� ��,�8�D�L��+�7����-�-�/�/� �#�2�2��2�C�C�� � � $� $� 1� >� D�"�D� � �d�'�� -� -� D� $� 1� 7� 7�� � C� C�D� � �?�c�2� 2� 2� � � $� $�R�W�\�\�#�/�9�%M�%M� N� N� N� �� � ��!1�!1�"�'�/�!B�!B�C�C�C� �j� (� (� � � $� $��%�%�b�g�o�6�6� 8� 8� 8� ��� �,�,�,� ����/�/�/� �>� !��D�N� � � $� "�D� � � ��)�3� /� /� D� $� 1� 7� 7�� � C� C�D� � �:� ��D�J�J� �� �C� (� (� 6���)�)�"�*�5�5�D�J� �7�d�?�?� � � $� $�R�W�\�\�#�/�6�%J�%J� K� K� K��#�s�z�1�1��!�(�(�����c�6J�F�)S�)S�T�T�T��z� K�"$�'�,�,�t���"H�"H����"$�'�,�,�t�� �"J�"J��� � � $� $�R�W�_�_�5J�5L�5L�%M�%M� N� N� N���W�d�3�3�I�� 4��!�(�(��3�3�3��~��(�(� ��������+���g�l�l�3�?�I�>�>�G�� 8��'�,�,�w��7�7�� � � $� $�W� -� -� -� �<���� �x� '� '��~�(�(�����c�o�u�)M�)M�N�N� .��!�(�(�����c�j�%�6>�AS�AU�AU�6U�6>�*@�*@�A�A�A�A� �!�(�(��-�-�-� � $� $�%7� 8� 8� .��)� .��!�(�(��)A�)A�(�)K�)K�L�L�L�L��!�(�(��-�-�-� �;� @��k�'�'��,�,�G�?�?�w�?�?�?�D�K� �:� /���)�)�#�.�.�D�J� �>� !��D�N�N�!�^�1�1�#�6�6�D�N� �9� ,��7�<�<� �9�=�=�L��w�|�|�I�u�5�5�H��w�}�}�\�*�*� 7��!�(�(��6�6�6��w�}�}�X�&�&� ,��!�(�(��2�2�2�� �!�!�(�+�+�+� �d�m�S� )� )� L� L� #�D�M� 2� 2�� � � ��� L� L� L�*�+J�K�K�K� L���� L� Ls �;]�]0c�v�ddlm}|jsdS|j���rb|�d��}|j�|���pg��|j � |j ��||j |j |j|j���|_ t!|j ��t"jdkr6|jt)��kr|j �|j��|j�|j �|j��|j�(|jD] \}}|j �||���!|j�$|jD]}|j �|���|j�|j �|j��|j �|j �|j ��|j�|j �|j��|j �|j �!|j ��|�"��dS)Nr)� new_compiler� build_clib)r6�verbose�dry_runr#rD)#rr�r*r_�has_c_libraries�get_finalized_commandr2rn�get_library_namesr3rkr�r6r�r�r#rrfrpr,r � initializer/�set_include_dirsr0� define_macror1�undefine_macro� set_libraries�set_library_dirsr4�set_runtime_library_dirsr5�set_link_objects�build_extensions)r<r�r�rp�value�macros r�runz build_ext.runs2��4�4�4�4�4�4��� � �F� � � ,� ,� .� .� <��3�3�L�A�A�J� �N� !� !�*�">�">�"@�"@�"F�B� G� G� G� � � $� $�Z�%:� ;� ;� ;�%� �d�m�-1�\�-1�\�+/�:�7�7�7�� � �4�=�)�)�)� �7�d�?�?�t�~����?�?� �M� $� $�T�^� 4� 4� 4� � � (� �M� *� *�4�+<� =� =� =� �;� "�!%�� 8� 8� ��u�� �*�*�4��7�7�7�7� �:� !��� 4� 4��� �,�,�U�3�3�3�3� �>� %� �M� '� '��� 7� 7� 7� � � (� �M� *� *�4�+<� =� =� =� �:� !� �M� 2� 2�4�:� >� >� >� � � (� �M� *� *�4�+<� =� =� =� �������rc�� t|t��std���t|��D�] \}}t|t��r�t|t ��rt |��dkrtd���|\}}tjd|��t|t��rt� |��std���t|t��std���t ||d��}dD]*}|� |��}|�t|||���+|� d ��|_d |vrtjd ��|� d ��}|r�g|_g|_|D]�} t| t ��rt | ��d vstd���t | ��dkr!|j�| d���kt | ��dkr|j�| ����|||<�� dS)Nz:'ext_modules' option must be a list of Extension instances�zMeach element of 'ext_modules' option must be an Extension instance or 2-tuplezvold-style (ext_name, build_info) tuple found in ext_modules for extension '%s' -- please convert to Extension instancezRfirst element of each tuple in 'ext_modules' must be the extension name (a string)zOsecond element of each tuple in 'ext_modules' must be a dictionary (build info)�sources)r/r3r2� extra_objects�extra_compile_args�extra_link_argsr4�def_filez9'def_file' element of build info dict no longer supported�macros)rAr�z9'macros' element of build info dict must be 1- or 2-tuplerAr)rc�list�DistutilsSetupError� enumerater �tuple�lenr �warnrd�extension_name_re�match�dict�get�setattr�runtime_library_dirs� define_macros� undef_macrosrk) r<r*r�ext�ext_name� build_info�key�valr�r�s r�check_extensions_listzbuild_ext.check_extensions_listVs��� ��*�d�+�+� P�%�N�P�P� P� � �+�+�> �> �F�A�s��#�y�)�)� ���c�5�)�)� 8�S��X�X��]�]�)�7�8�8�8�$'� �H�j� �H�?�@H� J� J� J��x��-�-� @�%�+�+�H�5�5� @�)�?�@�@�@��j�$�/�/� <�)�;�<�<�<� �H�j��&;�<�<�C�+� +� +��!�n�n�S�)�)���?��C��c�*�*�*��(2�~�~�g�'>�'>�C� $��Z�'�'���/�0�0�0�  �^�^�H�-�-�F�� 8�$&��!�#%�� �#�8�8�E�&�u�e�4�4�7��U���v�9M�9M�1�6�7�7�7��5�z�z�Q����(�/�/��a��9�9�9�9��U���q����)�0�0��7�7�7���J�q�M�M�}> �> rc��|�|j��g}|jD]}|�|j���|S�N)r�r*rnr�)r<� filenamesr�s r�get_source_fileszbuild_ext.get_source_files�sO�� �"�"�4�?�3�3�3�� ��?� *� *�C� � � �S�[� )� )� )� )��rc��|�|j��g}|jD]/}|�|�|j�����0|Sr�)r�r*rk�get_ext_fullpathrp)r<�outputsr�s r� get_outputszbuild_ext.get_outputs�s\�� �"�"�4�?�3�3�3� ���?� <� <�C� �N�N�4�0�0���:�:� ;� ;� ;� ;��rc��|�|j��|jr|���dS|���dSr�)r�r*r:�_build_extensions_parallel�_build_extensions_serialr;s rr�zbuild_ext.build_extensions�sR�� �"�"�4�?�3�3�3� �=� ,� � +� +� -� -� -� -� -� � )� )� +� +� +� +� +rc������j}�jdurtj��} ddlm}n#t $rd}YnwxYw|�����dS||���5���fd��jD��}t�j|��D]F\}}�� |��5|� ��ddd��n #1swxYwY�G ddd��dS#1swxYwYdS)NTr)�ThreadPoolExecutor)� max_workersc�F��g|]}���j|����SrX)�submit�build_extension)rYr��executorr<s ��rr[z8build_ext._build_extensions_parallel..�s:���3�3�3�� ���t�';�S�A�A�3�3�3r) r:rf� cpu_count�concurrent.futuresr�� ImportErrorr�r*�zip�_filter_build_errors�result)r<�workersr��futuresr��futr�s` @rr�z$build_ext._build_extensions_parallel�s������-�� �=�D� � ��l�n�n�G� � =� =� =� =� =� =� =��� � � ��G�G�G� ���� �?� � )� )� +� +� +� �F� � �G� 4� 4� 4� !��3�3�3�3�3�"&�/�3�3�3�G�����9�9� !� !���S��.�.�s�3�3�!�!��J�J�L�L�L�!�!�!�!�!�!�!�!�!�!�!����!�!�!�!�� !� !� !� !� !� !� !� !� !� !� !� !� !���� !� !� !� !� !� !sC�.� =�=�$AC#�(C �= C#� C � C#�C �C#�#C'�*C'c��|jD]D}|�|��5|�|��ddd��n #1swxYwY�EdSr�)r*r�r�)r<r�s rr�z"build_ext._build_extensions_serial�s����?� *� *�C��*�*�3�/�/� *� *��$�$�S�)�)�)� *� *� *� *� *� *� *� *� *� *� *���� *� *� *� *�� *� *s�A�A �A c#�K� dV�dS#tttf$r3}|js�|�d|j�d|����Yd}~dSd}~wwxYw)Nzbuilding extension "z " failed: )�CCompilerError�DistutilsError� CompileError�optionalr�rp)r<r��es rr�zbuild_ext._filter_build_errors�s����� %� �E�E�E�E�E���� �=� %� %� %��<� �� �I�I�I��x�x�x���$� %� %� %� %� %� %� %� %� %����� %���s� �A�(A�Ac ���|j}|�t|ttf��st d|jz���t |��}|�|j��}||jz}|j s-t||d��stj d|j��dStj d|j��|�||��}|jpg}|jdd�}|jD]}|�|f���|j�||j||j|j ||j���}|dd�|_|jr|�|j��|jpg}|jp|j�|��} |j�|||�|��|j|j ||�!|��|j |j| �� � dS)Nzjin 'ext_modules' option (extension '%s'), 'sources' must be present and must be a list of source filenames�newerz$skipping '%s' extension (up-to-date)zbuilding '%s' extension)� output_dirr�r/r!�extra_postargs�depends)r2r3r�r��export_symbolsr!r-� target_lang)"r�rcr�r�r�rp�sortedr�r�r#rr r!�info� swig_sourcesr�r�r�rkr6�compiler-r/�_built_objectsr�rnr��language�detect_language�link_shared_object� get_librariesr3r��get_export_symbols) r<r�r��ext_pathr�� extra_argsr�r1�objectsr�s rr�zbuild_ext.build_extension�s���+�� �?�*�W�t�U�m�"D�"D�?�%�/�14��:�;�;� ;� ��/�/���(�(���2�2���C�K�'��� � :�k�'�8�W�E�E� :� �I�<�c�h� G� G� G� �F� �H�.��� 9� 9� 9� �#�#�G�S�1�1�� �+�1�r� ��"�1�1�1�%���%� $� $�E� �M�M�5�(� #� #� #� #��-�'�'��48�O�06�69�6F�/3�z�8B�14�� (�>�>��&�a�a�a�j��� � � .� �N�N�3�,� -� -� -��(�.�B� ��<�I�4�=�#@�#@��#I�#I�� � �(�(� �X��(�(��-�-��)�!$�!9�%��2�2�3�7�7��*��� � )� "� "� "� "� "rc��� g}g}i}|jrtjd��|jsd|jvs d|jvrd}nd}|D]{}tj�|��\}} | dkr<|�|dz|z��|�|��|d||<�f|�|���||s|S|jp|� ��} | dg} | � |j��|jr| �d��|js|jD]} | �| ���|D];}||} tj d || ��|� | d | |gz���<|S) Nz/--swig-cpp is deprecated - use --swig-opts=-c++z-c++z.cppz.cz.i�_wrap�����z-pythonzswigging %s to %sz-o) r8r r�r9rfrl�splitextrkr7� find_swigrnr��spawn)r<r�� extension� new_sourcesr�� swig_targets� target_ext�source�baser�r7�swig_cmd�o�targets rr�zbuild_ext.swig_sources2s��� � � �� �� � �=� H� �H�F� G� G� G� �=� �V�t�~�5�5� �i�)� )� )��J�J��J�� +� +�F��'�*�*�6�2�2�K�T�3��d�{�{��"�"�4�'�>�J�#>�?�?�?��#�#�F�+�+�+�'2�2�� �V�$�$��"�"�6�*�*�*�*�� �� ��y�,�D�N�N�,�,���)�$�������'�'�'� �=� $� �O�O�F� #� #� #��~� #��(� #� #������"�"�"�"�"� :� :�F�!�&�)�F� �H�(�&�&� 9� 9� 9� �J�J�x�4���"8�8� 9� 9� 9� 9��rc�� tjdkrdStjdkrMdD]H}tj�d|zd��}tj�|��r|cS�IdSt dtjz���)N�posixr7rD)z1.3z1.2z1.1z c:\swig%szswig.exez>I don't know how to find (much less run) SWIG on platform '%s')rfrprlrm�isfile�DistutilsPlatformError)r<�vers�fns rr�zbuild_ext.find_swighs��� � �7�g� � ��6� �W��_�_�.� "� "���W�\�\�,��"5�z�B�B���7�>�>�"�%�%���I�I�I��"�z�(�%�')�w�/�0�0� 0rc�,� |�|��}|�d��}|�|d��}|jsDt jj|dd�|gz�}tj�|j|��Sd�|dd���}|�d��}tj� |� |����}tj�||��S)NrRr�r�build_py) �get_ext_fullnamere�get_ext_filenamerrfrlrmr+r��abspath�get_package_dir)r<r��fullname�modpath�filenamer.r� package_dirs rr�zbuild_ext.get_ext_fullpath�s��� � �(�(��2�2���.�.��%�%���(�(����5�5���|� :��w�|�W�S�b�S�\�8�*�%<�=�H��7�<�<����9�9� 9��(�(�7�1�R�4�=�)�)���-�-�j�9�9���g�o�o�h�&>�&>�w�&G�&G�H�H� ��w�|�|�K��2�2�2rc�0� |j�|S|jdz|zS)NrR)r.)r<r�s rrzbuild_ext.get_ext_fullname�s(�� &� �<� ��O��<�#�%��0� 0rc�|� ddlm}|�d��}|d��}tjj|�|zS)Nr�rwrR� EXT_SUFFIX)�distutils.sysconfigrwrerfrlrm)r<r�rwr�� ext_suffixs rrzbuild_ext.get_ext_filename�sO�� � 7�6�6�6�6�6��>�>�#�&�&��#�^�L�1�1� ��w�|�X�&��3�3rc�t� d|j�d��dz} |�d��nO#t$rBd|�d���dd���d��z}YnwxYwd |z}||jvr|j�|��|jS) N�_rRr��asciir�punycode�-�_�PyInit)rpre�encode�UnicodeEncodeError�replace�decoder�rk)r<r�r�� initfunc_names rr�zbuild_ext.get_export_symbols�s��� � �s�x�~�~�c�*�*�2�.�.�� Y� �M�M�'� "� "� "� "��!� Y� Y� Y��6�=�=��4�4�<�<�T�4�H�H�O�O�PW�X�X�X�F�F�F� Y����!�6�)� � �� 2� 2� 2� � � %� %�m� 4� 4� 4��!�!s�<�A B�Bc��� tjdkrYddlm}t |j|��s=d}|jr|dz}|tjdz tjdz dzfz}|j|gzSn�dd l m }d }|d ��r\ttd ��rd }nDtjdkrd }n1dtj vr#|d��dkrd }n|d��dkrd }|r|d��}|jd|zgzS|jS)NrIr)� MSVCCompilerz python%d%d�_d����r FrS�getandroidapilevelTrM�_PYTHON_HOST_PLATFORM�ANDROID_API_LEVEL�MACHDEP� LDVERSIONrP)rhrt�distutils._msvccompilerrrcr6r!� hexversionr2rrw�hasattrrf�environ)r<r�r�template� pythonlibrw�link_libpython� ldversions rr�zbuild_ext.get_libraries�sb�� � �<�7� "� "� <� <� <� <� <� <��d�m�\�:�:� 3�'���:�/�'�$��H�%���"�,�s�~��/C�t�.K�L�M� ��}� �{�2�2� 3�$ ;� :� :� :� :� :�"�N��~�0�1�1� .��3� 4�5�5� .�%)�N�N��\�X�-�-�%)�N�N�,�� �:�:�%�~�&9�:�:�a�?�?�)-���'�� �2�2�h�>�>�)-��� >�*�N�;�7�7� ��}��9�(<�'=�=�=��}�r) �__name__� __module__� __qualname__� descriptionrfrg�sep_byr � user_options�boolean_optionsr� help_optionsr=r�r�r�r�r�r�r�r�� contextlib�contextmanagerr�r�r�r�r�rrr�r�rXrrrr!s������L�K�($�b�j� 0�F� 5� >� �s� �'�<�>�>� *� +� 9� �#� 9�F� B� D� ,� .� .� �#� 9�F� B� D� D� ?� 4� ?� &� *� 6� .� (� 0�O) �L�VH�G�G�O� �$� #�^� 5� �L� ���0RL�RL�RL�h> �> �> �@L �L �L �\��� � � �,�,�,�!�!�!�(*�*�*� ��%�%���%�J"�J"�J"�X4�4�4�l0�0�0�03�3�3�61�1�1�4�4�4�"�"�"�&1�1�1�1�1rr)r8rf�rerh�distutils.corer�distutils.errorsrrrr�distutils.dep_utilr�distutils.extensionr �distutils.utilr r]r �siter r�r�rrrXrr�rAs;��� ���� � � � � � � � � � � � �"�"�"�"�"�"�����F�F�F�F�F�F�F�F�5�5�5�5�5�5�*�*�*�*�*�*�)�)�)�)�)�)�'�'�'�'�'�'��������������B�J�;�=�=����� Q �Q �Q �Q �Q ��Q �Q �Q �Q �Q r