� !A?h&C���dZddlZddlZddlZddlZddlmZddlTddl m Z m Z ddl m Z Gd�de��ZGd �d ee ��ZdS) zHdistutils.command.build_py Implements the Distutils 'build_py' command.�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�H�|�ddd��|jj|_|jj|_|jj|_i|_|jjr;|jj���D]\}}t|��|j|<�|���|_ t|j t��sV t|j ��|_ d|j cxkrdksnJ�dS#ttf$rtd���wxYwdS)N�build)rr)rrr�zoptimize 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*sL�� �"�"�7�#=�#5� 7� 7� 7� �)�2�� ��+�6��� �-�:������ � � (� <�"�/�;�A�A�C�C� <� <� ��d�)5�d�);�);�� ��&�&��-�-�/�/����$�-��-�-� J� J� #�D�M� 2� 2�� ��D�M�.�.�.�.�Q�.�.�.�.�.�.�.�.����/� J� J� J�*�+H�I�I�I� J����  J� Js � /C>�>!Dc���|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)z?Generate list of '(package,src_dir,build_dir,filenames)' tuples�.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�������}� ��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 �h��|j�dg��|j�|g��z}g�|D]t}tjtj�tj|��t|������}���fd�|D�����u�S)z6Return filenames for package's data files in 'src_dir'�c�Z��g|]'}|�v�tj�|���%|��(Sr<)rBr,�isfile)r=�fn�filess �rr@z,build_py.find_data_files..�s;���(�(�(��2�U�?�?��G�N�N�2�&�&�4C�"�?�?�?r) r�get�globrBr,rC�escaper�extend)rrrI�globs�pattern�filelistrQs @rrFzbuild_py.find_data_filesys�����"�&�&�r�2�.�.��$�(�(��"�5�5�6����� )� )�G��y�����d�k�'�.B�.B�L�QX�DY�DY�!Z�!Z�[�[�H� �L�L�(�(�(�(�x�(�(�(� )� )� )� )�� rc�B�d}|jD]�\}}}}|D]�}tj�||��}|�tj�|����|�tj�||��|d�������dS)z$Copy data files into build directoryNF�� preserve_mode)r%rBr,rC�mkpath�dirname� copy_file)r�lastdirrrIrJrK�filename�targets rr3zbuild_py.build_package_data�s�����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)z�Return the directory, relative to the top of the source distribution, where package 'package' should be found (at least according to the 'package_dir' option, if any).r8rMr�����)rDrrBr,rC�insert�KeyErrorrR)rrr,�tail�pdirs rrAzbuild_py.get_package_dir�s"���}�}�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)NrMz%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)) rBr,�exists�DistutilsFileError�isdirrCrOr�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)rBr,rOrrl)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) rnrSrBr,rCrT�abspathr!� script_name�splitext�basenamerG� debug_print) rrr� module_files�modules� setup_scriptr�abs_frps 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)a�Finds individually-specified Python modules, ie. those listed by module name in 'self.py_modules'. Returns a list of tuples (package, module_base, filename): 'package' is a tuple of the path through package-space to the module; 'module_base' is the bare (no packages, no dots) module name, and 'filename' is the path to the ".py" file (relative to the distribution root) that implements the module. r8rrcr9�__init__�.py) rrDrCrerArnrGrBr,rr) rr"rzrpr,r� module_baser�checkedrmrqs r� find_moduleszbuild_py.find_modules�sN������ �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�!A9�8A9c��g}|jr'|�|�����|jrJ|jD]B}|�|��}|�||��}|�|���C|S)a4Compute the list of all modules that will be built, whether they are specified one-module-at-a-time ('self.py_modules') or by whole packages ('self.packages'). Return a list of tuples (package, module, module_file), just like 'find_modules()' and 'find_package_modules()' do.)rrUr�r"rAr})rrzrr�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)rcr<)r=rps 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�)�listrBr,rC)rrJrrp� outfile_paths r�get_module_outfilezbuild_py.get_module_outfile/s/��!�{�T�'�]�]�2�f�u�n�5E�E� ��w�|�\�*�*rr9c���|���}g}|D]�\}}}|�d��}|�|j||��}|�|��|r|jr4|�t j�|d�����|j dkr9|�t j�||j �������|d�|j D��z }|S)Nr8rM)� optimizationrc�b�g|],\}}}}|D]"}tj�||����#�-Sr<)rBr,rC)r=rrIrJrKr`s rr@z(build_py.get_outputs..BsW�����6���)�Y�%���� �G�L�L��H� -� -����r) r�rDr�rrGr � importlib�util�cache_from_sourcerr%)rr0rz�outputsrrprqr`s rr5zbuild_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)Nr8z:'package' must be a string (dot-separated), list, or tuplerrZ) r&�strrDr��tuple� TypeErrorr�rrBr,r]r\r^)rrprqr�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�)rrzrrprqs rr1zbuild_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)r9)�__name__� __module__� __qualname__� description� user_options�boolean_options� negative_optrr-r6r$rFr3rArnrrr}r�r�r�r�r5r�r1r2r4r<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_filesrr1r"r2r3�run_2to3r4r5rs rr6zbuild_py_2to3.run�s������ �?� !� � � � � � � �=� &� � � � !� !� !� � #� #� %� %� %� � � �d�(�)�)�)� ���$�*�*�A�*�>�>�?�?�?�?�?rc��t�||||��}|dr |j�|d��|S)Nr9r)r r�r�rG)rrprqr�ress rr�zbuild_py_2to3.build_module�sG���#�#�D�&�+�w�G�G�� �q�6� .� � � %� %�c�!�f� -� -� -�� rN)r�r�r�r6r�r<rrr�r��s5������@�@�@� ����rr�)�__doc__rB�importlib.utilr�r�rS�distutils.corer�distutils.errorsr�rr� distutilsrr r�r<rr�r�s���0�0� � � � ����� � � � � � � � �"�"�"�"�"�"�����2�2�2�2�2�2�2�2�������yP�yP�yP�yP�yP��yP�yP�yP�v �����H�i�����r