� !A?h&C��� ddlZddlZddlZddlZddlmZddlTddlm Z m Z ddl m Z Gd�de��Z Gd�d e e ��ZdS) �N)�Command)�*)� convert_path� Mixin2to3)�logc��eZdZdZgd�ZddgZddiZd�Zd�Zd�Z d �Z d �Z d �Z d �Z d �Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Zd�Zd�Zd�Zd�ZdS)�build_pyz5"build" pure Python modules (copy to build directory)))z build-lib=�dzdirectory to "build" (copy) to)�compile�czcompile .py to .pyc)� no-compileNz!don't compile .py files [default])z optimize=�Ozlalso compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0])�force�fz2forcibly build everything (ignore file timestamps)r rr c�v�d|_d|_d|_d|_d|_d|_d|_d|_dS)Nr)� build_lib� py_modules�package� package_data� package_dirr �optimizer��selfs �G/opt/alt/python-internal/lib64/python3.11/distutils/command/build_py.py�initialize_optionszbuild_py.initialize_options s@���������� � �������� ��� ��� � � �c��|�ddd��|jj|_|jj|_|jj|_i|_|jjr;|jj���D]\}}t|��|j|<�|���|_ t|j t��s@ t|j ��|_ dS#ttf$rtd���wxYwdS)N�build)rr)rrzoptimize must be 0, 1, or 2)�set_undefined_options� distribution�packagesrrr�itemsr�get_data_files� data_files� isinstancer�int� ValueError�AssertionError�DistutilsOptionError)r�name�paths r�finalize_optionszbuild_py.finalize_options*s#�� �"�"�7�#=�#5� 7� 7� 7� �)�2�� ��+�6��� �-�:������ � � (� <�"�/�;�A�A�C�C� <� <� ��d�)5�d�);�);�� ��&�&��-�-�/�/����$�-��-�-� J� J� #�D�M� 2� 2�� � � ����/� J� J� J�*�+H�I�I�I� J����  J� Js � C(�(!D c���|jr|���|jr(|���|���|�|�d�����dS�Nr)�include_bytecode)r� build_modulesr!�build_packages�build_package_data� byte_compile� get_outputsrs r�runz build_py.runCsy��, �?� !� � � � � � � �=� &� � � � !� !� !� � #� #� %� %� %� ���$�*�*�A�*�>�>�?�?�?�?�?rc�^�� g}|js|S|jD]�}|�|��}tjj|jg|�d��z�}d�|rt|��dz��fd�|�||��D��}|� ||||f����|S)N�.r�c�$��g|] }|�d��� S�N�)�.0�file�plens �r� z+build_py.get_data_files..ss.������ $��T�U�U� ���r) r!�get_package_dir�osr+�joinr�split�len�find_data_files�append)r�datar�src_dir� build_dir� filenamesr>s @rr#zbuild_py.get_data_filesas����M����}� ��K��}� B� B�G��*�*�7�3�3�G��� ���'7�'�-�-��:L�:L�'L�N�I��D�� &��7�|�|�A�~������(,�(<�(<�W�g�(N�(N����I� �K�K��'�9�i�@� A� A� A� A�� rc �j�� |j�dg��|j�|g��z}g�|D]t}tjtj�tj|��t|������}���fd�|D�����u�S)N�c�Z��g|]'}|�v�tj�|���%|��(Sr;)rAr+�isfile)r<�fn�filess �rr?z,build_py.find_data_files..�s;���(�(�(��2�U�?�?��G�N�N�2�&�&�4C�"�?�?�?r) r�get�globrAr+rB�escaper�extend)rrrH�globs�pattern�filelistrPs @rrEzbuild_py.find_data_filesys����D��"�&�&�r�2�.�.��$�(�(��"�5�5�6����� )� )�G��y�����d�k�'�.B�.B�L�QX�DY�DY�!Z�!Z�[�[�H� �L�L�(�(�(�(�x�(�(�(� )� )� )� )�� rc�D� d}|jD]�\}}}}|D]�}tj�||��}|�tj�|����|�tj�||��|d�������dS)NF�� preserve_mode)r$rAr+rB�mkpath�dirname� copy_file)r�lastdirrrHrIrJ�filename�targets rr2zbuild_py.build_package_data�s���2���6:�o� 4� 4� 2�G�W�i��%� 4� 4������i��:�:��� � �B�G�O�O�F�3�3�4�4�4����r�w�|�|�G�X�>�>��-2��4�4�4�4� 4� 4� 4rc��� |�d��}|js|rtjj|�SdSg}|r{ |jd�|��}|�d|��tjj|�S#t $r"|�d|d��|d=YnwxYw|�{|j�d��}|�|�d|��|rtjj|�SdS)Nr7rLr�����)rCrrAr+rB�insert�KeyErrorrQ)rrr+�tail�pdirs rr@zbuild_py.get_package_dir�s(�� H��}�}�S�!�!���� �� ��w�|�T�*�*��r��D�� �/��+�C�H�H�T�N�N�;�D� �K�K��4�(�(�(��7�<��.�.��  �!�!�!��K�K��4��8�,�,�,��R����!����� �"�'�+�+�B�/�/���#��K�K��4�(�(�(����7�<��.�.��2s� B�)B/�.B/c��|dkrbtj�|��std|z���tj�|��std|z���|rVtj�|d��}tj�|��r|Stjd|��dS)NrLz%package directory '%s' does not existz>supposed package directory '%s' exists, but is not a directoryz __init__.pyz8package init file '%s' not found (or not a regular file)) rAr+�exists�DistutilsFileError�isdirrBrNr�warn)rrr�init_pys r� check_packagezbuild_py.check_package�s��� �"� � ��7�>�>�+�.�.� M�(�=� �K�M�M�M��7�=�=��-�-� ?�(�0�2=�>�?�?�?� � ?��g�l�l�;� �>�>�G��w�~�~�g�&�&� ?�����4�6=�?�?�?� �trc�t�tj�|��stjd||��dSdS)Nz!file %s (for module %s) not foundFT)rAr+rNrrk)r�module� module_files r� check_modulezbuild_py.check_module�s7���w�~�~�k�*�*� � �H�8�+�v� N� N� N��5��4rc�J�|�||��tjtj�tj|��d����}g}tj�|jj��}|D]�}tj�|��}||kr[tj� tj� |����d}|� |||f����|� d|z����|S)Nz*.pyrz excluding %s) rmrRrAr+rBrS�abspathr � script_name�splitext�basenamerF� debug_print) rrr� module_files�modules� setup_scriptr�abs_fros r�find_package_moduleszbuild_py.find_package_modules�s��� ���7�K�0�0�0��y�����d�k�+�.F�.F��!O�!O�P�P� ����w���t�'8�'D�E�E� �� @� @�A��G�O�O�A�&�&�E�� �$�$���)�)�"�'�*:�*:�1�*=�*=�>�>�q�A��������3�4�4�4�4�� � ��,�!>�?�?�?�?��rc�� i}g}|jD]�}|�d��}d�|dd���}|d} ||\}}n'#t$r|�|��}d}YnwxYw|s7|�||��} |df||<| r|�|d| f��tj�||dz��} |� || ��s��|�||| f����|S)Nr7rrbr8�__init__�.py) rrCrBrdr@rmrFrAr+rq) rr!ryror+r� module_baser�checkedrlrps r� find_moduleszbuild_py.find_modules�sS�� ����� �o� @� @�F��<�<��$�$�D��h�h�t�A�b�D�z�*�*�G��r�(�K� �)1�'�):�&��g�g��� � � �"�2�2�7�;�;� ����� ����� C��,�,�W�k�B�B��%0�!�$4���!��C��N�N�G�Z��#A�B�B�B� �'�,�,�{�K�%�4G�H�H�K��$�$�V�[�9�9� �� �N�N�G�[�+�>� ?� ?� ?� ?��s� A�!A:�9A:c� � g}|jr'|�|�����|jrJ|jD]B}|�|��}|�||��}|�|���C|Sr:)rrTr�r!r@r|)rryrr�ms r�find_all_moduleszbuild_py.find_all_moduless��� (� �� �?� 0� �N�N�4�,�,�.�.� /� /� /� �=� "��=� "� "��"�2�2�7�;�;� ��-�-�g�{�C�C�����q�!�!�!�!��rc�>�d�|���D��S)Nc��g|] }|d�� S)rbr;)r<ros rr?z-build_py.get_source_files..-s��A�A�A�v��r� �A�A�Ar)r�rs r�get_source_fileszbuild_py.get_source_files,s"��A�A��)>�)>�)@�)@�A�A�A�Arc�\�|gt|��z|dzgz}tjj|�S)Nr)�listrAr+rB)rrIrro� outfile_paths r�get_module_outfilezbuild_py.get_module_outfile/s/��!�{�T�'�]�]�2�f�u�n�5E�E� ��w�|�\�*�*rr8c���|���}g}|D]�\}}}|�d��}|�|j||��}|�|��|r|jr4|�t j�|d�����|j dkr9|�t j�||j �������|d�|j D��z }|S)Nr7rL)� optimizationrc�b�g|],\}}}}|D]"}tj�||����#�-Sr;)rAr+rB)r<rrHrIrJr_s rr?z(build_py.get_outputs..BsW�����6���)�Y�%���� �G�L�L��H� -� -����r) r�rCr�rrFr � importlib�util�cache_from_sourcerr$)rr/ry�outputsrrorpr_s rr4zbuild_py.get_outputs3s'���'�'�)�)����.5� ?� ?� *�W�f�k��m�m�C�(�(�G��.�.�t�~�w��O�O�H� �N�N�8� $� $� $�� ?��<�4��N�N�9�>�#C�#C� �r�$D�$3�$3�4�4�4��=�1�$�$��N�N�9�>�#C�#C� �t�}�$D�$>�$>�?�?�?�� ���:>�/���� �� �rc�~�t|t��r|�d��}n+t|ttf��st d���|�|j||��}tj � |��}|� |��|� ||d���S)Nr7z:'package' must be a string (dot-separated), list, or tuplerrY) r%�strrCr��tuple� TypeErrorr�rrAr+r\r[r])rrorpr�outfile�dirs r� build_modulezbuild_py.build_moduleJs��� �g�s� #� #� P��m�m�C�(�(�G�G��G�d�E�]�3�3� P��N�P�P� P� �)�)�$�.�'�6�J�J���g�o�o�g�&�&�� � � �C�����~�~�k�7�!�~�D�D�Drc�n�|���}|D]\}}}|�|||���dSr:)r�r�)rryrrorps rr0zbuild_py.build_modulesYsP���#�#�%�%��.5� <� <� *�W�f�k� � � �f�k�7� ;� ;� ;� ;�  <� � >� >� �F�/�/�/�/�/�/���� �"�:��� � ��b�f�_�F� �<� P� �L���#�z�&�$�,� P� P� P� P� �=�1� � � �L����#�z�&�$�,� P� P� P� P� P� P� � rN)r8)�__name__� __module__� __qualname__� description� user_options�boolean_options� negative_optrr,r5r#rEr2r@rmrqr|r�r�r�r�r4r�r0r1r3r;rrr r sx������K�K� � � �L�!�'�*�O� �9�-�L����J�J�J�2@�@�@�<���0 � � �4�4�4�%�%�%�N���6��� � � �2�2�2�h��� B�B�B�+�+�+�����. E� E� E�<�<�<�@�@�@�(P�P�P�P�Prr c��eZdZd�Zd�ZdS)� build_py_2to3c�.�g|_|jr|���|jr(|���|���|�|j��|�|�d�����dSr.) � updated_filesrr0r!r1r2�run_2to3r3r4rs rr5zbuild_py_2to3.run�s������ �?� !� � � � � � � �=� &� � � � !� !� !� � #� #� %� %� %� � � �d�(�)�)�)� ���$�*�*�A�*�>�>�?�?�?�?�?rc��t�||||��}|dr |j�|d��|S)Nr8r)r r�r�rF)rrorpr�ress rr�zbuild_py_2to3.build_module�sG���#�#�D�&�+�w�G�G�� �q�6� .� � � %� %�c�!�f� -� -� -�� rN)r�r�r�r5r�r;rrr�r��s5������@�@�@� ����rr�)rA�importlib.utilr�r�rR�distutils.corer�distutils.errorsr�rr� distutilsrr r�r;rr�r�s���0� � � � ����� � � � � � � � �"�"�"�"�"�"�����2�2�2�2�2�2�2�2�������yP�yP�yP�yP�yP��yP�yP�yP�v �����H�i�����r