;
Ñâ"Ic               @   sé   d  Z  d Z d d l Z d d l 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 m Z m Z d d l m Z d	 „  Z Gd
 „  d e	 ƒ Z Gd „  d e ƒ Z d Z d Z d Z d „  Z d „  Z d S(   u  distutils.cygwinccompiler

Provides the CygwinCCompiler class, a subclass of UnixCCompiler that
handles the Cygwin port of the GNU C compiler to Windows.  It also contains
the Mingw32CCompiler class which handles the mingw32 port of GCC (same as
cygwin in no-cygwin mode).
uF   $Id: cygwinccompiler.py 65863 2008-08-19 18:57:56Z benjamin.peterson $i    N(   u   gen_preprocess_optionsu   gen_lib_options(   u   UnixCCompiler(   u
   write_file(   u   DistutilsExecErroru   CompileErroru   UnknownFileError(   u   logc              C   s¦   t  j j d ƒ }  |  d k oƒ t  j |  d |  d … } | d k o d g S| d k o d g S| d	 k o d
 g S| d k o d g St d t ƒ ‚ n d S(   ua   Include the appropriate MSVC runtime library if Python was built
    with MSVC 7.0 or later.
    u   MSC v.iÿÿÿÿi   i
   u   1300u   msvcr70u   1310u   msvcr71u   1400u   msvcr80u   1500u   msvcr90u   Unknown MS Compiler version %i N(   u   sysu   versionu   findu
   ValueErroru   msc_Ver(   u   msc_posu   msc_ver(    (    u6   /mit/python/lib/python3.0/distutils/cygwinccompiler.pyu	   get_msvcr9   s    c             B   s‰   |  Ee  Z d  Z d Z d Z d Z d Z d Z d Z d d d d „ Z	 d	 „  Z
 d d d d d d d d d d d
 „
 Z d d d „ Z d S(   u   cygwinu   .ou   .au   .dllu   lib%s%su   %s%su   .exei    c             C   s[  t  j |  | | | ƒ t ƒ  \ } } |  j d | | f ƒ | t k	 o |  j d | ƒ n t ƒ  \ |  _ |  _ |  _	 |  j |  j
 d |  j |  j |  j	 f ƒ |  j d k o d |  _ n
 d |  _ |  j d k o
 d } n d	 } |  j d
 d d d d d d d d d |  j | f ƒ |  j d k o d g |  _ |  j d ƒ n t ƒ  |  _ d  S(   Nu%   Python's GCC status: %s (details: %s)uƒ   Python's pyconfig.h doesn't seem to support your compiler. Reason: %s. Compiling may fail because of undefined preprocessor macros.u   : gcc %s, ld %s, dllwrap %s
u   2.10.90u   gccu   dllwrapu   2.13u   -sharedu   -mdll -staticu   compileru   gcc -mcygwin -O -Wallu   compiler_sou   gcc -mcygwin -mdll -O -Wallu   compiler_cxxu   g++ -mcygwin -O -Wallu
   linker_exeu   gcc -mcygwinu	   linker_sou   %s -mcygwin %su   2.91.57u   msvcrtu,   Consider upgrading to a newer version of gcc(   u   UnixCCompileru   __init__u   check_config_hu   debug_printu   CONFIG_H_OKu   warnu   get_versionsu   gcc_versionu
   ld_versionu   dllwrap_versionu   compiler_typeu
   linker_dllu   set_executablesu   dll_librariesu	   get_msvcr(   u   selfu   verboseu   dry_runu   forceu   statusu   detailsu   shared_option(    (    u6   /mit/python/lib/python3.0/distutils/cygwinccompiler.pyu   __init__Z   s<    		
c             C   s×   | d k p | d k oZ y  |  j  d d | d | g ƒ WqÓ t k
 o' } z t | ƒ ‚ WYd  d  } ~ XqÓ Xn` y) |  j  |  j | | d | g | ƒ Wn3 t k
 o' } z t | ƒ ‚ WYd  d  } ~ Xn Xd  S(   Nu   .rcu   .resu   windresu   -iu   -o(   u   spawnu   DistutilsExecErroru   CompileErroru   compiler_so(   u   selfu   obju   srcu   extu   cc_argsu   extra_postargsu   pp_optsu   msg(    (    u6   /mit/python/lib/python3.0/distutils/cygwinccompiler.pyu   _compile˜   s     $c             C   sá  t  j  |
 p g  ƒ }
 t  j  | p g  ƒ } t  j  | p g  ƒ } | j |  j ƒ | d  k	 o2| |  j k p |  j d k ot j j | d ƒ } t j j	 t j j
 | ƒ ƒ \ } } t j j | | d ƒ } t j j | d | d ƒ } d t j j
 | ƒ d g } x | D] } | j | ƒ qW|  j t | | f d | ƒ |  j d	 k o* |
 j d
 | g ƒ |
 j d | g ƒ q‘| j | ƒ n |	 p |
 j d ƒ n t j |  | | | | | | | d  |	 |
 | | | ƒ d  S(   Nu   gcci    u   .defu   libu   .au
   LIBRARY %su   EXPORTSu
   writing %su   dllwrapu   --output-libu   --defu   -s(   u   copyu   extendu   dll_librariesu   Noneu
   EXECUTABLEu
   linker_dllu   osu   pathu   dirnameu   splitextu   basenameu   joinu   appendu   executeu
   write_fileu   UnixCCompileru   link(   u   selfu   target_descu   objectsu   output_filenameu
   output_diru	   librariesu   library_dirsu   runtime_library_dirsu   export_symbolsu   debugu   extra_preargsu   extra_postargsu
   build_tempu   target_langu   temp_diru   dll_nameu   dll_extensionu   def_fileu   lib_fileu   contentsu   sym(    (    u6   /mit/python/lib/python3.0/distutils/cygwinccompiler.pyu   link¦   sL     			 	u    c             C   s  | d  k o
 d } n g  } xë | D]ã } t j j t j j | ƒ ƒ \ } } | |  j d d g k o t d | | f ƒ ‚ n | o t j j | ƒ } n | d k p | d k o+ | j t j j	 | | | |  j
 ƒ ƒ q$ | j t j j	 | | |  j
 ƒ ƒ q$ W| S(   Nu    u   .rcu   .resu"   unknown file type '%s' (from '%s')(   u   Noneu   osu   pathu   splitextu   normcaseu   src_extensionsu   UnknownFileErroru   basenameu   appendu   joinu   obj_extension(   u   selfu   source_filenamesu	   strip_diru
   output_diru	   obj_namesu   src_nameu   baseu   ext(    (    u6   /mit/python/lib/python3.0/distutils/cygwinccompiler.pyu   object_filenames	  s"     
 $N(   u   __name__u
   __module__u   compiler_typeu   obj_extensionu   static_lib_extensionu   shared_lib_extensionu   static_lib_formatu   shared_lib_formatu   exe_extensionu   __init__u   _compileu   Noneu   linku   object_filenames(   u
   __locals__(    (    u6   /mit/python/lib/python3.0/distutils/cygwinccompiler.pyu   CygwinCCompilerP   s*   
>	Xu   CygwinCCompilerc             B   s&   |  Ee  Z d  Z d d d d „ Z d S(   u   mingw32i    c             C   s§   t  j |  | | | ƒ |  j d k o
 d } n d } |  j d k o
 d } n d } |  j d d d	 d
 d d d d d d |  j | | f ƒ g  |  _ t ƒ  |  _ d  S(   Nu   2.13u   -sharedu   -mdll -staticu   2.91.57u   --entry _DllMain@12u    u   compileru   gcc -mno-cygwin -O -Wallu   compiler_sou   gcc -mno-cygwin -mdll -O -Wallu   compiler_cxxu   g++ -mno-cygwin -O -Wallu
   linker_exeu   gcc -mno-cygwinu	   linker_sou   %s -mno-cygwin %s %s(   u   CygwinCCompileru   __init__u
   ld_versionu   gcc_versionu   set_executablesu
   linker_dllu   dll_librariesu	   get_msvcr(   u   selfu   verboseu   dry_runu   forceu   shared_optionu   entry_point(    (    u6   /mit/python/lib/python3.0/distutils/cygwinccompiler.pyu   __init__*  s     

		N(   u   __name__u
   __module__u   compiler_typeu   __init__(   u
   __locals__(    (    u6   /mit/python/lib/python3.0/distutils/cygwinccompiler.pyu   Mingw32CCompiler&  s   
u   Mingw32CCompileru   oku   not oku	   uncertainc              C   sÞ   d d l  m }  t j j d ƒ d k o t d f S|  j ƒ  } y& t | ƒ } | j ƒ  } | j	 ƒ  Wn> t
 k
 o2 } z t d | | j f f SWYd d } ~ Xn5 X| j d ƒ d k o t d | f St d	 | f Sd S(
   u¡  Check if the current Python installation (specifically, pyconfig.h)
    appears amenable to building extensions with GCC.  Returns a tuple
    (status, details), where 'status' is one of the following constants:
      CONFIG_H_OK
        all is well, go ahead and compile
      CONFIG_H_NOTOK
        doesn't look good
      CONFIG_H_UNCERTAIN
        not sure -- unable to read pyconfig.h
    'details' is a human-readable string explaining the situation.

    Note there are two ways to conclude "OK": either 'sys.version' contains
    the string "GCC" (implying that this Python was built with GCC), or the
    installed "pyconfig.h" contains the string "__GNUC__".
    i    (   u	   sysconfigu   GCCu   sys.version mentions 'GCC'u   couldn't read '%s': %sNu   __GNUC__u   '%s' mentions '__GNUC__'u    '%s' does not mention '__GNUC__'(   u	   distutilsu	   sysconfigu   sysu   versionu   findu   CONFIG_H_OKu   get_config_h_filenameu   openu   readu   closeu   IOErroru   CONFIG_H_UNCERTAINu   strerroru   CONFIG_H_NOTOK(   u	   sysconfigu   fnu   fu   su   exc(    (    u6   /mit/python/lib/python3.0/distutils/cygwinccompiler.pyu   check_config_h]  s    (c              C   sÎ  d d l  m }  d d l m } d d l } | d ƒ } | on t j | d d ƒ } | j ƒ  } | j ƒ  | j	 d | | j
 ƒ } | o |  | j d	 ƒ ƒ } q³ d } n d } | d
 ƒ } | on t j | d d ƒ } | j ƒ  } | j ƒ  | j	 d | | j
 ƒ } | o |  | j d	 ƒ ƒ }	 q:d }	 n d }	 | d ƒ }
 |
 on t j |
 d d ƒ } | j ƒ  } | j ƒ  | j	 d | | j
 ƒ } | o |  | j d	 ƒ ƒ } qÁd } n d } | |	 | f S(   uj    Try to find out the versions of gcc, ld and dllwrap.
        If not possible it returns None for it.
    i    (   u   LooseVersion(   u   find_executableNu   gccu    -dumpversionu   ru   (\d+\.\d+(\.\d+)*)i   u   ldu    -vu   dllwrapu
    --versionu    (\d+\.\d+(\.\d+)*)(   u   distutils.versionu   LooseVersionu   distutils.spawnu   find_executableu   reu   osu   popenu   readu   closeu   searchu   ASCIIu   groupu   None(   u   LooseVersionu   find_executableu   reu   gcc_exeu   outu
   out_stringu   resultu   gcc_versionu   ld_exeu
   ld_versionu   dllwrap_exeu   dllwrap_version(    (    u6   /mit/python/lib/python3.0/distutils/cygwinccompiler.pyu   get_versions  sD    





(   u   __doc__u   __revision__u   osu   sysu   copyu   distutils.ccompileru   gen_preprocess_optionsu   gen_lib_optionsu   distutils.unixccompileru   UnixCCompileru   distutils.file_utilu
   write_fileu   distutils.errorsu   DistutilsExecErroru   CompileErroru   UnknownFileErroru	   distutilsu   logu	   get_msvcru   CygwinCCompileru   Mingw32CCompileru   CONFIG_H_OKu   CONFIG_H_NOTOKu   CONFIG_H_UNCERTAINu   check_config_hu   get_versions(    (    (    u6   /mit/python/lib/python3.0/distutils/cygwinccompiler.pyu   <module>   s   )$	Ö3	2