Your IP : 3.137.174.253


Current Path : /opt/alt/python39/lib64/python3.9/distutils/command/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/distutils/command/__pycache__/build_py.cpython-39.pyc

a

R�f&C�@szdZddlZddlZddlZddlZddlmZddlTddl	m
Z
mZddlm
Z
Gdd�de�ZGd	d
�d
ee�ZdS)zHdistutils.command.build_py

Implements the Distutils 'build_py' command.�N)�Command)�*)�convert_path�	Mixin2to3)�logc@s�eZdZdZgd�ZddgZddiZdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�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
rcCs4d|_d|_d|_d|_d|_d|_d|_d|_dS)Nr)�	build_lib�
py_modules�package�package_data�package_dirr	�optimizer
��self�r�?/opt/alt/python39/lib64/python3.9/distutils/command/build_py.py�initialize_options szbuild_py.initialize_optionsc	Cs�|�ddd�|jj|_|jj|_|jj|_i|_|jjr^|jj��D]\}}t|�|j|<qF|��|_	t
|jt�s�z,t|j�|_d|jkr�dks�nJ�Wnt
tfy�td��Yn0dS)NZbuild)rr)r
r
r�zoptimize must be 0, 1, or 2)Zset_undefined_options�distribution�packagesrrr�itemsr�get_data_files�
data_files�
isinstancer�int�
ValueError�AssertionErrorZDistutilsOptionError)r�name�pathrrr�finalize_options*s$�



 zbuild_py.finalize_optionscCs:|jr|��|jr$|��|��|�|jdd��dS�Nr)�include_bytecode)r�
build_modulesr�build_packages�build_package_data�byte_compile�get_outputsrrrr�runCszbuild_py.runcs�g}|js|S|jD]h}|�|�}tjj|jg|�d��}d�|rPt|�d��fdd�|�||�D�}|�	||||f�q|S)z?Generate list of '(package,src_dir,build_dir,filenames)' tuples�.r�csg|]}|�d��qS�Nr)�.0�file�Zplenrr�
<listcomp>ssz+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�	filenamesrr4rras



�zbuild_py.get_data_filescsd|j�dg�|j�|g�}g�|D]:}t�tj�t�|�t|���}���fdd�|D��q$�S)z6Return filenames for package's data files in 'src_dir'�cs$g|]}|�vrtj�|�r|�qSr)r7r%�isfile)r2�fn��filesrrr5�s�z,build_py.find_data_files.<locals>.<listcomp>)	r�get�globr7r%r8�escaper�extend)rrr>Zglobs�patternZfilelistrrDrr;ys�zbuild_py.find_data_filescCs`d}|jD]P\}}}}|D]>}tj�||�}|�tj�|��|jtj�||�|dd�qq
dS)z$Copy data files into build directoryNF�Z
preserve_mode)rr7r%r8�mkpath�dirname�	copy_file)rZlastdirrr>r?r@�filename�targetrrrr+�s�zbuild_py.build_package_datacCs�|�d�}|js&|r tjj|�SdSn�g}|r�z|jd�|�}Wn(tyj|�d|d�|d=Yq*0|�d|�tjj|�Sq*|j�d�}|dur�|�d|�|r�tjj|�SdSdS)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/rAr���N)r9rr7r%r8�KeyError�insertrF)rrr%�tailZpdirrrrr6�s(
	zbuild_py.get_package_dircCsj|dkr8tj�|�s td|��tj�|�s8td|��|rftj�|d�}tj�|�rZ|St�d|�dS)NrAz%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))	r7r%�existsZDistutilsFileError�isdirr8rBr�warn)rrr�init_pyrrr�
