3 K”ReøSã @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;ú•/builddir/build/BUILDROOT/alt-python36-setuptools-38.5.2-7.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/setuptools/command/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)Úp1Úp2Z both_existZ use_samefileZnorm_p1Znorm_p2r;r;r<r1MscCs|S)Nr;)Úsr;r;r<Ú _to_ascii_srGc Cs*ytj|dƒdStk r$dSXdS)NÚasciiTF)rÚ text_typeÚ UnicodeError)rFr;r;r<Úisasciibs  rKcCs |jdƒS)NrH)Úencode)rFr;r;r<rGjsc Cs(y|jdƒdStk r"dSXdS)NrHTF)rLrJ)rFr;r;r<rKms  cCstj|ƒjƒjddƒS)NÚ z; )ÚtextwrapÚdedentÚstripÚreplace)Útextr;r;r<ÚusrSc@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=rFú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Úrecordr\Ú 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_installedÚ_dry_runÚ distributionÚverboseÚ_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)ÚverÚ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Ú) Ú dist_nameÚ dist_versionÚ dist_fullnameÚ py_versionÚpy_version_shortÚpy_version_nodotÚ sys_prefixrŸÚsys_exec_prefixrÕr×ÚuserbaseÚusersiter‘r’r–r³Fr¤r¥Úinstallr™cSsg|]}tjj|jƒƒ‘qSr;)r>r?Ú expanduserrP)r¾rFr;r;r<ú 3sz1easy_install.finalize_options..ú,z"%s (in --site-dirs) does not existz$ (in --site-dirs) is not on sys.pathzhttps://pypi.python.org/simplecSsg|] }|jƒ‘qSr;)rP)r¾rFr;r;r<råHsÚ*)Ú 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·Úget_nameÚ get_versionÚ get_fullnameÚgetattrÚ config_varsr©rªr¬r®Ú_fix_install_dir_for_user_siteÚexpand_basedirsÚ expand_dirsÚ_expandr’r‘r¯Úset_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•Ú isinstancerÚ string_typesr�Zscan_egg_linksÚadd_find_linksr˜ÚintÚ ValueErrorr–rr—Úoutputs) r»rÜrŸrÕrBr³r`Ú 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ÚposixÚunixÚ_user) rŽr©rªÚcreate_home_pathr¬r r§r¨r>ÚnamerQÚ 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™rržÚlenÚrangeÚ distutilsrÚexecuteÚ write_fileÚwarn_deprecated_options)r»ÚspecrÚroot_lenÚcounterrr;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ÚrandomÚrandintrÌÚmaxsizer?Újoinr‘)r»Úpidr;r;r<Úpseudo_tempname­s  zeasy_install.pseudo_tempnamecCsdS)Nr;)r»r;r;r<r¸sz$easy_install.warn_deprecated_optionsc Cs"t|jƒ}tjj|dƒ}||jk}| r:|j r:|jƒ}nd|jƒd}tjj |ƒ}y*|rbtj |ƒt |dƒj ƒtj |ƒWn t tfk rœ|jƒYnX| r¸|j r¸t|jƒƒ‚|rÖ|jdkrÜt||jƒ|_nd|_|tttƒƒkrôd|_n$|j�rtjj |ƒ �rd|_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ör›Úcheck_pth_processingr'r@rÉÚopenÚcloseÚOSErrorÚIOErrorÚcant_write_to_targetrÚno_default_version_msgr±r3rÚ _pythonpathrµ)r»Úinstdirr±Z is_site_dirZtestfileZ test_existsr;r;r<rù»s4        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érM) Ú_easy_install__cant_write_msgrÌÚexc_infor‘r>r?r@Ú_easy_install__not_exists_idÚ_easy_install__access_msgr)r»r r;r;r<r. s 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() rMT)Úexist_okr(Nr 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År'r>r?r@Ú _one_linerrÉÚdirnameÚ pkg_resourcesÚ py31compatÚmakedirsr*r,r-r.ÚwriterÎrÏr+rÌÚ executabler rêr%ÚlowerÚdistutils.spawnr8r›r÷) r»r1r±Zok_fileZ ok_existsrÓr;rnr@ÚbasenameZaltZuse_altr8r;r;r<r)sV            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“Úmetadata_isdirÚmetadata_listdirÚinstall_scriptÚ get_metadataÚinstall_wrapper_scripts)r»rÒÚ script_namer;r;r<Úinstall_egg_scriptsMsz easy_install.install_egg_scriptscCs\tjj|ƒrLxJtj|ƒD].\}}}x"|D]}|jjtjj||ƒƒq(WqWn |jj|ƒdS)N)r>r?rÇÚwalkrrør%)r»r?ÚbaserÚfilesr¿r;r;r<Ú add_output[s    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_editablecszeasy_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_editableks 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<Ú_tmpdiruszeasy_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_pyrXrþr'rrPr°ÚdownloadÚ install_itemr>r?r@rrRZfetch_distributionr\ršrýrÚ precedencer.Úprocess_distributionÚlocation)r»rÚdepsrWÚ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 %srrY)ršr>r?r;Úendswithr²r!rýÚ project_namer_r rÅrCÚ install_eggsr^Úegg_distribution)r»rr[rWr`Zinstall_neededrÒÚdistsr;r;r<r\¢s.         zeasy_install.install_itemcCs@t|}x2tD]*}d|}t||ƒdkrt||||ƒqWdS)z=Sets the install directories by applying the install schemes.Úinstall_N)r r rîr)r»r ÚschemerQÚattrnamer;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ýrQÚremoverKr´r rÅÚinstallation_reportÚ has_metadatar¯rÚget_metadata_linesršr÷Úas_requirementr'rVr+Úresolver2r,rr-Úreportr²)r»Ú requirementrÒr`rÅZdistreqZdistrosrr;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�rn)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 keptr2r)r>r?r%r–rQr@r r÷rÇr;rÉÚlistdirrr#ÚshutilÚmove)r»rÚ dist_filenameÚ setup_baseÚdstr Úcontentsr;r;r<Ú maybe_moveÿs"       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<rIsz$easy_install.install_wrapper_scriptscCsNt|jƒƒ}t||ƒ}|r8|j|ƒtƒ}tj|ƒ|}|j|t|ƒdƒdS)z/Generate a legacy script wrapper and install itrqN) rVrpÚis_python_scriptÚ_load_templaterÏr}Ú get_headerr€rG)r»rÒrJÚ script_textÚdev_pathrZ is_scriptÚbodyr;r;r<rGs   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)rQr"Ú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¾re)r»r;r<rå8sz-easy_install.write_script..zInstalling %s script to %sNr(iÿ)rÄr rÅr’r>r?r%rOrÆÚ current_umaskr#r@rÉr*r?Úchmod)r»rJr{ÚmoderÃÚtargetÚmaskrnr;)r»r<r€5s   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 %sr2zMultiple setup scripts in %sr)rArbÚ install_eggÚ install_exeÚ install_wheelr>r?ÚisfilerÚunpack_progressrÇÚabspathÚ startswithr–r|r%r@rrrr~r rÅÚreport_editableÚbuild_and_install)r»rrxrWryÚ setup_scriptZsetupsr;r;r<rdIs<   zeasy_install.install_eggscCs>tjj|ƒr"t|tjj|dƒƒ}nttj|ƒƒ}tj ||d�S)NzEGG-INFO)Úmetadata) r>r?rÇr)r%r*Ú zipimportÚ zipimporterr(Ú from_filename)r»Úegg_pathr˜r;r;r<reus    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‘rCr“rÆr#rer1rÇr½r Ú remove_treer@rrÉr”rvrwÚcopytreertÚmkpathÚunpack_and_compileÚcopy2r;Úupdate_dist_cachesr!rO)r»rœrWÚ destinationrÒZnew_dist_is_zippedrnrZr;r;r<rŽ}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 .exer˜r rŠ)rcrŠÚplatformz.eggz.tmpzEGG-INFOzPKG-INFOr(zMetadata-Version: 1.0 Útarget_versionz%s: %s Ú_ú-rDcsg|]}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_namer_r#r)Ú _providerÚ exe_to_eggr@r*r?ÚitemsrQÚtitler+rÄr}rrÚ make_zipfiler¸rÆrŽ) r»rxrWÚcfgrÒrœÚegg_tmpZ _egg_infoZpkg_infrnÚkÚvr;)r’r<r�³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.dllr2rz.pyzSCRIPTS/z.pthzWARNING: can't process %séÿÿÿÿrµ)rAr”rrêr>r?r%rbrÚ strip_moduleÚsplitextrør r÷)ÚsrcrzrFÚoldÚnewÚpartsra)r±Ú native_libsÚprefixesÚ to_compileÚ top_levelr;r<Úprocessès$      z(easy_install.exe_to_egg..processz.pydr´r2z.pyzEGG-INFOr¿r¼z.txtr(rMNrµrµrµ)r¿r¼)r6rrArbrêrr¶r>r?r%røZ write_stubÚ byte_compileZwrite_safety_flagZ analyze_eggrÏr@r*r?r+) r»rxr±rÀZstubsÚresr»ÚresourceZpyfiler Útxtrnr;)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)r�)rÚ is_compatibleÚAssertionErrorr>r?r%r‘rªr“rÆr#rÇr½r ržr@rrÉZinstall_as_eggrCr;r£rOre)r»Ú wheel_pathrWÚwheelr¤r;r;r<r�s.      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)srMrØ) r›r Ú_easy_install__mv_warningr‘rr!rÌr?Ú_easy_install__id_warningr_rcrŠrÏ) r»ÚreqrÒÚwhatr Zegglocr rŠÚextrasr;r;r<rmCsz 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)NrM)r>r?r;rÌr@Ú_easy_install__editable_msgrÏ)r»rr—r;Úpythonr;r;r<r•\s 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³r2rr¨z-qz-nz Running %s %sú zSetup script exited with %s)rÌÚmodulesÚ setdefaultrrrÁr¸rûrÆr rÅrr%rrÐrr—)r»r—ryr—r³r;r;r<ras      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?))rSrTr>r?r;Ú_set_fetcher_optionsrørr&rŽr_rÆr r÷rÈrr¸) r»r—ryr—Údist_dirZall_eggsÚeggsrQrÒr;r;r<r–us$   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�r2r§r¨)r2z setup.cfgN)r•r³r”r˜r³r�) r·rºÚcopyr­rQÚdictr>r?r%rZ edit_config) r»rMZei_optsZfetch_directivesZ fetch_optionsrQrÚsettingsZ 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ÚwtrM)r±rQr›r_r rÅrlrúÚpathsrkrørÆÚsaver>r?r%r‘r½rÉr*r?Ú make_relativer+)r»rÒr`r¿rnr;r;r<rj¥s4           zeasy_install.update_pthcCstjd||ƒ|S)NzUnpacking %s to %s)r Údebug)r»r¸rzr;r;r<r’Ê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)rbr”rør’rÆ)r¸rz)r»Úto_chmodr¾r;r<ÚpfÓs    z+easy_install.unpack_and_compile..pfimií)rrÁrÆr>ÚstatÚST_MODErŠ)r»rœr¤rárnr‹r;)r»ràr¾r<r¡Ïs   zeasy_install.unpack_and_compilec Csjtjr dSddlm}z@tj|jdƒ||dd|jd�|jrT|||jd|jd�Wdtj|jƒXdS)Nr)rÁr2)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<r/sz#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"r‡r@r rßÚior*Úreadr”rrÅrÆr#r?rÁ)r»ZsitepyÚsourceÚcurrentÚstrmr;r;r<rZs,       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ärÚ iteritemsrïr”rÇÚ debug_printr>)r»Úhomer r?r;r;r<r 8szeasy_install.create_home_pathz/$base/lib/python$py_version_short/site-packagesz $base/bin)r‘r’)rz$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ãrMr)rr)Úget_finalized_commandrïrŸrØr r©r>r ÚDEFAULT_SCHEMEr­rîrrærr?rä)r»rrïrhrrrr;r;r<róNs         zeasy_install._expand)rTNrU)rVrWrX)rYrZr[)r\r]r^)r_r`ra)rbrFrc)rdrerf)rgrhri)rjrkrl)rmrnro)rprqrr)rsrtru)rvNrw)rxryrz)r{r|r})r~rr€)r�r‚rƒ)r„r…r†)r‡rˆr‰)rŠNr‹)rŒNr�)F)F)T)N)rÉ)QÚ__name__Ú __module__Ú __qualname__Ú__doc__Ú descriptionZcommand_consumes_argumentsÚ user_optionsÚboolean_optionsr©rªr­Zhelp_msgrøÚ negative_optrrür¼rÄrÂÚ staticmethodrÔrrðrrñròrr'rrùrNrOÚlstripr3r5r6r.r)rKrOrPrRÚ contextlibÚcontextmanagerrXr2r\r r^rtr|rIrGr‚r€rdrerŽr�r¬r�rÊrËrmrÏr•rr–rÕrjr’r¡rÁrèr/rZr rÙr rörór;r;r;r<r2xsØ    0 z   *    ;  $ $ '  ,6-5   %    cCs tjjddƒjtjƒ}td|ƒS)NrçrØ)r>rér©rêÚpathsepÚfilter)r­r;r;r<r0esr0c 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ÚriscosÚLibz site-packagesr´ÚlibrÐNrÊz site-pythonÚdarwinzPython.frameworkÚHOMEÚLibraryÚPythonÚpurelibÚplatlib)rr)Úextendr0rÌrŸrÕrør¥r>r?r%ÚseprŠrér©rr©rªr­ÚgetsitepackagesÚAttributeErrorrÁrr!)Úsitedirsr½rŸrôZhome_spZ lib_pathsZsite_libr;r;r<rõjsV            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" packagesr2z.pthúeasy-install.pthúsetuptools.pthÚimportN)rr) r!r>r?rÇrurbr*r%rÁr r+r”Úrstrip)ÚinputsÚseenr;rNr rnÚlinesÚliner;r;r<Ú expand_paths«s4           rc 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-INFOr2z .egg-inforNz EGG-INFO/z.pthz -nspkg.pthÚPURELIBÚPLATLIBú\rz%s/%s/cSsg|]\}}|jƒ|f‘qSr;)rA)r¾reÚyr;r;r<råsz$get_exe_prefixes..)r4rØ)r5rØ)r6rØ)r7r8)r9rØ)r:r;)r%ÚZipFileÚinfolistr¿rêrrbrûr%ÚupperrírÚPY3r‡r rPrQr”rør+ÚsortÚreverse)Z exe_filenamer½rWrÅr r»r{Úpthr;r;r<r6ýs>     & 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!rr>r?r;ÚbasedirÚ_loadr&Ú__init__r rÜrkr%)r»r¿rr?r;r;r<rG)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) NFÚrtrTú#r2rµrµ)rÜrÙÚfromkeysrr>r?r‘r¿r*r”rrørPr!r%rEr@ÚpopÚdirtyr+)r»Z saw_importrrnrr?r;r;r<rF2s2        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 %srMrÛzDeleting empty %sF)rLrÁrrÞrÜr rßr¿Ú _wrap_linesr%r>r?r½rÉr*r?r@)r»Z rel_pathsrÚdatarnr;r;r<rÝQs   zPthDistributions.savecCs|S)Nr;)rr;r;r<rMgszPthDistributions._wrap_linescCsN|j|jko$|j|jkp$|jtjƒk}|r>|jj|jƒd|_tj||ƒdS)z"Add `dist` to the distribution mapTN) r_rÜrr>ÚgetcwdrørLr&rk)r»rÒÚnew_pathr;r;r<rkks  zPthDistributions.addcCs6x$|j|jkr$|jj|jƒd|_qWtj||ƒdS)z'Remove `dist` from the distribution mapTN)r_rÜrlrLr&)r»rÒr;r;r<rlys zPthDistributions.removecCs”tjjt|ƒƒ\}}t|jƒ}|g}tjdkr2dp6tj}xVt|ƒ|krŠ||jkrn|jtj ƒ|j ƒ|j |ƒStjj|ƒ\}}|j|ƒq:W|SdS)Nr´) r>r?rêr!rrEÚaltseprrøÚcurdirrCr%)r»r?ÚnpathÚlastZbaselenr»rr;r;r<rÞ€s    zPthDistributions.make_relativeN) r÷rørùrúrLrGrFrÝrÿrMrkrlrÞr;r;r;r<r3$s  c@s(eZdZedd„ƒZedƒZedƒZdS)ÚRewritePthDistributionsccs(|jVx|D] }|VqW|jVdS)N)ÚpreludeÚpostlude)Úclsrrr;r;r<rM‘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ùÚ classmethodrMr:rVrWr;r;r;r<rU�s  rUZSETUPTOOLS_SYS_PATH_TECHNIQUEÚrawZrewritecCs ttjtƒrtStjtjjƒƒS)z_ Return a regular expression based on first_line_re suitable for matching strings. )rþrÚpatternrVÚreÚcompiler‡r;r;r;r<Ú_first_line_reªs r^cCsd|tjtjgkr.tjdkr.t|tjƒ||ƒStjƒ\}}}t j ||d|dd||ffƒdS)Nr rr2z %s %s) r>rÉrlr rŠrâÚS_IWRITErÌr4rÚreraise)ÚfuncÚargÚexcÚetZevr§r;r;r<Ú auto_chmod¶s  recCs.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)Ú dist_pathr�Únormalized_pathr;r;r<r£¾s <  r£cCsTg}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. r2rØ)rr!r”r>rrø)rkÚcacheÚresultÚ prefix_lenÚpÚnpr;r;r<Ú"_collect_zipimporter_cache_entriess   rqcCsDx>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)rq)rkrlÚupdaterroÚ old_entryZ new_entryr;r;r<Ú_update_zipimporter_cache$s  rtcCst||ƒdS)N)rt)rkrlr;r;r<rfDsrfcCsdd„}t|tj|d�dS)NcSs |jƒdS)N)Úclear)r?rsr;r;r<Ú2clear_and_remove_cached_zip_archive_directory_dataIszf_remove_and_clear_zip_directory_cache_data..clear_and_remove_cached_zip_archive_directory_data)rr)rtr™Ú_zip_directory_cache)rkrvr;r;r<riHsriZ__pypy__cCsdd„}t|tj|d�dS)NcSs&|jƒtj|ƒ|jtj|ƒ|S)N)rur™ršÚupdaterw)r?rsr;r;r<Ú)replace_cached_zip_archive_directory_data_s zT_replace_zip_directory_cache_data..replace_cached_zip_archive_directory_data)rr)rtr™rw)rkryr;r;r<rh^s rhúc Cs2yt||dƒWnttfk r(dSXdSdS)z%Is this string a valid Python script?ÚexecFTN)r]Ú SyntaxErrorÚ TypeError)rRr¿r;r;r<Ú is_pythonqs 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ìr*rír,r-)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)rbr;r;r<Ú nt_quote_arg…sr„cCsH|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)rbr~r”Ú splitlinesrA)r„r¿r;r;r<r�Šs  r�)rŠcGsdS)Nr;)r—r;r;r<Ú_chmodœsr†cCsRtjd||ƒyt||ƒWn0tjk rL}ztjd|ƒWYdd}~XnXdS)Nzchanging mode of %s to %ozchmod failed: %s)r rßr†r>Úerror)r?r‹rr;r;r<rŠ s rŠc@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;)rXr;r;r<r~±szCommandSpec.bestcCstjjtjƒ}tjjd|ƒS)NÚ__PYVENV_LAUNCHER__)r>r?rBrÌr@rér©)rXÚ_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)rXÚparamr;r;r<Ú from_param½s  zCommandSpec.from_paramcCs||jƒgƒS)N)r‹)rXr;r;r<rŒÌ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)rXÚstringr­r;r;r<r�ÐszCommandSpec.from_stringcCs8tj|j|ƒƒ|_tj|ƒ}t|ƒs4dg|jdd…<dS)Nz-xr)r�rêÚ_extract_optionsÚoptionsr‚rƒrK)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. rMrr2rØ)r…r^ÚmatchÚgrouprP)Z orig_scriptÚfirstr—r”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"'r2rµ)r”rb)ÚitemZ_QUOTESÚqr;r;r<Ú _strip_quotesìs  zCommandSpec._strip_quotescCs tjdd„|Dƒƒ}d|dS)Ncss|]}tj|jƒƒVqdS)N)rˆržrP)r¾rœr;r;r<rÀ÷sz&CommandSpec._render..z#!rM)r‚rƒ)r­r•r;r;r<ršôszCommandSpec._renderN)r÷rørùrúr”rÙr‘rYr~r‹r�rŒr�r–rÿr“r›ržršr;r;r;r<rˆ¨s       rˆc@seZdZedd�ZdS)ÚWindowsCommandSpecF)rN)r÷rørùrÙr‘r;r;r;r<rŸÿsrŸc@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)r}z` 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ÚWindowsScriptWriterr}r~Úget_script_headerr)rXrÒr@ÚwininstÚwriterÚheaderr;r;r<Úget_script_argss zScriptWriter.get_script_argscCs6tjdtƒ|rd}|jjƒj|ƒ}|j|ƒ|jƒS)NzUse get_headerz python.exe)r r÷r¡Úcommand_spec_classr~r�r–r›)rXr„r@r¤Úcmdr;r;r<r£!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)rªr«) rƒrVrpÚ get_entry_mapr­Ú_ensure_safe_namerêrÏÚ_get_script_args) rXrÒr¦rÚtype_r˜r Úepr„r—rÂr;r;r<r+s     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<r­=s zScriptWriter._ensure_safe_namecCs tjdtƒ|rtjƒS|jƒS)NzUse best)r r÷r¡r¢r~)rXZ force_windowsr;r;r<Ú get_writerFs zScriptWriter.get_writercCs.tjdkstjdkr&tjdkr&tjƒS|SdS)zD Select the best ScriptWriter for this environment. Úwin32Újavar N)rÌr¥r>r Ú_namer¢r~)rXr;r;r<r~LszScriptWriter.bestccs|||fVdS)Nr;)rXr¯r r¦r„r;r;r<r®VszScriptWriter._get_script_argsrØcCs"|jjƒj|ƒ}|j|ƒ|jƒS)z;Create a #! line, getting options (if any) from script_text)r¨r~r�r–r›)rXr„r@r©r;r;r<rƒ[s zScriptWriter.get_header)NF)NF)N)rØN)r÷rørùrúrNrOrrêrˆr¨rYr§r£rrÿr­r²r~r®rƒr;r;r;r<r}s       r}c@sLeZdZeZedd„ƒZedd„ƒZedd„ƒZedd„ƒZ e d d „ƒZ d S) r¢cCstjdtƒ|jƒS)NzUse best)r r÷r¡r~)rXr;r;r<r²fs zWindowsScriptWriter.get_writercCs"tt|d�}tjjddƒ}||S)zC Select the best ScriptWriter suitable for Windows )r@ZnaturalZSETUPTOOLS_LAUNCHERr@)rÙÚWindowsExecutableLauncherWriterr>rér©)rXZ writer_lookupÚlauncherr;r;r<r~ls 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)rªr«ÚPATHEXTú;zK{ext} not listed in PATHEXT; scripts will not be recognized as executables.z.pyz -script.pyz.pycz.pyoz.execsg|] }ˆ|‘qSr;r;)r¾re)r r;r<rå†sz8WindowsScriptWriter._get_script_args..rˆN) rÙr>rérArêrÎrÏr r÷Ú UserWarningrlÚ_adjust_header) rXr¯r r¦r„Úextr r¹rÃr;)r r<r®ys   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.exer«)r’Úrepl)r\r]ÚescapeÚ IGNORECASEÚsubÚ _use_header)rXr¯Z orig_headerr[r½Z pattern_obÚ new_headerr;r;r<r»‰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Ör2ú"r³rµ)rPrÌr¥r)rÂZ clean_headerr;r;r<rÁ—s zWindowsScriptWriter._use_headerN) r÷rørùrŸr¨rYr²r~r®r»rÿrÁr;r;r;r<r¢cs    r¢c@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 r«z -script.pywz.pywÚcliz -script.pyz.pyz.pycz.pyocsg|] }ˆ|‘qSr;r;)r¾re)r r;r<rå³szDWindowsExecutableLauncherWriter._get_script_args..rˆz.exerqz .exe.manifestN)r»Úget_win_launcherr=Úload_launcher_manifest) rXr¯r r¦r„Z launcher_typer¼r¹ÚhdrrÃZm_namer;)r r<r®¥s   z0WindowsExecutableLauncherWriter._get_script_argsN)r÷rørùrYr®r;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=rQr")ÚtypeZ launcher_fnr;r;r<rÅÈs  rÅcCs0tjtdƒ}tjr|tƒS|jdƒtƒSdS)Nzlauncher manifest.xmlzutf-8)r<r"r÷rÚPY2Úvarsr‡)r Úmanifestr;r;r<rÆØs  rÆFcCstj|||ƒS)N)rvrÈ)r?Ú ignore_errorsÚonerrorr;r;r<rÈàsrÈcCstjdƒ}tj|ƒ|S)Né)r>Úumask)Útmpr;r;r<r‰äs  r‰cCs:ddl}tjj|jdƒ}|tjd<tjj|ƒtƒdS)Nr) rËr>r?r;Ú__path__rÌÚargvrør5)rËZargv0r;r;r<Ú bootstrapês   rÔc 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<r×ûsz8main..DistributionWithoutHelpCommands._show_helpN)r÷rørùÚ common_usager×r;)r(r;r<ÚDistributionWithoutHelpCommandsøsrÚr2z-qr2z-v)Ú script_argsrJÚ distclass)rËrÕZsetuptools.distr(rÌrÓrÖ)rÓrØrÕrÚ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)Úscript)rÙr>r?rC)rJ)ÚUSAGEr;r<Ú gen_usage sz_patch_usage..gen_usage)Údistutils.corerNrOrÚcorerß)rrßZsavedr;)rÞr<rÖ s   rÖ)N)rz)N)‡rúrrærrrÚdistutils.errorsrrrr Údistutils.command.installr r rr r Zdistutils.command.build_scriptsrrBrrÌr>r™rvrSr%r\râr"rNr r©r9rr‚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ÚfilterwarningsÚ PEP440WarningÚ__all__r=r1rÊrGrKr:r2r0rõrr4r6r3rUrér©r^rer£rqrtrfriÚbuiltin_module_namesrhr~r�r„r�rŠr†Ú ImportErrorrÁrˆr‹Zsys_executablerŸÚobjectr}r¢r¶r§r£rÅrÆrÈr‰rÔr5rrÖr;r;r;r<Ú sÌ           D vA))'l R    T`A