ó
±›Rc           @   s'  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l	 Z	 d d l
 Z
 d d l Z d d l m Z m Z m Z m Z d d l m Z m Z d d l m Z m Z m Z m Z d d l m Z d d l m Z d d l m Z d d l m Z  d d l! Z" d	 e# f d
 „  ƒ  YZ$ d e e e j% d ƒ ƒ Z& d Z' d e j( f d „  ƒ  YZ) d e j( f d „  ƒ  YZ* d e j( f d „  ƒ  YZ+ d e j( f d „  ƒ  YZ, d „  Z- e j. d „  d „ ƒ Z/ e j. d „  ƒ Z0 e j. d „  ƒ Z1 e j. d „  ƒ Z2 d S(   s   Easy install Tests
iÿÿÿÿN(   t   StringIOt   BytesIOt   nextt   urlparse(   t	   run_setupt   SandboxViolation(   t   easy_installt   fix_jython_executablet   get_script_argst   nt_quote_arg(   t   PthDistributions(   R   (   t   Distributiont   FakeDistc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   | d k r i  Si d d 6S(   Nt   console_scriptst   ept   name(    (   t   selft   group(    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt   get_entry_map   s    c         C   s   d S(   Nt   spec(    (   R   (    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt   as_requirement   s    (   t   __name__t
   __module__R   R   (    (    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR      s   	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')()
    )
t    s0   from setuptools import setup

setup(name='foo')
t   TestEasyInstallTestc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   s„   t  ƒ  } t | ƒ } t | _ t j ƒ  | _ z? | j ƒ  t j	 j
 | j d ƒ } |  j t j	 j | ƒ ƒ Wd  t j | j ƒ Xd  S(   Ns   site.py(   R   R   t   Falset   sitepy_installedt   tempfilet   mkdtempt   install_dirt   install_site_pyt   ost   patht   joint
   assertTruet   existst   shutilt   rmtree(   R   t   distt   cmdt   sitepy(    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt   test_install_site_py7   s    		
c         C   si   t  ƒ  } t j } z6 g  t t | ƒ ƒ D] } | ^ q( d d !\ } } Wd  | t _ X|  j | t ƒ d  S(   Ni    i   (   R   t   syst   platformR   R   t   assertEqualt   WANTED(   R   R&   t   old_platformt   iR   t   script(    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt   test_get_script_argsC   s    		6
c         C   s  t  ƒ  } t | ƒ } d „  | _ t | _ d d g | _ t j j t	 j
 ƒ  d ƒ | _ d g | _ | j ƒ  |  j | j j i  ƒ t | ƒ } d „  | _ d d g | _ t j j t	 j
 ƒ  d ƒ | _ d g | _ | j ƒ  t | j j j ƒ  ƒ } |  j | d d g ƒ d  S(   Nc           S   s   t  S(   N(   t   True(    (    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt   <lambda>S   s    t   link1t   link2t   okc           S   s   t  S(   N(   R2   (    (    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR3   ]   s    (   R   R   t   check_pth_processingR2   t   no_find_linkst
   find_linksR   R    R!   R   R   R   t   argst   ensure_finalizedR,   t   package_indext   scanned_urlst   sortedt   keys(   R   R&   R'   R?   (    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt   test_no_find_linksN   s"    		

(   R   R   R)   R1   R@   (    (    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR   5   s   		t   TestPTHFileWriterc           B   s   e  Z d  „  Z d „  Z RS(   c         C   sV   t  d t j ƒ  g ƒ } |  j | j ƒ | j t t j ƒ  ƒ ƒ |  j | j ƒ d S(   sb   a pth file manager should set dirty
        if a distribution is in site but also the cwd
        s   does-not_existN(   R
   R   t   getcwdR"   t   dirtyt   addt   PRDistribution(   R   t   pth(    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt!   test_add_from_cwd_site_sets_dirtyg   s    c         C   si   t  j d k r d } n d } t d | g ƒ } |  j | j ƒ | j t | ƒ ƒ |  j | j ƒ d  S(   Nt   nts%   /test/location/does-not-have-to-exists   c:\does_not_exists   does-not_exist(   R   R   R
   R"   RC   RD   RE   (   R   t   locationRF   (    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt   test_add_from_site_is_ignoredp   s    	(   R   R   RG   RJ   (    (    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyRA   f   s   		t   TestUserInstallTestc           B   sG   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   sÊ   t  j ƒ  |  _ t j j |  j d ƒ } t | d ƒ } | j t ƒ | j	 ƒ  t j
 ƒ  |  _ t j |  j ƒ t j |  _ t j |  _ t j |  _ t  j ƒ  t _ t j |  _ t  j ƒ  t _ t j t _ d  S(   Ns   setup.pyt   w(   R   R   t   dirR   R    R!   t   opent   writet   SETUP_PYt   closeRB   t   old_cwdt   chdirt   sitet   ENABLE_USER_SITEt   old_enable_sitet   easy_install_pkgt   __file__t   old_filet	   USER_BASEt   old_baset	   USER_SITEt   old_site(   R   t   setupt   f(    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt   setUp}   s    
c         C   st   t  j |  j ƒ t j |  j ƒ t j t j ƒ t j t j ƒ |  j	 t _ |  j
 t _ |  j t _ |  j t _ d  S(   N(   R   RS   RR   R$   R%   RM   RT   RZ   R\   R[   R]   RV   RU   RY   RW   RX   (   R   (    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt   tearDownŽ   s    c         C   sT   t  t _ t ƒ  } d | _ t | ƒ } d g | _ | j ƒ  |  j | j	 d ƒ d  S(   Ns   setup.pyt   pys   user should be implied(
   R2   RT   RU   R   t   script_nameR   R:   R;   R"   t   user(   R   R&   R'   (    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt   test_user_install_implied™   s    			
c         C   s_   y t  d ƒ Wn t k
 r" d  SXt j d ƒ } t j d t j d t j ƒ | j d ƒ d  S(   Nt   multiprocessingt   test_easy_installt   levelt   streams   this should not break(	   t
   __import__t   ImportErrort   loggingt	   getLoggert   basicConfigt   INFOR*   t   stderrt   info(   R   t   log(    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt   test_multiproc_atexit£   s    c         C   sT   t  t _ t ƒ  } d | _ t | ƒ } d g | _ | j ƒ  |  j | j	 d ƒ d  S(   Ns   setup.pyRb   s   NOT user should be implied(
   R   RT   RU   R   Rc   R   R:   t   initialize_optionst   assertFalseRd   (   R   R&   R'   (    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt6   test_user_install_not_implied_without_usersite_enabled®   s    			
c   
      C   sÆ  t  j ƒ  } t  j ƒ  } t j j | d ƒ } t | d ƒ } z | j d ƒ Wd  | j ƒ  Xt j j	 | ƒ t j
 j d ƒ } t j j j t j ƒ t j
 d <zŽ t ƒ  } d | _ t | ƒ } | | _ d g | _ | j ƒ  | j j | g ƒ | j d ƒ } |  j t j j | j ƒ t j j | ƒ ƒ Wd  t j j | ƒ x[ | | g D]M }	 t j j |	 ƒ sJt j j |	 ƒ r|qJn  y t j |	 ƒ WqJqJXqJW| d  k	 r·| t j
 d <n
 t j
 d =Xd  S(   Ns   foo-1.0.egg-infoRL   s
   Name: foo
t
   PYTHONPATHs   setup.pyt   foo(   R   R   R   R    R!   RN   RO   RQ   R*   t   appendt   environt   gett   pathsepR   Rc   R   R   R:   R;   t   local_indext   scanR,   t   realpathRI   t   removeR#   t   isdirR$   R%   t   None(
   R   t   new_locationt   targett   egg_fileR_   t	   old_ppathR&   R'   t   rest   basedir(    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt   test_local_index¸   s@    			
&c         C   s_  i d d 6d d 6d g d 6t  j j |  j ƒ g d 6} t  j j |  j d ƒ } t  j j | d ƒ } t  j | ƒ t | d	 ƒ } | j t j	 d
 | ƒ ƒ | j
 ƒ  t  j j |  j d ƒ } t | t j	 d ƒ ƒ t j } t j } t ƒ  t _ t ƒ  t _ zI y$ t ƒ  � t | d g ƒ Wd QXWn t k
 rC|  j d ƒ n XWd | t _ | t _ Xd S(   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.
        t   test_pkgR   s   0.0t   versiont   foobart   setup_requirest   dependency_linkss   setup.pyRL   sI               import setuptools
            setuptools.setup(**%r)
        s   foobar-0.1.tar.gzs§                   import setuptools
                setuptools.setup(
                    name='foobar',
                    version='0.1'
                )
            t   installNs$   Installation caused SandboxViolation(   R   R    t   abspathRM   R!   t   mkdirRN   RO   t   textwrapt   dedentRQ   t   make_trivial_sdistR*   t   stdoutRp   R    t   reset_setup_stop_contextR   R   t   fail(   R   t   test_setup_attrsRŠ   t   test_setup_pyR_   t   foobar_patht
   old_stdoutt
   old_stderr(    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt   test_setup_requiresá   s8    


		
	(	   R   R   R`   Ra   Re   Rs   Rv   R‰   R�   (    (    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyRK   {   s   			
		
	)t   TestSetupRequiresc           B   s)   e  Z d  „  Z e e j d „  ƒ ƒ Z RS(   c         C   s,  t  j j j ƒ  } | j ƒ  d } t | j ƒ | } | j d ƒ rH d St j	 ƒ  �Œ } t
 ƒ  �z } t d | ƒ �b d | j d | d d | | g } t ƒ  �1 t d	 g ƒ � |  j t t j | ƒ Wd QXWd QXWd QXWd QXWd QX|  j d
 t | j ƒ k od k n ƒ |  j | j d j d ƒ d S(   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).
        i   s   :0NRw   s   --index-urls   --allow-hostss   --exclude-scriptss   --install-dirR   i   i   i    s   /does-not-exist/(   t
   setuptoolst   testst   servert
   MockServert   startR   t   urlt   endswithRž   t   create_sdistt   tempdir_contextt   environment_contextR–   t   argv_contextt   assertRaisest
   SystemExitRW   t   mainR"   t   lent   requestsR,   R    (   R   t   p_indext   netloct   p_index_loct	   dist_filet   temp_install_dirt	   ei_params(    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt'   test_setup_requires_honors_fetch_params  s&    
			
	+,c          c   sL   t  ƒ  �= }  t j j |  d ƒ } t | t j d ƒ j ƒ  ƒ | VWd QXd S(   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!   R”   R’   R“   t   lstrip(   RM   t	   dist_path(    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR¦   8  s    (   R   R   Rµ   t   staticmethodt
   contextlibt   contextmanagerR¦   (    (    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyRž     s   	"c         C   s›   t  j d d ƒ } y
 t } Wn t k
 r5 t } n X| | j d ƒ ƒ } t | j ƒ  ƒ | _ t  j	 |  d ƒ } z | j
 | d | ƒWd | j ƒ  Xd S(   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.
    R   s   setup.pys   utf-8s   w:gzt   fileobjN(   t   tarfilet   TarInfoR   t   AttributeErrorR    t   encodeR­   t   getvaluet   sizeRN   t   addfileRQ   (   R·   t   setup_pyt   setup_py_filet   MemFilet   setup_py_bytesR&   (    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR”   N  s    

c         C   s   d  S(   N(   R‚   (   RM   (    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR3   c  s    c         c   sJ   t  j ƒ  } t j ƒ  } z |  | ƒ | VWd  |  | ƒ t j | ƒ Xd  S(   N(   R   R   R   RB   R$   R%   (   t   cdt   temp_dirt   orig_dir(    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR§   b  s    
	
c          k   s[   t  j j ƒ  } t  j j |  ƒ z	 d  VWd  x |  D] } t  j | =q2 Wt  j j | ƒ Xd  S(   N(   R   Rz   t   copyt   update(   t   updatest   old_envt   key(    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR¨   m  s    	c         c   s'   t  j } |  t  j (d  V| t  j (d  S(   N(   R*   t   argv(   t   replt   old_argv(    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR©   x  s    

c          c   s-   t  j j }  d t  j _ d V|  t  j _ d S(   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	   distutilst   coret   _setup_stop_afterR‚   (   t   setup_stop_after(    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyR–     s    (3   t   __doc__R*   R   R$   R   t   unittestRT   R¹   R’   R¼   Rl   t   distutils.coreRÒ   t   setuptools.compatR    R   R   R   t   setuptools.sandboxR   R   t   setuptools.command.easy_installR   R   R   R	   R
   t   setuptools.commandRW   t   setuptools.distR   t   pkg_resourcesRE   t   setuptools.tests.serverRŸ   t   objectR   t
   executableR-   RP   t   TestCaseR   RA   RK   Rž   R”   Rº   R§   R¨   R©   R–   (    (    (    s\   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/setuptools/tests/test_easy_install.pyt   <module>   s@   ""1™:	