check_package�s&����zbuild_py.check_packagecCs&tj�|�st�d||�dSdSdS)Nz!file %s (for module %s) not foundFT)r7r%rBrrW)r�module�module_filerrr�check_module�szbuild_py.check_modulec	Cs�|�||�t�tj�t�|�d��}g}tj�|jj�}|D]P}tj�|�}||kr�tj�	tj�
|��d}|�|||f�q>|�d|�q>|S)Nz*.pyrzexcluding %s)
rYrGr7r%r8rH�abspathrZscript_name�splitext�basenamer<Zdebug_print)	rrrZmodule_files�modulesZsetup_scriptrZabs_frZrrr�find_package_modules�szbuild_py.find_package_modulesc	Cs�i}g}|jD]�}|�d�}d�|dd��}|d}z||\}}Wn tyf|�|�}d}Yn0|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/rrQr0�__init__�.py)
rr9r8rRr6rYr<r7r%r\)rrr`rZr%rZmodule_baser�checkedrXr[rrr�find_modules�s*



zbuild_py.find_modulescCsNg}|jr|�|���|jrJ|jD]$}|�|�}|�||�}|�|�q$|S)a4Compute 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.)rrIrerr6ra)rr`rr�mrrr�find_all_moduless

zbuild_py.find_all_modulescCsdd�|��D�S)NcSsg|]}|d�qS)rQr)r2rZrrrr5-�z-build_py.get_source_files.<locals>.<listcomp>)rgrrrr�get_source_files,szbuild_py.get_source_filescCs$|gt|�|dg}tjj|�S)Nrc)�listr7r%r8)rr?rrZZoutfile_pathrrr�get_module_outfile/szbuild_py.get_module_outfiler0cCs�|��}g}|D]p\}}}|�d�}|�|j||�}|�|�|r|jr^|�tjj|dd��|j	dkr|�tjj||j	d��q|dd�|j
D�7}|S)Nr/rA)�optimizationrcSs,g|]$\}}}}|D]}tj�||��qqSr)r7r%r8)r2rr>r?r@rOrrrr5Bs
�z(build_py.get_outputs.<locals>.<listcomp>)rgr9rkrr<r	�	importlib�util�cache_from_sourcerr)rr(r`ZoutputsrrZr[rOrrrr-3s&


�

�
�zbuild_py.get_outputscCsbt|t�r|�d�}nt|ttf�s,td��|�|j||�}tj	�
|�}|�|�|j||dd�S)Nr/z:'package' must be a string (dot-separated), list, or tuplerrK)
r �strr9rj�tuple�	TypeErrorrkrr7r%rMrLrN)rrZr[rZoutfile�dirrrr�build_moduleJs
�
zbuild_py.build_modulecCs*|��}|D]\}}}|�|||�qdSr1)rert)rr`rrZr[rrrr)Yszbuild_py.build_modulescCsP|jD]D}|�|�}|�||�}|D]$\}}}||ks:J�|�|||�q$qdSr1)rr6rart)rrrr`Zpackage_rZr[rrrr*bs


zbuild_py.build_packagescCs�tjr|�d�dSddlm}|j}|dtjkr>|tj}|jrZ||d|j	||j
d�|jdkr||||j|j	||j
d�dS)Nz%byte-compiling is disabled, skipping.r)r,rQ)rr
�prefix�dry_run)�sys�dont_write_bytecoderW�distutils.utilr,rr7�sepr	r
rvr)rrEr,rurrrr,vs


�

�zbuild_py.byte_compileN)r0)�__name__�
__module__�__qualname__ZdescriptionZuser_optionsZboolean_optionsZnegative_optrr&r.rr;r+r6rYr\rarergrirkr-rtr)r*r,rrrrrs.



'4
	rc@seZdZdd�Zdd�ZdS)�
build_py_2to3cCsLg|_|jr|��|jr*|��|��|�|j�|�|jdd��dSr')	�
updated_filesrr)rr*r+Zrun_2to3r,r-rrrrr.�szbuild_py_2to3.runcCs,t�||||�}|dr(|j�|d�|S)Nr0r)rrtrr<)rrZr[r�resrrrrt�szbuild_py_2to3.build_moduleN)r{r|r}r.rtrrrrr~�sr~)�__doc__r7�importlib.utilrmrwrGZdistutils.corerZdistutils.errorsryrrZ	distutilsrrr~rrrr�<module>s}

?>