관리-도구
편집 파일: build_py.cpython-39.pyc
a �����DOg&C����������������������@���sz���d�Z�ddlZddlZddlZddlZddlmZ�ddlT�ddl m Z mZ�ddlm Z �G�dd��de�ZG�d d ��d ee�ZdS�)zHdistutils.command.build_py Implements the Distutils 'build_py' command.�����N)�Command)�*)�convert_path� Mixin2to3)�logc�������������������@���s����e�Zd�ZdZg�d�ZddgZddiZdd��Zdd ��Zd d��Z dd ��Z dd��Zdd��Zdd��Z dd��Zdd��Zdd��Zdd��Zdd��Zdd��Zd d!��Zd.d#d$�Zd%d&��Zd'd(��Zd)d*��Zd+d,��Zd-S�)/�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 ���r ���r���c�����������������C���s4���d�|�_�d�|�_d�|�_d�|�_d�|�_d|�_d|�_d�|�_d�S�)Nr���)� build_lib� py_modules�package�package_data�package_dirr ����optimizer �����self��r����2/usr/lib64/python3.9/distutils/command/build_py.py�initialize_options ���s����zbuild_py.initialize_optionsc�������������� ���C���s����|���ddd��|�jj|�_|�jj|�_|�jj|�_i�|�_|�jjr^|�jj���D�]\}}t|�|�j|<�qF|����|�_ t |�jt�s�z,t|�j�|�_d|�j��kr�dks�n�J��W�n�t tfy����td��Y�n0�d�S�)NZbuild)r���r���)r ���r ���r�������zoptimize must be 0, 1, or 2)Zset_undefined_options�distribution�packagesr���r���r����itemsr����get_data_files� data_files� isinstancer����int� ValueError�AssertionErrorZDistutilsOptionError)r����name�pathr���r���r����finalize_options*���s$����� zbuild_py.finalize_optionsc�����������������C���s:���|�j�r|�����|�jr$|�����|�����|��|�jdd���d�S��Nr���)�include_bytecode)r���� build_modulesr����build_packages�build_package_data�byte_compile�get_outputsr���r���r���r����runC���s����zbuild_py.runc��������������������s����g�}|�j�s|S�|�j�D�]h}|��|�}tjj|�jg|�d����}d��|rPt|�d�����fdd�|��||�D��}|� ||||f��q|S�)z?Generate list of '(package,src_dir,build_dir,filenames)' tuples�.r�������c��������������������s���g�|�]}|��d����qS��Nr���)�.0�file��plenr���r���� <listcomp>s���s���z+build_py.get_data_files.<locals>.<listcomp>) r����get_package_dir�osr%����joinr����split�len�find_data_files�append)r����datar����src_dir� build_dir� filenamesr���r4���r���r���a���s���� �zbuild_py.get_data_filesc��������������������sd���|�j��dg��|�j��|g���}g���|D�]:}t�tj�t�|�t|���}�����fdd�|D����q$��S�)z6Return filenames for package's data files in 'src_dir'��c��������������������s$���g�|�]}|��vrt�j�|�r|�qS�r���)r8���r%����isfile)r2����fn��filesr���r���r6�������s����z,build_py.find_data_files.<locals>.<listcomp>) r����get�globr8���r%���r9����escaper����extend)r���r���r?���Zglobs�patternZfilelistr���rE���r���r<���y���s�����zbuild_py.find_data_filesc�����������������C���s`���d}|�j�D�]P\}}}}|D�]>}tj�||�}|��tj�|���|�jtj�||�|dd��qq dS�)z$Copy data files into build directoryNF�Z preserve_mode)r���r8���r%���r9����mkpath�dirname� copy_file)r���Zlastdirr���r?���r@���rA����filename�targetr���r���r���r+�������s�����zbuild_py.build_package_datac�����������������C���s����|��d�}|�js&|r tjj|��S�dS�n�g�}|r�z|�jd�|��}W�n(�tyj���|�d|d���|d=�Y�q*0�|�d|��tjj|��S�q*|�j�d�}|dur�|�d|��|r�tjj|��S�dS�dS�)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).r/���rB���r������N)r:���r���r8���r%���r9����KeyError�insertrG���)r���r���r%����tailZpdirr���r���r���r7�������s(���� zbuild_py.get_package_dirc�����������������C���sj���|dkr8t�j�|�s td|���t�j�|�s8td|���|rft�j�|d�}t�j�|�rZ|S�t�d|��d�S�)NrB���z%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)) r8���r%����existsZDistutilsFileError�isdirr9���rC���r����warn)r���r���r����init_pyr���r���r���� check_package����s&��������zbuild_py.check_packagec�����������������C���s&���t�j�|�st�d||��dS�dS�d�S�)Nz!file %s (for module %s) not foundFT)r8���r%���rC���r���rX���)r����module�module_filer���r���r����check_module����s����zbuild_py.check_modulec����������� ������C���s����|���||��t�tj�t�|�d��}g�}tj�|�jj�}|D�]P}tj�|�}||kr�tj� tj� |��d�}|�|||f��q>|��d|���q>|S�)Nz*.pyr���zexcluding %s) rZ���rH���r8���r%���r9���rI����abspathr����script_name�splitext�basenamer=���Zdebug_print) r���r���r���Zmodule_files�modulesZsetup_scriptr���Zabs_fr[���r���r���r����find_package_modules����s����zbuild_py.find_package_modulesc�������������� ���C���s����i�}g�}|�j�D�]�}|�d�}d�|dd���}|d�}z||�\}}W�n �tyf���|��|�}d}Y�n0�|s�|��||�} |df||<�| r�|�|d| f��tj�||d��} |�� || �s�q|�||| f��q|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. r/���r���rR���r0����__init__�.py) r���r:���r9���rS���r7���rZ���r=���r8���r%���r]���)r���r���rb���r[���r%���r���Zmodule_baser����checkedrY���r\���r���r���r����find_modules����s*���� zbuild_py.find_modulesc�����������������C���sN���g�}|�j�r|�|������|�jrJ|�jD�]$}|��|�}|��||�}|�|��q$|S�)a4��Compute 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.)r���rJ���rg���r���r7���rc���)r���rb���r���r����mr���r���r����find_all_modules��s���� zbuild_py.find_all_modulesc�����������������C���s���dd��|�����D��S�)Nc�����������������S���s���g�|�]}|d���qS�)rR���r���)r2���r[���r���r���r���r6���-�������z-build_py.get_source_files.<locals>.<listcomp>)ri���r���r���r���r����get_source_files,��s����zbuild_py.get_source_filesc�����������������C���s$���|gt�|��|d�g�}tjj|��S�)Nre���)�listr8���r%���r9���)r���r@���r���r[���Zoutfile_pathr���r���r����get_module_outfile/��s����zbuild_py.get_module_outfiler0���c�����������������C���s����|�����}g�}|D�]p\}}}|�d�}|��|�j||�}|�|��|r|�jr^|�tjj|dd���|�j dkr|�tjj||�j d���q|dd��|�j D��7�}|S�)Nr/���rB���)�optimizationr���c�����������������S���s,���g�|�]$\}}}}|D�]}t�j�||��qqS�r���)r8���r%���r9���)r2���r���r?���r@���rA���rP���r���r���r���r6���B��s��� �z(build_py.get_outputs.<locals>.<listcomp>)ri���r:���rm���r���r=���r ���� importlib�util�cache_from_sourcer���r���)r���r(���rb���Zoutputsr���r[���r\���rP���r���r���r���r-���3��s&���� � � �zbuild_py.get_outputsc�����������������C���sb���t�|t�r|�d�}nt�|ttf�s,td��|��|�j||�}tj � |�}|��|��|�j||dd�S�)Nr/���z:'package' must be a string (dot-separated), list, or tupler���rL���) r ����strr:���rl����tuple� TypeErrorrm���r���r8���r%���rN���rM���rO���)r���r[���r\���r���Zoutfile�dirr���r���r����build_moduleJ��s���� � zbuild_py.build_modulec�����������������C���s*���|�����}|D�]\}}}|��|||��qd�S�r1���)rg���rv���)r���rb���r���r[���r\���r���r���r���r)���Y��s����zbuild_py.build_modulesc�����������������C���sP���|�j�D�]D}|��|�}|��||�}|D�]$\}}}||ks:J��|��|||��q$qd�S�r1���)r���r7���rc���rv���)r���r���r���rb���Zpackage_r[���r\���r���r���r���r*���b��s���� zbuild_py.build_packagesc�����������������C���s����t�jr|��d��d�S�ddlm}�|�j}|d�tjkr>|tj�}|�jrZ||d|�j ||�j d��|�jdkr||||�j|�j ||�j d��d�S�)Nz%byte-compiling is disabled, skipping.r���)r,���rR���)r���r ����prefix�dry_run)�sys�dont_write_bytecoderX����distutils.utilr,���r���r8����sepr ���r ���rx���r���)r���rF���r,���rw���r���r���r���r,���v��s���� � �zbuild_py.byte_compileN)r0���)�__name__� __module__�__qualname__�descriptionZuser_optionsZboolean_optionsZnegative_optr���r&���r.���r���r<���r+���r7���rZ���r]���rc���rg���ri���rk���rm���r-���rv���r)���r*���r,���r���r���r���r���r������s.��� '4 r���c�������������������@���s���e�Zd�Zdd��Zdd��ZdS�)� build_py_2to3c�����������������C���sL���g�|�_�|�jr|�����|�jr*|�����|�����|��|�j���|��|�jdd���d�S�r'���) � updated_filesr���r)���r���r*���r+���Zrun_2to3r,���r-���r���r���r���r���r.������s����zbuild_py_2to3.runc�����������������C���s,���t��|�|||�}|d�r(|�j�|d���|S�)Nr0���r���)r���rv���r����r=���)r���r[���r\���r����resr���r���r���rv������s����zbuild_py_2to3.build_moduleN)r}���r~���r���r.���rv���r���r���r���r���r�������s���r����)�__doc__r8����importlib.utilro���ry���rH���Zdistutils.corer���Zdistutils.errorsr{���r���r���Z distutilsr���r���r����r���r���r���r����<module>���s�����}