ó
§xxTc           @   s	  d  d l  Z  d  d l Z d  d l m Z d  d l Z d  d l 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 m Z d  d l Z d  d l m Z e a d	 e j e j e j f d
 „  ƒ  YZ d „  Z e d k re j e ƒ  ƒ n  d S(   iÿÿÿÿN(   t   StringIO(   t	   Extensiont   Distribution(   t	   build_ext(   t	   sysconfig(   t   support(   t   DistutilsSetupErrort   CompileErrort   DistutilsPlatformError(   t   test_supportt   BuildExtTestCasec           B   s:  e  Z d  „  Z d „  Z d „  Z d „  Z e j e j	 d k  d ƒ d „  ƒ Z
 d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e j e j d k d ƒ d „  ƒ Z e j e j d k d ƒ d „  ƒ Z e j e j d k d ƒ d „  ƒ Z e j e j d k d ƒ d „  ƒ Z d „  Z RS(   c         C   s°   t  t |  ƒ j ƒ  |  j ƒ  |  _ t |  _ t j j	 |  j ƒ |  j
 t j j |  j ƒ t j d k r¬ d d  l } | j |  _ |  j ƒ  | _ d d l m } | j | _ n  d  S(   Ns   2.6iÿÿÿÿ(   R   (   t   superR
   t   setUpt   mkdtempt   tmp_dirt   Falset
   xx_createdt   syst   patht   appendt
   addCleanupt   removet   versiont   sitet	   USER_BASEt   old_user_baset   distutils.commandR   (   t   selfR   R   (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyR      s    	c         C   s0   |  j  r t j d ƒ n  t t |  ƒ j ƒ  d  S(   Nt   xx(   R   R	   t   unloadR   R
   t   tearDown(   R   (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyR   %   s    	c   	      C   sî  t  j |  j ƒ t |  _ t j j |  j d ƒ } t d | g ƒ } t	 i d d 6| g d 6ƒ } |  j | _
 t | ƒ } t  j | ƒ |  j | _ |  j | _ t j } t j s¾ t ƒ  t _ n  z | j ƒ  | j ƒ  Wd  | t _ Xt rý |  j d t ƒ n t |  ƒ j a d d  l } x$ d D] } |  j t | | ƒ ƒ qW|  j | j d d ƒ d ƒ |  j | j d d ƒ d ƒ |  j | j ƒ  j  ƒ  d  ƒ t j" r¸d } |  j | j# | ƒ n  |  j$ | j% ƒ  | j% ƒ |  j$ | j& ƒ  | j& ƒ d  S(   Ns
   xxmodule.cR   t   namet   ext_moduless   Already tested in %siÿÿÿÿt   errort   foot   newt   roji   i   i   i   i   i   s/   This is a template module just for instruction.(   s   errors   foos   newR$   ('   R   t   copy_xxmodule_cR   t   TrueR   t   osR   t   joinR   R   t   package_dirR   t   fixup_build_extt	   build_libt
   build_tempR   t   stdoutR	   t   verboseR    t   ensure_finalizedt   runt   ALREADY_TESTEDt   skipTestt   typet   __name__R   t
   assertTruet   hasattrt   assertEqualR"   R#   t   demot   Nonet   HAVE_DOCSTRINGSt   __doc__t   assertIsInstancet   Nullt   Str(	   R   t   xx_ct   xx_extt   distt   cmdt
   old_stdoutR   t   attrt   doc(    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyt   test_build_ext,   s>    			

	c         C   s²   t  i d d 6ƒ } t | ƒ } t j } d t _ d d l m } | j d ƒ } d | d <z | j ƒ  Wd  | t _ | d  k rŠ | d =n
 | | d <X|  j	 t
 | j ƒ d ƒ d  S(	   NR   R   t   sunosiÿÿÿÿ(   t   _config_varst   Py_ENABLE_SHAREDi   i    (   R   R   R   t   platformt   distutils.sysconfigRH   t   getR/   R9   t   assertGreatert   lent   library_dirs(   R   RA   RB   t   oldRH   t   old_var(    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyt   test_solaris_enable_sharedV   s    		
	
s   2.6s$   site.USER_SITE was introduced in 2.6c   
      C   sú   d d  l  } t i d d 6ƒ } t | ƒ } g  | j D] \ } } } | ^ q5 } |  j d | ƒ d | _ t j j | j	 d ƒ } t j j | j	 d ƒ }	 t j
 | ƒ t j
 |	 ƒ | j ƒ  |  j | | j ƒ |  j | | j ƒ |  j |	 | j ƒ d  S(   NiÿÿÿÿR   R   t   useri   t   libt   include(   R   R   R   t   user_optionst   assertInRS   R'   R   R(   R   t   mkdirR/   RO   t   rpatht   include_dirs(
   R   R   RA   RB   R   t   shortt   labelt   optionsRT   t   incl(    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyt   test_user_sitek   s    "	
c         C   s-  t  d d g ƒ g } t i d d 6| d 6ƒ } t | ƒ } | j ƒ  t j ƒ  } |  j | | j ƒ t j d d ƒ } |  j | | j ƒ t | ƒ } d | _ | j ƒ  |  j	 | j d	 d
 d g ƒ t | ƒ } d t
 j | _ | j ƒ  |  j d | j ƒ |  j d | j ƒ t | ƒ } d t
 j | _ | j ƒ  |  j	 | j d d g ƒ t | ƒ } d | _ | j ƒ  |  j	 | j d d g ƒ t | ƒ } d | _ | j ƒ  |  j	 | j d d g ƒ t | ƒ } d  | _ | j ƒ  |  j	 | j g  ƒ t | ƒ } d | _ | j ƒ  |  j	 | j d d g ƒ d  S(   NR"   t   xxxR   R   R    t   plat_specifici   s   my_lib, other_lib lastlibt   my_libt	   other_libt   lastlibs   my_lib_dir%sother_lib_dirt
   my_lib_dirt   other_lib_dirs   one%stwot   onet   twos   one,twot   1s   1 2t   2(   Rg   Ri   (   Rh   Ri   (   R   R   R   t   finalize_optionsR   t   get_python_incRW   RZ   t	   librariesR7   R'   t   pathsepRO   RY   t   definet   undefR9   t	   swig_opts(   R   t   modulesRA   RB   t
   py_includet   plat_py_include(    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyt   test_finalize_options‡   sJ    
	


	
	
	
	
c         C   s³  t  ƒ  } t | ƒ } | j ƒ  |  j t | j d ƒ d d g } |  j t | j | ƒ d g } |  j t | j | ƒ d g } |  j t | j | ƒ d i d g d 6d d 6d d 6f g } | j | ƒ | d	 } |  j | t ƒ |  j | j	 d ƒ |  j
 t | d ƒ ƒ d i d g d 6d d 6d d 6d d g d 6f g } |  j t | j | ƒ d d g | d	 d d <| j | ƒ |  j | d	 j d g ƒ |  j | d	 j d g ƒ d  S(   NR"   t   bars   foo-bart    s   foo.bart   sourcesRm   t   somei    Ri   Rj   t   3t   macrosi   (   Rv   s   fooRv   (   s   foo-barRw   (   s   foo.barRw   (   Ri   Rj   Rz   (   Ri   Rj   (   Rz   (   Ri   Rj   (   R   R   Rk   t   assertRaisesR   t   check_extensions_listR<   R   R7   Rm   t   assertFalseR6   t   undef_macrost   define_macros(   R   RA   RB   t   extst   ext(    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyt   test_check_extensions_listÆ   s0    	
		
c         C   sb   t  d d g ƒ g } t i d d 6| d 6ƒ } t | ƒ } | j ƒ  |  j | j ƒ  d g ƒ d  S(   NR"   R`   R   R   R    (   R   R   R   R/   R7   t   get_source_files(   R   Rr   RA   RB   (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyt   test_get_source_filesõ   s
    
c         C   sI   t  ƒ  } t | ƒ } d | _ | j ƒ  | j ƒ  |  j | j d ƒ d  S(   Nt   unix(   R   R   t   compilerR/   R0   R7   (   R   RA   RB   (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyt   test_compiler_optionü   s    		

c         C   s*  |  j  ƒ  } t j j | d ƒ } |  j | d ƒ t d | g ƒ } t i d d 6| g d 6ƒ } t | ƒ } t j	 | ƒ | j
 ƒ  |  j t | j ƒ  ƒ d ƒ t j j |  j d ƒ | _ t j j |  j d	 ƒ | _ t j j |  j  ƒ  ƒ } t j ƒ  } t j | ƒ z' d | _ | j ƒ  | j ƒ  d
 } Wd  t j | ƒ X|  j t j j | ƒ ƒ |  j t j j | ƒ d t j d ƒ ƒ t j j | ƒ }	 |  j |	 | ƒ d  | _ d
 | _ | j ƒ  | j ƒ  d
 } |  j t j j | ƒ ƒ |  j t j j | ƒ d t j d ƒ ƒ t j j | ƒ }	 |  j |	 | j ƒ | j d ƒ }
 i d d 6|
 _ | j  d ƒ } t j j! | ƒ d
 } |  j | | j ƒ d | _ t j j |  j  ƒ  ƒ } t j ƒ  } t j | ƒ z | j  d ƒ } Wd  t j | ƒ Xt j j! | ƒ d
 } t j j! | ƒ d } |  j | d ƒ d  S(   Ns   foo.cs   void initfoo(void) {};
R"   R   R   R    i   t   buildt   tempti    iÿÿÿÿt   SOt   build_pyRv   Rw   ("   R   R'   R   R(   t
   write_fileR   R   R   R   R*   R/   R7   RN   t   get_outputsR   R+   R,   t   realpatht   getcwdt   chdirt   inplaceR0   R5   t   existst   splitextR   t   get_config_vart   dirnameR9   R‡   t   get_finalized_commandR)   t   get_ext_fullpatht   split(   R   R   t   c_fileR‚   RA   RB   t   other_tmp_dirt   old_wdt   so_filet   so_dirRŒ   R   t   lastdir(    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyt   test_get_outputs  sb    
	
		
	c         C   s²  t  j ƒ  d } t ƒ  } t | ƒ } d | _ i d d 6| j _ d d g | j _ t j	 ƒ  } t j
 j | d d d | ƒ } | j d ƒ } |  j | | ƒ d	 | _ t j
 j | d
 ƒ | _ t j
 j | d
 d d | ƒ } | j d ƒ } |  j | | ƒ | j d ƒ } i  | _ d d g | j _ | j d ƒ } t j
 j | d
 d d d | ƒ } |  j | | ƒ d | _ | j d ƒ } t j
 j | d d d | ƒ } |  j | | ƒ d  S(   NR‹   i   t   srcRw   t   lxmls	   lxml.htmlt   etrees
   lxml.etreei    t   tmpdirRŒ   t   twisteds   twisted.runner.portmapt   runnert   portmap(   R   t   get_config_varsR   R   R’   t   distributionR)   t   packagesR'   R�   R   R(   R˜   R7   R+   R—   (   R   R‚   RA   RB   t   curdirt   wantedR   RŒ   (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyt   test_ext_fullpathF  s4    					c   	      C   sè   t  j j |  j d ƒ } t d | g ƒ } t i d d 6| g d 6ƒ } t | ƒ } | j ƒ  d | _ i d d 6| j	 _
 d d	 g | j	 _ t  j ƒ  } t j d
 ƒ } t  j j | d d d | ƒ } | j d ƒ } |  j | | ƒ d  S(   Ns   lxml.etree.cs
   lxml.etreeR¢   R   R    i   R¡   Rw   s	   lxml.htmlR‹   R£   (   R'   R   R(   R   R   R   R   R/   R’   R©   R)   Rª   R�   R   R•   R˜   R7   (	   R   t   etree_ct	   etree_extRA   RB   R«   R‚   R¬   R   (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyt   test_build_ext_inplaceh  s    
	c         C   sz  d d  l  } d d  l } d d  l } | j j } zt j d d t ƒd d l m	 } d d l
 m } t j j |  j d ƒ } | d | g ƒ } t i d d	 6| g d
 6ƒ } | | ƒ } | j ƒ  d | _ i d d 6| j _ d d g | j _ t j ƒ  }	 t j d ƒ }
 t j j |	 d d d |
 ƒ } | j d ƒ } |  j | | ƒ Wd  | | j _ | | j _ | | j j	 _ Xd  S(   Niÿÿÿÿt   setuptools_build_extt
   deprecated(   R   (   R   s   lxml.etree.cs
   lxml.etreeR¢   R   R    i   R¡   Rw   s	   lxml.htmlR‹   R£   (   t   distutils.coret   distutils.extensiont   distutils.command.build_extt	   extensionR   R	   t   import_moduleR&   R±   R   t   setuptools_extensionR'   R   R(   R   R   R/   R’   R©   R)   Rª   R�   R   R•   R˜   R7   t   coret   command(   R   t	   distutilst	   saved_extR±   R   R®   R¯   RA   RB   R«   R‚   R¬   R   (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyt   test_setuptools_compatw  s,    $
	c         C   s�   t  i d d 6ƒ } t | ƒ } | j ƒ  t j d ƒ } t j j d d ƒ } | j | ƒ } t j j | j	 d d | ƒ } |  j
 | | ƒ d  S(   Nt   UpdateManagerR   R‹   t   fdsend(   R   R   R/   R   R•   R'   R   R(   R˜   R+   R7   (   R   RA   RB   R‚   t   ext_namet   ext_pathR¬   (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyt   test_build_ext_path_with_os_sep•  s    
t   win32s   these tests require Windowsc         C   s€   t  i d d 6ƒ } t | ƒ } | j ƒ  t j d ƒ } d } | j | ƒ } t j j | j	 d d | ƒ } |  j
 | | ƒ d  S(   NR¾   R   R‹   s   UpdateManager/fdsendR¿   (   R   R   R/   R   R•   R˜   R'   R   R(   R+   R7   (   R   RA   RB   R‚   RÀ   RÁ   R¬   (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyt"   test_build_ext_path_cross_platformŸ  s    
t   darwins   test only relevant for MacOSXc         C   s   |  j  d d  ƒ d  S(   Ns   ==(   t   _try_compile_deployment_targetR9   (   R   (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyt   test_deployment_target_default«  s    c         C   s   |  j  t |  j d d ƒ d  S(   Nt   >s   10.1(   R|   R   RÆ   (   R   (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyt   test_deployment_target_too_low²  s    	c         C   s}   t  j d ƒ } | ry g  | j d ƒ D] } t | ƒ ^ q% } | d c d 7<d j d „  | Dƒ ƒ } |  j d | ƒ n  d  S(   Nt   MACOSX_DEPLOYMENT_TARGETt   .iÿÿÿÿi   c         s   s   |  ] } t  | ƒ Vq d  S(   N(   t   str(   t   .0t   i(    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pys	   <genexpr>Ã  s    t   <(   R   R•   R™   t   intR(   RÆ   (   R   t	   deptargett   x(    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyt    test_deployment_target_higher_ok¹  s    (c   	      C   sº  t  j } | j ƒ  t  _ |  j t t  d | ƒ | d  k r\ t  j j d ƒ ri t  j d =qi n | t  j d <t  j j |  j	 d ƒ } t
 | d ƒ �! } | j t j d | ƒ ƒ Wd  QXt j d ƒ } t t t | j d ƒ d d !ƒ ƒ } | d	 d
 k  rd | } n
 d | } t d | g d d | f g ƒ} t i d d 6| g d 6ƒ } |  j	 | _ t | ƒ } |  j	 | _ |  j	 | _ y | j ƒ  | j ƒ  Wn t k
 rµ|  j d ƒ n Xd  S(   Nt   environRÊ   s   deptargetmodule.ct   wsî                   #include <AvailabilityMacros.h>

                int dummy;

                #if TARGET %s MAC_OS_X_VERSION_MIN_REQUIRED
                #else
                #error "Unexpected target"
                #endif

            RË   i    i   i   i
   s	   %02d%01d0s
   %02d%02d00RÑ   t   extra_compile_argss   -DTARGET=%sR   R    s*   Wrong deployment target during compilation(   R'   RÔ   t   copyR   t   setattrR9   RL   R   R(   R   t   opent   writet   textwrapt   dedentR   R•   t   tuplet   mapRÐ   R™   R   R   R)   R   R+   R,   R/   R0   R   t   fail(	   R   t   operatort   targett   orig_environt   deptarget_ct   fpt   deptarget_extRA   RB   (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyRÆ   Æ  s@    	
%
	
(   R4   t
   __module__R   R   RF   RR   t   unittestt   skipIfR   R   R_   Ru   Rƒ   R…   Rˆ   R    R­   R°   R½   RÂ   t
   skipUnlessRJ   RÄ   RÇ   RÉ   RÓ   RÆ   (    (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyR
      s(   			*		?	/			?	"			
$$$$c           C   s   t  j t ƒ S(   N(   Rç   t	   makeSuiteR
   (    (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyt
   test_suite   s    t   __main__(   R   R'   R    RÛ   R³   R   R   Rµ   R   R»   R   t   distutils.testsR   t   distutils.errorsR   R   R   Rç   t   testR	   R   R1   t   TempdirManagert   LoggingSilencert   TestCaseR
   Rë   R4   t   run_unittest(    (    (    sJ   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_build_ext.pyt   <module>   s$   	ÿ ê	