B ‘–ReK ã @ s‚ d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m Z ddlmZ ddlm Z ddlZe d ¡ZG d d„ deƒZdS )zRdistutils.command.build_scripts Implements the Distutils 'build_scripts' command.é N)ÚST_MODE)Ú sysconfig)ÚCommand)Únewer)Úconvert_path)Úlogs ^#!.*python[0-9.]*([ ].*)?$c @ sH e Zd ZdZdddgZdgZdd„ Zdd „ Zd d„ Zdd „ Z dd„ Z dS )Ú build_scriptsz("build" scripts (copy and fixup #! line))z build-dir=Údzdirectory to "build" (copy) to)ÚforceÚfz1forcibly build everything (ignore file timestamps)zexecutable=Úez*specify final destination interpreter pathr c C s" d | _ d | _d | _d | _d | _d S )N)Ú build_dirÚscriptsr Ú executableÚoutfiles)Úself© r ú¡/builddir/build/BUILDROOT/alt-python37-setuptools-58.3.0-4.el8.x86_64/opt/alt/python37/lib/python3.7/site-packages/setuptools/_distutils/command/build_scripts.pyÚinitialize_options s z build_scripts.initialize_optionsc C s | dddd¡ | jj| _d S )NÚbuild)r r )r r )r r )Úset_undefined_optionsÚdistributionr )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 | ¡ d S )N)r Úcopy_scripts)r r r r Úrun/ s zbuild_scripts.runc C s¾ | | j¡ g }g }x(| jD ]}d}t|ƒ}tj | jtj |¡¡}| |¡ | j spt ||ƒspt d|¡ qyt |dƒ}W n tk rž | js–‚ d}Y nXX t |j¡\}}| d¡ | ¡ } | sÖ| d| ¡ qt | ¡} | röd}| d¡pôd }|rt d || j¡ | |¡ | jstjs.| j}n(tj t d¡dt d ¡t d¡f ¡}t |¡}d| | d } y| d¡ W n$ tk r¢ t d !| ¡ƒ‚Y nX y| |¡ W n& tk rØ t d !| |¡ƒ‚Y nX t |dƒ}| "| ¡ | #| $¡ ¡ W dQ R X |r<| %¡ q|r&| %¡ | |¡ | &||¡ qW tj'dkr¶xh|D ]`}| jrlt d|¡ nDt (|¡t) d@ }|dB d@ }||krRt d|||¡ t *||¡ qRW ||fS )a" Copy each script listed in 'self.scripts'; if it's marked as a Python script in the Unix way (first line matches 'first_line_re', ie. starts with "\#!" and contains "python"), then adjust the first line to refer to the current Python interpreter as we copy. Fznot copying %s (up-to-date)ÚrbNr 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)+Úmkpathr 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 Úpython_buildr Úget_config_varÚfsencodeÚdecodeÚUnicodeDecodeErrorÚ ValueErrorÚformatÚwriteÚ writelinesÚ readlinesÚcloseÚ copy_fileÚnameÚstatr Úchmod)r r Z updated_filesÚscriptÚadjustÚoutfiler ÚencodingÚlinesÚ first_liner5 Úpost_interpr ÚshebangÚoutfÚfileZoldmodeZnewmoder r r r 5 s zbuild_scripts.copy_scriptsN)Ú__name__Ú __module__Ú__qualname__ÚdescriptionÚuser_optionsÚboolean_optionsr r r r r r r r r r s r )Ú__doc__r&