� !A?hRn����dZddlZddlZddlZddlZddlmZddlmZddl m Z ddl m Z ddl mZddlmZdd lmZmZmZdd lmZdd l mZdd lmZdd lmZeduZdZiiid�ZeD]6ZdD]1\ZZeZ ej!eZ"edkree"vrdZ e"e eee<�2�7eD]�Z#ee#�$��D]�\ZZ%ej&dde%��Z%e%�'dd��Z%e%�'dd��Z%edkre%dz Z%ej(dkredkre%�'dd��Z%e%ee#e<����erdddd d!d�ed"<ddd#d$d!d�ed%<Gd&�d'e��Z)dS)(zFdistutils.command.install Implements the Distutils 'install' command.�N)�log)�Command)�DEBUG)�get_config_vars)�DistutilsPlatformError)� write_file)� convert_path� subst_vars� change_root)� get_platform)�DistutilsOptionError)� USER_BASE)� USER_SITE)�purelib�platlib�headers�scripts�data)� unix_prefix� unix_home�nt))r� posix_prefix)r� posix_home)rrr�includez \{(.+?)\}z$\g<1>z$installed_basez$basez$py_version_nodot_platz$py_version_nodotz /$dist_name)�� rz/lib/z /$platlibdir/z $usersitez4$userbase/Python$py_version_nodot/Include/$dist_namez)$userbase/Python$py_version_nodot/Scriptsz $userbase�nt_userz=$userbase/include/python$py_version_short$abiflags/$dist_namez $userbase/bin� unix_userc�0�eZdZdZgd�Zgd�Zer0e�dddezf��e�d��ddiZ d �Z d �Z d �Z d �Z d �Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdefdefd efd!efd"d#�fgZdS)$�installz'install everything from build directory))zprefix=Nzinstallation prefix)z exec-prefix=Nz.(Unix only) prefix for platform-specific files)zhome=Nz+(Unix only) home directory to install under)z install-base=Nz;base installation directory (instead of --prefix or --home))zinstall-platbase=Nz\base installation directory for platform-specific files (instead of --exec-prefix or --home))zroot=Nz�-K�-K�-M�-M�*4�07�#�:J�2�A�2�:N�0N�06��9I�"�1�"�9M�0M�*0�&,�/:�+6�(0�*-�.� � ��� � A�+/�+@�D� �Z� (�+/�+@�D� �Z� (� � $�T� *� *� L�)2�)A�(�)K�)K�D� �X� &� ������ ���/�0�0�0�$(�#4���� �'+�'<����$� � %� %� %� %� %� %� %� �.� !� !� !� �F�4�#� $� $� $� ������ ���+�,�,�,� �9� $� � !� !� #� #� #� � � #�� �,� 8�#'�#7�� � �#'�#7�� � ���5�)�Y�$�f�i� 9� 9� 9� � 7� � � �z�:� 6� 6� 6� ��� � � �#�/����7�<�<��(8�$�/�J�J��� �9� � � � �i�� �9�'��� <� <� <� ���.�/�/�/� �"�"�7�#?�#=� ?� ?� ?� ?� ?s� E+�+ E:�9E:c��tsdSddlm}tj|dz��|jD]�}|d}|ddkr |dd�}||jvr4|j|}|�|��}t||�� }n%|�|��}t||��}tjd||����dS)zDumps the list of user options.Nr)� longopt_xlate�:������=z %s: %s) r�distutils.fancy_getoptr�r�debug� user_options� negative_opt� translate�getattr)rC�msgr��opt�opt_name�vals rDrazinstall.dump_dirs�s���� � �F�8�8�8�8�8�8� � �#��)�����$� 1� 1�C��1�v�H���|�s�"�"�#�A�b�D�>���4�,�,�,��,�X�6��#�-�-�m�<�<��!�$��1�1�1���#�-�-�m�<�<���d�H�-�-�� �I�j�(�C� 0� 0� 0� 0� 1� 1rFc���|j�|j�;|j�|j�|j�|j�|j�|j�td���dS|j r@|j �td���|j x|_|_|� d��dS|j �*|j x|_|_|� d��dS|j�s|j�td���t j�t&j��|_t j�t&j��|_n|j� |j|_|j|_|j|_|� d��dS)z&Finalizes options for posix platforms.NzPinstall-base or install-platbase supplied, but installation scheme is incomplete�$User base directory is not specifiedrrz*must not supply exec-prefix without prefixr)r.r/r4r1r2r3r5r6r r(r8r� select_schemer-r+r,r^ry�normpathrdrBs rDrbzinstall.finalize_unix�s��� � � (�D�,A�,M��!�)��%�-��%�-��$�,��$�,��!�)�*�:�;�;�;� �F� �9� .��$�,�,�:�<�<�<�8<�8M� M�D� �� 5� � � �{� +� +� +� +� +� �Y� "�8<� � A�D� �� 5� � � �{� +� +� +� +� +��{�"��#�/�.�F�H�H�H�!�g�.�.�s�z�:�:�� �#%�7�#3�#3�C�O�#D�#D�� � ��#�+�'+�{�D�$� $� �D� �$(�$4�D� !� � � �}� -� -� -� -� -rFc�4�|jrM|j�td���|jx|_|_|�t jdz��dS|j�*|jx|_|_|�d��dS|j �.t j � tj ��|_ |j x|_|_ |�t j��dS#t$rtdt jz���wxYw)z)Finalizes options for non-posix platformsNr��_userrz)I don't know how to install stuff on '%s')r(r8rr.r/r�r^r_r-r+ryr�rd�KeyErrorrBs rDrczinstall.finalize_other�s&�� �9� M��$�,�,�:�<�<�<�8<�8M� M�D� �� 5� � � �r�w��0� 1� 1� 1� 1� 1� �Y� "�8<� � A�D� �� 5� � � �{� +� +� +� +� +��{�"� �g�.�.�s�z�:�:�� �8<� � C�D� �� 5� M��"�"�2�7�+�+�+�+�+��� M� M� M�,�A�B�G�K�M�M�M� M���s �C0�0'Dc��t|}tD].}d|z}t||���t||||���/dS)z=Sets the install directories by applying the install schemes.�install_N)�INSTALL_SCHEMES� SCHEME_KEYSr��setattr)rCr_�scheme�key�attrnames rDr�zinstall.select_scheme�sX��!��&��� 5� 5�C�!�C�'�H��t�X�&�&�.���h��s� �4�4�4�� 5� 5rFc���|D]y}t||��}|�etjdkstjdkrtj�|��}t ||j��}t|||���zdS)NrHr)r�r^r_ry� expanduserr rmr�)rC�attrs�attrr�s rD� _expand_attrszinstall._expand_attrs�s���� )� )�D��$��%�%�C����7�g�%�%���D����'�,�,�S�1�1�C� ��d�&6�7�7����d�C�(�(�(��  )� )rFc�4�|�gd���dS)zNCalls `os.path.expanduser` on install_base, install_platbase and root.)r.r/r0N�r�rBs rDrqzinstall.expand_basedirs�s%�� ���G�G�G�H�H�H�H�HrFc�4�|�gd���dS)z+Calls `os.path.expanduser` on install dirs.)r1r2r4r3r5r6Nr�rBs rDrszinstall.expand_dirs�s;�� ���@�@�@� A� A� A� A� ArFc �r�|D]3}d|z}t||tt||�������4dS)z!Call `convert_path` over `names`.r�N)r�r r��rC�namesr_r�s rDrvzinstall.convert_paths�sP��� C� C�D���$�D� �D�$� �W�T�4�-@�-@� A� A� B� B� B� B� C� CrFc���|j�|jj|_|j��tjd��t |jt ��r|j�d��|_t|j��dkr|jdx}}n2t|j��dkr |j\}}ntd���t|��}nd}d}||_ ||_ dS) z4Set `path_file` and `extra_dirs` using `extra_path`.NzIDistribution option extra_path is deprecated. See issue27919 for details.�,r*rrJzY'extra_path' option must be a list, tuple, or comma-separated string with 1 or 2 elementsrI) r;rhrr`� isinstance�strrf�lenr r � path_filer{)rCr�r{s rDrwzinstall.handle_extra_paths��� �?� "�"�/�:�D�O� �?� &� �H�.� � � ��$�/�3�/�/� =�"&�/�"7�"7��"<�"<����4�?�#�#�q�(�(�)-���);�;� �J�J��T�_�%�%��*�*�(,��%� �:�:�*�D�E�E�E� &�j�1�1�J�J��I��J�#���$����rFc �~�|D]9}d|z}t||t|jt||�������:dS)z:Change the install directories pointed by name using root.r�N)r�r r0r�r�s rDr|zinstall.change_roots"sT��� M� M�D���$�D� �D�$� �D�I�w�t�T�7J�7J� K� K� L� L� L� L� M� MrFc�p�|jsdSttj�d����}|j���D]f\}}|�|��rLtj�|��s-|� d|z��tj |d���gdS)zCreate directories under ~.N�~zos.makedirs('%s', 0o700)i�) r(r r^ryr�rm�items� startswith�isdir� debug_print�makedirs)rCr-r_rys rDrtzinstall.create_home_path(s����y� � �F��B�G�.�.�s�3�3�4�4���*�0�0�2�2� )� )�J�D�$����t�$�$� )�R�W�]�]�4�-@�-@� )�� � �!;�d�!B�C�C�C�� �D�%�(�(�(�� )� )rFc��|js\|�d��|j�d��j}|jr!|t ��krtd���|���D]}|�|���|j r|� ��|j r�|� ��}|j rFt|j ��}tt|����D]}|||d�||<�|�t"|j |fd|j z��t%t&jjt,j��}t%t&jj|��}t&j�t&j�|j����}|jr.|j r|js$||vrt5jd|j��dSdSdSdS)zRuns the command.r]z"Can't install when cross-compilingNz'writing list of installed files to '%s'z�modules installed to '%s', which is not in Python's module search path (sys.path) -- you'll have to change the search path yourself)r=� run_commandrh�get_command_obj� plat_namer>r r�get_sub_commandsr��create_path_filerA� get_outputsr0r��range�executer�mapr^ryr�rd�normcaser4r<rr�)rC� build_plat�cmd_name�outputs�root_len�counter�sys_pathr4s rD�runz install.run4s#���� @� � � �W� %� %� %��*�:�:�7�C�C�M�J��}� @��|�~�~�!=�!=�,�.?�@�@�@��-�-�/�/� '� '�H� � � �X� &� &� &� &� �>� $� � !� !� #� #� #� �;� &��&�&�(�(�G��y� C��t�y�>�>��$�S��\�\�2�2�C�C�G�'.�w�'7�� � �'B�G�G�$�$� �L�L���+�w�/�B���%� &� &� &� �r�w�'���2�2���r�w�'��2�2���g�&�&�r�w�'7�'7��8H�'I�'I�J�J� � �M� )��� )�$(�$:� )� �x� '� '� �I�H��'� )� )� )� )� )� )� )� '� '� )� )rFc���tj�|j|jdz��}|jr)|�t||jgfd|z��dS|� d|z��dS)zCreates the .pth file�.pthz creating %szpath file '%s' not createdN) r^ryrzrxr�r<r�rr{r`)rC�filenames rDr�zinstall.create_path_file`s����7�<�<�� 4� $��� 7�9�9�� � !� ?� �L�L��"�T�_�$5�6�&��1� 3� 3� 3� 3� 3� �I�I�2�X�=� >� >� >� >� >rFc�^�g}|���D]G}|�|��}|���D]}||vr|�|����H|jrG|jr@|�t j�|j |jdz����|S)z.Assembles the outputs of all the sub-commands.r�) r��get_finalized_commandr��appendr�r<r^ryrzrx)rCr�r��cmdr�s rDr�zinstall.get_outputsns������-�-�/�/� -� -�H��,�,�X�6�6�C� �O�O�-�-� -� -���7�*�*��N�N�8�,�,�,�� -� �>� B�d�4� B� �N�N�2�7�<�<��(<�(,���(?�A�A� B� B� B��rFc��g}|���D]>}|�|��}|�|������?|S)z*Returns the inputs of all the sub-commands)r�r��extend� get_inputs)rC�inputsr�r�s rDr�zinstall.get_inputss[�����-�-�/�/� ,� ,�H��,�,�X�6�6�C� �M�M�#�.�.�*�*� +� +� +� +�� rFc�f�|j���p|j���S)zSReturns true if the current distribution has any Python modules to install.)rh�has_pure_modules�has_ext_modulesrBs rD�has_libzinstall.has_lib�s2���!�2�2�4�4�4��!�1�1�3�3� 5rFc�4�|j���S)zLReturns true if the current distribution has any headers to install.)rh� has_headersrBs rDr�zinstall.has_headers����� �,�,�.�.�.rFc�4�|j���S)zMReturns true if the current distribution has any scripts to. install.)rh� has_scriptsrBs rDr�zinstall.has_scripts�r�rFc�4�|j���S)zJReturns true if the current distribution has any data to. install.)rh�has_data_filesrBs rD�has_datazinstall.has_data�s��� �/�/�1�1�1rFr4r3r5r6�install_egg_infoc��dS)NT�rBs rD�zinstall.�s��T�rF) �__name__� __module__� __qualname__� descriptionr��boolean_optionsr7r�rr�rEr~rarbrcr�r�rqrsrvrwr|rtr�r�r�r�r�r�r�r�� sub_commandsr�rFrDr r Zs������;�K�9 �9 �9 �L�v9�8�8�O��'����V�T�@�9�L�N� O� O� O����v�&�&�&� �9�-�L�F�F�F�^U?�U?�U?�t1�1�1�&&.�&.�&.�PM�M�M�,5�5�5�)�)�)�I�I�I� A�A�A� C�C�C� %� %� %�DM�M�M� )�)�)�*)�*)�*)�X ?� ?� ?����"���5�5�5� /�/�/� /�/�/� 2�2�2�#��0�&� �4�&� �4�#��1�'�)9�)9�:� �L�L�LrFr )*�__doc__rdrnr^�re� distutilsr�distutils.corer�distutils.debugr�distutils.sysconfigr�distutils.errorsr�distutils.file_utilr�distutils.utilr r r r r �siterrr7r�r�r��distutils_scheme_name�sys_scheme_name�sys_key�_INSTALL_SCHEMES� sys_scheme�main_keyr��value�sub�replacerlr r�rFrD�r�s���/�/� � � � ����� � � � � � � � �������"�"�"�"�"�"�!�!�!�!�!�!�/�/�/�/�/�/�3�3�3�3�3�3�*�*�*�*�*�*�@�@�@�@�@�@�@�@�@�@�'�'�'�'�'�'�1�1�1�1�1�1��������������$�&� � C� �#%�2�R�@�@�� � J� J�C�3� J� J�.������/��@� � �)� � ��:� 5� 5�  �G�6@��6I��-�.�s�3�3� J� � /� /�H�%�h�/�5�5�7�7� /� /� ��U����|�Y��6�6��� � �/��9�9��� � �6�8K�L�L�� �)� � � �]� "�E� � �v� %� %�#��*:�*:��M�M�'�?�;�;�E�).���!�#�&�&� /�� ���I�>�� " �" �O�I���� K�"�� $ �$ �O�K� �M �M �M �M �M �g�M �M �M �M �M rF