ó
ÓnùWc           @   sd  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  m! Z! d d l m Z" d d l# 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/ d „  Z0 e j1 d „  d „ ƒ Z2 e j1 d „  ƒ Z3 e j1 d „  ƒ Z4 e j1 d „  ƒ Z5 e j1 d „  ƒ Z6 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   Distribution(   t   working_sett   VersionConflictt   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(    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyt   get_entry_map   s    c         C   s   d S(   Nt   spec(    (   R   (    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyt   as_requirement!   s    (   t   __name__t
   __module__R   R   (    (    (    sI   /var/www/html/venv/build/setuptools/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(    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyt   test_install_site_py9   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(    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyt   test_get_script_argsE   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(    (    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyt   <lambda>U   s    t   link1t   link2t   okc           S   s   t  S(   N(   R4   (    (    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyR5   _   s    (   R   R   t   check_pth_processingR4   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)   RA   (    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyt   test_no_find_linksP   s"    		

(   R   R   R+   R3   RB   (    (    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyR   7   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(    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyt!   test_add_from_cwd_site_sets_dirtyi   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$   RE   RF   RG   (   R   t   locationRH   (    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyt   test_add_from_site_is_ignoredr   s    	(   R   R   RI   RL   (    (    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyRC   h   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   closeRD   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(    (    sI   /var/www/html/venv/build/setuptools/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!   RU   RT   R&   R'   RO   RV   R\   R^   R]   R_   RX   RW   R[   RY   RZ   (   R   (    (    sI   /var/www/html/venv/build/setuptools/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(
   R4   RV   RW   R   t   script_nameR   R<   R=   R$   t   user(   R   R(   R)   (    (    sI   /var/www/html/venv/build/setuptools/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(    (    sI   /var/www/html/venv/build/setuptools/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.pyRd   s   NOT user should be implied(
   R   RV   RW   R   Re   R   R<   t   initialize_optionst   assertFalseRf   (   R   R(   R)   (    (    sI   /var/www/html/venv/build/setuptools/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-infoRN   s
   Name: foo
t
   PYTHONPATHs   setup.pyt   foo(   R   R   R!   R"   R#   RP   RQ   RS   R,   t   appendt   environt   gett   pathsepR   Re   R   R   R<   R=   t   local_indext   scanR.   t   realpathRK   t   removeR%   t   isdirR&   R'   t   None(
   R   t   new_locationt   targett   egg_fileRa   t	   old_ppathR(   R)   t   rest   basedir(    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyt   test_local_indexº   s@    			
&c         C   s}   t  |  j ƒ } t j j | d ƒ } y4 t ƒ  % t ƒ   t | d g ƒ Wd QXWd QXWn t k
 rx |  j	 d ƒ n 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.
        s   setup.pyt   installNs$   Installation caused SandboxViolation(
   t   create_setup_requires_packageRO   R!   R"   R#   t   quiet_contextt   reset_setup_stop_contextR   R   t   fail(   R   t   test_pkgt   test_setup_py(    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyt   test_setup_requiresã   s    

 (	   R   R   Rb   Rc   Rg   Ru   Rx   R‹   R“   (    (    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyRM   }   s   			
		
	)t   TestSetupRequiresc           B   s2   e  Z d  „  Z e e j d „  ƒ ƒ Z d „  Z RS(   c         C   s<  t  j j j ƒ  } | j ƒ  d } t | j ƒ | } | j d ƒ rH d St ƒ  Ÿ t	 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 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   :0NRy   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Ž   R”   t   create_sdistt   tempdir_contextt   environment_contextR   t   argv_contextt   assertRaisest
   SystemExitRY   t   mainR$   t   lent   requestsR.   R"   (   R   t   p_indext   netloct   p_index_loct	   dist_filet   temp_install_dirt	   ei_params(    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyt'   test_setup_requires_honors_fetch_paramsø   s(    

			
	1,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#   t   make_trivial_sdistt   textwrapt   dedentt   lstrip(   RO   t	   dist_path(    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyRœ     s    c   	      C   s  t  j ƒ  } t d d d d d ƒ} t j | ƒ zÓ t ƒ  Ä } t | ƒ } t j j	 | d ƒ } t
 ƒ  R \ } } t ƒ  : y t | d g ƒ Wn t k
 r± |  j d ƒ n XWd	 QXWd	 QX| j ƒ  } |  j t | ƒ d
 k ƒ |  j | d j ƒ  d ƒ Wd	 QXWd	 t  j | ƒ 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.
        s   does-not-mattert   project_namet   foobart   versions   0.0s   setup.pys   --names9   Installing setup.py requirements caused a VersionConflictNi    iÿÿÿÿR‘   (   t   pkg_resourcest   __getstate__RG   R   RF   R   R   R!   R"   R#   RŽ   R   R   R   R   t	   readlinesR$   R£   t   stript   __setstate__(	   R   t   pr_statet	   fake_distt   temp_dirR‘   R’   t   stdoutRr   t   lines(    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyt.   test_setup_requires_overrides_version_conflict0  s$    		
$(   R   R   R«   t   staticmethodt
   contextlibt   contextmanagerRœ   R¾   (    (    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyR”   ö   s   	#c         C   sÍ   i d d 6d d 6d g d 6t  j j |  ƒ g d 6} t  j j |  d ƒ } t  j j | d ƒ } t  j | ƒ t | d	 ƒ } | j t j d
 | ƒ ƒ | j	 ƒ  t  j j |  d ƒ } t
 | t j d ƒ ƒ | 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‘   R   s   0.0R³   s   foobar==0.1t   setup_requirest   dependency_linkss   setup.pyRN   s=           import setuptools
        setuptools.setup(**%r)
    s   foobar-0.1.tar.gzs               import setuptools
            setuptools.setup(
                name='foobar',
                version='0.1'
            )
        (   R!   R"   t   abspathR#   t   mkdirRP   RQ   R­   R®   RS   R¬   (   R"   t   test_setup_attrsR‘   R’   Ra   t   foobar_path(    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyR   S  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   sizeRP   t   addfileRS   (   R°   t   setup_pyt   setup_py_filet   MemFilet   setup_py_bytesR(   (    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyR¬   x  s    

c         C   s   d  S(   N(   R„   (   RO   (    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyR5     s    c         c   sJ   t  j ƒ  } t j ƒ  } z |  | ƒ | VWd  |  | ƒ t j | ƒ Xd  S(   N(   R   R   R!   RD   R&   R'   (   t   cdR»   t   orig_dir(    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyR   Œ  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!   R|   t   copyt   update(   t   updatest   old_envt   key(    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyRž   —  s    	c         c   s'   t  j } |  t  j (d  V| t  j (d  S(   N(   R,   t   argv(   t   replt   old_argv(    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyRŸ   ¢  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(    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyR   ©  s    c          c   su   t  j }  t  j } t ƒ  } t  _ t ƒ  } t  _ z | | f VWd | j d ƒ | j d ƒ |  t  _ | t  _ Xd S(   sk   
    Redirect stdout/stderr to StringIO objects to prevent console output from
    distutils commands.
    Ni    (   R,   R¼   Rr   R    t   seek(   t
   old_stdoutt
   old_stderrt
   new_stdoutt
   new_stderr(    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyRŽ   ·  s    			(7   t   __doc__R,   R!   R&   R   t   unittestRV   RÀ   R­   RÉ   Rn   t   distutils.coreRÞ   t   setuptools.compatR    R   R   R   t   setuptools.sandboxR   R   t   setuptools.command.easy_installR   R   R   R	   R
   t   setuptools.commandRY   t   setuptools.distR   R´   R   R   RG   t   setuptools.tests.serverR•   t   objectR   t
   executableR/   RR   t   TestCaseR   RC   RM   R”   R   R¬   RÁ   R   Rž   RŸ   R   RŽ   (    (    (    sI   /var/www/html/venv/build/setuptools/setuptools/tests/test_easy_install.pyt   <module>   sH   ""1y]	%	
