Current File : //lib/python3.9/site-packages/pip/_internal/commands/__pycache__/install.cpython-39.pyc
a

[��f�l�@sHddlZddlZddlZddlZddlZddlmZmZddlm	Z	m
Z
mZddlm
Z
ddlmZddlmZddlmZddlmZmZmZdd	lmZmZdd
lmZmZddlmZddl m!Z!dd
l"m#Z#ddl$m%Z%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6m7Z7m8Z8m9Z9ddl:m;Z;ddl<m=Z=m>Z>ddl?m@Z@mAZAmBZBe4eC�ZDe#e@d�dd�ZEGdd�de�ZFd/eGeeHeeHeGeeHe
eHd �d!d"�ZIeeHeGeGd#�d$d%�ZJd0eeGeeHeeHeeHeGeGd&�d'd(�ZKe
e*ee
eHdd)�d*d+�ZLeMeGeGeHd,�d-d.�ZNdS)1�N)�
SUPPRESS_HELP�Values)�Iterable�List�Optional)�canonicalize_name)�
WheelCache)�
cmdoptions)�make_target_python)�RequirementCommand�warn_if_run_as_root�with_cleanup)�ERROR�SUCCESS)�CommandError�InstallationError)�
get_scheme)�get_environment)�
FormatControl)�ConflictDetails�check_install_conflicts)�install_given_reqs)�InstallRequirement)�get_requirement_tracker)�WINDOWS)�parse_distutils_args��test_writable_dir)�	getLogger)�
ensure_dir�get_pip_version�(protect_pip_from_modification_on_windows�write_output)�
TempDirectory)�running_under_virtualenv�virtualenv_no_global)�BinaryAllowedPredicate�build� should_build_for_install_command)�format_control�returncsttd��fdd�}|S)N)�reqr*cs t|jp
d�}��|�}d|vS)N�Zbinary)r�nameZget_allowed_formats)r+Zcanonical_nameZallowed_formats�r)��B/usr/lib/python3.9/site-packages/pip/_internal/commands/install.py�check_binary_allowed5s
z6get_check_binary_allowed.<locals>.check_binary_allowed)r�bool)r)r1r/r.r0�get_check_binary_allowed4sr3c@szeZdZdZdZdd�dd�Zeeee	e
d�dd	��Ze	ee
dd
�dd�Zeeeed
�dd�Zee	dd�dd�ZdS)�InstallCommandaI
    Install packages from:

    - PyPI (and other indexes) using requirement specifiers.
    - VCS project urls.
    - Local project directories.
    - Local or remote source archives.

    pip also supports installing from "requirements files", which provide
    an easy way to specify a whole environment to be installed.
    a%
      %prog [options] <requirement specifier> [package-index-options] ...
      %prog [options] -r <requirements file> [package-index-options] ...
      %prog [options] [-e] <vcs project url> ...
      %prog [options] [-e] <local project path> ...
      %prog [options] <archive url/path> ...N)r*cCsj|j�t���|j�t���|j�t���|j�t���|j�t���|jjddddddd�t�|j�|jjddd	d
