ó ž­çSc@sndZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl mZmZmZddlmZmZddlmZmZmZmZddlmZddlmZddlmZdd lmZm Z ddlmZ!ddl"Z#ddlZd d l$m%Z%d e&fd „ƒYZ'deeej(dƒƒZ)dZ*dej+fd„ƒYZ,dej+fd„ƒYZ-dej+fd„ƒYZ.dej+fd„ƒYZ/d„Z0d„Z1ej2d„d„ƒZ3ej2d„ƒZ4ej2d„ƒZ5ej2d„ƒZ6ej2d „ƒZ7dS(!sEasy install Tests iÿÿÿÿN(tStringIOtBytesIOturlparse(t run_setuptSandboxViolation(t easy_installtfix_jython_executabletget_script_argst nt_quote_arg(tPthDistributions(R(t Distribution(t working_settVersionConflicti(tskipIftFakeDistcBseZd„Zd„ZRS(cCs|dkriSidd6S(Ntconsole_scriptsteptname((tselftgroup((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt get_entry_maps cCsdS(Ntspec((R((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pytas_requirement"s(t__name__t __module__RR(((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyRs sü#!%s # EASY-INSTALL-ENTRY-SCRIPT: 'spec','console_scripts','name' __requires__ = 'spec' import sys from pkg_resources import load_entry_point if __name__ == '__main__': sys.exit( load_entry_point('spec', 'console_scripts', 'name')() ) ts0from setuptools import setup setup(name='foo') tTestEasyInstallTestcBs#eZd„Zd„Zd„ZRS(cCs„tƒ}t|ƒ}t|_tjƒ|_z?|jƒtj j |jdƒ}|j tj j |ƒƒWdt j|jƒXdS(Nssite.py(R RtFalsetsitepy_installedttempfiletmkdtempt install_dirtinstall_site_pytostpathtjoint assertTruetexiststshutiltrmtree(Rtdisttcmdtsitepy((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyttest_install_site_py:s    cCsitƒ}tj}z6gtt|ƒƒD] }|^q(dd!\}}Wd|t_X|j|tƒdS(Nii(RtsystplatformtnextRt assertEqualtWANTED(RR(t old_platformtiRtscript((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyttest_get_script_argsFs   6 cCstƒ}t|ƒ}d„|_t|_ddg|_tjjt j ƒdƒ|_ dg|_ |j ƒ|j|jjiƒt|ƒ}d„|_ddg|_tjjt j ƒdƒ|_ dg|_ |j ƒt|jjjƒƒ}|j|ddgƒdS(NcSstS(N(tTrue(((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pytVstlink1tlink2tokcSstS(N(R5(((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR6`s(R Rtcheck_pth_processingR5t no_find_linkst find_linksR!R"R#RRRtargstensure_finalizedR/t package_indext scanned_urlstsortedtkeys(RR(R)RB((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyttest_no_find_linksQs"          (RRR+R4RC(((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR8s tTestPTHFileWritercBseZd„Zd„ZRS(cCsVtdtjƒgƒ}|j|j ƒ|jttjƒƒƒ|j|jƒdS(sba pth file manager should set dirty if a distribution is in site but also the cwd sdoes-not_existN(R R!tgetcwdR$tdirtytaddtPRDistribution(Rtpth((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt!test_add_from_cwd_site_sets_dirtyjscCsitjdkrd}nd}td|gƒ}|j|j ƒ|jt|ƒƒ|j|j ƒdS(Ntnts%/test/location/does-not-have-to-existsc:\does_not_existsdoes-not_exist(R!RR R$RFRGRH(RtlocationRI((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyttest_add_from_site_is_ignoredss (RRRJRM(((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyRDis tTestUserInstallTestcBsGeZd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(cCsÊtjƒ|_tjj|jdƒ}t|dƒ}|jtƒ|j ƒtj ƒ|_ tj |jƒt j|_tj|_t j|_tjƒt _t j|_tjƒt _t jt_dS(Nssetup.pytw(RRtdirR!R"R#topentwritetSETUP_PYtcloseREtold_cwdtchdirtsitetENABLE_USER_SITEtold_enable_siteteasy_install_pkgt__file__told_filet USER_BASEtold_baset USER_SITEtold_site(Rtsetuptf((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pytsetUp€s      cCsttj|jƒtj|jƒtjtjƒtjtjƒ|j t_|j t_|j t_ |j t_dS(N(R!RVRUR&R'RPRWR]R_R^R`RYRXR\RZR[(R((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyttearDown‘s   cCsTtt_tƒ}d|_t|ƒ}dg|_|jƒ|j|j dƒdS(Nssetup.pytpysuser should be implied( R5RWRXR t script_nameRR=R>R$tuser(RR(R)((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyttest_user_install_impliedœs      cCs_ytdƒWntk r"dSXtjdƒ}tjdtjdtjƒ|jdƒdS(Ntmultiprocessingttest_easy_installtleveltstreamsthis should not break( t __import__t ImportErrortloggingt getLoggert basicConfigtINFOR,tstderrtinfo(Rtlog((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyttest_multiproc_atexit¦s cCsTtt_tƒ}d|_t|ƒ}dg|_|jƒ|j|j dƒdS(Nssetup.pyResNOT user should be implied( RRWRXR RfRR=tinitialize_optionst assertFalseRg(RR(R)((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt6test_user_install_not_implied_without_usersite_enabled±s      c Csêtjƒ}tjƒ}tjj|dƒ}t|dƒ}z|jdƒWd|jƒXtjj |ƒtj j dƒ}tjj jtjƒtj dt local_indextscantnormcasetrealpathRLR/tremoveR%tisdirR&R'tNone( Rt new_locationttargettegg_fileRbt old_ppathR(R)trestactualtexpectedtbasedir((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyttest_local_index»sB         !& c Cst|jƒ}tjj|dƒ}y4tƒ%tƒt|dgƒWdQXWdQXWn.tk rx|j dƒnt k rˆnXdS(sáRegression test for Distribute issue #318 Ensure that a package with setup_requires can be installed when setuptools is installed in the user site-packages without causing a SandboxViolation. ssetup.pytinstallNs$Installation caused SandboxViolation( tcreate_setup_requires_packageRPR!R"R#t quiet_contexttreset_setup_stop_contextRRtfailt IndexError(Rttest_pkgt test_setup_py((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyttest_setup_requiresås     ( RRRcRdRhRvRyRR˜(((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyRN~s  *tTestSetupRequirescBs2eZd„Zeejd„ƒƒZd„ZRS(cCs<tjjjƒ}|jƒd}t|jƒ|}|jdƒrHdStƒŸt j ƒŒ}t ƒz}t d|ƒbd|jd|dd||g}t ƒ1td gƒ|jttj|ƒWdQXWdQXWdQXWdQXWdQXWdQX|jd t|jƒkod knƒ|j|jd jd ƒdS(sÉ When easy_install installs a source distribution which specifies setup_requires, it should honor the fetch parameters (such as allow-hosts, index-url, and find-links). is:0NRzs --index-urls --allow-hostss--exclude-scriptss --install-dirRiiis/does-not-exist/(t setuptoolstteststservert MockServertstartRturltendswithR’R™t create_sdistttempdir_contexttenvironment_contextR“t argv_contextt assertRaisest SystemExitRZtmainR$tlentrequestsR/R"(Rtp_indextnetloct p_index_loct dist_filettemp_install_dirt ei_params((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt'test_setup_requires_honors_fetch_paramsþs(        1,ccsLtƒ=}tjj|dƒ}t|tjdƒjƒƒ|VWdQXdS(sl Return an sdist with a setup_requires dependency (of something that doesn't exist) s"setuptools-test-fetcher-1.0.tar.gzs import setuptools setuptools.setup( name="setuptools-test-fetcher", version="1.0", setup_requires = ['does-not-exist'], ) N(R¢R!R"R#tmake_trivial_sdistttextwraptdedenttlstrip(RPt dist_path((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR¡!s c Cstjƒ}tdddddƒ}tj|ƒzÓtƒÄ}t|ƒ}tjj |dƒ}t ƒR\}}t ƒ:yt |dgƒWnt k r±|jdƒnXWd QXWd QX|jƒ}|jt|ƒd kƒ|j|d jƒd ƒWd QXWd tj|ƒXd S( sö Regression test for issue #323. Ensures that a distribution's setup_requires requirements can still be installed and used locally even if a conflicting version of that requirement is already on the path. sdoes-not-mattert project_nametfoobartversions0.0ssetup.pys--names9Installing setup.py requirements caused a VersionConflictNiiÿÿÿÿR–(t pkg_resourcest __getstate__RHR RGR¢R‘R!R"R#R’R“RR R”t readlinesR$R¨tstript __setstate__( Rtpr_statet fake_distttemp_dirR–R—tstdoutRstlines((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt.test_setup_requires_overrides_version_conflict6s$        $(RRR°t staticmethodt contextlibtcontextmanagerR¡RÃ(((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR™üs #cCsÍidd6dd6dgd6tjj|ƒgd6}tjj|dƒ}tjj|dƒ}tj|ƒt|d ƒ}|jtjd |ƒƒ|j ƒtjj|d ƒ}t |tjd ƒƒ|S( sÔCreates a source tree under path for a trivial test package that has a single requirement in setup_requires--a tarball for that requirement is also created and added to the dependency_links argument. R–Rs0.0R¸s foobar==0.1tsetup_requirestdependency_linksssetup.pyROs= import setuptools setuptools.setup(**%r) sfoobar-0.1.tar.gzs import setuptools setuptools.setup( name='foobar', version='0.1' ) ( R!R"tabspathR#tmkdirRQRRR²R³RTR±(R"ttest_setup_attrsR–R—Rbt foobar_path((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR‘Ys"     cCs›tjddƒ}y t}Wntk r5t}nX||jdƒƒ}t|jƒƒ|_tj |dƒ}z|j |d|ƒWd|j ƒXdS(s‹Create a simple sdist tarball at dist_path, containing just a setup.py, the contents of which are provided by the setup_py string. Rssetup.pysutf-8sw:gztfileobjN( ttarfiletTarInfoRtAttributeErrorRtencodeR¨tgetvaluetsizeRQtaddfileRT(Rµtsetup_pyt setup_py_filetMemFiletsetup_py_bytesR(((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR±~s   cCsdS(N(R†(RP((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR6“sccsJtjƒ}tjƒ}z||ƒ|VWd||ƒtj|ƒXdS(N(RRR!RER&R'(tcdRÀtorig_dir((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR¢’s     cks[tjjƒ}tjj|ƒz dVWdx|D]}tj|=q2Wtjj|ƒXdS(N(R!R}tcopytupdate(tupdatestold_envtkey((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR£s  ccs'tj}|tj(dV|tj(dS(N(R,targv(trepltold_argv((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR¤¨s  ccs-tjj}dtj_dV|tj_dS(s When the setuptools tests are run using setup.py test, and then one wants to invoke another setup() command (such as easy_install) within those tests, it's necessary to reset the global variable in distutils.core so that the setup() command will run naturally. N(t distutilstcoret_setup_stop_afterR†(tsetup_stop_after((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR“¯s  ccsutj}tj}tƒ}t_tƒ}t_z||fVWd|jdƒ|jdƒ|t_|t_XdS(sk Redirect stdout/stderr to StringIO objects to prevent console output from distutils commands. Ni(R,RÁRsRtseek(t old_stdoutt old_stderrt new_stdoutt new_stderr((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR’½s     (8t__doc__R,R!R&RtunittestRWRÅR²RÎRotdistutils.coreRãtsetuptools.compatRRRtsetuptools.sandboxRRtsetuptools.command.easy_installRRRRR tsetuptools.commandRZtsetuptools.distR R¹R R RHtsetuptools.tests.serverRšt py26compatR tobjectRt executableR0RStTestCaseRRDRNR™R‘R±RÆR¢R£R¤R“R’(((sL/usr/local/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pytsJ           "  1~] %