3
g/                 @   s  d Z ddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZ ddlmZmZ ddlmZmZ ddlmZ ddlmZmZ ddlmZmZ dd	lmZ dd
lmZ ddlm Z  ddl!m"Z" ddl#m$Z$ ddl%m&Z& ddl'm(Z( ddl)m*Z*m+Z+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6 ej7e8Z9ej:dej;Z<ee&ge=f Z>ee
e& e
e& f Z?e@e=dddZAe&e=e>e=dddZBe&e=dddZCe&e>e=d d!d"ZDe&ee= dd#d$ZEe&ee@d%d&d'ZFee=d(d)d*ZGe&e@dd+d,d-ZHe&e@e=e
e@ e
e@ e=ee@ d.d/d0ZIe&e@e
e@ e
e@ e=ee@ d1d2d3ZJe&e
e@ e=d4d5d6ZKe	e& ee=e
e@ e
e@ e?d7d8d9ZLdS ):z;Orchestrator for building wheels from InstallRequirements.
    N)AnyCallableIterableListOptionalTuple)canonicalize_namecanonicalize_version)InvalidVersionVersion)
WheelCache)InvalidWheelFilenameUnsupportedWheel)FilesystemWheelget_wheel_distribution)Link)Wheel)build_wheel_pep517)build_wheel_editable)build_wheel_legacy)InstallRequirement)
indent_log)
ensure_dir	hash_fileis_wheel_installed)make_setuptools_clean_args)call_subprocess)TempDirectory)path_to_url)vcsz([a-z0-9_.]+)-([a-z0-9_.!+-]+))sreturnc             C   s   t tj| S )zjDetermine whether the string looks like an egg_info.

    :param s: The string to parse. E.g. foo-2.1
    )bool_egg_info_research)r     r%   Y/var/www/tester-filtro-web/env/lib/python3.6/site-packages/pip/_internal/wheel_builder.py_contains_egg_info&   s    r'   )req
need_wheelcheck_binary_allowedr!   c             C   s   | j r
dS | jr&|r"tjd| j dS |r.dS | js8dS | jrF| j S | jrPdS || sjtjd| j dS t	 stjd| j dS dS )zBReturn whether an InstallRequirement should be built into a wheel.Fz(Skipping %s, due to already being wheel.TzCSkipping wheel build for %s, due to binaries being disabled for it.zOUsing legacy 'setup.py install' for %s, since package 'wheel' is not installed.)

constraintis_wheelloggerinfoname
source_direditablesupports_pyproject_editable
use_pep517r   )r(   r)   r*   r%   r%   r&   _should_build.   s6    r4   )r(   r!   c             C   s   t | dtdS )NT)r)   r*   )r4   _always_true)r(   r%   r%   r&   should_build_for_wheel_commandc   s    r6   )r(   r*   r!   c             C   s   t | d|dS )NF)r)   r*   )r4   )r(   r*   r%   r%   r&    should_build_for_install_commandi   s    r7   c             C   s   | j s| j rdS | jrf| jjrf| j  s,t| js6ttj| jj}|sLt|j| jj	| jrbdS dS | jspt| jj
 \}}t|rdS dS )z
    Return whether a built InstallRequirement can be stored in the persistent
    wheel cache, assuming the wheel cache is available, and _should_build()
    has determined a wheel needs to be built.
    FT)r1   r0   linkis_vcsAssertionErrorr   get_backend_for_schemeschemeis_immutable_rev_checkouturlsplitextr'   )r(   vcs_backendbaseextr%   r%   r&   _should_cacher   s    

rC   )r(   wheel_cacher!   c             C   s>   t |j}| jst|r.t| r.|j| j}n|j| j}|S )zdReturn the persistent or temporary cache directory where the built
    wheel need to be stored.
    )r"   	cache_dirr8   r:   rC   get_path_for_linkget_ephem_path_for_link)r(   rD   Zcache_availablerE   r%   r%   r&   _get_cache_dir   s    

rH   )_r!   c             C   s   dS )NTr%   )rI   r%   r%   r&   r5      s    r5   )r(   
wheel_pathr!   c       	      C   s   t | jp
d}ttjj|}t |j|kr>tdj||jtt	||}t
|j}t|t|jkrztdj||j|j}|d krtdyt|}W n& tk
r   d| }t|Y nX |tdkrt|jt rtdj|d S )N z7Wheel has unexpected file name: expected {!r}, got {!r}zMissing Metadata-VersionzInvalid Metadata-Version: z1.2z6Metadata 1.2 mandates PEP 440 version, but {!r} is not)r   r/   r   ospathbasenamer   formatr   r   strversionr	   metadata_versionr   r   r
   