d�|jjddd
t	d�|jjdddddd�|jjdddddd�|j�t�
��|jjdddd	dd�|jjdddddgdd�|jjddd	d d�|jjd!d"d#d	d$d�|j�t���|j�t���|j�t�
��|j�t���|j�t���|j�t���|jjd%d	d&d'd(d)�|jjd*d
d&d+d,�|jjd-d
d.d'd/d)�|jjd0d
d1d'd2d)�|j�t���|j�t���|j�t���|j�t���|j�t���t�tj|j�}|j�d3|�|j�d3|j�dS)4Nz-tz--target�
target_dir�dirz�Install packages into <dir>. By default this will not replace existing files/folders in <dir>. Use --upgrade to replace existing packages in <dir> with new versions.)�dest�metavar�default�helpz--user�
use_user_site�
store_truez�Install to the Python user install directory for your platform. Typically ~/.local/, or %APPDATA%\Python on Windows. (See the Python documentation for site.USER_BASE for full details.))r7�actionr:z	--no-user�store_falsez--root�	root_pathz=Install everything relative to this alternate root directory.z--prefix�prefix_pathzIInstallation prefix where lib, bin and other top-level folders are placedz-Uz	--upgrade�upgradez�Upgrade all specified packages to the newest available version. The handling of dependencies depends on the upgrade-strategy used.z--upgrade-strategy�upgrade_strategyzonly-if-neededZeageraGDetermines how dependency upgrading should be handled [default: %default]. "eager" - dependencies are upgraded regardless of whether the currently installed version satisfies the requirements of the upgraded package(s). "only-if-needed" -  are upgraded only when they do not satisfy the requirements of the upgraded package(s).)r7r9�choicesr:z--force-reinstall�force_reinstallz;Reinstall all packages even if they are already up-to-date.z-Iz--ignore-installed�ignore_installedz�Ignore the installed packages, overwriting them. This can break your system if the existing package is of a different version or was installed with a different package manager!z	--compile�compileTz'Compile Python source files to bytecode)r=r7r9r:z--no-compilez.Do not compile Python source files to bytecode)r=r7r:z--no-warn-script-location�warn_script_locationz0Do not warn when installing scripts outside PATHz--no-warn-conflicts�warn_about_conflictsz%Do not warn about broken dependenciesr)Zcmd_optsZ
add_optionr	�requirements�constraintsZno_depsZpreZeditableZadd_target_python_optionsr�src�ignore_requires_pythonZno_build_isolation�
use_pep517Z
no_use_pep517�install_options�global_optionsZ	no_binaryZonly_binaryZ
prefer_binaryZrequire_hashesZprogress_barZmake_option_groupZindex_group�parserZinsert_option_group)�selfZ
index_optsr/r/r0�add_optionsQs��
��������
�����zInstallCommand.add_options)�options�argsr*c)s.|jr|jdurtd��t�|�d}|jr2|j}tj|dd�|jpHg}t	�
dt��t|j|j
|j|j|jd�|_d}d}|jr�d|_tj�|j�|_tj�|j�r�tj�|j�s�td��tdd	�}|j}|�|�|jp�g}|�|�}t|�}	|j|||	|jd
�}
t|j|j�}|�t ��}t|j!ddd�}
�zx|�"|||
|�}|D]}d|_#�qLt$||j�|j%|
||||
|jd
�}|j&||
|||j|j|j|j'||j(d�
}|�)|
�|j*||jd�}z|�+d�}Wnt,�y�d}Yn0|j-du}t.|d�t/|
j���fdd�|j0�1�D�}t2||dggd�\}}dd�|D�}|�r^t3d�4d�5|����|D]}|j(�sbd|_6�qb|�7|�}d}|j8�o�|j9}|�r�|�:|�}|j;}|j�s�|j
�r�d}t<||||j||j
||j|j=d�	}t>|j||j|j
|jd�}t?|�} |j@tA�Bd�d�g}!|D]T}"|"jC}#z(| �D|#�}$|$du�rN|#�d|$jE��}#WntF�ydYn0|!�G|#��q|du�r�|jH||�I|�d�d �5|!�}%|%�r�tJd!|%�WnPtK�y�}&z6|jLd"k}'tM|&|'|j�}(t	jN|(|'d#�tOWYd}&~&Sd}&~&00|j�r$|�sJ�|�P|j||j�tQ�tRS)$Nz'Can not combine '--user' and '--target'zto-satisfy-onlyT)Zcheck_targetzUsing %s)r@r5r?�
isolated_modez=Target path exists but is not a directory, will not continue.�target)�kind)rS�session�
target_pythonrL�install)�deleterWZglobally_managed)Ztemp_build_dirrS�req_trackerrX�finderr;)
�preparerr]rS�wheel_cacher;rErLrDrBrM)Zcheck_supported_wheelsZpipF)�
modifying_pipcsg|]}t|��r|�qSr/)r(��.0�r�r1r/r0�
<listcomp>bs
�z&InstallCommand.run.<locals>.<listcomp>)r_ZverifyZ
build_optionsrOcSsg|]}|jr|j�qSr/)rMr-rar/r/r0rerszYCould not build wheels for {}, which is required to install pyproject.toml-based projectsz, i� )�root�home�prefixrGr;Z	pycompile)�userrgrfrh�isolatedr-)�key�-)�resolver_variant� zSuccessfully installed %s�)�exc_info)Sr;r5rr	Zcheck_install_build_globalrArBZcheck_dist_restrictionrN�logger�verboser �decide_user_installr@r?rUrE�os�path�abspath�exists�isdirr#�
enter_contextrOZget_default_sessionr
Z_build_package_finderrLrZ	cache_dirr)rZno_cleanZget_requirementsZpermit_editable_wheels�'reject_location_related_install_optionsZmake_requirement_preparerZ
make_resolverrDrMZtrace_basic_info�resolveZget_requirement�KeyErrorZsatisfied_byr!r3rI�valuesr'r�format�joinZlegacy_install_reasonZget_installation_orderZignore_dependenciesrH�_determine_conflictsrGrrF�get_lib_location_guessesr�sort�operator�
attrgetterr-Zget_distribution�version�	Exception�append�_warn_about_conflictsZdetermine_resolver_variantr"�OSError�	verbosity�create_os_error_message�errorr�_handle_target_dirrr))rQrSrTrBrN�target_temp_dirZtarget_temp_dir_pathrOrXrYr]r_r\Z	directoryZreqsr+r^ZresolverZrequirement_setZpip_reqr`Z
reqs_to_build�_Zbuild_failuresZpep517_build_failure_namesrc�
to_install�	conflictsZshould_warn_about_conflictsrGZ	installedZ
lib_locations�env�items�result�itemZinstalled_distZinstalled_descr��show_traceback�messager/rdr0�run�sV

