N3{Y  @sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlmZddlmZmZddlZddlmZmZddlmZddlmZmZddlmZdd lmZmZdd l m!Z!m"Z"m#Z#m$Z$dd l%m&Z&m'Z'dd l(m)Z)dd l*m+Z+ddl,m-Z-ddl,m.Z.ddl(m/Z/m0Z0ddl1m2Z2m3Z3m4Z4m5Z5m6Z6ddlm7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEejFjGdejHjIejJZKddddddgZLddZMddZNejOdfkrddZPd d!ZQnd"dZPd#d!ZQGd$ddeZRd%d&ZSd'd(ZTd)dZUd*dZVd+d,ZWGd-dde=ZXeKd.d/d0ZYd1d2ZZd3d4Z[d5d6Z\d7d8d9Z]d:d;Z^d<d=Z_d>d?Z`ydd@lmaZbWneck rdAdBZbYnXdCdDZadEdFZdGdGdHdHeeZfGdIdJdJefZgGdKdLdLegZhefjiZidMdNZjdOdPZkd.eZdQdRZldSdTZmdUdVZnddWdZodS)Xa 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://pythonhosted.org/setuptools/easy_install.html N)glob)logdir_util)Command_dont_write_bytecode) run_setup)get_pathget_config_vars) get_platform) convert_path subst_vars)DistutilsArgErrorDistutilsOptionErrorDistutilsErrorDistutilsPlatformError)INSTALL_SCHEMES SCHEME_KEYS)setopt)unpack_archive) PackageIndex) URL_SCHEME) bdist_eggegg_info) iteritemsmaxsize basestringunicodereraise) yield_linesnormalize_pathresource_stringensure_directoryget_distributionfind_distributions Environment Requirement Distribution PathMetadata EggMetadata WorkingSetDistributionNotFoundVersionConflict DEVELOP_DISTZ__VENV_LAUNCHER__samefile easy_installPthDistributionsextract_wininst_cfgmainget_exe_prefixescCstjddkS)NP)structcalcsizer7r7:/tmp/pip-r2rszybt-build/setuptools/command/easy_install.pyis_64bit@sr9cCstjj|o!tjj|}ttjdo9|}|rUtjj||Stjjtjj|}tjjtjj|}||kS)Nr-)ospathexistshasattrr-normpathnormcase)Zp1Zp2Z both_existZ use_samefileZnorm_p1Znorm_p2r7r7r8r-Cs$cCs|S)Nr7)sr7r7r8 _to_asciiMsrBc Cs2yt|ddSWntk r-dSYnXdS)NasciiTF)r UnicodeError)rAr7r7r8isasciiOs   rEcCs |jdS)NrC)encode)rAr7r7r8rBVsc Cs2y|jddSWntk r-dSYnXdS)NrCTF)rFrD)rAr7r7r8rEXs   c@s#eZdZdZdZdZdddddddddddddddddddddgZdd dd dd0d3d9d<g Zej rd@ej Z ej dAde fej dAnidd*6Z eZdBdCZdDdEZdFdGZdHdIZdJdKZdLdMZdNdOZdPdQZdRdSZdTdUZdVdWZdXdYZdZd[Zd\d]Zd^d_Zd`daZdbdcddZ dbdedfZ!dgdhZ"ddidjZ#dkdlZ$dmdnZ%dodpZ&ddqdrZ'dsfdtduZ(dvdwZ)dxdyZ*dzd{Z+d|d}Z,d~dZ-dddZ.ddZ/ddZ0ddZ1ddZ2ddZ3ddZ4ddZ5ddZ6ddZ7ddZ8ddZ9e:de:ddddZ;e:ddddZ<ddZ=dS)r.z'Manage a download/build/install processz Find/get/install Python packagesTprefix=Ninstallation prefixzip-okzinstall package as a zipfile multi-versionm%make apps have to require() a versionupgradeU1force upgrade (searches PyPI for latest versions) install-dir=dinstall package to DIR script-dir=rAinstall scripts to DIRexclude-scriptsxDon't install scripts always-copya'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 packagesbuild-directory=b/download/extract/build in DIR; keep the results optimize=Olalso 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-unzipZ*don't install as a zipfile, no matter what site-dirs=S)list of directories where .pth files workeditablee+Install specified packages in editable formno-depsNdon't install dependencies allow-hosts=H$pattern(s) that hostnames must matchlocal-snapshots-okl(allow building eggs from local checkoutsversion"print version information and exit no-find-links9Don't load find-links defined in packages being installedz!install in user site-package '%s'usercCstjr3tjjt}|jtj|_n d|_d|_ |_ d|_ |_ |_ d|_d|_d|_d|_d|_|_d|_|_|_d|_|_|_d|_|_|_d|_d|_d|_d|_ d|_!d|_"d|_#d|_$d|_%tjrQtj&|_'tj|_(nd|_'d|_(d|_)d|_*d|_+|_,d|_-i|_.d|_/d|_0|j1j2|_2|j1j3||j1j4ddS)NrFr.)5siteENABLE_USER_SITEr:r;abspath__file__ startswith USER_SITErzip_oklocal_snapshots_ok install_dir script_direxclude_scripts index_url find_linksbuild_directoryargsoptimizerecordrO always_copy multi_versionrqno_deps allow_hostsrootprefix no_reportr}install_purelibinstall_platlibinstall_headers install_libinstall_scripts install_data install_baseinstall_platbase USER_BASEinstall_userbaseinstall_usersite no_find_links package_indexpth_filealways_copy_from site_dirsinstalled_projectssitepy_installed_dry_run distributionverbose_set_command_optionsget_option_dict)selfZwhereamir7r7r8initialize_optionssL                          zeasy_install.initialize_optionscCsx|D]}tjj|s1tjj|rtjd||jstjj|r|tjj| r|t|qtj |qqqWdS)Nz Deleting %s) r:r;r<islinkrinfodry_runisdirrmtreeunlink)rblockersfilenamer7r7r8delete_blockerss $ % zeasy_install.delete_blockersc Csx|jr-tdtdjtjntjjd}tdd\}}i |jjd6|jj d6|jj d6|d 6|dd d 6|d|d d 6|d6|d6|d6|d6t tddd6|_ t jr|j|j d<|j|j ds1y>t>|j=|_=d|j=kod kns t?nWq1t?k r-t+d,Yq1Xn|j-rS|j@ rStAd-n|jBsktAd.ng|_CdS)3Nz setuptools %s setuptoolsrr exec_prefix dist_name dist_version dist_fullname py_versionr@py_version_shortpy_version_nodot sys_prefixsys_exec_prefixabiflagsuserbaseusersitez$User base directory is not specifiedposix unix_user_userrrrrFrrinstallrcSs(g|]}tjj|jqSr7)r:r; expanduserstrip).0rAr7r7r8 s z1easy_install.finalize_options..,z"%s (in --site-dirs) does not existz$ (in --site-dirs) is not on sys.pathzhttps://pypi.python.org/simplecSsg|]}|jqSr7)r)rrAr7r7r8r)s * search_pathhostsrz--optimize must be 0, 1, or 2z9Must specify a build directory (-b) when using --editablez:No urls, filenames, or requirements specified (see --help)) install_dirr)rz script_dir)recordr)optimizer)Dr}printr"sysexitsplitr rget_name get_version get_fullnamegetattr config_varsrrrrrcreate_home_pathrrrr:name select_schemeexpand_basedirs expand_dirs_expandrrrset_undefined_optionsrrmaprr; get_site_dirs all_site_dirsrrrwarnrappendrqcheck_site_dirr shadow_pathinsertrr create_indexr$ local_indexr isinstancerrZscan_egg_linksadd_find_linksrint ValueErrorrr routputs) rrrrr>rrS path_itemrr7r7r8finalize_optionss              " !        zeasy_install.finalize_optionscCsx|D]y}t||}|dk rtjdksFtjdkr[tjj|}nt||j}t|||qqWdS)Nrnt)rr:rr;rr rsetattr)rattrsattrvalr7r7r8 _expand_attrsMs  zeasy_install._expand_attrscCs|jdddgdS)zNCalls `os.path.expanduser` on install_base, install_platbase and root.rrrN)r)rr7r7r8rVszeasy_install.expand_basedirscCs#|jddddddgdS)z+Calls `os.path.expanduser` on install dirs.rrrrrrN)r)rr7r7r8r[s zeasy_install.expand_dirsc Cs|j|jjkr(tj|jnzx%|jD]}|j||j q5W|jr|j}|j rt |j }x5t t |D]}|||d||.T)rrr:r;rrrcheck_pth_processingrr<ropencloseOSErrorIOErrorcant_write_to_targetrno_default_version_msgrr/environgetrpathseprr)rinstdirrZ is_site_dirZtestfileZ test_existsrr7r7r8rs6 !"   zeasy_install.check_site_dircCs_d}|tjd|jf}tjj|jsE|d7}n |d7}t|dS)Nacan'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). aK 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://pythonhosted.org/setuptools/easy_install.html Please make the appropriate changes for your system and try again. )rexc_inforr:r;r<r)rtemplatemsgr7r7r8rs  z!easy_install.cant_write_to_targetc Cs.|j}tjd||jd}|d}tjj|}y]|r^tj|ntjj|}tjj|stj |nt |d}Wn"t t fk r|j YnHXz|jd|f|jd}tj}tjdkrctjj|\}}tjj|d} |jd krctjj| rc| }qcnd d lm} | |d d dgd tjj|rtjd|dSWd|r|jntjj|rtj|ntjj|r tj|nX|js*tjd|ndS)z@Empirically verify whether .pth files are supported in inst. dirz Checking .pth file support in %sz.pthz.okrz7import os; f = open(%r, 'w'); f.write('OK'); f.close() Nrz pythonw.exez python.exer)spawnz-Ez-cpassz-TEST PASSED: %s appears to support .pth filesTz+TEST FAILED: %s does NOT support .pth filesF)rrrrr:r;r<rdirnamemakedirsrrrrwriterr executablerrrlowerdistutils.spawnr%rr) rr rZok_fileZ ok_existsr'rar*basenameZaltr%r7r7r8rsP    $   z!easy_install.check_pth_processingcCs|j ro|jdroxS|jdD]?}|jd|rHq)n|j|||jd|q)Wn|j|dS)z=Write all the scripts for `dist`, unless scripts are excludedscriptszscripts/N)rmetadata_isdirmetadata_listdirinstall_script get_metadatainstall_wrapper_scripts)rdist script_namer7r7r8install_egg_scriptssz easy_install.install_egg_scriptscCs|tjj|rhxctj|D]?\}}}x-|D]%}|jjtjj||q8Wq"Wn|jj|dS)N)r:r;rwalkrrr)rr;basedirsfilesrr7r7r8 add_outputs  *zeasy_install.add_outputcCs#|jrtd|fndS)NzjInvalid argument %r: you can't use filenames or URLs with --editable (except via the --find-links option).)rqr )rr r7r7r8 not_editables zeasy_install.not_editablecCsW|js dStjjtjj|j|jrStd|j|jfndS)Nz2%r already exists in %s; can't do a checkout there)rqr:r;r<rrkeyr )rr r7r7r8check_editable$s  'zeasy_install.check_editableFc Cstjdd}d}|js.|jnzYt|tst|r|j||jj ||}|j d|||dSt j j |r|j||j d|||dSt|}n|j||jj|||j|j|j |j}|dkrDd|}|jr5|d7}nt|nB|jtkrm|j|||d|S|j ||j||SWdt j j |rt|nXdS)Nrz easy_install-Tz+Could not find suitable distribution for %rz2 (--always-copy skips system and development eggs)Using)tempfilemkdtemprqinstall_site_pyrr%rr<rdownload install_itemr:r;r<parse_requirement_argr>Zfetch_distributionrOrrr precedencer,process_distributionlocationr)rr depstmpdirrCr4r$r7r7r8r..s:           zeasy_install.easy_installcCs|p |j}|p*tjj||k}|p@|jd }|p||jdk o|tjjt|t|jk}|r| rx4|j|jD]}|j |krPqqWd}nt j dtjj ||r!|j |||}xP|D]}|j|||qWn,|j|g}|j||d|d|dk r}x!|D]}||kr`|Sq`WndS)Nz.eggTz Processing %srr?)rr:r;r'endswithrrr project_namerHrrr- install_eggsrGegg_distribution)rr rCrJrIinstall_neededr4distsr7r7r8rDWs.      zeasy_install.install_itemcCsUt|}xDtD]<}d|}t||dkrt||||qqWdS)z=Sets the install directories by applying the install schemes.install_N)rrrr)rrschemer=attrnamer7r7r8r{s    zeasy_install.select_schemec Gs6|j||jj||jj||j|||j|j.get_templatezscript template.pyz.pyz (dev).pyrdN)strrYis_python_scriptrjget_script_headerlocalsrhrB)rr4r5 script_textZdev_pathr Z is_scriptrlr7)rkr8r1s zeasy_install.install_scripttcsjfdd|Dtjd|jtjjj|}j|t}j st |tjj |rtj |nt |d|}|j||jt|d|ndS)z1Write an executable file to the scripts directorycs(g|]}tjjj|qSr7)r:r;rr)rrX)rr7r8rs z-easy_install.write_script..zInstalling %s script to %sriN)rrrrr:r;rr; current_umaskrr!r<rrr)rchmod)rr5remodertargetmaskrar7)rr8rhs      zeasy_install.write_scriptcCs|jjdr(|j||gS|jjdrP|j||gS|}tjj|r|jd rt|||jn'tjj |rtjj |}n|j |r|j r|dk r|j |||}ntjj|d}tjj|sttjj|dd}|s[tdtjj |nt|dkrtdtjj |n|d }n|jrtj|j||gS|j||SdS) Nz.eggz.exez.pyzsetup.pyrz"Couldn't find a setup script in %sr!zMultiple setup scripts in %sr)r+rK install_egg install_exer:r;isfilerunpack_progressrrrrrfrr<rrrrqrrreport_editablebuild_and_install)rr rbrJrc setup_scriptZsetupsr7r7r8rMs4"  zeasy_install.install_eggscCs[tjj|r3t|tjj|d}nttj|}tj |d|S)NzEGG-INFOmetadata) r:r;rr'rr( zipimport zipimporterr& from_filename)regg_pathrr7r7r8rN+s!zeasy_install.egg_distributioncCstjj|jtjj|}tjj|}|jsLt|n|j|}t ||stjj |rtjj | rt j |d|jn2tjj|r|jtj|fd|nt|tjj |r+|j|rtjd}}qtjd}}na|j|rZ|j||jd}}n2|j|r|tjd}}ntjd}}|j|||f|dtjj|tjj|fn|j||j|S)Nrz Removing ZMovingZCopyingZ Extractingz %s to %s)r:r;rrr-rrr!rNr-rrr remove_treer<rruncache_zipdirrr`racopytreer^mkpathunpack_and_compilecopy2r'r;)rrrJ destinationr4rarMr7r7r8rx2s4$  %   ) zeasy_install.install_eggc st|}|dkr+td|ntdd|jddd|jdddt}tjj||jd}|_ |d}tjj|d }tjj|d }t |t |||_ |j ||tjj|s}t|d } | jd xU|jdD]D\} } | d kr(| jd| jddj| fq(q(W| jntjj|d|jfddt|Dtj||d|jd|j|j||S)Nz(%s is not a valid distutils Windows .exerLrrr}platformz.eggz.tmpzEGG-INFOzPKG-INFOrzMetadata-Version: 1.0 target_versionz%s: %s _-r.cs)g|]}tjj|dqS)r)r:r;r)rr)rr7r8rts z,easy_install.install_exe..rr)r0rr&rr r:r;regg_namerHr!r' _provider exe_to_eggr<rr)itemsrjtitlerrrgr make_zipfilerrrx) rrbrJcfgr4regg_tmpZ _egg_infoZpkg_infrakvr7)rr8rySs8  &    0  zeasy_install.install_exec st|ggifdd}t||g}xD]}|jjdrY|jd}|d}tj|dd|d.processz.pydrr!z.pyzEGG-INFOrrz.txtr Nrrr)z top_levelz native_libs)r2rr+rKrrrr:r;rrZ write_stub byte_compileZwrite_safety_flagZ analyze_eggrpr<rr)r) rrbrrZstubsresrresourceZpyfilerZtxtrar7)rrrrrr8r}s4        !zeasy_install.exe_to_eggZ Installedc Cszd}|jrN|j rN|d7}|jtttjkrN|d7}qNn|j}|j}|j }d}|t S)z9Helpful installation message for display to package usersz %(what)s %(eggloc)s%(extras)sa 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.) r) rrrrrrr;rHrLr}rp) rreqr4whatr$Zegglocrr}r[r7r7r8rVs     z easy_install.installation_reportcCs&tjj|}tj}dtS)Na" 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. )r:r;r'rr*rp)rr r~r'pythonr7r7r8r|s zeasy_install.report_editablec Cs+tjjdttjjdtt|}|jdkrid|jd}|jdd|n"|jdkr|jddn|jr|jdd nt j d |t |ddd j |yt ||Wn<tk r&tjd}td |jdfYnXdS) Nzdistutils.command.bdist_eggzdistutils.command.egg_inforrr!rrz-qz-nz Running %s %s zSetup script exited with %s)rmodules setdefaultrrlistrrrrrrrr SystemExitr"rr)rr~rcrrr7r7r8rs"  * zeasy_install.run_setupc Csddg}tjdddtjj|}z|jtjj||j||j|||t|g}g}x?|D]7}x.||D]"}|j|j |j |qWqW| r|j rt j d|n|SWdt|t j|jXdS)Nrz --dist-dirrz egg-dist-tmp-dirz+No eggs found in %s (setup script problem?))r@rAr:r;r'_set_fetcher_optionsrrr$rxrHrrrrrr) rr~rcrZdist_dirZall_eggseggsr=r4r7r7r8r}s$    $   zeasy_install.build_and_installc Cs|jjdj}d }i}xF|jD]8\}}||krOq1n|d||jdd .pfimi)rrrr:statST_MODErt)rrrrrarur7)rrrr8rEs   zeasy_install.unpack_and_compilecCstr|jddSddlm}zetj|jd||ddddd|j|jr||d|jddd|jnWdtj|jXdS)Nz%byte-compiling is disabled, skipping.r)rr!rforcer) rrdistutils.utilrrrrrr)rrrr7r7r8rXs  zeasy_install.byte_compilecCs&d}||jtjjddfS)Nabad 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://pythonhosted.org/setuptools/easy_install.html#custom-installation-locations Please make the appropriate changes for your system and try again.rr)rr:rr)rr#r7r7r8rksz#easy_install.no_default_version_msgcCs?|jr dStjj|jd}tdd}d}tjj|rtjd|jt |d}|j }t j dkr|j }n|j|jd std |qn||kr2tjd ||jst|t |d }|j||jn|j|gnd |_dS)z8Make sure there's a site.py in the target dir, if neededNzsite.pyrz site-patch.pyrzChecking existing site.py in %srbr@z def __boot():z;%s is not a setuptools-generated site.py; please remove it.z Creating %swbT)r@)rr:r;rrr r<rrrreadr version_inforirrrrrr!r)r)rZsitepysourcecurrentrar7r7r8rBs2        zeasy_install.install_site_pycCs|js dSttjjd}xct|jD]R\}}|j|r5tjj| r5|j d|tj |dq5q5WdS)zCreate directories under ~.N~zos.makedirs('%s', 0700)i) rr r:r;rrrrr debug_printr()rhomerr;r7r7r8rs "zeasy_install.create_home_pathrrz/$base/lib/python$py_version_short/site-packagesrz $base/binz$base/Lib/site-packagesz $base/ScriptscGs |jdj}|jr|j}|j|d<|jjtj|j}xH|j D]7\}}t ||ddkr\t |||q\q\Wnddl m }xo|D]g}t ||}|dk r|||}tjdkrtjj|}nt |||qqWdS)Nrr8r)r r)get_finalized_commandrrrrrr:rDEFAULT_SCHEMErrrrr r;r)rrrrRrrr r7r7r8rs      zeasy_install._expand)rGNrH)rIrJrK)rLrMrN)zupgraderPrQ)rRrSrT)rUrArV)rWrXrY)rZr[r\)r]r^r_)r`rarb)rcrdre)rfrgrh)riNrj)rkrlrm)rnrorp)zeditablerrrs)rtrurv)rwrxry)rzr{r|)zversionNr~)rNr)>__name__ __module__ __qualname____doc__ descriptionZcommand_consumes_arguments user_optionsboolean_optionsrrrZhelp_msgr negative_optrrrrrrrrr rrrrrr6r;r<r>r.rDrrGr^rfr3r1rhrMrNrxryrrVr|rr}rrTr{rrrrBrrrrrr7r7r7r8r._s      3     * ' 0    )$ /   (  ! * 2    $     $   c CsddtjjddjtjD}tjg}tjtjkr_|jtjnx8|D]0}|rftj dkr|jtj j |ddntj d kr|j tj j |d d tjdd dtj j |d d gn%|j |tj j |d dgtj dkrd|krtjjd}|r|jtj j |ddtjdd dqqqqfqfWtdtdf}x*|D]"}||kr|j|qqWtjr|jtjnttt|}|S)NcSsg|]}|r|qSr7r7)rrr7r7r8rs z!get_site_dirs..rros2emxriscosLibz site-packagesrlibrr@z site-pythondarwinzPython.frameworkHOMELibraryPythonpurelibplatlib)rr)r:rrrrrrrrrr;rsepextendr}rrrrrrr)sitedirsrrrZ lib_pathsZsite_libr7r7r8rsF  "     rccs^i}xQ|D]I}t|}||kr1q nd||egg path translations for a given .exe filePURELIB/rPLATLIB/pywin32_system32PLATLIB/SCRIPTS/EGG-INFO/scripts/DATA/lib/site-packagesrr@rzPKG-INFOr!z .egg-inforNz EGG-INFO/z.pthz -nspkg.pthPURELIBPLATLIB\rz%s/%s/cSs(g|]\}}|j|fqSr7)r+)rrXyr7r7r8rs z$get_exe_prefixes..)rr)rr)r r)r r )r r)r r)r@)rZipFileinfolistrrrrKrrupperrrrrirrrjrrrsortreverse)Z exe_filenamerrJrrrrepthr7r7r8r2_s<  ")"3   c Cs=ytj|SWn%tk r8td|fYnXdS)Nz1Not a URL, existing file, or requirement spec: %r)r%parserr)r r7r7r8rEs  rEc@sgeZdZdZdZfddZddZddZd d Zd d Z d dZ dS)r/z)A .pth file with Distribution paths in itFcCs||_ttt||_ttjj|j|_|j t j |gddx6t |j D]%}tt|jt|dqoWdS)NT)rrrrrr:r;r'basedir_loadr$__init__rrrUr#)rrrr;r7r7r8rs  zPthDistributions.__init__cCsg|_d}tj|j}tjj|jr3t|jd}x|D]}|j drpd}qOn|j }|jj ||j sO|j j drqOnt tjj|j|}|jdc Cs;yt||dWnttfk r2dSYnXdSdS)z%Is this string a valid Python script?execFTN)r) SyntaxError TypeError)textrr7r7r8 is_python-s  rCc CsRy)t|}|jd}|jWnttfk rG|SYnX|dkS)zCDetermine if the specified executable is a .sh (contains a #! line)rz#!)rrrrr)r*fpmagicr7r7r8is_sh6s  rFcCsg}d}d}d|kp'd|k}|r@|jdnx|D]z}|dkrf|d7}qG|dkr|jd|dd d}qG|r|jd|d}n|j|qGW|r|jd|n|r|jd||jdnd j|S) z@Quote a command line argument according to Windows parsing rulesFrr "rr!rz\"r)rr)r5result needquotenbcr7r7r8r-?s,      r-cCsb|jds|jdr"dSt||r5dS|jdr^d|jdjkSdS)zMIs this text, as a whole, a Python script? (as opposed to shell/bat/etc. z.pyz.pywTz#!rrF)rKrCrr*r+)rqrr7r7r8rn`srn)rtcGsdS)Nr7)rr7r7r8_chmodqsrMc Cs`tjd||yt||Wn5tjk r[tjd}tjd|YnXdS)Nzchanging mode of %s to %or!zchmod failed: %s)rrrMr:errorrr")r;rurrr7r7r8rtss rtcCsntjjdrjt|rjddl}|jjjddkrI|S|r_tj dqjd|Sn|S)Njavarzos.nameLinuxzWARNING: Unable to adapt shebang line for Jython, the following script is NOT executable see http://bugs.jython.org/issue1112 for more information.z/usr/bin/env %s) rrrrFrOlangSystem getPropertyrr)r*r1rOr7r7r8r.{s   r.c@sgeZdZdZejdjZee dddZ eddZ edd Z d S) ScriptWriterz` Encapsulates behavior around writing entry point scripts for console and gui apps. a6 # EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r __requires__ = %(spec)r import sys from pkg_resources import load_entry_point if __name__ == '__main__': sys.exit( load_entry_point(%(spec)r, %(group)r, %(name)r)() ) Fc cs|j|}t|j}td||}xvdD]n}|d}x[|j|jD]D\} } |jt} x%|j|| || D] } | VqWq`Wq:WdS)zW Yield write_script() argument tuples for a distribution's entrypoints rconsoleguiZ_scriptsN)zconsolezgui) get_writerrmrYro get_entry_maprr#rp_get_script_args) clsr4r*r/Z gen_classr headertype_r,reprqrr7r7r8rgs  " zScriptWriter.get_script_argscCs#|stjdkrtjS|S)Nwin32)rrWindowsScriptWriterrW)rZZ force_windowsr7r7r8rWs zScriptWriter.get_writerccs|||fVdS)Nr7)rZr\rr[rqr7r7r8rYszScriptWriter._get_script_argsN) rrrrtextwrapdedentlstripr# classmethodsys_executablergrWrYr7r7r7r8rTs  rTc@sFeZdZeddZeddZeddZdS)r_cCs2tdtd|}tjjdd}||S)z: Get a script writer suitable for Windows r*ZnaturalZSETUPTOOLS_LAUNCHER)rWindowsExecutableLauncherWriterr:rr)rZZ writer_lookuplauncherr7r7r8rWs  zWindowsScriptWriter.get_writerc#stdddd|}|tjdjjdkrRtjd|tnddd d d dd g}|j||j ||}fd d|D}|||d|fVdS)z For Windows, add a .py extensionrUz.pyarVz.pywPATHEXT;zH%s not listed in PATHEXT; scripts will not be recognized as executables.z.pyz -script.pyz.pycz.pyoz.execsg|]}|qSr7r7)rrX)rr7r8rs z8WindowsScriptWriter._get_script_args..rrN) rr:rr+rwarningsr UserWarningr_adjust_header)rZr\rr[rqextrrr7)rr8rYs"  z$WindowsScriptWriter._get_script_argscCsd}d}|dkr(||}}ntjtj|tj}|jd|d|}|dd jd}tjd krtj j | r|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.exerVstringreplrr!rHr^r) r(r)escape IGNORECASEsubrrrr:r;r<)r\Z orig_headerr'rnZ pattern_obZ new_headerZ clean_headerr7r7r8rks "z"WindowsScriptWriter._adjust_headerN)rrrrcrWrY staticmethodrkr7r7r7r8r_s   r_c@s"eZdZeddZdS)rec #s|dkr$d}d}dg}nd}d}dddg}|j||}fd d |D} |||d | fVd t|d fVtsd} | td fVndS)zG For Windows, add a .py extension and an .exe launcher rVz -script.pywz.pywcliz -script.pyz.pyz.pycz.pyocsg|]}|qSr7r7)rrX)rr7r8rs zDWindowsExecutableLauncherWriter._get_script_args..rrz.exerdz .exe.manifestN)rkget_win_launcherr9load_launcher_manifest) rZr\rr[rqZ launcher_typerlrr2rZm_namer7)rr8rYs    z0WindowsExecutableLauncherWriter._get_script_argsN)rrrrcrYr7r7r7r8res recCstd|}tjjdkr7|jdd}ntrU|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.exeZarm.z-arm.z-64.z-32.r)rmachiner+rjr9r )typeZ launcher_fnr7r7r8rt s  rtcCsHtjtd}tjddkr0|tS|jdtSdS)Nzlauncher manifest.xmlrr@zutf-8) pkg_resourcesr rrrvarsri)rmanifestr7r7r8rus rucCs~|rdd}n|dkr0dd}ng}ytj|}Wn.tjk ry|tj|tjYnXx|D]}tjj||}ytj|j}Wntjk rd}YnXt j |rt |||qytj |Wqtjk r3|tj |tjYqXqWytj |Wn.tjk ry|tj |tjYnXdS)zRecursively delete a directory tree. This code is taken from the Python 2.4 version of 'shutil', because the 2.3 version doesn't really work right. cWsdS)Nr7)rr7r7r8onerror,szrmtree..onerrorNcWsdS)Nr7)rr7r7r8r|/sr)r:r_rNrr"r;rlstatst_moderS_ISDIRrrrmdir)r; ignore_errorsr|namesrfullnamerur7r7r8r%s2   "rcCs tjd}tj||S)N)r:umask)tmpr7r7r8rsHs rscCsMddl}tjj|jd}|tjd.gen_usagec s7jj}zj_|SWd|j_XdS)N)corer)raZ old_gen_usage)rrr7r8 with_ei_usageds    zmain..with_ei_usagecs+eZdZdZfddZdS)z-main..DistributionWithoutHelpCommandsrcs#fdddS)NcsjS)N) _show_helpr7)r&rkwrr7r8pszJmain..DistributionWithoutHelpCommands._show_help..r7)rrr)r&r)rrrr8rosz8main..DistributionWithoutHelpCommands._show_helpN)rrr common_usagerr7)r&rr7r8DistributionWithoutHelpCommandsls rr!cs6ddddgdtjdp)ddS)N script_argsz-qr.z-vr5r distclass)rrr7)rrrrr7r8ruszmain..)rrZsetuptools.distr&distutils.corerr)rrr7) r&rrrrrrrrr8r1Us  )prrr:rr`r@rr(rrrr`rirr5rrrrryrrrZsetuptools.sandboxrZsetuptools.py31compatrr rr r r distutils.errorsr rrrdistutils.command.installrrZsetuptools.commandrZsetuptools.archive_utilrZsetuptools.package_indexrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,rrr;r>r*rd__all__r9r-rrBrEr.rrr0r2rEr/ror9rr;rCrFr-rnrtrM ImportErrorr.objectrTr_rergrtrurrsrr1r7r7r7r8 s               "(d        ~ . ) / & j    !    ..   #