Файловый менеджер - Редактировать - /home/digitalm/venv/lib/python3.7/site-packages/setuptools/_distutils/command/__pycache__/build_scripts.cpython-37.pyc
Назад
B �5�g� � @ s� d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m Z ddlmZ dd l mZ ddlZe�d �ZeZG dd� de�ZdS ) zRdistutils.command.build_scripts Implements the Distutils 'build_scripts' command.� N)�ST_MODE)� sysconfig� )�Command)�newer)�convert_path)�logz^#!.*python[0-9.]*([ ].*)?$c @ sl e Zd ZdZdddgZdgZdd� Zdd � Zd d� Zdd � Z dd� Z dd� Zdd� Zdd� Z edd� �ZdS )� 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 S )N)� build_dir�scriptsr � executable)�self� r �S/tmp/pip-install-251nq386/setuptools/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_files2 s zbuild_scripts.get_source_filesc C s | j s d S | �� d S )N)r �copy_scripts)r r r r �run5 s zbuild_scripts.runc C sD | � | j� g }g }x| jD ]}| �|||� qW | �|� ||fS )a2 Copy each script listed in ``self.scripts``. If a script is marked as a Python script (first line matches 'shebang_pattern', i.e. starts with ``#!`` and contains "python"), then adjust in the copy the first line to refer to the current Python interpreter. )�mkpathr r �_copy_script� _change_modes)r �outfiles� updated_files�scriptr r r r : s zbuild_scripts.copy_scriptsc C s� d }t |�}tj�| jtj�|��}|�|� | jsNt||�sNt � d|� d S yt�|�}W n t k r| | jst� d }Y n*X |�� }|s�| �d| � d S t�|�}|�|� |�rvt �d|| j� | j�sftjs�| j}n(tj�t�d�dt�d�t�d�f �}|�d��pd } d | | d } | �| |j� t|d|jd ��}|�| � |�|�� � W d Q R X |�r�|�� n|�r�|�� | �||� d S )Nznot copying %s (up-to-date)z%s is an empty file (skipping)zcopying and adjusting %s -> %s�BINDIRz python%s%s�VERSION�EXE� � z#!� �w)�encoding) r �os�path�joinr �basename�appendr r r �debug�tokenize�open�OSError�dry_run�readline�warn�shebang_pattern�match�infor �python_buildr �get_config_var�group�_validate_shebangr) �write� writelines� readlines�close� copy_file)r r! r r Z shebang_match�outfiler � first_liner �post_interp�shebang�outfr r r r M sP zbuild_scripts._copy_scriptc C s* t jdkrd S x|D ]}| �|� qW d S )N�posix)r* �name�_change_mode)r r �filer r r r � s zbuild_scripts._change_modesc C s\ | j rt�d|� d S t�|�t d@ }|dB d@ }||krXt�d|||� t�||� d S )Nzchanging mode of %si� im z!changing mode of %s from %o to %o)r3 r r8 r* �statr �chmod)r rJ ZoldmodeZnewmoder r r rI � s zbuild_scripts._change_modec C sj y| � d� W n" tk r0 td�| ���Y nX y| � |� W n$ tk rd td�| |���Y nX d S )Nzutf-8z,The shebang ({!r}) is not encodable to utf-8z?The shebang ({!r}) is not encodable to the script encoding ({}))�encode�UnicodeEncodeError� ValueError�format)rE r) r r r r<