3 \X ã @ s” d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm Z d dl mZmZ d dlm Z d dlZejdƒZG d d „ d eƒZG dd„ deeƒZdS ) é N)ÚST_MODE)Ú sysconfig)ÚCommand)Únewer)Úconvert_pathÚ Mixin2to3)Úlogs ^#!.*python[0-9.]*([ ].*)?$c @ sH e Zd ZdZdddgZdgZdd„ Zd d„ Zdd„ Zdd„ Z dd„ Z dS )Ú build_scriptsz("build" scripts (copy and fixup #! line)ú build-dir=Údúdirectory to "build" (copy) toÚforceÚfú1forcibly build everything (ignore file timestampsúexecutable=Úeú*specify final destination interpreter pathc C s" d | _ d | _d | _d | _d | _d S )N)Ú build_dirÚscriptsr Ú executableÚoutfiles)Úself© r ú7/usr/lib64/python3.6/distutils/command/build_scripts.pyÚinitialize_options s z build_scripts.initialize_optionsc C s | j ddddƒ | jj| _d S ) NZbuildr r r r )r r )r r )r r )Zset_undefined_optionsZdistributionr )r r r r Úfinalize_options% s zbuild_scripts.finalize_optionsc C s | j S )N)r )r r r r Úget_source_files, s zbuild_scripts.get_source_filesc C s | j s d S | jƒ d S )N)r Úcopy_scripts)r r r r Úrun/ s zbuild_scripts.runc " C s | j | jƒ g }g }�x,| jD �] }d}t|ƒ}tjj| jtjj|ƒƒ}|j|ƒ | j rtt ||ƒ rttjd|ƒ qyt |dƒ}W n tk r¢ | jsš‚ d }Y nXX tj|jƒ\}}|jdƒ |jƒ } | sÚ| jd| ƒ qtj| ƒ} | rúd}| jdƒpød}|�rtjd || jƒ |j|ƒ | j�stj�s2| j}n(tjjtjd ƒdtjdƒtjd ƒf ƒ}tj|ƒ}d| | d } y| jdƒ W n$ tk �r¦ t dj!| ƒƒ‚Y nX y| j|ƒ W n& tk �rÜ t dj!| |ƒƒ‚Y nX t |dƒ�}|j"| ƒ |j#|j$ƒ ƒ W d Q R X |�r@|j%ƒ q|�r*|j%ƒ |j|ƒ | j&||ƒ qW tj'dk�rºxh|D ]`}| j�rptjd|ƒ nDtj(|ƒt) d@ }|dB d@ }||k�rVtjd|||ƒ tj*||ƒ �qVW ||fS )NFznot copying %s (up-to-date)Úrbr z%s is an empty file (skipping)Té ó zcopying and adjusting %s -> %sÚBINDIRz python%s%sÚVERSIONÚEXEs #!ó zutf-8z.The shebang ({!r}) is not decodable from utf-8zAThe shebang ({!r}) is not decodable from the script encoding ({})ÚwbÚposixzchanging mode of %siÿ im z!changing mode of %s from %o to %o)+Zmkpathr r r ÚosÚpathÚjoinÚbasenameÚappendr r r ÚdebugÚopenÚOSErrorÚdry_runÚtokenizeÚdetect_encodingÚreadlineÚseekÚwarnÚ first_line_reÚmatchÚgroupÚinfor Zpython_buildr Úget_config_varÚfsencodeÚdecodeÚUnicodeDecodeErrorÚ ValueErrorÚformatÚwriteÚ writelinesÚ readlinesÚcloseZ copy_fileÚnameÚstatr Úchmod)r r Ú updated_filesZscriptZadjustZoutfiler ÚencodingÚlinesZ first_liner7 Zpost_interpr ZshebangZoutfÚfileZoldmodeZnewmoder r r r 5 s� zbuild_scripts.copy_scriptsN)r r r )r r r )r r r )Ú__name__Ú __module__Ú__qualname__ZdescriptionZuser_optionsZboolean_optionsr r r r r r r r r r s r c @ s e Zd Zdd„ ZdS )Úbuild_scripts_2to3c C s&