����



��
��
�




��

���


�
��


�
�
�

�zInstallCommand.run)r5r�rAr*csNt|�g}td|jd�}|j}|j}|j}tj�|�rB|�|�tj�|�r`||kr`|�|�tj�|�rv|�|�|D]�}	t�	|	�D]�}
|	|kr�tj�
||
��t�fdd�|dd�D��r�q�tj�
||
�}tj�|��r0|s�t�
d|�q�tj�|��rt�
d|�q�tj�|��r&t�|�n
t�|�t�tj�
|	|
�|�q�qzdS)Nr,)rgc3s|]}|���VqdS�N)�
startswith)rb�s��ddirr/r0�	<genexpr>��z4InstallCommand._handle_target_dir.<locals>.<genexpr>���zKTarget directory %s already exists. Specify --upgrade to force replacement.z�Target directory %s already exists and is a link. pip will not automatically replace links, please remove if replacement is desired.)rrru�purelib�platlib�datartrwr��listdirr�anyrqZwarning�islinkrx�shutil�rmtree�remove�move)rQr5r�rAZlib_dir_list�schemeZpurelib_dirZplatlib_dirZdata_dirZlib_dirr�Ztarget_item_dirr/r�r0r��sH


��
z!InstallCommand._handle_target_dir)r�r*cCs.z
t|�WSty(t�d�YdS0dS)NzwError while checking for conflicts. Please file an issue on pip's issue tracker: https://github.com/pypa/pip/issues/new)rr�rq�	exception)rQr�r/r/r0r�s
�z#InstallCommand._determine_conflicts)�conflict_detailsrmr*c
Cs�|\}\}}|s|sdSg}|dkr0|�d�n|dks<J�|�d�|D]<}||d}||D]"}	dj|||	dd�}
|�|
�qbqJ|D]P}||d}||D]6\}}}
d	j|||
|||dkr�d
ndd�}
|�|
�q�q�t�d
�|��dS)N�legacyz�pip's legacy dependency resolver does not consider dependency conflicts when selecting packages. This behaviour is the source of the following dependency conflicts.z
2020-resolverz�pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.rz@{name} {version} requires {requirement}, which is not installed.ro)r-r��requirementzg{name} {version} requires {requirement}, but {you} have {dep_name} {dep_version} which is incompatible.�youzyou'll)r-r�r��dep_name�dep_versionr��
)r�r~rqZcriticalr)rQr�rmZpackage_set�missingZconflicting�partsZproject_namer�Z
dependencyr�r�r�r+r/r/r0r�sH������z$InstallCommand._warn_about_conflicts)�__name__�
__module__�__qualname__�__doc__�usagerRr
rr�str�intr�r#r2r�rrrr�r�r/r/r/r0r4=s  g�7�
�r4F)rirgrfrjrhr*cCs td|||||d�}|j|jgS)Nr,)rirgrfrjrh)rr�r�)rirgrfrjrhr�r/r/r0r�Os�r�)rfrjr*cCstdd�tt||d��D��S)Ncss|]}t|�VqdSr�r)rb�dr/r/r0r�bs�z)site_packages_writable.<locals>.<genexpr>�rfrj)�all�setr�r�r/r/r0�site_packages_writableas�r�)r;r@r5r?rUr*cCs�|dur|st�d�dS|rF|r*td��t�r8td��t�d�dS|dusRJ�|sZ|rht�d�dStjs|t�d	�dSt||d
�r�t�d�dSt�d�dS)
aZDetermine whether to do a user install based on the input options.

    If use_user_site is False, no additional checks are done.
    If use_user_site is True, it is checked for compatibility with other
    options.
    If use_user_site is None, the default behaviour depends on the environment,
    which is provided by the other arguments.
    Nz$Non-user install by explicit requestFzVCan not combine '--user' and '--prefix' as they imply different installation locationszZCan not perform a '--user' install. User site-packages are not visible in this virtualenv.z User install by explicit requestTz3Non-user install due to --prefix or --target optionz4Non-user install because user site-packages disabledr�z0Non-user install because site-packages writeablezMDefaulting to user installation because normal site-packages is not writeable)	rq�debugrr%r�site�ENABLE_USER_SITEr��info)r;r@r5r?rUr/r/r0rshs8
