
þîh  ã               @   sþ   d  d l  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 d  d l 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 e e ƒ Z Gd d „  d e
 ƒ Z d S)é    N)ÚValues)ÚPath)Ú
WheelCache)Ú
cmdoptions)ÚRequirementCommandÚwith_cleanup)ÚSUCCESS)ÚPylockÚis_valid_pylock_file_name)Úget_build_tracker)Úcheck_legacy_setup_py_options)Ú	getLogger)Úget_pip_version)ÚTempDirectoryc               @   sV   e  Z d  Z d Z d Z d d d d � „  Z e e e e	 e
 d d d	 � „  ƒ Z d S)
ÚLockCommandaÖ  
    EXPERIMENTAL - Lock packages and their dependencies from:

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

    pip also supports locking from "requirements files", which provide an easy
    way to specify a whole environment to be installed.

    The generated lock file is only guaranteed to be valid for the current
    python version and platform.
    zô
      %prog [options] [-e] <local project path> ...
      %prog [options] <requirement specifier> [package-index-options] ...
      %prog [options] -r <requirements file> [package-index-options] ...
      %prog [options] <archive url/path> ...N)Úreturnc             C   sõ  |  j  j t j d d d d d d d d d d	 d
 d ƒƒ |  j  j t j ƒ  ƒ |  j  j t j ƒ  ƒ |  j  j t j ƒ  ƒ |  j  j t j ƒ  ƒ |  j  j t j ƒ  ƒ |  j  j t j	 ƒ  ƒ |  j  j t j
 ƒ  ƒ |  j  j t j ƒ  ƒ |  j  j t j ƒ  ƒ |  j  j t j ƒ  ƒ |  j  j t j ƒ  ƒ |  j  j t j ƒ  ƒ |  j  j t j ƒ  ƒ |  j  j t j ƒ  ƒ |  j  j t j ƒ  ƒ |  j  j t j ƒ  ƒ |  j  j t j ƒ  ƒ t j t j |  j ƒ } |  j j d | ƒ |  j j d |  j  ƒ d  S)Nz--outputz-oÚdestÚoutput_fileÚmetavarÚpathÚtypeÚdefaultzpylock.tomlÚhelpz7Lock file name (default=pylock.toml). Use - for stdout.r   )Úcmd_optsÚ
add_optionr   Z	PipOptionÚrequirementsÚconstraintsÚno_depsÚpreÚeditableÚsrcÚignore_requires_pythonZno_build_isolationÚ
use_pep517Zno_use_pep517Zcheck_build_depsZconfig_settingsÚ	no_binaryÚonly_binaryZprefer_binaryÚrequire_hashesZprogress_barÚmake_option_groupÚindex_groupÚparserÚinsert_option_group)ÚselfÚ
index_opts© r,   ú:/tmp/pip-build-zijwfla7/pip/pip/_internal/commands/lock.pyÚadd_options0   s>    	
zLockCommand.add_options)ÚoptionsÚargsr   c             C   s!  t  j d t ƒ  ƒ t  j d ƒ |  j | ƒ } |  j d | d | d | j ƒ } |  j t ƒ  ƒ } t	 d | j
 d d d	 d
 ƒ } |  j | | | | ƒ } t | | ƒ t | j ƒ } x | D] }	 d
 |	 _ q¼ W|  j d | d | d | d | d | d d d |  j ƒ }
 |  j d |
 d | d | d | d d d d
 d | j d d d | j ƒ 	} |  j | ƒ | j | d d
 ƒ} | j d k r�t j ƒ  } n4 t | j ƒ } t | ƒ s»t  j d | ƒ | j } t j | j j ƒ  d | ƒj ƒ  } | j d k r
t  j! j" | ƒ n | j# | d d ƒt$ S)NzUsing %szspip lock is currently an experimental command. It may be removed/changed in a future release without prior warning.r/   Úsessionr!   ÚdeleteÚkindÚinstallZglobally_managedTZtemp_build_dirÚbuild_trackerÚfinderÚuse_user_siteFÚ	verbosityÚpreparerÚwheel_cacheÚignore_installedZupgrade_strategyzto-satisfy-onlyr"   Zcheck_supported_wheelsú-z!%s is not a valid lock file name.Úbase_dirÚencodingzutf-8)%ÚloggerÚverboser   ÚwarningZget_default_sessionÚ_build_package_finderr!   Úenter_contextr   r   Úno_cleanZget_requirementsr   r   Ú	cache_dirZpermit_editable_wheelsZmake_requirement_preparerr8   Zmake_resolverr"   Ztrace_basic_infoÚresolver   r   Úcwdr
   Úparentr	   Zfrom_install_requirementsr   ÚvaluesZas_tomlÚsysÚstdoutÚwriteZ
write_textr   )r*   r/   r0   r1   r6   r5   Ú	directoryÚreqsr:   Úreqr9   ÚresolverÚrequirement_setr=   Zoutput_file_pathZpylock_tomlr,   r,   r-   Úrun[   sh    	
					zLockCommand.run)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úusager.   r   r   ÚlistÚstrÚintrR   r,   r,   r,   r-   r      s
   +r   )rJ   Úoptparser   Zpathlibr   Zpip._internal.cacher   Zpip._internal.clir   Zpip._internal.cli.req_commandr   r   Zpip._internal.cli.status_codesr   Zpip._internal.models.pylockr	   r
   Z,pip._internal.operations.build.build_trackerr   Zpip._internal.req.req_installr   Zpip._internal.utils.loggingr   Zpip._internal.utils.miscr   Zpip._internal.utils.temp_dirr   rS   r?   r   r,   r,   r,   r-   Ú<module>   s   