3 Ävh¤Tã @sdZddlmZddlmZddlmZmZddlmZmZm Z m Z ddl m Z m Z ddlmZmZddlmZdd lmZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd l Z dd l!Z!dd l"Z"dd l#Z#dd l$Z$dd l%Z%dd l&m'Z'dd l(m)Z)m*Z*dd l+m,Z,ddl-m.Z.ddl/m0Z0m1Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7ddl8m9Z9m:Z:m;Z;ddl4mm?Z?ddl@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOdd lPZ@ejQde@jRd�ddddddgZSdd „ZTd!d„ZUe'jV�r2d"d#„ZWd$d%„ZXnd&d#„ZWd'd%„ZXd(d)„ZYGd*d„de,ƒZZd+d,„Z[d-d.„Z\d/d0„Z]d1d„Z^d2d„Z_Gd3d„deGƒZ`Gd4d5„d5e`ƒZaejbjcd6d7ƒd8k�rºeaZ`d9d:„Zdd;d<„Zed=d>„Zfd?d@„ZgdpdAdB„ZhdCdD„ZidEdF„ZjdGejkk�rejZlndHdI„ZldqdKdL„ZmdMdN„ZndOdP„ZodQdR„ZpyddSlmqZrWnesk �r^dTdU„ZrYnXdVdW„ZqGdXdY„dYetƒZueujvƒZwGdZd[„d[euƒZxGd\d]„d]eyƒZzGd^d_„d_ezƒZ{Gd`da„dae{ƒZ|ezj}Z}ezj~Z~dbdc„Zddde„Z€dfeefdgdh„Z�didj„Z‚dkdl„Zƒdrdmd„Z„e"j…dndo„ƒZ†d S)sa% Easy Install ------------ A tool for doing automatic download/extract/build of distutils-based Python packages. For detailed documentation, see the accompanying EasyInstall.txt file, or visit the `EasyInstall home page`__. __ https://setuptools.readthedocs.io/en/latest/easy_install.html é)Úglob)Ú get_platform)Ú convert_pathÚ subst_vars)ÚDistutilsArgErrorÚDistutilsOptionErrorÚDistutilsErrorÚDistutilsPlatformError)ÚINSTALL_SCHEMESÚ SCHEME_KEYS)ÚlogÚdir_util)Ú first_line_re)Úfind_executableN)Úsix)Ú configparserÚmap)ÚCommand)Ú run_setup)Úget_pathÚget_config_vars)Ú rmtree_safe)Úsetopt)Úunpack_archive)Ú PackageIndexÚparse_requirement_argÚ URL_SCHEME)Ú bdist_eggÚegg_info)ÚWheel)Ú yield_linesÚnormalize_pathÚresource_stringÚensure_directoryÚget_distributionÚfind_distributionsÚ EnvironmentÚ RequirementÚ DistributionÚ PathMetadataÚ EggMetadataÚ WorkingSetÚDistributionNotFoundÚVersionConflictÚ DEVELOP_DISTÚdefault)ÚcategoryÚsamefileÚ easy_installÚPthDistributionsÚextract_wininst_cfgÚmainÚget_exe_prefixescCstjdƒdkS)NÚPé)ÚstructÚcalcsize©r;r;ú"/usr/lib/python3.6/easy_install.pyÚis_64bitIsr=cCsjtjj|ƒotjj|ƒ}ttjdƒo&|}|r:tjj||ƒStjjtjj|ƒƒ}tjjtjj|ƒƒ}||kS)z  Determine if two paths reference the same file. Augments os.path.samefile to work on Windows and suppresses errors if the path doesn't exist. r1)ÚosÚpathÚexistsÚhasattrr1ÚnormpathÚnormcase)Zp1Zp2Z both_existZ use_samefileZnorm_p1Znorm_p2r;r;r<r1MscCs|S)Nr;)Úsr;r;r<Ú _to_ascii_srEc Cs*ytj|dƒdStk r$dSXdS)NÚasciiTF)rZ text_typeÚ UnicodeError)rDr;r;r<Úisasciibs  rHcCs |jdƒS)NrF)Úencode)rDr;r;r<rEjsc Cs(y|jdƒdStk r"dSXdS)NrFTF)rIrG)rDr;r;r<rHms  cCstj|ƒjƒjddƒS)NÚ z; )ÚtextwrapÚdedentÚstripÚreplace)Útextr;r;r<ÚusrPc@s¶eZdZdZdZdZd´dµd¶d·d¸d¹dºd»d¼d½d¾d¿dÀdÁdÂdÃdÄdÅdÆdÇdÈgZdd dd dd0d3d9ddÍd’d“„Z?ejd”ƒj ƒZ@d•d–„ZAd—d˜„ZBd™dš„ZCd›dœ„ZDd�dž„ZEdŸd „ZFd¡d¢„ZGd£d¤„ZHejd¥ƒj ƒZId¦d§„ZJd¨d©„ZKdªd«„ZLeMeMd¬d­d®�d¯�ZNeMd°d±d®�ZOd²d³„ZPdS)Îr2z'Manage a download/build/install processz Find/get/install Python packagesTúprefix=Núinstallation prefixúzip-okÚzúinstall package as a zipfileú multi-versionÚmú%make apps have to require() a versionÚupgradeÚUú1force upgrade (searches PyPI for latest versions)ú install-dir=Údúinstall package to DIRú script-dir=rDúinstall scripts to DIRúexclude-scriptsÚxúDon't install scriptsú always-copyÚaú'Copy all needed packages to install dirú index-url=Úiú base URL of Python Package Indexú find-links=Úfú(additional URL(s) to search for packagesúbuild-directory=Úbú/download/extract/build in DIR; keep the resultsú optimize=ÚOúlalso compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0]úrecord=ú3filename in which to record list of installed filesú always-unzipÚZú*don't install as a zipfile, no matter whatú site-dirs=ÚSú)list of directories where .pth files workÚeditableÚeú+Install specified packages in editable formúno-depsÚNúdon't install dependenciesú allow-hosts=ÚHú$pattern(s) that hostnames must matchúlocal-snapshots-okÚlú(allow building eggs from local checkoutsÚversionú"print version information and exitú no-find-linksú9Don't load find-links defined in packages being installedz!install in user site-package '%s'ÚusercCs,d|_d|_|_d|_|_|_d|_d|_d|_d|_ d|_ |_ d|_ |_ |_d|_|_|_d|_|_|_d|_d|_d|_d|_d|_d|_d|_d|_d|_tjrÌtj |_!tj"|_#n d|_!d|_#d|_$d|_%d|_&|_'d|_(i|_)d|_*d|_+|j,j-|_-|j,j.||j,j/dƒƒdS)NrFr2)0r‹Úzip_okÚlocal_snapshots_okÚ install_dirÚ script_dirÚexclude_scriptsÚ index_urlÚ find_linksÚbuild_directoryÚargsÚoptimizeÚrecordrYÚ always_copyÚ multi_versionr{Úno_depsÚ allow_hostsÚrootÚprefixÚ no_reportr‡Úinstall_purelibÚinstall_platlibÚinstall_headersÚ install_libÚinstall_scriptsÚ install_dataÚ install_baseÚinstall_platbaseÚsiteÚENABLE_USER_SITEÚ USER_BASEÚinstall_userbaseÚ USER_SITEÚinstall_usersiteÚ no_find_linksÚ package_indexÚpth_fileÚalways_copy_fromÚ site_dirsÚinstalled_projectsÚsitepy_installedZ_dry_runÚ distributionÚverboseZ_set_command_optionsÚget_option_dict)Úselfr;r;r<Úinitialize_options¨sF     zeasy_install.initialize_optionscCs"dd„|Dƒ}tt|j|ƒƒdS)Ncss*|]"}tjj|ƒstjj|ƒr|VqdS)N)r>r?r@Úislink)Ú.0Úfilenamer;r;r<ú Úsz/easy_install.delete_blockers..)ÚlistrÚ _delete_path)r¶ÚblockersZextant_blockersr;r;r<Údelete_blockersØszeasy_install.delete_blockerscCsJtjd|ƒ|jrdStjj|ƒo.tjj|ƒ }|r8tntj}||ƒdS)Nz Deleting %s) r ÚinfoÚdry_runr>r?Úisdirr¸ÚrmtreeÚunlink)r¶r?Zis_treeZremoverr;r;r<r½ßs  zeasy_install._delete_pathcCs6tjdd…}tdƒ}d}t|jftƒŽƒtƒ‚dS)zT Render the Setuptools version and installation details, then exit. NéÚ setuptoolsz=setuptools {dist.version} from {dist.location} (Python {ver}))Úsysr‡r$ÚprintÚformatÚlocalsÚ SystemExit)ZverÚdistÚtmplr;r;r<Ú_render_versionès zeasy_install._render_versionc Cst|jo |jƒtjjƒd}tddƒ\}}|jjƒ|jjƒ|jjƒ||dd…|d|d||||t tddƒdœ |_ t j r”|j |j d <|j|j d <|jƒ|jƒ|jƒ|jd d d dƒ|jdkrÎ|j|_|jdkrÞd|_|jdd!ƒ|jdd"ƒ|j�r|j�r|j|_|j|_|jdd#ƒtttjƒ}tƒ|_|jdk �r°dd„|jjdƒDƒ}xV|D]N}t jj!|ƒ�s~t"j#d|ƒn,t|ƒ|k�ršt$|dƒ‚n|jj%t|ƒƒ�q^W|j&�sÀ|j'ƒ|j(�pÊd|_(|jdd…|_)x4|jt|jƒfD] }||j)k�rð|j)j*d|ƒ�qðW|j+dk �r8dd„|j+jdƒDƒ}ndg}|j,dk�r`|j-|j(|j)|d�|_,t.|j)tjƒ|_/|j0dk �rœt1|j0t2j3ƒ�r¢|j0jƒ|_0ng|_0|j4�r¾|j,j5|j)tjƒ|j�sÔ|j,j6|j0ƒ|jdd$ƒt1|j7t8ƒ�s@y2t8|j7ƒ|_7d|j7k�odkn�st9‚Wnt9k �r>t$dƒ‚YnX|j&�rZ|j: �rZt;dƒ‚|j<�sjt;d ƒ‚g|_=dS)%NrrœÚ exec_prefixrÅéÚabiflagsÚ) Z dist_nameZ dist_versionZ dist_fullnameÚ py_versionÚpy_version_shortÚpy_version_nodotZ sys_prefixrœZsys_exec_prefixrÏrÑÚuserbaseZusersiterŽr�r“r°Fr¡r¢Úinstallr–cSsg|]}tjj|jƒƒ‘qSr;)r>r?Ú expanduserrM)r¹rDr;r;r<ú 3sz1easy_install.finalize_options..ú,z"%s (in --site-dirs) does not existz$ (in --site-dirs) is not on sys.pathzhttps://pypi.org/simple/cSsg|] }|jƒ‘qSr;)rM)r¹rDr;r;r<rÙHsÚ*)Z search_pathÚhostsr•z--optimize must be 0, 1, or 2z9Must specify a build directory (-b) when using --editablez:No urls, filenames, or requirements specified (see --help))rŽrŽ)rŽr�)r–r–)r•r•)>r‡rÎrÇÚsplitrr³Zget_nameZ get_versionZ get_fullnameÚgetattrÚ config_varsr¦r§r©r«Ú_fix_install_dir_for_user_siteÚexpand_basedirsÚ expand_dirsÚ_expandr�rŽr¬Zset_undefined_optionsr‹ržr¢rr!r?Ú get_site_dirsÚ all_site_dirsr°r>rÂr ÚwarnrÚappendr{Úcheck_site_dirr‘Ú shadow_pathÚinsertršr­Ú create_indexr&Ú local_indexr’Ú isinstancerZ string_typesr�Zscan_egg_linksÚadd_find_linksr•ÚintÚ ValueErrorr“rr”Úoutputs) r¶rÓrœrÏrBr°r]Z path_itemrÜr;r;r<Úfinalize_optionsós¨                zeasy_install.finalize_optionscCs`|j stj rdS|jƒ|jdkr2d}t|ƒ‚|j|_|_tj j ddƒd}|j |ƒdS)z; Fix the install_dir if "--user" was used. Nz$User base directory is not specifiedÚposixZunixZ_user) r‹r¦r§Úcreate_home_pathr©r r¤r¥r>ÚnamerNÚ select_scheme)r¶ÚmsgZ scheme_namer;r;r<ràms z+easy_install._fix_install_dir_for_user_sitecCs\xV|D]N}t||ƒ}|dk rtjdks0tjdkrrõr?rØrrßÚsetattr)r¶ÚattrsÚattrÚvalr;r;r<Ú _expand_attrs|s    zeasy_install._expand_attrscCs|jdddgƒdS)zNCalls `os.path.expanduser` on install_base, install_platbase and root.r¤r¥r›N)rý)r¶r;r;r<rá…szeasy_install.expand_basedirscCsddddddg}|j|ƒdS)z+Calls `os.path.expanduser` on install dirs.ržrŸr¡r r¢r£N)rý)r¶Údirsr;r;r<râŠszeasy_install.expand_dirsc CsÊ|j|jjkrtj|jƒzšx|jD]}|j||j ƒq$W|jrª|j}|j r‚t |j ƒ}x(t t |ƒƒD]}|||d…||<qfWddl m }|j|j|j|fd|jƒ|jƒWdtj|jjƒXdS)Nr)Ú file_utilz'writing list of installed files to '%s')r´r³r Ú set_verbosityr”r2r™r–rñr›ÚlenÚrangeÚ distutilsrÿÚexecuteZ write_fileÚwarn_deprecated_options)r¶ÚspecrñZroot_lenZcounterrÿr;r;r<Úrun–s$       zeasy_install.runc CsDy tjƒ}Wn"tk r.tjdtjƒ}YnXtjj|j d|ƒS)zÈReturn a pseudo-tempname base in the install directory. This code is intentionally naive; if a malicious party can write to the target directory you're already in deep doodoo. rztest-easy-install-%s) r>ÚgetpidÚ ExceptionÚrandomZrandintrÇÚmaxsizer?ÚjoinrŽ)r¶Úpidr;r;r<Úpseudo_tempname­s  zeasy_install.pseudo_tempnamecCsdS)Nr;)r¶r;r;r<r¸sz$easy_install.warn_deprecated_optionscCsdt|jƒ}tjj|dƒ}tjj|ƒsTytj|ƒWn ttfk rR|j ƒYnX||j k}| rv|j rv|j ƒ}nd|j ƒd}tjj|ƒ}y*|ržtj|ƒt|dƒjƒtj|ƒWn ttfk rØ|j ƒYnX| rô|j rôt|jƒƒ‚|�r|jdk�rt||j ƒ|_nd|_|tttƒƒk�r6d|_n$|j �rZtjj|ƒ �rZd|_d|_||_dS)z;Verify that self.install_dir is .pth-capable dir, if neededzeasy-install.pthz .write-testÚwNT)r!rŽr>r?r r@ÚmakedirsÚOSErrorÚIOErrorÚcant_write_to_targetrår˜Úcheck_pth_processingrrÄÚopenÚcloserÚno_default_version_msgr®r3rÚ _pythonpathr²)r¶Úinstdirr®Z is_site_dirZtestfileZ test_existsr;r;r<rè»s>         zeasy_install.check_site_diraS can't create or remove files in install directory The following error occurred while trying to add or remove files in the installation directory: %s The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was: %s zÀ This directory does not currently exist. Please create it and try again, or choose a different installation directory (using the -d or --install-dir option). a« Perhaps your account does not have write access to this directory? If the installation directory is a system-owned directory, you may need to sign in as the administrator or "root" account. If you do not have administrative access to this machine, you may wish to choose a different installation directory, preferably one that is listed in your PYTHONPATH environment variable. For information on other options, you may wish to consult the documentation at: https://setuptools.readthedocs.io/en/latest/easy_install.html Please make the appropriate changes for your system and try again. cCsP|jtjƒd|jf}tjj|jƒs6|d|j7}n|d|j7}t |ƒ‚dS)NérJ) Ú_easy_install__cant_write_msgrÇÚexc_inforŽr>r?r@Ú_easy_install__not_exists_idÚ_easy_install__access_msgr)r¶r÷r;r;r<rs z!easy_install.cant_write_to_targetc Cs¦|j}tjd|ƒ|jƒd}|d}tjj|ƒ}tdƒd}y8|rNtj|ƒtjj |ƒ}t j j |dd�t |dƒ}Wn ttfk r–|jƒYnøXz´|j|jftƒŽƒ|jƒd }tj}tjd k�rtjj|ƒ\}} tjj|d ƒ} | jƒd k�otjj| ƒ} | �r| }d dlm} | |dddgd ƒtjj|ƒ�rJtjd|ƒdSWd |�r\|jƒtjj|ƒ�rttj|ƒtjj|ƒ�rŒtj|ƒX|j�s¢tjd|ƒdS)z@Empirically verify whether .pth files are supported in inst. dirz Checking .pth file support in %sz.pthz.okzz import os f = open({ok_file!r}, 'w') f.write('OK') f.close() rJT)Úexist_okrNrøz pythonw.exez python.exer)Úspawnz-Ez-cÚpassz-TEST PASSED: %s appears to support .pth filesz+TEST FAILED: %s does NOT support .pth filesF)rŽr rÀrr>r?r@Ú _one_linerrÄÚdirnameÚ pkg_resourcesZ py31compatrrrrrÚwriterÉrÊrrÇÚ executablerõrÝr ÚlowerÚdistutils.spawnr r˜ræ) r¶rr®Zok_fileZ ok_existsrÍr#rkr&ÚbasenameZaltZuse_altr r;r;r<rsV            z!easy_install.check_pth_processingcCs\|j rN|jdƒrNx:|jdƒD],}|jd|ƒr2q|j|||jd|ƒƒqW|j|ƒdS)z=Write all the scripts for `dist`, unless scripts are excludedÚscriptszscripts/N)r�Zmetadata_isdirZmetadata_listdirÚinstall_scriptZ get_metadataÚinstall_wrapper_scripts)r¶rÌÚ script_namer;r;r<Úinstall_egg_scriptsSsz easy_install.install_egg_scriptscCs\tjj|ƒrLxJtj|ƒD].\}}}x"|D]}|jjtjj||ƒƒq(WqWn |jj|ƒdS)N)r>r?rÂÚwalkrñrçr )r¶r?ÚbaserþÚfilesrºr;r;r<Ú add_outputas    zeasy_install.add_outputcCs|jrtd|fƒ‚dS)NzjInvalid argument %r: you can't use filenames or URLs with --editable (except via the --find-links option).)r{r)r¶rr;r;r<Ú not_editableiszeasy_install.not_editablecCs<|js dStjjtjj|j|jƒƒr8td|j|jfƒ‚dS)Nz2%r already exists in %s; can't do a checkout there)r{r>r?r@r r“Úkeyr)r¶rr;r;r<Úcheck_editableqs zeasy_install.check_editablec cs@tjtjdƒd�}zt|ƒVWdtjj|ƒo8tt |ƒƒXdS)Nz easy_install-)rœ) ÚtempfileÚmkdtemprÚuÚstrr>r?r@rÃr)r¶Útmpdirr;r;r<Ú_tmpdir{szeasy_install._tmpdirFcCs|js|jƒ|jƒ�ô}t|tƒs„t|ƒrT|j|ƒ|jj||ƒ}|j d|||dƒSt j j |ƒr||j|ƒ|j d|||dƒSt |ƒ}|j|ƒ|jj|||j|j|j |jƒ}|dkrÖd|}|jrÌ|d7}t|ƒ‚n0|jtkrô|j|||dƒ|S|j ||j||ƒSWdQRXdS)NTz+Could not find suitable distribution for %rz2 (--always-copy skips system and development eggs)ÚUsing)r{Úinstall_site_pyr;rír'rr3r­ÚdownloadÚ install_itemr>r?r@rr5Zfetch_distributionrYr—rìrZ precedencer.Úprocess_distributionÚlocation)r¶rÚdepsr:ÚdlrÌr÷r;r;r<r2„s2         zeasy_install.easy_installcCs|p|j}|ptjj|ƒ|k}|p,|jdƒ }|pT|jdk oTtjjt|ƒƒt|jƒk}|r†| r†x$|j|jD]}|j |krnPqnWd}t j dtjj |ƒƒ|rÊ|j |||ƒ}x<|D]}|j|||ƒq²Wn |j|ƒg}|j||d|dƒ|dk �rx|D]}||krú|SqúWdS)Nz.eggTz Processing %srr<)r—r>r?r#Úendswithr¯r!rìÚ project_namerAr rÀr)Ú install_eggsr@Úegg_distribution)r¶rr>r:rBZinstall_neededrÌZdistsr;r;r<r?¨s.         zeasy_install.install_itemcCs@t|}x2tD]*}d|}t||ƒdkrt||||ƒqWdS)z=Sets the install directories by applying the install schemes.Zinstall_N)r r rÞrù)r¶rõÚschemer4Zattrnamer;r;r<röÌs  zeasy_install.select_schemecGs¾|j|ƒ|jj|ƒ||j|jkr2|jj|ƒ|jj|ƒ|j|ƒ||j|j<tj |j ||f|žŽƒ|j dƒr�|j r�|jj |jdƒƒ| r¢|j r¢dS|dk rÆ|j|jkrÆtjd|ƒdS|dksÖ||krê|jƒ}tt|ƒƒ}tj d|ƒytgƒj|g|j|jƒ}Wn^tk �rB}ztt|ƒƒ‚WYdd}~Xn0tk �rp}zt|jƒƒ‚WYdd}~XnX|j�s‚|j�r®x*|D]"}|j|jk�rˆ|j|jƒƒ�qˆWtj d|ƒdS)Nzdependency_links.txtzSkipping dependencies for %szProcessing dependencies for %sz'Finished processing dependencies for %s)Ú update_pthr­Úaddrìr4Úremover.r±r rÀÚinstallation_reportÚ has_metadatar¬rîZget_metadata_linesr—ræÚas_requirementr'r9r+Zresolver2r,rr-Zreportr¯)r¶Z requirementrÌrBrÀZdistreqZdistrosr|r;r;r<r@ÕsB            z!easy_install.process_distributioncCs2|jdk r|j S|jdƒr dS|jdƒs.dSdS)Nz not-zip-safeTzzip-safeF)rŒrM)r¶rÌr;r;r<Ú should_unzipüs   zeasy_install.should_unzipcCs¶tjj|j|jƒ}tjj|ƒr:d}tj||j|j|ƒ|Stjj|ƒrL|}nRtjj |ƒ|krftj |ƒtj |ƒ}t |ƒdkržtjj||dƒ}tjj|ƒrž|}t |ƒtj||ƒ|S)Nz<%r already exists in %s; build directory %s will not be keptrr)r>r?r r“r4r@r rærÂr#rÄÚlistdirrr#ÚshutilÚmove)r¶rÚ dist_filenameÚ setup_baseÚdstr÷Úcontentsr;r;r<Ú maybe_moves"       zeasy_install.maybe_movecCs0|jr dSx tjƒj|ƒD]}|j|ŽqWdS)N)r�Ú ScriptWriterÚbestÚget_argsÚ write_script)r¶rÌr”r;r;r<r,sz$easy_install.install_wrapper_scriptscCsNt|jƒƒ}t||ƒ}|r8|j|ƒtƒ}tj|ƒ|}|j|t|ƒdƒdS)z/Generate a legacy script wrapper and install itrnN) r9rNÚis_python_scriptÚ_load_templaterÊrXÚ get_headerr[rE)r¶rÌr-Ú script_textÚdev_pathrZ is_scriptZbodyr;r;r<r+"s   zeasy_install.install_scriptcCs(d}|r|jddƒ}td|ƒ}|jdƒS)z‰ There are a couple of template scripts in the package. This function loads one of them and prepares it for use. z script.tmplz.tmplz (dev).tmplrÆzutf-8)rNr"Údecode)r`rõZ raw_bytesr;r;r<r],s   zeasy_install._load_templateÚtc s¦ˆj‡fdd„|Dƒƒtjd|ˆjƒtjjˆj|ƒ}ˆj|ƒˆjrLdSt ƒ}t |ƒtjj |ƒrptj |ƒt |d|ƒ�}|j|ƒWdQRXt|d|ƒdS)z1Write an executable file to the scripts directorycsg|]}tjjˆj|ƒ‘qSr;)r>r?r r�)r¹rb)r¶r;r<rÙ>sz-easy_install.write_script..zInstalling %s script to %sNriÿ)r¿r rÀr�r>r?r r2rÁÚ current_umaskr#r@rÄrr%Úchmod)r¶r-rVÚmoder¾ÚtargetÚmaskrkr;)r¶r<r[;s   zeasy_install.write_scriptcCs`|jƒjdƒr|j||ƒgS|jƒjdƒr8|j||ƒgS|jƒjdƒrT|j||ƒgS|}tjj|ƒr€|jdƒ r€t|||j ƒntjj |ƒr˜tjj |ƒ}|j |ƒr¾|j r¾|dk r¾|j|||ƒ}tjj|dƒ}tjj|ƒ�s2ttjj|ddƒƒ}|�stdtjj |ƒƒ‚t|ƒdk�r*td tjj |ƒƒ‚|d }|j�rPtj|j||ƒƒgS|j||ƒSdS) Nz.eggz.exez.whlz.pyzsetup.pyrÛz"Couldn't find a setup script in %srzMultiple setup scripts in %sr)r'rDÚ install_eggÚ install_exeÚ install_wheelr>r?ÚisfilerÚunpack_progressrÂÚabspathÚ startswithr“rWr r@rrrr{r rÀÚreport_editableÚbuild_and_install)r¶rrSr:rTÚ setup_scriptZsetupsr;r;r<rFOs<   zeasy_install.install_eggscCs>tjj|ƒr"t|tjj|dƒƒ}nttj|ƒƒ}tj ||d�S)NzEGG-INFO)Úmetadata) r>r?rÂr)r r*Ú zipimportÚ zipimporterr(Z from_filename)r¶Úegg_pathrrr;r;r<rG{s    zeasy_install.egg_distributionc Cs�tjj|jtjj|ƒƒ}tjj|ƒ}|js2t|ƒ|j|ƒ}t ||ƒ�s|tjj |ƒrttjj |ƒ rtt j ||jd�n"tjj|ƒr–|jtj|fd|ƒyÀd}tjj |ƒrÎ|j|ƒrÀtjd}}n tjd}}nL|j|ƒrð|j|ƒ|jd}}n*d}|j|ƒ�rtjd}}n tjd}}|j|||f|dtjj|ƒtjj|ƒfƒt||d �Wn$tk �rzt|dd �‚YnX|j|ƒ|j|ƒS) N)rÁz Removing FZMovingZCopyingZ ExtractingTz %s to %s)Úfix_zipimporter_caches)r>r?r rŽr)rmrÁr#rGr1rÂr¸r Ú remove_treer@rrÄrnrQrRZcopytreerOZmkpathÚunpack_and_compileZcopy2r#Úupdate_dist_cachesr r2)r¶rur:Ú destinationrÌZnew_dist_is_zippedrkrWr;r;r<rhƒsT               zeasy_install.install_eggc sTt|ƒ}|dkrtd|ƒ‚td|jddƒ|jddƒtƒd�}tjj||jƒdƒ}||_ |d}tjj|dƒ}tjj|d ƒ}t |ƒt ||ƒ|_ |j ||ƒtjj|ƒ�st|d ƒ} | jd ƒx<|jdƒD].\} } | d krÌ| jd | jddƒjƒ| fƒqÌW| jƒtjj|dƒ‰|j‡fdd„tj|ƒDƒƒtj|||j|jd�|j||ƒS)Nz(%s is not a valid distutils Windows .exerrrõr‡)rEr‡Úplatformz.eggz.tmpzEGG-INFOzPKG-INFOrzMetadata-Version: 1.0 Útarget_versionz%s: %s Ú_ú-r*csg|]}tjjˆ|dƒ‘qS)r)r>r?r )r¹r”)r�r;r<rÙÜsz,easy_install.install_exe..)r´rÁ)r4rr(Úgetrr>r?r Úegg_namerAr#r)Z _providerÚ exe_to_eggr@rr%ÚitemsrNÚtitlerr¿rXrZrZ make_zipfiler´rÁrh) r¶rSr:ÚcfgrÌruÚegg_tmpZ _egg_infoZpkg_infrkÚkÚvr;)r�r<ri¹s<      " zeasy_install.install_exec s>t|ƒ‰g‰g‰i‰‡‡‡‡‡fdd„}t|ˆ|ƒg}xtˆD]l}|jƒjdƒr>|jdƒ}|d}tj|dƒd|d<tjj ˆf|žŽ}ˆj |ƒ|j |ƒtj ||ƒq>W|j ˆƒtj tjj ˆdƒtjˆ|ƒƒxbdD]Z} tƒ| rÜtjj ˆd| d ƒ} tjj| ƒsÜt| d ƒ} | jd j tƒ| ƒd ƒ| jƒqÜWd S)z;Extract a bdist_wininst to the directories an egg would usecsø|jƒ}xÔˆD]Ì\}}|j|ƒr||t|ƒd…}|jdƒ}tjjˆf|žŽ}|jƒ}|jdƒsl|jdƒr¢tj |d ƒ|d <dˆtjj |dƒd<ˆj |ƒn4|jdƒrÖ|dkrÖdˆtjj |dƒd<ˆj |ƒ|SqW|jdƒsôt j d |ƒdS) Nú/z.pydz.dllrrz.pyzSCRIPTS/z.pthzWARNING: can't process %séÿÿÿÿr‰)r'rnrrÝr>r?r rDrÚ strip_moduleÚsplitextrçr ræ)ÚsrcrUrDÚoldÚnewÚpartsrC)r…Ú native_libsÚprefixesÚ to_compileÚ top_levelr;r<Úprocessîs$      z(easy_install.exe_to_egg..processz.pydrˆrz.pyzEGG-INFOr“r�z.txtrrJNr‰r‰r‰)r“r�)r6rr'rDrÝrrŠr>r?r rçZ write_stubÚ byte_compileZwrite_safety_flagZ analyze_eggrÊr@rr%r) r¶rSr…r”ZstubsÚresr�ZresourceZpyfilerõZtxtrkr;)r…r�r‘r’r“r<r�æs6           zeasy_install.exe_to_eggc Csât|ƒ}|jƒst‚tjj|j|jƒƒ}tjj|ƒ}|j sBt |ƒtjj |ƒrntjj |ƒ rnt j||j d�n"tjj|ƒr�|jtj|fd|ƒz.|j|j|fdtjj|ƒtjj|ƒfƒWdt|dd�X|j|ƒ|j|ƒS)N)rÁz Removing zInstalling %s to %sF)rv)rZ is_compatibleÚAssertionErrorr>r?r rŽr€rmrÁr#rÂr¸r rwr@rrÄZinstall_as_eggr)r#ryr2rG)r¶Z wheel_pathr:Zwheelrzr;r;r<rjs.      zeasy_install.install_wheela( Because this distribution was installed --multi-version, before you can import modules from this package in an application, you will need to 'import pkg_resources' and then use a 'require()' call similar to one of these examples, in order to select the desired version: pkg_resources.require("%(name)s") # latest installed version pkg_resources.require("%(name)s==%(version)s") # this exact version pkg_resources.require("%(name)s>=%(version)s") # this version or higher zõ Note also that the installation directory must be on sys.path at runtime for this to work. (e.g. by being the application's script directory, by being on PYTHONPATH, or by being added to sys.path by your code.) Ú Installedc Cs`d}|jr@|j r@|d|j7}|jtttjƒkr@|d|j7}|j }|j }|j }d}|t ƒS)z9Helpful installation message for display to package usersz %(what)s %(eggloc)s%(extras)srJrÒ) r˜r�Ú_easy_install__mv_warningrŽrr!rÇr?Ú_easy_install__id_warningrArEr‡rÊ) r¶ZreqrÌZwhatr÷Zegglocrõr‡Zextrasr;r;r<rLIsz easy_install.installation_reportaR Extracted editable version of %(spec)s to %(dirname)s If it uses setuptools in its setup script, you can activate it in "development" mode by going to that directory and running:: %(python)s setup.py develop See the setuptools documentation for the "develop" command for more info. cCs"tjj|ƒ}tj}d|jtƒS)NrJ)r>r?r#rÇr&Ú_easy_install__editable_msgrÊ)r¶rrqr#Úpythonr;r;r<robs zeasy_install.report_editablecCsätjjdtƒtjjdtƒt|ƒ}|jdkrNd|jd}|jdd|ƒn|jdkrd|jddƒ|jrv|jdd ƒt j d |t |ƒdd…d j |ƒƒyt ||ƒWn6tk rÞ}ztd |jdfƒ‚WYdd}~XnXdS) Nzdistutils.command.bdist_eggzdistutils.command.egg_inforÐr‡rrr~z-qz-nz Running %s %sú zSetup script exited with %s)rÇÚmodulesÚ setdefaultrrr¼r´rêrÁr rÀrr rrËrr”)r¶rqrTr”r‡r;r;r<rgs      zeasy_install.run_setupc CsÄddg}tjdtjj|ƒd�}zŠ|jtjj|ƒƒ|j|ƒ|j|||ƒt|gƒ}g}x2|D]*}x$||D]}|j|j |j |ƒƒqlWq^W| r¦|j r¦t j d|ƒ|St|ƒt j|jƒXdS)Nrz --dist-dirz egg-dist-tmp-)rœÚdirz+No eggs found in %s (setup script problem?))r6r7r>r?r#Ú_set_fetcher_optionsrçrr&rhrArÁr rærÃrr´) r¶rqrTr”Zdist_dirZall_eggsZeggsr4rÌr;r;r<rp{s$   zeasy_install.build_and_installc Cst|jjdƒjƒ}d }i}x2|jƒD]&\}}||kr4q"|d||jdd ƒ<q"Wt|d �}tjj|d ƒ}t j ||ƒd S)a When easy_install is about to run bdist_egg on a source dist, that source dist might have 'setup_requires' directives, requiring additional fetching. Ensure the fetcher options given to easy_install are available to that command as well. r2r’r°r‘r•ršrr}r~)r2z setup.cfgN)r’r°r‘r•r°rš) r³rµÚcopyr‚rNÚdictr>r?r rZ edit_config) r¶r0Zei_optsZfetch_directivesZ fetch_optionsr4rüZsettingsZ cfg_filenamer;r;r<r¡“s  z!easy_install._set_fetcher_optionscCs0|jdkrdSxX|j|jD]H}|js2|j|jkrtjd|ƒ|jj|ƒ|j|jkr|jj|jƒqW|js¼|j|jjkrŠtjd|ƒn2tjd|ƒ|jj |ƒ|j|jkr¼|jj |jƒ|j �s,|jj ƒ|jdk�r,t jj|jdƒ}t jj|ƒ�rt j|ƒt|dƒ}|j|jj|jƒdƒ|jƒdS)Nz&Removing %s from easy-install.pth filez4%s is already the active version in easy-install.pthz"Adding %s to easy-install.pth filerÆzsetuptools.pthÚwtrJ)r®r4r˜rAr rÀrKréÚpathsrJrçrÁÚsaver>r?r rŽr¸rÄrr%Ú make_relativer)r¶rÌr]rºrkr;r;r<rI«s4           zeasy_install.update_pthcCstjd||ƒ|S)NzUnpacking %s to %s)r Údebug)r¶rŒrUr;r;r<rlÐszeasy_install.unpack_progresscshg‰g‰‡‡‡fdd„}t|||ƒˆjˆƒˆjsdx.ˆD]&}tj|ƒtjdBd@}t||ƒq:WdS)Ncs\|jdƒr"|jdƒ r"ˆj|ƒn|jdƒs6|jdƒr@ˆj|ƒˆj||ƒˆj rX|pZdS)Nz.pyz EGG-INFO/z.dllz.so)rDrnrçrlrÁ)rŒrU)r¶Úto_chmodr’r;r<ÚpfÙs    z+easy_install.unpack_and_compile..pfimií)rr•rÁr>ÚstatÚST_MODErd)r¶rurzrªrkrer;)r¶r©r’r<rxÕs   zeasy_install.unpack_and_compilec Csjtjr dSddlm}z@tj|jdƒ||dd|jd�|jrT|||jd|jd�Wdtj|jƒXdS)Nr)r•r)r•ÚforcerÁ) rÇÚdont_write_bytecodeÚdistutils.utilr•r rr´rÁr•)r¶r’r•r;r;r<r•ès zeasy_install.byte_compilea€ bad install directory or PYTHONPATH You are attempting to install a package to a directory that is not on PYTHONPATH and which Python does not read ".pth" files from. The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was: %s and your PYTHONPATH environment variable currently contains: %r Here are some of your options for correcting the problem: * You can choose a different installation directory, i.e., one that is on PYTHONPATH or supports .pth files * You can add the installation directory to the PYTHONPATH environment variable. (It must then also be on PYTHONPATH whenever you run Python and want to use the package(s) you are installing.) * You can set up the installation directory to support ".pth" files by using one of the approaches described here: https://setuptools.readthedocs.io/en/latest/easy_install.html#custom-installation-locations Please make the appropriate changes for your system and try again.cCs|j}||jtjjddƒfS)NÚ PYTHONPATHrÒ)Ú_easy_install__no_default_msgrŽr>Úenvironr)r¶Útemplater;r;r<rsz#easy_install.no_default_version_msgcCsÞ|jr dStjj|jdƒ}tddƒ}|jdƒ}d}tjj|ƒr€tj d|jƒt j |ƒ�}|j ƒ}WdQRX|j dƒs€td |ƒ‚||krÔtjd |ƒ|jsÈt|ƒt j |d dd ��}|j|ƒWdQRX|j|gƒd |_dS)z8Make sure there's a site.py in the target dir, if neededNzsite.pyrÆz site-patch.pyzutf-8rÒzChecking existing site.py in %sz def __boot():z;%s is not a setuptools-generated site.py; please remove it.z Creating %sr)ÚencodingT)r²r>r?r rŽr"rar@r r¨ÚiorÚreadrnrrÀrÁr#r%r•)r¶ZsitepyÚsourceZcurrentZstrmr;r;r<r=s,       zeasy_install.install_site_pycCsj|js dSttjjdƒƒ}xJtj|jƒD]:\}}|j|ƒr(tjj |ƒ r(|j d|ƒtj |dƒq(WdS)zCreate directories under ~.Nú~zos.makedirs('%s', 0o700)iÀ) r‹rr>r?rØrZ iteritemsrßrnrÂZ debug_printr)r¶Úhomerõr?r;r;r<rô>szeasy_install.create_home_pathz/$base/lib/python$py_version_short/site-packagesz $base/bin)rŽr�)róz$base/Lib/site-packagesz $base/ScriptscGsÄ|jdƒj}|jrh|jƒ}|j|d<|jjtj|jƒ}x0|j ƒD]$\}}t ||dƒdkr@t |||ƒq@Wddl m }xJ|D]B}t ||ƒ}|dk rz|||ƒ}tjdkr°tjj|ƒ}t |||ƒqzWdS)Nr×r0r)rró)Zget_finalized_commandrßrœr¢r rr>rõÚDEFAULT_SCHEMEr‚rÞrùr¯rr?rØ)r¶rúrßrHrûrürr;r;r<rãTs         zeasy_install._expand)rQNrR)rSrTrU)rVrWrX)rYrZr[)r\r]r^)r_rDr`)rarbrc)rdrerf)rgrhri)rjrkrl)rmrnro)rprqrr)rsNrt)rurvrw)rxryrz)r{r|r})r~rr€)r�r‚rƒ)r„r…r†)r‡Nrˆ)r‰NrŠ)F)F)T)N)r˜)QÚ__name__Ú __module__Ú __qualname__Ú__doc__Ú descriptionZcommand_consumes_argumentsZ user_optionsZboolean_optionsr¦r§rªZhelp_msgrçZ negative_optrrër·r¿r½Ú staticmethodrÎròràrýrárârrrrèrKrLÚlstriprrrrrr.r2r3r5Ú contextlibÚcontextmanagerr;r2r?rör@rOrWr,r+r]r[rFrGrhrir�rjr™ršrLr›rorrpr¡rIrlrxr•r±rr=rôr£r rºrãr;r;r;r<r2xsØ    0 z   0    ;  $ $ '  ,6-5   %    cCs tjjddƒjtjƒ}td|ƒS)Nr°rÒ)r>r²rrÝÚpathsepÚfilter)r‚r;r;r<rksrc CsŽg}|jtƒƒtjg}tjtjkr0|jtjƒxØ|D]Ð}|r6tjdkr`|jtjj |ddƒƒn\tj dkr¢|jtjj |ddtj dd …dƒtjj |dd ƒgƒn|j|tjj |ddƒgƒtjd kr6d |kr6tj j d ƒ}|r6tjj |ddtj dd …dƒ}|j|ƒq6Wtdƒtdƒf}x"|D]}||k�r |j|ƒ�q Wtj�rR|jtjƒy|jtjƒƒWntk �rzYnXttt|ƒƒ}|S)z& Return a list of 'site' dirs Úos2emxÚriscosZLibz site-packagesrˆÚlibrœNrÅz site-pythonÚdarwinzPython.frameworkÚHOMEÚLibraryÚPythonÚpurelibÚplatlib)rÆrÇ)ÚextendrrÇrœrÏrçr{r>r?r Úsepr‡r²rrr¦r§rªÚgetsitepackagesÚAttributeErrorr¼rr!)Úsitedirsr‘rœr¹Zhome_spZ lib_pathsZsite_libr;r;r<räpsV            räccsîi}xä|D]Ü}t|ƒ}||kr q d||<tjj|ƒs6q tj|ƒ}||fVxš|D]’}|jdƒs`qP|dkrjqPttjj||ƒƒ}tt |ƒƒ}|j ƒxP|D]H}|j dƒs–t|j ƒƒ}||kr–d||<tjj|ƒsÎq–|tj|ƒfVq–WqPWq WdS)zBYield sys.path directories that might contain "old-style" packagesrz.pthúeasy-install.pthúsetuptools.pthÚimportN)rÔrÕ) r!r>r?rÂrPrDrr r¼r rrnÚrstrip)ZinputsÚseenr#r1rõrkÚlinesÚliner;r;r<Ú expand_paths±s4           rÛc Cs&t|dƒ}�z tj|ƒ}|dkr$dS|d|d|d}|dkrHdS|j|dƒtjd|jdƒƒ\}}}|dkrzdS|j|d|ƒd d d œ}tj|ƒ}y<|j|ƒ} | j d d ƒd} | j t j ƒƒ} |j tj| ƒƒWntjk ròdSX|jdƒ �s|jdƒ �rdS|S|jƒXdS)znExtract configuration data from a bdist_wininst .exe Returns a configparser.RawConfigParser, or None ÚrbNé ééé zegg path translations for a given .exe fileúPURELIB/rÒúPLATLIB/pywin32_system32úPLATLIB/úSCRIPTS/úEGG-INFO/scripts/úDATA/lib/site-packagesrˆrÅrÐzPKG-INFOrz .egg-inforNz EGG-INFO/z.pthz -nspkg.pthÚPURELIBÚPLATLIBú\rÖz%s/%s/cSsg|]\}}|jƒ|f‘qSr;)r')r¹rbÚyr;r;r<rÙ$sz$get_exe_prefixes..)rírÒ)rîrÒ)rïrÒ)rðrñ)ròrÒ)rórô)räZZipFileZinfolistrºrÝrrDrêr Úupperr¶rZPY3rar rMrNrnrçrÚsortÚreverse)Z exe_filenamer‘rTrÀrõr�rVZpthr;r;r<r6s>     & c@sTeZdZdZdZffdd„Zdd„Zdd„Zed d „ƒZ d d „Z d d„Z dd„Z dS)r3z)A .pth file with Distribution paths in itFcCsp||_ttt|ƒƒ|_ttjj|jƒƒ|_|j ƒt j |gddƒx(t |j ƒD]}tt|jt|dƒƒƒqNWdS)NT)rºr¼rr!rÓr>r?r#ÚbasedirÚ_loadr&Ú__init__r r¥rJr%)r¶rºrÓr?r;r;r<rü/szPthDistributions.__init__cCsg|_d}tj|jƒ}tjj|jƒrÒt|jdƒ}x˜|D]�}|j dƒrJd}q6|j ƒ}|jj |ƒ|j ƒ s6|j ƒj dƒrxq6t tjj|j|ƒƒ}|jd<tjj|ƒ s¬||kr¾|jjƒd|_q6d||<q6W|jƒ|jrä| räd|_x&|joú|jdj ƒ �r |jjƒqæWdS) NFZrtrÖTú#rr‰r‰)r¥r£ÚfromkeysrÓr>r?rkrºrrnr×rçrMr!r rúr@ÚpopÚdirtyr)r¶Z saw_importrØrkrÚr?r;r;r<rû8s2        zPthDistributions._loadc Cs¶|js dStt|j|jƒƒ}|r„tjd|jƒ|j|ƒ}dj |ƒd}t j j |jƒr`t j |jƒt|jdƒ�}|j|ƒWdQRXn(t j j|jƒr¬tjd|jƒt j |jƒd|_dS)z$Write changed .pth file back to diskNz Saving %srJr¤zDeleting empty %sF)rr¼rr§r¥r r¨rºÚ _wrap_linesr r>r?r¸rÄrr%r@)r¶Z rel_pathsrÙÚdatarkr;r;r<r¦Ws   zPthDistributions.savecCs|S)Nr;)rÙr;r;r<rmszPthDistributions._wrap_linescCsN|j|jko$|j|jkp$|jtjƒk}|r>|jj|jƒd|_tj||ƒdS)z"Add `dist` to the distribution mapTN) rAr¥rÓr>Úgetcwdrçrr&rJ)r¶rÌÚnew_pathr;r;r<rJqs  zPthDistributions.addcCs6x$|j|jkr$|jj|jƒd|_qWtj||ƒdS)z'Remove `dist` from the distribution mapTN)rAr¥rKrr&)r¶rÌr;r;r<rKs zPthDistributions.removecCs”tjjt|ƒƒ\}}t|jƒ}|g}tjdkr2dp6tj}xVt|ƒ|krŠ||jkrn|jtj ƒ|j ƒ|j |ƒStjj|ƒ\}}|j|ƒq:W|SdS)Nrˆ) r>r?rÝr!rrúÚaltseprÐrçÚcurdirrùr )r¶r?ZnpathZlastZbaselenr�rÐr;r;r<r§†s    zPthDistributions.make_relativeN) r»r¼r½r¾rrürûr¦rÀrrJrKr§r;r;r;r<r3*s  c@s(eZdZedd„ƒZedƒZedƒZdS)ÚRewritePthDistributionsccs(|jVx|D] }|VqW|jVdS)N)ÚpreludeÚpostlude)ÚclsrÙrÚr;r;r<r—s  z#RewritePthDistributions._wrap_linesz? import sys sys.__plen = len(sys.path) zÐ import sys new = sys.path[sys.__plen:] del sys.path[sys.__plen:] p = getattr(sys, '__egginsert', 0) sys.path[p:p] = new sys.__egginsert = p + len(new) N)r»r¼r½Ú classmethodrr"rr r;r;r;r<r–s  rZSETUPTOOLS_SYS_PATH_TECHNIQUEÚrawZrewritecCs ttjtƒrtStjtjjƒƒS)z_ Return a regular expression based on first_line_re suitable for matching strings. )rírÚpatternr9ÚreÚcompilerar;r;r;r<Ú_first_line_re°s rcCsd|tjtjgkr.tjdkr.t|tjƒ||ƒStjƒ\}}}t j ||d|dd||ffƒdS)Nrørrz %s %s) r>rÄrKrõrdr«ÚS_IWRITErÇrrZreraise)ÚfuncÚargÚexcZetZevr}r;r;r<Ú auto_chmod¼s  rcCs.t|ƒ}t|tjƒ|r"t|ƒnt|ƒdS)aa Fix any globally cached `dist_path` related data `dist_path` should be a path of a newly installed egg distribution (zipped or unzipped). sys.path_importer_cache contains finder objects that have been cached when importing data from the original distribution. Any such finders need to be cleared since the replacement distribution might be packaged differently, e.g. a zipped egg distribution might get replaced with an unzipped egg folder or vice versa. Having the old finders cached may then cause Python to attempt loading modules from the replacement distribution using an incorrect loader. zipimport.zipimporter objects are Python loaders charged with importing data packaged inside zip archives. If stale loaders referencing the original distribution, are left behind, they can fail to load modules from the replacement distribution. E.g. if an old zipimport.zipimporter instance is used to load data from a new zipped egg archive, it may cause the operation to attempt to locate the requested data in the wrong location - one indicated by the original distribution's zip archive directory information. Such an operation may then fail outright, e.g. report having read a 'bad local file header', or even worse, it may fail silently & return invalid data. zipimport._zip_directory_cache contains cached zip archive directory information for all existing zipimport.zipimporter instances and all such instances connected to the same archive share the same cached directory information. If asked, and the underlying Python implementation allows it, we can fix all existing zipimport.zipimporter instances instead of having to track them down and remove them one by one, by updating their shared cached zip archive directory information. This, of course, assumes that the replacement distribution is packaged as a zipped egg. If not asked to fix existing zipimport.zipimporter instances, we still do our best to clear any remaining zipimport.zipimporter related cached data that might somehow later get used when attempting to load data from the new distribution and thus cause such load operations to fail. Note that when tracking down such remaining stale data, we can not catch every conceivable usage from here, and we clear only those that we know of and have found to cause problems if left alive. Any remaining caches should be updated by whomever is in charge of maintaining them, i.e. they should be ready to handle us replacing their zip archives with new distributions at runtime. N)r!Ú_uncacherÇÚpath_importer_cacheÚ!_replace_zip_directory_cache_dataÚ*_remove_and_clear_zip_directory_cache_data)Z dist_pathrvÚnormalized_pathr;r;r<ryÄs <  rycCsTg}t|ƒ}xB|D]:}t|ƒ}|j|ƒr|||d…tjdfkr|j|ƒqW|S)ap Return zipimporter cache entry keys related to a given normalized path. Alternative path spellings (e.g. those using different character case or those using alternative path separators) related to the same path are included. Any sub-path entries are included as well, i.e. those corresponding to zip archives embedded in other zip archives. rrÒ)rr!rnr>rÐrç)rÚcacheÚresultZ prefix_lenÚpZnpr;r;r<Ú"_collect_zipimporter_cache_entriess   rcCsDx>t||ƒD]0}||}||=|o*|||ƒ}|dk r |||<q WdS)a— Update zipimporter cache data for a given normalized path. Any sub-path entries are processed as well, i.e. those corresponding to zip archives embedded in other zip archives. Given updater is a callable taking a cache entry key and the original entry (after already removing the entry from the cache), and expected to update the entry and possibly return a new one to be inserted in its place. Returning None indicates that the entry should not be replaced with a new one. If no updater is given, the cache entries are simply removed without any additional processing, the same as if the updater simply returned None. N)r)rrÚupdaterrÚ old_entryZ new_entryr;r;r<Ú_update_zipimporter_cache*s  r!cCst||ƒdS)N)r!)rrr;r;r<rJsrcCsdd„}t|tj|d�dS)NcSs |jƒdS)N)Úclear)r?r r;r;r<Ú2clear_and_remove_cached_zip_archive_directory_dataOszf_remove_and_clear_zip_directory_cache_data..clear_and_remove_cached_zip_archive_directory_data)r)r!rsÚ_zip_directory_cache)rr#r;r;r<rNsrZ__pypy__cCsdd„}t|tj|d�dS)NcSs&|jƒtj|ƒ|jtj|ƒ|S)N)r"rsrtÚupdater$)r?r r;r;r<Ú)replace_cached_zip_archive_directory_dataes zT_replace_zip_directory_cache_data..replace_cached_zip_archive_directory_data)r)r!rsr$)rr&r;r;r<rds rúc Cs2yt||dƒWnttfk r(dSXdSdS)z%Is this string a valid Python script?ÚexecFTN)rÚ SyntaxErrorÚ TypeError)rOrºr;r;r<Ú is_pythonws r+cCsJy(tj|dd��}|jdƒ}WdQRXWnttfk r@|SX|dkS)zCDetermine if the specified executable is a .sh (contains a #! line)zlatin-1)r´rÐNz#!)rµrr¶rr)r&ÚfpÚmagicr;r;r<Úis_sh�s r.cCs tj|gƒS)z@Quote a command line argument according to Windows parsing rules)Ú subprocessÚ list2cmdline)rr;r;r<Ú nt_quote_arg‹sr1cCsH|jdƒs|jdƒrdSt||ƒr&dS|jdƒrDd|jƒdjƒkSdS)zMIs this text, as a whole, a Python script? (as opposed to shell/bat/etc. z.pyz.pywTz#!rœrF)rDr+rnÚ splitlinesr')r_rºr;r;r<r\�s  r\)rdcGsdS)Nr;)r”r;r;r<Ú_chmod¢sr3cCsRtjd||ƒyt||ƒWn0tjk rL}ztjd|ƒWYdd}~XnXdS)Nzchanging mode of %s to %ozchmod failed: %s)r r¨r3r>Úerror)r?rer|r;r;r<rd¦s rdc@sŠeZdZdZgZeƒZedd„ƒZedd„ƒZ edd„ƒZ edd „ƒZ ed d „ƒZ d d „Z edd„ƒZdd„Zedd„ƒZedd„ƒZdS)Ú CommandSpeczm A command spec for a #! header, specified as a list of arguments akin to those passed to Popen. cCs|S)zV Choose the best CommandSpec class based on environmental conditions. r;)r r;r;r<rY·szCommandSpec.bestcCstjjtjƒ}tjjd|ƒS)NÚ__PYVENV_LAUNCHER__)r>r?rBrÇr&r²r)r Z_defaultr;r;r<Ú_sys_executable¾szCommandSpec._sys_executablecCs:t||ƒr|St|tƒr ||ƒS|dkr0|jƒS|j|ƒS)zg Construct a CommandSpec from a parameter to build_scripts, which may be None. N)rír¼Úfrom_environmentÚ from_string)r Zparamr;r;r<Ú from_paramÃs  zCommandSpec.from_paramcCs||jƒgƒS)N)r7)r r;r;r<r8ÒszCommandSpec.from_environmentcCstj|f|jŽ}||ƒS)z} Construct a command spec from a simple string representing a command line parseable by shlex.split. )ÚshlexrÝÚ split_args)r Ústringr‚r;r;r<r9ÖszCommandSpec.from_stringcCs8tj|j|ƒƒ|_tj|ƒ}t|ƒs4dg|jdd…<dS)Nz-xr)r;rÝÚ_extract_optionsÚoptionsr/r0rH)r¶r_Úcmdliner;r;r<Úinstall_optionsßs zCommandSpec.install_optionscCs:|djƒd}tƒj|ƒ}|r.|jdƒp0dnd}|jƒS)zH Extract any options from the first line of the script. rJrrrÒ)r2rÚmatchÚgrouprM)Z orig_scriptÚfirstrBr?r;r;r<r>ås zCommandSpec._extract_optionscCs|j|t|jƒƒS)N)Ú_renderr¼r?)r¶r;r;r<Ú as_headerïszCommandSpec.as_headercCs6d}x,|D]$}|j|ƒr |j|ƒr |dd…Sq W|S)Nz"'rr‰)rnrD)ÚitemZ_QUOTESÚqr;r;r<Ú _strip_quotesòs  zCommandSpec._strip_quotescCs tjdd„|Dƒƒ}d|dS)Ncss|]}tj|jƒƒVqdS)N)r5rIrM)r¹rGr;r;r<r»ýsz&CommandSpec._render..z#!rJ)r/r0)r‚r@r;r;r<rEúszCommandSpec._renderN)r»r¼r½r¾r?r£r<r rYr7r:r8r9rArÀr>rFrIrEr;r;r;r<r5®s       r5c@seZdZedd�ZdS)ÚWindowsCommandSpecF)róN)r»r¼r½r£r<r;r;r;r<rJsrJc@sŠeZdZdZejdƒjƒZeZ e ddd„ƒZ e ddd„ƒZ e dd d „ƒZ ed d „ƒZe d d„ƒZe dd„ƒZe dd„ƒZe ddd„ƒZdS)rXz` Encapsulates behavior around writing entry point scripts for console and gui apps. a– # EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r __requires__ = %(spec)r import re import sys from pkg_resources import load_entry_point if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.exit( load_entry_point(%(spec)r, %(group)r, %(name)r)() ) NFcCs6tjdtƒ|rtntjƒ}|jd||ƒ}|j||ƒS)Nz Use get_argsrÒ)ÚwarningsræÚDeprecationWarningÚWindowsScriptWriterrXrYÚget_script_headerrZ)r rÌr&ÚwininstÚwriterÚheaderr;r;r<Úget_script_argss zScriptWriter.get_script_argscCs6tjdtƒ|rd}|jjƒj|ƒ}|j|ƒ|jƒS)NzUse get_headerz python.exe)rKrærLÚcommand_spec_classrYr:rArF)r r_r&rOÚcmdr;r;r<rN's   zScriptWriter.get_script_headerc csŒ|dkr|jƒ}t|jƒƒ}xjdD]b}|d}xT|j|ƒjƒD]B\}}|j|ƒ|jtƒ}|j||||ƒ} x| D] } | VqrWq>Wq"WdS)z� Yield write_script() argument tuples for a distribution's console_scripts and gui_scripts entry points. NÚconsoleÚguiZ_scripts)rUrV) r^r9rNZ get_entry_mapr‚Ú_ensure_safe_namer³rÊÚ_get_script_args) r rÌrQrÚtype_rCrõZepr_r”r–r;r;r<rZ1s     zScriptWriter.get_argscCstjd|ƒ}|rtdƒ‚dS)z? Prevent paths in *_scripts entry point names. z[\\/]z+Path separators not allowed in script namesN)rÚsearchrð)rõZ has_path_sepr;r;r<rWCs zScriptWriter._ensure_safe_namecCs tjdtƒ|rtjƒS|jƒS)NzUse best)rKrærLrMrY)r Z force_windowsr;r;r<Ú get_writerLs zScriptWriter.get_writercCs.tjdkstjdkr&tjdkr&tjƒS|SdS)zD Select the best ScriptWriter for this environment. Úwin32ÚjavarøN)rÇr{r>rõÚ_namerMrY)r r;r;r<rYRszScriptWriter.bestccs|||fVdS)Nr;)r rYrõrQr_r;r;r<rX\szScriptWriter._get_script_argsrÒcCs"|jjƒj|ƒ}|j|ƒ|jƒS)z;Create a #! line, getting options (if any) from script_text)rSrYr:rArF)r r_r&rTr;r;r<r^as zScriptWriter.get_header)NF)NF)N)rÒN)r»r¼r½r¾rKrLrÁr³r5rSr rRrNrZrÀrWr[rYrXr^r;r;r;r<rX s       rXc@sLeZdZeZedd„ƒZedd„ƒZedd„ƒZedd„ƒZ e d d „ƒZ d S) rMcCstjdtƒ|jƒS)NzUse best)rKrærLrY)r r;r;r<r[ls zWindowsScriptWriter.get_writercCs"tt|d�}tjjddƒ}||S)zC Select the best ScriptWriter suitable for Windows )r&ZnaturalZSETUPTOOLS_LAUNCHERr&)r£ÚWindowsExecutableLauncherWriterr>r²r)r Z writer_lookupZlauncherr;r;r<rYrs zWindowsScriptWriter.bestc #s–tddd�|}|tjdjƒjdƒkrBdjftƒŽ}tj|t ƒdddd d dd g}|j |ƒ|j ||ƒ}‡fd d „|Dƒ}ˆ|||d|fVdS)z For Windows, add a .py extensionz.pyaz.pyw)rUrVZPATHEXTú;zK{ext} not listed in PATHEXT; scripts will not be recognized as executables.z.pyz -script.pyz.pycz.pyoz.execsg|] }ˆ|‘qSr;r;)r¹rb)rõr;r<rÙŒsz8WindowsScriptWriter._get_script_args..rbN) r£r>r²r'rÝrÉrÊrKræÚ UserWarningrKÚ_adjust_header) r rYrõrQr_Úextr÷r�r¾r;)rõr<rXs   z$WindowsScriptWriter._get_script_argscCsNd}d}|dkr||}}tjtj|ƒtjƒ}|j||d�}|j|ƒrJ|S|S)zŠ Make sure 'pythonw' is used for gui and and 'python' is used for console (regardless of what sys.executable is). z pythonw.exez python.exerV)r=Úrepl)rrÚescapeÚ IGNORECASEÚsubÚ _use_header)r rYZ orig_headerr rdZ pattern_obÚ new_headerr;r;r<rb�s z"WindowsScriptWriter._adjust_headercCs$|dd…jdƒ}tjdkp"t|ƒS)zÝ Should _adjust_header use the replaced header? On non-windows systems, always use. On Windows systems, only use the replaced header if it resolves to an executable on the system. rÐrú"r\r‰)rMrÇr{r)riZ clean_headerr;r;r<rh�s zWindowsScriptWriter._use_headerN) r»r¼r½rJrSr r[rYrXrbrÀrhr;r;r;r<rMis    rMc@seZdZedd„ƒZdS)r_c #s”|dkrd}d}dg}nd}d}dddg}|j||ƒ}‡fd d „|Dƒ} ˆ|||d | fVˆd t|ƒd fVtƒs�ˆd} | tˆƒd fVdS)zG For Windows, add a .py extension and an .exe launcher rVz -script.pywz.pywZcliz -script.pyz.pyz.pycz.pyocsg|] }ˆ|‘qSr;r;)r¹rb)rõr;r<rÙ¹szDWindowsExecutableLauncherWriter._get_script_args..rbz.exernz .exe.manifestN)rbÚget_win_launcherr=Úload_launcher_manifest) r rYrõrQr_Z launcher_typercr�Zhdrr¾Zm_namer;)rõr<rX«s   z0WindowsExecutableLauncherWriter._get_script_argsN)r»r¼r½r rXr;r;r;r<r_ªsr_cCs2d|}tƒr|jddƒ}n |jddƒ}td|ƒS)z« Load the Windows launcher (executable) suitable for launching a script. `type` should be either 'cli' or 'gui' Returns the executable as a byte string. z%s.exeÚ.z-64.z-32.rÆ)r=rNr")ÚtypeZ launcher_fnr;r;r<rkÎs  rkcCs0tjtdƒ}tjr|tƒS|jdƒtƒSdS)Nzlauncher manifest.xmlzutf-8)r$r"r»rÚPY2Úvarsra)rõZmanifestr;r;r<rlÞs  rlFcCstj|||ƒS)N)rQrÃ)r?Ú ignore_errorsÚonerrorr;r;r<rÃæsrÃcCstjdƒ}tj|ƒ|S)Né)r>Úumask)Ztmpr;r;r<rcês  rccCs:ddl}tjj|jdƒ}|tjd<tjj|ƒtƒdS)Nr) rÆr>r?r#Ú__path__rÇÚargvrçr5)rÆZargv0r;r;r<Ú bootstrapðs   rwc s‚ddlm}ddlm‰G‡fdd„dˆƒ}|dkrBtjdd…}tƒ�0|fddd g|tjdpfd|d œ|—ŽWdQRXdS) Nr)Úsetup)r(cseZdZdZ‡fdd„ZdS)z-main..DistributionWithoutHelpCommandsrÒc s(tƒ�ˆj|f|ž|ŽWdQRXdS)N)Ú _patch_usageÚ _show_help)r¶r”Úkw)r(r;r<rz sz8main..DistributionWithoutHelpCommands._show_helpN)r»r¼r½Z common_usagerzr;)r(r;r<ÚDistributionWithoutHelpCommandsþsr|rz-qr2z-v)Z script_argsr-Z distclass)rÆrxZsetuptools.distr(rÇrvry)rvr{rxr|r;)r(r<r5ús    c #sLddl}tjdƒjƒ‰‡fdd„}|jj}||j_z dVWd||j_XdS)Nrze usage: %(script)s [options] requirement_or_url ... or: %(script)s --help csˆttjj|ƒd�S)N)Zscript)r£r>r?r))r-)ÚUSAGEr;r<Ú gen_usage sz_patch_usage..gen_usage)Zdistutils.corerKrLrÁZcorer~)rr~Zsavedr;)r}r<ry s   ry)N)r')N)‡r¾rr¯rrrZdistutils.errorsrrrr Zdistutils.command.installr r rr r Zdistutils.command.build_scriptsrr(rrÇr>rsrQr6rärr«r rKrKr¦r9rÂr/r;rµZsetuptools.externrZsetuptools.extern.six.movesrrrÆrZsetuptools.sandboxrZsetuptools.py31compatrrZsetuptools.py27compatrZsetuptools.commandrZsetuptools.archive_utilrZsetuptools.package_indexrrrrrZsetuptools.wheelrr$r r!r"r#r$r%r&r'r(r)r*r+r,r-r.Zpkg_resources.py31compatÚfilterwarningsZ PEP440WarningÚ__all__r=r1rorErHr"r2rrärÛr4r6r3rr²rrrryrr!rrÚbuiltin_module_namesrr+r.r1r\rdr3Ú ImportErrorr¼r5r7Zsys_executablerJÚobjectrXrMr_rRrNrkrlrÃrcrwr5rÃryr;r;r;r<Ú sÌ           D |A))'l R    T`A