Edit File: build_py.cpython-36.pyc
3 � \C������������������@���s~���d�Z�ddlZddlZddlZddlmZ�ddlmZ�ddlT�ddl m Z mZ�ddlm Z �G�dd ��d e�ZG�d d��dee�ZdS�)zHdistutils.command.build_py Implements the Distutils 'build_py' command.�����N)�glob)�Command)�*)�convert_path� Mixin2to3)�logc���������������@���s����e�Zd�ZdZd8d9d:d;d<gZddgZddiZdd��Zdd��Zdd��Z dd��Z dd��Zdd��Zdd��Z dd ��Zd!d"��Zd#d$��Zd%d&��Zd'd(��Zd)d*��Zd+d,��Zd=d.d/�Zd0d1��Zd2d3��Zd4d5��Zd6d7��Zd S�)>�build_pyz5"build" pure Python modules (copy to build directory)� build-lib=�d�directory to "build" (copy) to�compile�c�compile .py to .pyc� no-compileN�!don't compile .py files [default]� optimize=�O�lalso compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0]�force�f�2forcibly build everything (ignore file timestamps)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.6/distutils/command/build_py.py�initialize_options ���s����zbuild_py.initialize_optionsc�������������C���s����|�j�ddd��|�jj|�_|�jj|�_|�jj|�_i�|�_|�jjrbx&|�jjj��D�]\}}t|�|�j|<�qHW�|�j��|�_ t |�jt�s�y.t|�j�|�_d|�j��ko�dkn��s�t �W�n �tt fk r����td��Y�nX�d�S�) NZbuildr���r���r�������zoptimize must be 0, 1, or 2)r���r���)r���r���)Zset_undefined_options�distribution�packagesr���r���r����itemsr����get_data_files� data_files� isinstancer����int�AssertionError� ValueErrorZDistutilsOptionError)r����name�pathr���r���r����finalize_options*���s"���� "zbuild_py.finalize_optionsc�������������C���s:���|�j�r|�j���|�jr$|�j���|�j���|�j|�jdd���d�S�)Nr���)�include_bytecode)r���� build_modulesr#����build_packages�build_package_data�byte_compile�get_outputs)r���r���r���r����runC���s����zbuild_py.runc����������������s����g�}|�j�s|S�xr|�j�D�]h}|�j|�}tjj|�jg|jd����}d��|rRt|�d�����fdd�|�j||�D��}|j ||||f��qW�|S�)z?Generate list of '(package,src_dir,build_dir,filenames)' tuples�.r�������c����������������s���g�|�]}|��d����qS�)Nr���)�.0�file)�plenr���r���� <listcomp>t���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���)r9���r���r%���a���s���� zbuild_py.get_data_filesc����������������s`���|�j�jdg��|�j�j|g���}g���x:|D�]2}ttjj|t|���}��j��fdd�|D����q&W���S�)z6Return filenames for package's data files in 'src_dir'��c����������������s$���g�|�]}|��krt�jj|�r|�qS�r���)r<���r,����isfile)r7����fn)�filesr���r���r:�������s���� z,build_py.find_data_files.<locals>.<listcomp>)r����getr���r<���r,���r=���r����extend)r���r���rC���Zglobs�patternZfilelistr���)rI���r���r@���y���s���� zbuild_py.find_data_filesc�������������C���sh���d}x^|�j�D�]T\}}}}xF|D�]>}tjj||�}|�jtjj|���|�jtjj||�|dd��qW�qW�dS�)z$Copy data files into build directoryNF)� preserve_mode)r&���r<���r,���r=����mkpath�dirname� copy_file)r���Zlastdirr���rC���rD���rE����filename�targetr���r���r���r1�������s���� zbuild_py.build_package_datac�������������C���s����|j�d�}|�js&|r tjj|��S�dS�n�g�}x�|r�y|�jdj|��}W�n*�tk rn���|jd|d���|d=�Y�q,X�|jd|��tjj|��S�q,W�|�jjd�}|dk r�|jd|��|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).r5���rF���r���r6���N���rS���)r>���r���r<���r,���r=����KeyError�insertrJ���)r���r���r,����tailZpdirr���r���r���r;�������s(���� zbuild_py.get_package_dirc�������������C���sj���|dkr8t�jj|�s td|���t�jj|�s8td|���|rft�jj|d�}t�jj|�rZ|S�tjd|��d�S�)NrF���z%package directory '%s' does not existz>supposed package directory '%s' exists, but is not a directoryz__init__.pyz!package init file '%s' not found z(or not a regular file)z8package init file '%s' not found (or not a regular file)) r<���r,����existsZDistutilsFileError�isdirr=���rG���r����warn)r���r���r����init_pyr���r���r���� check_package����s���� zbuild_py.check_packagec�������������C���s&���t�jj|�stjd||��dS�dS�d�S�)Nz!file %s (for module %s) not foundFT)r<���r,���rG���r���rY���)r����module�module_filer���r���r����check_module����s����zbuild_py.check_modulec������� ������C���s����|�j�||��ttjj|d��}g�}tjj|�jj�}xX|D�]P}tjj|�}||krztjjtjj |��d�}|j |||f��q8|�jd|���q8W�|S�)Nz*.pyr���zexcluding %s)r[���r���r<���r,���r=����abspathr"���Zscript_name�splitext�basenamerA���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�}x�|�j�D�]�}|jd�}dj|dd���}|d�}y||�\}}W�n"�tk rj���|�j|�}d}Y�nX�|s�|�j||�} |df||<�| r�|j|d| f��tjj||d��} |�j || �s�q|j||| f��qW�|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. r5���r���r6����__init__z.pyrS���rS���) r���r>���r=���rT���r;���r[���rA���r<���r,���r^���)r���r#���rb���r\���r,���r���Zmodule_baser���ZcheckedrZ���r]���r���r���r����find_modules����s*���� zbuild_py.find_modulesc�������������C���sR���g�}|�j�r|j|�j����|�jrNx.|�jD�]$}|�j|�}|�j||�}|j|��q&W�|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���rK���re���r#���r;���rc���)r���rb���r���r����mr���r���r����find_all_modules��s���� zbuild_py.find_all_modulesc�������������C���s���dd��|�j���D��S�)Nc�������������S���s���g�|�]}|d��qS�)r6���rS���r���)r7���r\���r���r���r���r:���-��s����z-build_py.get_source_files.<locals>.<listcomp>)rg���)r���r���r���r����get_source_files,��s����zbuild_py.get_source_filesc�������������C���s$���|gt�|��|d�g�}tjj|��S�)Nz.py)�listr<���r,���r=���)r���rD���r���r\���Zoutfile_pathr���r���r����get_module_outfile/��s����zbuild_py.get_module_outfiler6���c�������������C���s����|�j���}g�}xx|D�]p\}}}|jd�}|�j|�j||�}|j|��|r|�jr`|jtjj|dd���|�j dkr|jtjj||�j d���qW�|dd��|�j D��7�}|S�)Nr5���rF���)�optimizationr���c�������������S���s,���g�|�]$\}}}}|D�]}t�jj||��qqS�r���)r<���r,���r=���)r7���r���rC���rD���rE���rQ���r���r���r���r:���C��s��� z(build_py.get_outputs.<locals>.<listcomp>)rg���r>���rj���r���rA���r���� importlib�util�cache_from_sourcer���r&���)r���r.���rb���Zoutputsr���r\���r]���rQ���r���r���r���r3���3��s"���� zbuild_py.get_outputsc�������������C���sb���t�|t�r|jd�}nt�|ttf�s,td��|�j|�j||�}tj j |�}|�j|��|�j||dd�S�)Nr5���z:'package' must be a string (dot-separated), list, or tupler���)rM���) r'����strr>���ri����tuple� TypeErrorrj���r���r<���r,���rO���rN���rP���)r���r\���r]���r���Zoutfile�dirr���r���r����build_moduleJ��s���� zbuild_py.build_modulec�������������C���s.���|�j���}x |D�]\}}}|�j|||��qW�d�S�)N)re���rs���)r���rb���r���r\���r]���r���r���r���r/���Y��s����zbuild_py.build_modulesc�������������C���sX���xR|�j�D�]H}|�j|�}|�j||�}x,|D�]$\}}}||ks>t�|�j|||��q(W�qW�d�S�)N)r#���r;���rc���r)���rs���)r���r���r���rb���Zpackage_r\���r]���r���r���r���r0���b��s���� zbuild_py.build_packagesc�������������C���s����t�jr|�jd��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���)r2���r6���)r���r����prefix�dry_runrS���)�sys�dont_write_bytecoderY����distutils.utilr2���r���r<����sepr���r���ru���r���)r���rI���r2���rt���r���r���r���r2���v��s���� zbuild_py.byte_compile)r ���r ���r���)r���r ���r���)r���Nr���)r���r���r���)r���r���r���)r6���)�__name__� __module__�__qualname__ZdescriptionZuser_optionsZboolean_optionsZnegative_optr ���r-���r4���r%���r@���r1���r;���r[���r^���rc���re���rg���rh���rj���r3���rs���r/���r0���r2���r���r���r���r���r������s8���� '4 r���c���������������@���s���e�Zd�Zdd��Zdd��ZdS�)� build_py_2to3c�������������C���sL���g�|�_�|�jr|�j���|�jr*|�j���|�j���|�j|�j���|�j|�jdd���d�S�)Nr���)r.���) � updated_filesr���r/���r#���r0���r1���Zrun_2to3r2���r3���)r���r���r���r���r4������s����zbuild_py_2to3.runc�������������C���s,���t�j|�|||�}|d�r(|�jj|d���|S�)Nr6���r���)r���rs���r~���rA���)r���r\���r]���r����resr���r���r���rs������s����zbuild_py_2to3.build_moduleN)rz���r{���r|���r4���rs���r���r���r���r���r}������s���r}���)�__doc__r<����importlib.utilrl���rv���r���Zdistutils.corer���Zdistutils.errorsrx���r���r���Z distutilsr���r���r}���r���r���r���r����<module>���s�����}