isinstance)	r(   rJ   canonical_namewdistZdist_verstrZmetadata_version_valuerR   msgr%   r%   r&   _verify_one   s0    

rX   )r(   
output_dirverifybuild_optionsglobal_optionsr1   r!   c       	   &   C   s   |rdnd}yt | W n2 tk
rJ } ztjd|| j| dS d}~X nX | j t| ||||}W dQ R X |r|ryt| | W n6 tt	fk
r } ztjd|| j| dS d}~X nX |S )zaBuild one wheel.

    :return: The filename of the built wheel, or None if the build failed.
    r1   wheelzBuilding %s for %s failed: %sNzBuilt %s for %s is invalid: %s)
r   OSErrorr-   warningr/   	build_env_build_one_inside_envrX   r   r   )	r(   rY   rZ   r[   r\   r1   ZartifacterJ   r%   r%   r&   
_build_one   s(    rc   )r(   rY   r[   r\   r1   r!   c             C   sd  t ddN}| jst| jr| js(t| js2t|rDtjd| j |rVtjd| j |rtt| j| j| j|j	d}qt
| j| j| j|j	d}nt| j| j| j|||j	d}|d k	rDtj	j|}tj	j||}y@t|\}	}
tj|| tjd| j||
|	j  tjd| |S  tk
rB } ztjd	| j| W Y d d }~X nX | jsVt| | d S Q R X d S )
Nr]   )kindz7Ignoring --global-option when building %s using PEP 517z6Ignoring --build-option when building %s using PEP 517)r/   backendmetadata_directorytempd)r/   setup_py_pathr0   r\   r[   rg   z3Created wheel for %s: filename=%s size=%d sha256=%szStored in directory: %sz Building wheel for %s failed: %s)r   r/   r:   r3   rf   pep517_backendr-   r_   r   rM   r   r   rh   unpacked_source_directoryrL   rN   joinr   shutilmover.   	hexdigest	Exception_clean_one_legacy)r(   rY   r[   r\   r1   temp_dirrJ   
wheel_name	dest_pathZ
wheel_hashlengthrb   r%   r%   r&   ra      sf    








ra   )r(   r\   r!   c             C   sV   t | j|d}tjd| j yt|| jd dS  tk
rP   tjd| j dS X d S )N)r\   zRunning setup.py clean for %s)cwdTz Failed cleaning build dir for %sF)	r   rh   r-   r.   r/   r   r0   ro   error)r(   r\   Z
clean_argsr%   r%   r&   rp   1  s    rp   )requirementsrD   rZ   r[   r\   r!   c       
      C   s  | sg g fS t jddjdd | D  t  g g  }}xx| D ]p}|jsNtt||}t||||||jon|j	}	|	rt
t|	|_|jj|_|jjst|j| q@|j| q@W W dQ R X |rt jddjdd	 |D  |r t jd
djdd	 |D  ||fS )zBuild wheels.

    :return: The list of InstallRequirement that succeeded to build and
        the list of InstallRequirement that failed to build.
    z*Building wheels for collected packages: %sz, c             s   s   | ]}|j V  qd S )N)r/   ).0r(   r%   r%   r&   	<genexpr>R  s    zbuild.<locals>.<genexpr>NzSuccessfully built %s c             S   s   g | ]
}|j qS r%   )r/   )rx   r(   r%   r%   r&   
<listcomp>o  s    zbuild.<locals>.<listcomp>zFailed to build %sc             S   s   g | ]
}|j qS r%   )r/   )rx   r(   r%   r%   r&   r{   t  s    )r-   r.   rk   r   r/   r:   rH   rc   r1   permit_editable_wheelsr   r   r8   	file_pathlocal_file_pathr,   append)
rw   rD   rZ   r[   r\   Zbuild_successesbuild_failuresr(   rE   Z
wheel_filer%   r%   r&   build@  s@    




r   )M__doc__loggingos.pathrL   rerl   typingr   r   r   r   r   r   pip._vendor.packaging.utilsr   r	   Zpip._vendor.packaging.versionr
   r   pip._internal.cacher   pip._internal.exceptionsr   r   pip._internal.metadatar   r   pip._internal.models.linkr   pip._internal.models.wheelr   Z$pip._internal.operations.build.wheelr   Z-pip._internal.operations.build.wheel_editabler   Z+pip._internal.operations.build.wheel_legacyr   pip._internal.req.req_installr   pip._internal.utils.loggingr   pip._internal.utils.miscr   r   r   $pip._internal.utils.setuptools_buildr   pip._internal.utils.subprocessr   pip._internal.utils.temp_dirr   pip._internal.utils.urlsr   pip._internal.vcsr   	getLogger__name__r-   compile
IGNORECASEr#   r"   BinaryAllowedPredicateZBuildResultrP   r'   r4   r6   r7   rC   rH   r5   rX   rc   ra   rp   r   r%   r%   r%   r&   <module>   s    
	2 A