Ñò
¨Kc           @   sò   d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k l Z d  d k l Z d  d k l Z d  d k l Z d  d k	 l
 Z
 d  d k l Z d  d k l Z e
 d	 e i i d
 d ƒ g d e i i e i ƒ  g ƒg Z d „  Z d „  Z d S(   iÿÿÿÿN(   t   dist(   t	   sysconfig(   t	   file_util(   t   util(   t	   Extension(   t   new_compiler(   t	   build_extt   _test_extensiont   testss   _test_extension.ct   include_dirsc          C   s°   t  ƒ  t i i t i i t ƒ ƒ }  g  } t i t i i |  d ƒ ƒ D]- } | d t i i t i i	 | ƒ ƒ d qH ~ } t
 i ƒ  i | ƒ } t
 i ƒ  } | i | ƒ | S(   sT   Collect all tests under the tests directory and return a
    unittest.TestSuite
    s	   test_*.pys   tests.%si    (   t   build_test_extensionst   ost   patht   realpatht   dirnamet   __file__t   globt   joint   splitextt   basenamet   unittestt
   TestLoadert   loadTestsFromNamest	   TestSuitet   addTests(   t	   tests_dirt   _[1]t   tt   test_module_listt	   test_listt   suite(    (    s6   /home/ambroff/code/greenlet/greenlet/tests/__init__.pyt   test_collector   s    Rc             s®   t  i i d d t i ƒ  t i d d !f ƒ ‰  t ƒ  ‰ t i	 ƒ  }  t
 i
 |  ƒ ‰ ˆ i ƒ  ˆ i ˆ i ƒ t i ˆ ƒ ‡  ‡ ‡ f d †  } x t D] } | | ƒ q– Wd S(   sÔ  Because distutils sucks, it just copies the entire contents of the build
    results dir (e.g. build/lib.linux-i686-2.6) during installation. That means
    that we can't put any files there that we don't want to distribute. </3.

    To deal with that, this code will compile the test extension and place the
    object files in the normal temp directory using the same logic as distutils,
    but linked shared library will go directly into the tests directory.
    t   builds
   temp.%s-%si    i   c            sÉ   ˆ i  |  i d ˆ  d |  i d t d |  i ƒ} t i i ˆ  ˆ i |  i	 ƒ ƒ } ˆ i
 | | d ˆ i |  ƒ d |  i d |  i d ˆ i |  ƒ d t d	 ˆ  d
 ˆ i |  i ƒ ƒt i | t i i ƒ d S(   s:   compile sources, link shared library, and copy it into CWDt
   output_dirR	   t   debugt   dependst	   librariest   library_dirst   runtime_library_dirst   export_symbolst
   build_tempt   target_langN(   t   compilet   sourcesR	   t   FalseR#   R   R   R   t   get_ext_filenamet   namet   link_shared_objectt   get_librariesR%   R&   t   get_export_symbolst   detect_languageR   t	   copy_filet   curdir(   t	   extensiont   objectst   output_file(   t   build_temp_dirt   build_ext_cmdt   compiler(    s6   /home/ambroff/code/greenlet/greenlet/tests/__init__.pyt   build_and_copy4   s&    					N(   R   R   R   R   t   get_platformt   syst   versionR   R    t   DistributionR   t   finalize_optionst   set_library_dirsR%   R   t   customize_compilert   TEST_EXTENSIONS(   t   distributionR;   R5   (    (   R8   R9   R:   s6   /home/ambroff/code/greenlet/greenlet/tests/__init__.pyR
   #   s    		&	
 (   R   R   R   R=   t	   distutilsR    R   R   R   t   distutils.coreR   t   distutils.ccompilerR   t   distutils.commandR   R   R   R4   t   get_python_incRC   R   R
   (    (    (    s6   /home/ambroff/code/greenlet/greenlet/tests/__init__.pyt   <module>   s   	