��



�rs)rIrSr*cCs�ttttd�dd�}g}|D]0}|j}t|�}|r |�d�||���|��q |rzt|�}|rz|�d�||�����|s�dStd�d�	|����dS)	z�If any location-changing --install-option arguments were passed for
    requirements or on the command-line, then show a deprecation warning.
    )�option_namesr*cSsdd�|D�S)NcSsg|]}d�|�dd���qS)z--{}r�rl)r~�replace)rbr-r/r/r0re�r�zSreject_location_related_install_options.<locals>.format_options.<locals>.<listcomp>r/)r�r/r/r0�format_options�sz?reject_location_related_install_options.<locals>.format_optionsz{!r} from {}z{!r} from command lineNz�Location-changing options found in --install-option: {}. This is unsupported, use pip-level options like --user, --prefix, --root, and --target instead.z; )
rr�rrNrr�r~�keysrr)rIrSr�Z	offendersr�rNZlocation_optionsr/r/r0rz�s0�����rz)r�r��using_user_siter*cCs�g}|�d�|s,|�d�|�t|��n
|�d�|dd7<|jtjkr�d}d}t�sz|sz|�|d|��g�n
|�|�|�d	�tr�|jtjkr�|j	r�t
|j	�d
kr�|�d�d�|���dS)
zrFormat an error message for an OSError

    It may occur anytime during the execution of the install command.
    z,Could not install packages due to an OSErrorz: �.r�r�z"Consider using the `--user` optionzCheck the permissionsz or z.
iz�HINT: This error might have occurred since this system does not have Windows Long Path support enabled. You can find information on how to enable this at https://pip.pypa.io/warnings/enable-long-paths
r,)
r�r��errnoZEACCESr$�extend�lowerr�ENOENT�filename�lenr�strip)r�r�r�r�Zuser_option_partZpermissions_partr/r/r0r��s>



��

�
����r�)FNNFN)NNNF)Or�r�rtr�r�Zoptparserr�typingrrrZpip._vendor.packaging.utilsrZpip._internal.cacherZpip._internal.clir	Zpip._internal.cli.cmdoptionsr
Zpip._internal.cli.req_commandrrr
Zpip._internal.cli.status_codesrrZpip._internal.exceptionsrrZpip._internal.locationsrZpip._internal.metadatarZ#pip._internal.models.format_controlrZpip._internal.operations.checkrrZpip._internal.reqrZpip._internal.req.req_installrZpip._internal.req.req_trackerrZpip._internal.utils.compatrZ"pip._internal.utils.distutils_argsrZpip._internal.utils.filesystemrZpip._internal.utils.loggingrZpip._internal.utils.miscrr r!r"Zpip._internal.utils.temp_dirr#Zpip._internal.utils.virtualenvr$r%Zpip._internal.wheel_builderr&r'r(r�rqr3r4r2r�r�r�rsrzr�r�r/r/r/r0�<module>s�	��	��>�(