o $"b@sddlmZmZddlZddlZddlmZddlmZddl m Z ddl m Z ddl mZdd lmZmZGd d d eZeeGd d d eZdS))absolute_importunicode_literalsN)ABCMeta) add_metaclass)fs_supports_symlink)Path) ensure_text)Creator CreatorMetacs4eZdZfddZeddZeddZZS)ViaGlobalRefMetacs.tt|d|_d|_tsd|_dSdS)Nz(the filesystem does not supports symlink)superr __init__ copy_error symlink_errorrself __class__F/usr/lib/python3/dist-packages/virtualenv/create/via_global_ref/api.pyrs  zViaGlobalRefMeta.__init__cC|j SN)rrrrrcan_copyzViaGlobalRefMeta.can_copycCrr)rrrrr can_symlinkrzViaGlobalRefMeta.can_symlink)__name__ __module__ __qualname__rpropertyrr __classcell__rrrrr s   r csheZdZfddZeddZefddZddZd d Z d d Z fd dZ fddZ Z S)ViaGlobalRefApics*tt||||||_|j|_dSr)r r!r_should_symlinksymlinks system_siteenable_system_site_package)roptions interpreterrrrr#s  zViaGlobalRefApi.__init__cCst|ddt|dd}}|d|d}}dD]+}||kr"|nd}||kr*|nd}|dur7|dur7dS|dur>dS|durEdSqdS)NcopiesFr#)clizenv varfiledefaultT)getattr get_source)r&r(r#copy_srcsym_srclevels_optc_optrrrr"(szViaGlobalRefApi._should_symlinkcstt||||||jdddddd|}|js#|js#td|jr0|jdd dd d d|jrB|jd d |j dddddSdS)Nz--system-site-packagesF store_truer$zCgive the virtual environment access to the system site-packages dir)r+actiondesthelpz(neither symlink or copy method supportedz --symlinksTr#zZtry to use symlinks rather than copies, when symlinks are not the default for the platformz--copiesz --always-copyr(z[try to use copies rather than symlinks, even when symlinks are the default for the platform)r r!add_parser_arguments add_argumentadd_mutually_exclusive_grouprr RuntimeError)clsparserr'metaapp_datagrouprrrr79s:  z$ViaGlobalRefApi.add_parser_argumentscCs |dSr) install_patchrrrrcreateXs zViaGlobalRefApi.createcCsd|}|r0|jd}tdtt||d|jd}tdtt|||dSdS)Nz_virtualenv.pthz%create virtualenv import hook file %szimport _virtualenv_virtualenv.pyz create %s)env_patch_textpurelibloggingdebugrstr write_text)rtextpth dest_pathrrrr@[s   zViaGlobalRefApi.install_patchc Csh|jttjd}|}|dttj t |j t |j WdS1s-wYdS)zIPatch the distutils package to not be derailed by its configuration filesrBz"__SCRIPT_DIR__"N)r>ensure_extractedr__file__parent read_textreplacereprospathrelpathrG script_dirrD)r resolved_pathrIrrrrCes$$zViaGlobalRefApi.env_patch_textcstt|d|jfgS)Nglobal)r r!_argsr%rrrrrXkszViaGlobalRefApi._argscs&tt||jr dnd|jd<dS)Ntruefalsezinclude-system-site-packages)r r! set_pyenv_cfgr% pyenv_cfgrrrrr[nszViaGlobalRefApi.set_pyenv_cfg)rrrr staticmethodr" classmethodr7rAr@rCrXr[r rrrrr!!s   r!) __future__rrrErRabcrsixrvirtualenv.inforvirtualenv.util.pathrvirtualenv.util.sixrcreatorr r r r!rrrrs