
 Qc           @   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
 m Z m Z d d l Z d d l Z d d l m Z m Z m Z m Z m Z d d l m Z m Z m Z m Z m Z d d l j Z d d l j Z d d l m Z d d l m  Z  d d l! m" Z" d d l# j$ Z% e rfd d	 l! m& a& n  e% j' e(  Z) e* d
  Z+ e* e, f  Z- e. d  \ Z/ Z0 e, a1 e, a2 e, a3 e, a4 e, a5 e, a6 g  a7 i  a8 d   Z9 d   Z: d   Z; d   Z< d   Z= d   Z> d   Z? d   Z@ d d  ZA d d  ZB d   ZC d   ZD d   ZE d eF f d     YZG d eG f d     YZH d   ZI d eG f d      YZJ d!   ZK eL eL e, d"  ZM e. d  \ Z/ Z0 d# eG f d$     YZN d% eG f d&     YZO d' eO f d(     YZP d) eG f d*     YZQ d+ eG f d,     YZR d- e	 j	 f d.     YZS d/ eG eS f d0     YZT d1 eF f d2     YZU d3   ZV d4   ZW d5   ZX d6   ZY eL d7  ZZ d S(8   s"   
Build packages using spec files.
iN(   t   pyi_archivet   pyi_carchive(   t   HOMEPATHt	   CONFIGDIRt   PLATFORMt   DEFAULT_DISTPATHt   DEFAULT_WORKPATH(   t   is_wint   is_unixt   is_aixt	   is_darwint	   is_cygwin(   t   hashlib(   t   dylib(   t   misc(   t   winmanifestt    i   c         C   sa   t  j j |   } t  j j |  s4 t  j |  n  t |  d  } t j | |  | j   d  S(   Nt   w(   t   ost   patht   dirnamet   existst   makedirst   opent   pprintt   close(   t   filenamet   dataR   t   outf(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt
   _save_dataE   s    c         C   s   t  t |  d  j    S(   Nt   rU(   t   evalR   t   read(   R   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt
   _load_dataN   s    c          C   sM   t  j d d  }  t r% d |  }  n  d |  }  d |  }  t  j d |   d  S(   Nt   UPXR   s   --strip-loadconf s   --compress-icons=0 s   --best (   t   compatt   getenvR   t   setenv(   t   f(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   setupUPXFlagsR   s    

c         C   s$   y t  j |   d SWn d SXd  S(   Ni   i    (   R   t   stat(   t   fnm(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   mtime`   s    c         C   s   t  j j t  j j |    S(   N(   R   R   t   abspatht   normpath(   t   apath(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   absnormpathg   s    c         C   s  t  j j t d  } g  } x|  D]\ } } } | d k rY | j | | | f  q" n  | d  } t |  t |  k p t | d  j   d  t j	   k } | ry$ t
 j | |  t j d |  Wqt k
 rt  j j |  d } d | k r&| j d	  d  | j d	  d }	 }
 n | j d	  d }	 }
 t  j j | |	  }	 t  j j |	  sst  j |	  n  t  j j |	 |
 |  } t |  t |  k pt | d  j   d  t j	   k } | rt
 j | |  t j d |  qqXn  | j | | | f  q" W| S(
   s   Given a TOC or equivalent list of tuples, generates all the required
    pyc/pyo files, writing in a local directory if required, and returns the
    list of tuples with the updated pathnames.
    t
   localpycost   PYMODULEit   rbi   s   compiled %si   t   __init__t   .(   R   R   t   joint   WORKPATHt   appendR*   R   R    t   impt	   get_magict
   py_compilet   compilet   loggert   debugt   IOErrort   splitextt   splitR   R   (   t   toct   basepatht   new_toct   nmR)   t   typt
   source_fnmt   needs_compilet   extt   leadingt   mod_name(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   compile_pycosk   s:    	
%*%c         C   s   t    } x{ |  D]s \ } } } | d k rm t j j |  d } t j j |  d | k sm | | } qm n  | j | | | f  q W| S(   sK   
    Returns a new TOC with proper library suffix for EXTENSION items.
    t	   EXTENSIONt
   DEPENDENCYi   (   RK   RL   (   t   TOCR   R   R>   R6   (   R@   RB   t   inmR)   RD   t   binext(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   addSuffixToExtensions   s    	c         C   s$   | | k r  t  j d |   t St S(   s.   
    rebuild is required if values differ
    s   building because %s changed(   R;   t   infot   Truet   False(   t   attrt   oldt   newt
   last_build(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   _check_guts_eq   s    i    c         C   sx   xq | D]i \ } } } t  |  | k r< t j d |  t S| r t  | d   | k r t j d | d   t Sq Wt S(   s   
    rebuild is required if mtimes of files listed in old toc are newer
    than ast_build

    if pyc=1, check for .py files, too
    s   building because %s changedi(   R*   R;   RQ   RR   RS   (   RT   RU   R@   RW   t   pycRC   R)   RD   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   _check_guts_toc_mtime   s    c         C   s.   t  |  | | |  p- t |  | | | d | S(   s   
    rebuild is required if either toc content changed if mtimes of
    files listed in old toc are newer than ast_build

    if pyc=1, check for .py files, too
    RY   (   RX   RZ   (   RT   RU   R@   RW   RY   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   _check_guts_toc   s    c         C   s   d } t  j |   r5 t j d |  t   | d 7} n  t j |   rd t j d |  t  | d 7} n  | r} t d t   n  t S(   s   
    Check that path does not overlap with WORKPATH or SPECPATH (i.e.
    WORKPATH and SPECPATH may not start with path, which could be
    caused by a faulty hand-edited specfile)

    Raise SystemExit if there is overlap, return True otherwise
    i    s;   Specfile error: The output path "%s" contains WORKPATH (%s)i   s;   Specfile error: The output path "%s" contains SPECPATH (%s)s\   Error: Please edit/recreate the specfile (%s) and set a different output name (e.g. "dist").(   R5   t
   startswithR;   t   errort   SPECPATHt
   SystemExitt   SPECRR   (   R   t   specerr(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   _check_path_overlap   s    	
	
c         C   s   t  r d } n2 t j j   r1 t d |   } n t d |    | j   j   d k ry t j	 d |   t
 j |   n t d   d S(   sq   
    Remove directory and all its contents, but only after user confirmation,
    or if the -y option is set
    t   ysX   WARNING: The output directory "%s" and ALL ITS CONTENTS will be REMOVED! Continue? (y/n)s   Error: The output directory "%s" is not empty. Please remove all its contents or use the -y option (remove output directory without confirmation).s   Removing dir %ss   User abortedN(   t	   NOCONFIRMt   syst   stdoutt   isattyt	   raw_inputR_   t   stript   lowerR;   RQ   t   shutilt   rmtree(   R   t   choice(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   _rmtree   s    	
c         C   s   t  j j r- |  j t  j j t  j j  }  n  |  j t  j j  } t  j j } xq t t d t |   |  D]Q \ } } | j	   j
 d  rm | j | | d   } t  j j |  r t Sqm qm Wt S(   sW   Check if path points to a file inside a python egg file (or to an egg
       directly).i    s   .eggi   (   R   R   t   altsept   replacet   sepR?   t   zipt   ranget   lenRj   t   endswithR4   t   isfileRR   RS   (   t   ptht
   componentsRq   t   it   namet   eggpth(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt	   check_egg  s    !+t   Targetc           B   s;   e  Z d  Z d   Z d   Z g  Z d   Z d d  Z RS(   i    c         C   st   |  j  j |  _ |  j  j d 7_ t j j t d |  j |  j  j f  |  _ t j j |  j  |  _	 t
   |  _ d  S(   Ni   s   out%02d-%s.toc(   t	   __class__t   invcnumR   R   R4   R5   t   __name__t   outt   basenamet   outnmRM   t   dependencies(   t   self(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR2   $  s    c         C   s?   t  j d |  j j  |  j t |  j   r; |  j   n  d  S(   Ns   checking %s(   R;   RQ   R~   R   t
   check_gutsR*   R   t   assemble(   R   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   __postinit__.  s    c         C   s   d  S(   N(    (   R   RW   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR   5  s    s   missing or badc         C   s   y t  |  j  } Wn* t j d t j j |  j  |  d SXt |  t |  j	  k rr t j d |  j
  d Sx[ t |  j	  D]J \ } \ } } | d k r q n  | | | | t |  |  |  r d Sq W| S(   s3   
        returns None if guts have changed
        s   building because %s %ss   building because %s is badN(   R!   R   R;   RQ   R   R   R   t   NoneRt   t   GUTSR   t	   enumeratet   getattr(   R   RW   t   missingR   Ry   RT   t   func(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   get_guts8  s    """(   R   t
   __module__R   R2   R   R   R   R   (    (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR}   !  s   	
		t   Analysisc           B   sy  e  Z d  Z e e e j j e d d   e e j j e	 d d   e e j j e	 d d   e e j j e d d   e e j j e d d   e e j j e d d   e e j j e d d   f  Z
 d d d d d g  d  Z d e f d	 e f d
 e f d e f d e f d d   f d e f d e f d e f d e f f
 Z d   Z d   Z d   Z d   Z RS(   si  
    Class does analysis of the user's main Python scripts.

    An Analysis has five outputs, all TOCs (Table of Contents) accessed as
    attributes of the analysis.

    scripts
            The scripts you gave Analysis as input, with any runtime hook scripts
            prepended.
    pure
            The pure Python modules.
    binaries
            The extensionmodules and their dependencies. The secondary dependecies
            are filtered. On Windows files from C:\Windows are excluded by default.
            On Linux/Unix only system libraries from /lib or /usr/lib are excluded.
    datas
            Data-file dependencies. These are data-file that are found to be needed
            by modules. They can be anything: plugins, font files, images, translations,
            etc.
    zipfiles
            The zipfiles dependencies (usually .egg files).
    t   supports   _mountzlib.pys   useUnicode.pys   useTK.pys   unpackTK.pys   removeTK.pyc         C   s  t  j |   i  t _ | t j d <t j j t d d  } t j j | d  t j j | d  t j j | d  t j j | d  t j j | d  g |  _ xn | D]f } t	 |  |  j
 k r t j d	 |  q n  t j j |  s t d
 |   n  |  j j |  q Wg  |  _ xF | D]> } t j |  }	 |	 r|  j j |	  t j d |	  qqW| rg  | D] }
 t	 |
  ^ qn|  _ n  | pg  |  _ |  j j t  | |  _ | |  _ | |  _ t   |  _ t   |  _ t   |  _ t   |  _ t   |  _ t   |  _  |  j!   d S(   s  
        scripts
                A list of scripts specified as file names.
        pathex
                An optional list of paths to be searched before sys.path.
        hiddenimport
                An optional list of additional (hidden) modules to include.
        hookspath
                An optional list of additional paths to search for hooks.
                (hook-modules).
        excludes
                An optional list of module or package names (their Python names,
                not path names) that will be ignored (as though they were not found).
        runtime_hooks
                An optional list of scripts to use as users' runtime hooks. Specified
                as file names.
        t   scriptst   PyInstallert   loaders   _pyi_bootstrap.pys   pyi_importers.pys   pyi_archive.pys   pyi_carchive.pys   pyi_os_path.pys&   Ignoring obsolete auto-added script %ss   script '%s' not founds   Extending PYTHONPATH with %sN("   R}   R2   Re   t   _PYI_SETTINGSR   R   R4   R   t   inputsR.   t   _old_scriptsR;   t   warnR   t
   ValueErrorR6   t   pathexR   t   get_path_to_toplevel_modulesRQ   t   hiddenimportst   extendt   HIDDENIMPORTSt	   hookspatht   custom_runtime_hookst   excludesRM   R   t   puret   binariest   zipfilest   datasR   R   (   R   R   R   R   R   R   t   runtime_hookst   _init_code_patht   scriptt   script_toplevel_dirR   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR2   o  sH    		%			R   R   R   R   R   R   c          G   s   t  t |  i d d 6 S(   Ni   RY   (   t   applyRZ   (   t   args(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   <lambda>  s   R   R   R   R   c   
      C   s   | d k r, t  j d |  j j |  j  t Sx7 |  j D], } t |  | k r6 t  j d |  t Sq6 Wt j	 |  |  } | s t S| d \ } } } } } }	 t
 |  |  _ t
 |  |  _ t
 |  |  _ t
 |  |  _ t
 |  |  _ |	 |  _ t S(   Ni    s#   building %s because %s non existents   building because %s changedi(   R;   RQ   R~   R   R   RR   R   R*   R}   R   RM   R   R   R   R   R   R   RS   (
   R   RW   R)   R   R   R   R   R   R   R   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR     s$    	c            s   d d l  m } d d l m  m } d d l m   t j j	 t
 d d  } t j j	 | d  g }    f d   } | d	 | g t j d
 |   d d  } | | d | } | j   d S(   s   
        New assemble function based on module 'modulegraph' for resolving
        dependencies on Python modules.

        PyInstaller is not able to handle some cases of resolving dependencies.
        Rather try use a module for that than trying to fix current implementation.
        i(   t   ModuleGraph(   t   get_impliest   find_needed_modules(   t   hooksR   R   s   _pyi_bootstrap.pyc             s      }  t  j j t  j j   j   } t j | t  j d  } xm | D]e } t  j j |  j d  j	 d  } d | } t
 j | |  } t | d  rK | j |  | <qK qK W|  S(   sT   
            Collect all hiddenimports from hooks and from modulegraph.
            s	   hook-*.pys   hook-s   .pys   PyInstaller.hooks.hook-%sR   (   R   R   R   R+   t   __file__t   globRq   R   t   lstript   rstripR7   t   load_sourcet   hasattrR   (   t   impliest   hook_dirt   filesR&   RI   t   hook_mod_namet   hook_mod(   R   R   (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   collect_implies  s    	!$
R   R   R<   i    R   N(   t   modulegraph.modulegraphR   t   modulegraph.find_modulesR   R   R   R   R   R   R4   R   Re   t   report(   R   R   R   R   R   R   t   graph(    (   R   R   sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   assemble_modulegraph  s     		c         C   s  t  j d t j j |  j   i  t _ t j	 } t
 s x@ t j j |  ry t j j t j j |  t j |   } q: Wd  } nF t j d d d t d t j   d d#  } t j j t t d	  | _ g  } | j t j d
 | d
 f g d | d  i  } g  } x |  j D] } t j j |  s<t d |   n  t j j |  \ } } | sit j   } n  t |  } t j j |  \ }	 }
 d | | <| j  |	  qWt! j" j# j$ | j%   |  j& |  j' |  j( d t } |  j& t! _) g  } xT t* |  j  D]C \ } } t  j d |  | j+ |  | j  | | | d f  qWg  t! _) xu |  j, D]j } | | j- k rt  j d |  qYn  t  j d |  | j. |  | | j- k rYt  j/ d |  qYqYWg  } g  } g  } g  } |  j0 rVt  j d  x^ |  j0 D]P } t j j1 |  } t j j t j j |   d | d f } | j  |  qWn  t  j d  x0 | j- j2   D] \ } } | j t3 |   qsWx4 | D], \ } } } t  j d |  | j+ |  qWx;| j- j2   D]*\ } } | d  k rqn  | j | j4  t5 | t! j" j- j6  r&qt5 | t! j" j- j7  rm| j  | j8 | j9 d f  | j | j:  qt5 | t! j" j- j; t! j" j- j< f  r| j  d t j j t= | j>   t= | j>  d f  q| j | j:  | d k r| j  | | j9 d f  qqW| j t j | d |  t
 r:| j?   n  |  j@ |  | rt j j tA d d  } | jB d d t j j | d  d f  n  | | d d +tC |  |  _D tC |  |  _E tC |  |  _: tC |  |  _F tC |  |  _4 y tG |  j  } Wn d  } n XtC tH |  jE   |  _E tI g  |  jJ D] } tK |  | d  ^ q0 } | | k rtL |  j |  tM tN d  } x% | jO   D] } | jP | d   qW| jQ   t  j d! tN  d St  j d" |  j  d S($   Ns   running Analysis %st   type_t   win32Rz   t   processorArchitecturet   versioni   i    s   .exe.manifestR   t   manifests%   Error: Analysis: script %s not found!t   workpaths   Analyzing %st   PYSOURCEs)   Hidden import %r has been found otherwises   Analyzing hidden import %rs   Hidden import %r not founds   Including custom run-time hookss   Looking for run-time hookss   Analyzing rthook %sRK   s   eggs/t   ZIPFILEt   __main__R0   R   R   is   _pyi_egg_install.pyR   s   
s   Warnings written to %ss   %s no change!(   i   i    i    i    (R   R;   RQ   R   R   R   R   t	   bindependt   seenRe   t
   executableR   t   islinkR4   R   t   readlinkR   R   t   Manifestt   specnmt   processor_architectureR5   R   R   t   DependenciesR   R   R_   R?   R#   t   getcwdR.   R>   R6   R   t   dependt
   imptrackert   ImportTrackert   keysR   R   R   t
   __pathex__R   t   analyze_scriptR   t   modulest   analyze_oneR]   R   R+   t   itemst   _findRTHookR   t
   isinstancet   BuiltinModulet   ExtensionModuleR   R   R   t   PkgInZipModulet   PyInZipModulet   strt   ownert   writeprettyxmlt   _check_python_libraryR   t   insertRM   R   R   R   R!   RJ   t   tupleR   R   R   R   t   WARNFILEt   getwarningst   writeR   (   R   t   pythont   depmanifestR   t   dirst   pynmsR   t   dt   baset   pynmRG   t   importTrackerR   Ry   t   modnmR   R   R   t   rthookst	   hook_fileR   t   modR   t   mod_typeR   t   oldstufft   gt   newstufft   wft   ln(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR   !  s    		.		
(		+'" 
+
/
c         C   s   t  j   } | r t j d |  t   } x6 | D]. \ } } } | d k r2 | j | g  q2 q2 W| | k r t j d  | j t j j	 |  | d f  q n t
 d   d S(   s   
        Verify presence of the Python dynamic library in the binary dependencies.
        Python library is an essential piece that has to be always included.
        s   Using Python library %st   BINARYs,   Adding Python library to binary dependenciess   Python library not found!N(   R   t   get_python_library_pathR;   RQ   t   sett   updateR6   R   R   R   R=   (   R   R   t
   python_libt   depsRC   R   RD   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR     s    	(N(   R   R   t   __doc__R  R.   R   R   R4   R   R   R   R   R2   RX   RZ   R   R   R   R   R   (    (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR   N  s2   $	L										?	c         C   s   g  } x t  j |   p g  D]} } t j j |  } t j j |  d } t j j |  re | } n t j j t d d d |  } | j	 | | d f  q W| S(   Ni    R   R   R   R   (
   R   t   getR   R   R   R>   t   isabsR4   R   R6   (   R   t   rsltR   RC   R   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR     s    	t   PYZc           B   sV   e  Z d  Z d Z d	 d d  Z d e f d e f d e f f Z d   Z	 d   Z
 RS(
   sF   
    Creates a ZlibArchive that contains all pure Python modules.
    R
  i	   c         C   sl   t  j |   | |  _ | |  _ | d k rB |  j d  d |  _ n  | |  _ t t d  |  _	 |  j
   d S(   sR  
        toc
                A TOC (Table of Contents), normally an Analysis.pure?
        name
                A filename for the .pyz. Normally not needed, as the generated
                name will do fine.
        level
                The Zlib compression level to use. If 0, the zlib module is
                not required.
        it   pyzt   PYZ_dependenciesN(   R}   R2   R@   Rz   R   R   t   levelRJ   t   configR   R   (   R   R@   Rz   R  (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR2     s    			Rz   R  R@   c         C   s^   t  j j |  j  s> t j d |  j t  j j |  j   t St	 j
 |  |  } | sZ t St S(   Ns#   rebuilding %s because %s is missing(   R   R   R   Rz   R;   RQ   R   R   RR   R}   R   RS   (   R   RW   R   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR     s    	c         C   s~   t  j d t j j |  j   t j d |  j  } |  j	 t
 d } | j |  j |  t |  j |  j |  j |  j	 f  d S(   Ns   building PYZ (ZlibArchive) %sR  R  i   (   R;   RQ   R   R   R   R   R    t   ZlibArchiveR  R@   R  t   buildRz   R   (   R   R  R@   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR     s    "N(   R   R   R  RD   R   R2   RX   R[   R   R   R   (    (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR
    s   			c         C   s.   t  |  d  j   } t j |  j   } | S(   NR1   (   R   R    R   t   md5t   digest(   R)   R   R  (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   cacheDigest  s    c         C   s  | r | r t  r t s1 |  j   j d  r5 |  S| rD t } n t } | rY t } n t } d t j d t j d f } t j	 j
 t d | | | f  } t j	 j |  s t j |  n  t j	 j
 | d  } t j	 j |  r t |  } n i  } t j	 j t j	 j |    } t |   }	 t j	 j
 | |  }
 d } | | k r|	 | | k rnt j |
  qt  rt j |
 |  n  |
 Sn  | r)| rt |  d t d t }  n  d	 } t d
 d k rt j d k rd } n  d } t j d  rt j	 j
 t d |  } n  | | d |
 g } n5 | r^g  } t  rGd g } n  d g | |
 g } n  t j |  |
  t j |
 d  t r
|  j   j d  r
y t j t j	 j  |
   } WnN t! j" j# k
 r} | j$ d t! j% k rqt& j# t j	 j  |
     q
Xt j' | k r
t( | t j'  r
x| t j' D]} x| t j' | D]} yb t j)   } d j
 |
 t* t j'  t* |  t* |  g  | _+ | j, | t j' | | t  Wn@ t- k
 r} t& j# d | |  t& j# |
  t& j. |  qQXt( | j/  } t0 g  | j/ D] } | j ^ q } xV t D]N } | j | k r7t& j1 d | j |
  | j/ j2 |  | j3 | j  q7q7Wt( | j/  | k rQy) | j4 t j	 j  |
  | g | g  Wqt- k
 r} t& j# t j	 j  |
     qXqQqQWq9Wq
n  | rdy+ t& j1 d d j
 |   t5 j6 |   Wqdt7 k
 r`} t8 d |   qdXn  |	 | | <t9 | |  t  rt j |
 |  n  |
 S(   s  
    Cache prevents preprocessing binary files again and again.

    'dist_nm'  Filename relative to dist directory. We need it on Mac
               to determine level of paths for @loader_path like
               '@loader_path/../../' for qt4 plugins.
    s	   .manifests   py%d%si    i   s   bincache%d%d_%ss	   index.datRi   t   upxs   --bestt   hasUPXi   t   nts   --lzmat   upx_dirs   -qs   -Si  s   .pydt   :s*   Cannot parse manifest resource %s, %s froms'   Adding %r to dependent assemblies of %rs   Executing - t    s   Execution failed: %sN(   i   (:   R
   R   Rj   Ru   RR   RS   Re   t   version_infoR   R   R4   R   R   R   R!   t   normcaseR   R  R   t   removeR   t   mac_set_relative_dylib_depst
   checkCacheR  Rz   R  Rk   t   copy2t   chmodt   pyasmR   t   GetManifestResourcesR+   t   winresourcet
   pywintypesR]   R   t   ERROR_BAD_EXE_FORMATR;   t   RT_MANIFESTRt   R   R   R   t   parse_stringt	   Exceptiont	   exceptiont   dependentAssembliesR  RQ   R6   R  t   update_resourcesR#   t   exec_commandt   OSErrorR_   R   (   R)   Ri   R  t   dist_nmt   pyvert   cachedirt   cacheindexfnt   cache_indext   basenmR  t
   cachedfilet   cmdt   bestoptt   upx_executablet   strip_optionst   rest   eRz   t   languageR   t   exct   olent   dept	   _depNamest   pydep(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR    s    		"	"			
	
t   PKGc           B   s   e  Z d  Z d Z i
 d d 6d d 6d d 6d d	 6d
 d 6d d 6d d 6d d 6d d 6d d 6Z d d d e e d  Z d e f d e f d e	 f d e f d e f d e f f Z
 d   Z d   Z RS(   s   
    Creates a CArchive. CArchive is the data structure that is embedded
    into the executable. This data structure allows to include various
    read-only data in a sigle-file deployment.
    RA  t   mR0   t   sR   t   bRK   t   zR
  t   at   xt   DATAR   t   ZR   t
   EXECUTABLER   RL   i    c         C   s   t  j |   | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ | d	 k rf |  j	 d  d |  _ n  |  j d	 k r i t
 d 6t
 d 6t
 d 6t
 d 6t
 d 6t
 d 6|  _ n  |  j   d	 S(
   s  
        toc
                A TOC (Table of Contents)
        name
                An optional filename for the PKG.
        cdict
                Dictionary that specifies compression by typecode. For Example,
                PYZ is left uncompressed so that it can be accessed inside the
                PKG. The default uses sensible values. If zlib is not available,
                no compression is used.
        exclude_binaries
                If True, EXTENSIONs and BINARYs will be left out of the PKG,
                and forwarded to its container (usually a COLLECT).
        strip_binaries
                If True, use 'strip' command to reduce the size of binary files.
        upx_binaries
        it   pkgRK   RH  R   RJ  R   R0   N(   R}   R2   R@   t   cdictRz   t   exclude_binariest   strip_binariest   upx_binariesR   R   t
   COMPRESSEDR   (   R   R@   Rz   RL  RM  RN  RO  (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR2     s"    						
Rz   RL  R@   RM  RN  RO  c         C   s^   t  j j |  j  s> t j d |  j t  j j |  j   d St j	 |  |  } | sZ t
 St S(   Ns#   rebuilding %s because %s is missingi   (   R   R   R   Rz   R;   RQ   R   R   R}   R   RR   RS   (   R   RW   R   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR     s    	c         C   s@  t  j d t j j |  j   g  } g  } i  } t |  j  } xj| D]b\ } } } t j j |  r{ t	 |  r{ qG n  | d k rJ|  j
 r | d k r |  j j | | | f  qt | d |  j d |  j o t p t d | } | d k r| | k rqG n  d | | <| j | | |  j j | d	  |  j j | d
  f  qG | d k rr| j | d d	 d f  qG | j | | |  j j | d	  |  j j | d
  f  qG Wt j j t j    } t j d |  }	 |	 j |  j |  t |  j |  j |  j |  j |  j
 |  j |  j f  x | D] }
 t j |
  q%Wd S(   Ns   building PKG (CArchive) %sR   RK   RL   Ri   R  R.  i   i    RD  t   OPTIONR   t   ot
   pylib_name(   s   BINARYs	   EXTENSIONs
   DEPENDENCY(   R;   RQ   R   R   R   Rz   RP   R@   Rv   R|   RM  R   R6   R  RN  RO  R   R   RL  R  t	   xformdictR   R  R   t   CArchiveR  R   R   R  (   R   t   trasht   mytocR   R@   RN   R)   RD   RS  t   archivet   item(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR     s>    	
;	N(   R   R   R  RD   RT  R   RS   R2   RX   RZ   R   R   R   (    (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyRA    s,   

	$						t   EXEc        
   B   s   e  Z d  Z d Z d   Z d e f d e f d e f d e f d e f d e f d	 e f d
 e f d f	 Z d   Z d   Z	 d   Z
 d   Z RS(   sh   
    Creates the final executable of the frozen app.
    This bundles all necessary files together.
    RJ  c         O   s  t  j |   | j d t  |  _ | j d t  |  _ | j d t  |  _ | j d t  |  _ | j d d  |  _
 | j d d  |  _ | j d d  |  _ | j d d  |  _ | j d	 g   |  _ | j d
 t  |  _ t d r| j d t  |  _ n	 t |  _ |  j r=t j j t t j j |  j
   |  _
 n' t j j t t j j |  j
   |  _
 t j j |  j
  } t st rt j j |  d } n  | d |  _ t   |  _ x | D] } t | t  r|  j j |  qt | t   r9|  j j  t j j | j
  | j
 | j! f  |  j j | j"  q|  j j |  qWt rt j j t t# d  } t$ j% | |  j |  j  |  _ |  j j  t j j |  j
  d | d f  n  t& |  j d | j d d  d |  j d |  j d |  j |  _' |  j' j" |  _" |  j(   d S(   s  
        args
                One or more arguments that are either TOCs Targets.
        kwargs
            Possible keywork arguments:

            console
                On Windows or OSX governs whether to use the console executable
                or the windowed executable. Always True on Linux/Unix (always
                console executable - it does not matter there).
            debug
                Setting to True gives you progress mesages from the executable
                (for console=False there will be annoying MessageBoxes on Windows).
            name
                The filename for the executable.
            exclude_binaries
                Forwarded to the PKG the EXE builds.
            icon
                Windows or OSX only. icon='myicon.ico' to use an icon file or
                icon='notepad.exe,0' to grab an icon resource.
            version
                Windows only. version='myversion.txt'. Use grab_version.py to get
                a version resource from an executable and then edit the output to
                create your own. (The syntax of version resources is so arcane
                that I wouldn't attempt to write one from scratch).
        t
   append_pkgRM  t   consoleR<   Rz   t   iconR   R   t	   resourcesRi   R  R  i    s   .pkgs   .exe.manifests	   .manifestR   RL  RN  RO  N()   R}   R2   R  RR   R[  RS   RM  R\  R<   R   Rz   R]  t   versrsrcR   R^  Ri   R  R  R   R   R4   R5   R   t   DISTPATHR   R   R>   t   pkgnameRM   R@   R   R   R6   RD   R   R   R   t   create_manifestRA  RK  R   (   R   R   t   kwargst	   base_namet   argR   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR2   7  sP    
		*'."	Rz   R\  R<   R]  R_  R^  Ri   R  t   mtmc         C   sI  t  j j |  j  s> t j d |  j t  j j |  j   d S|  j r t  j j |  j	  r t j d t  j j |  j	   d St
 j |  |  } | s t S| d d !\ } } } | s | s | r t d r t j d  n  | d } | t |  j  k rt j d	 |  j  t S| t |  j j  k  rEt j d
 |  j  t St S(   Ns    rebuilding %s because %s missingi   s   rebuilding because %s missingi   i   t   hasRsrcUpdatesE   ignoring icon, version, manifest and resources = platform not capableis(   rebuilding %s because mtimes don't matchs(   rebuilding %s because pkg is more recent(   R   R   R   Rz   R;   RQ   R   R   R[  Ra  R}   R   RR   R  R*   RK  R   RS   (   R   RW   R   R]  R_  R^  Rf  (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR     s,    	 	
c         C   sE   |  j  s | d } n  |  j r, | d } n  t j j d d t |  S(   NR   t   _dR   t
   bootloader(   R\  R<   R   R   R4   R   (   R   t   exe(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   _bootloader_file  s
    		c         C   s  t  j d t j j |  j   g  } t j j t j j |  j   se t j	 t j j |  j   n  t
 |  j d  } |  j d  } t j j t |  } t s t r | d } n  t d rR|  j s |  j s |  j rRt j   } t j | |  t j | d  |  j r$t j | |  j  n  |  j rCt j | |  j  n  x|  j D]} | j d  } xI t d t |   D]2 } y t | |  | | <Wqxt  k
 rqxXqxW| d	 } d  } }	 }
 t |  d k r| d } n  t |  d
 k r| d
 }	 n  t |  d k r#| d }
 n  y8 t" j# | | | p;d g |	 pGd g |
 pSd g  WqMt" j$ j% k
 r7} | j& d	 t" j' k rt  j( |  qMn  | s|	 rt  j% d  qMn  d | |	 f k rt  j% d  qMn  y) t" j) | | | |	 g |
 pd	 g  Wq8t" j$ j% k
 r3} t  j( |  q8XqMXqMW| j* |  | } n  t+ | d |  j, d |  j- } |  j. | |  |  j/ rt  j d |  j  |  j. |  j0 j |  n, t  j d |  j1  t j |  j0 j |  j1  | j2   t j |  j d  |  j |  j3 |  j4 |  j |  j |  j |  j, |  j- t5 |  j  f	 } t |  t |  j6  k sat7  t8 |  j |  x | D] } t j9 |  qxWd S(   Ns   building EXE from %st   wbt   runs   .exeRg  i  t   ,i   i    i   i   t   *s'   resource type and/or name not specifieds[   no wildcards allowed for resource type and name when source file does not contain resourcesRi   R  s   Appending archive to EXE %ss   Copying archive to %s(:   R;   RQ   R   R   R   R   R   R   Rz   R   R   Rk  R4   R   R   R   R  R]  R_  R^  t   tempfilet   mktempRk   R  R   t	   CopyIconst   versioninfot
   SetVersionR?   Rs   Rt   t   intR   R   R#  t   UpdateResourcesFromResFileR$  R]   R   R%  R)  t   UpdateResourcesFromDataFileR6   R  Ri   R  t   copyR[  RK  Ra  R   R\  R<   R*   R   t   AssertionErrorR   R  (   R   RV  R   Rj  t   tmpnmR9  Ry   t   resfilet   restypet   resnamet   reslangR<  t   gutsRY  (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR     s    !			
			
!c         C   s?   t  | d  } x) | j d  } | s+ Pn  | j |  q d  S(   NR1   i@   i   i   (   R   R    R   (   R   R)   R   t   infR   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyRx    s    N(   s   mtmN(   R   R   R  RD   R2   RX   R   R   R   Rk  R   Rx  (    (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyRZ  0  s    	Z												Pt   DLLc           B   s   e  Z d  Z d   Z RS(   s  
    On Windows, this provides support for doing in-process COM servers. It is not
    generalized. However, embedders can follow the same model to build a special
    purpose process DLL so the Python support in their app is hidden. You will
    need to write your own dll.
    c         C   s   t  j d t j j |  j   t |  j d  } |  j d  } t j j	 t
 |  d } |  j | |  |  j |  j j |  | j   t j |  j d  t |  j |  j |  j |  j |  j |  j |  j |  j |  j |  j t |  j  f
  d S(   Ns   building DLL %sRl  t
   inprocsrvrs   .dlli  i   (   R;   RQ   R   R   R   R   R   Rz   Rk  R4   R   Rx  RK  R   R   R   R\  R<   R]  R_  R   R^  Ri   R  R*   (   R   R   t   dll(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR      s    
	1(   R   R   R  R   (    (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR    s   t   COLLECTc           B   sS   e  Z d  Z d   Z d e f d e f d e f d e f f Z d   Z d   Z RS(   sM   
    In one-dir mode creates the output folder with all necessary files.
    c         O   s  t  j |   | j d t  |  _ t d rD | j d t  |  _ n	 t |  _ | j d  |  _ t j	 j
 t t j	 j |  j   |  _ t   |  _ x4| D],} t | t  r |  j j |  q t | t   r|  j j t j	 j | j  | j | j f  t | t  rxU | j D]J \ } } } | t j	 j | j  d k r|  j j | | | f  qqW| j s|  j j t j	 j | j  | j d f  qn  |  j j | j  q |  j j |  q W|  j   d S(   s   
        args
                One or more arguments that are either TOCs Targets.
        kws
            Possible keywork arguments:

                name
                    The name of the directory to be built.
        Ri   R  R  Rz   s	   .manifestRA  N(   R}   R2   R  RS   RN  R  RO  Rz   R   R   R4   R`  R   RM   R@   R   R   R6   RD   RZ  R[  Ra  R   R   (   R   R   t   kwsRe  t   tocnmR)   RD   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR2   3  s,    

	'. 	1Rz   RN  RO  R@   c         C   s   d S(   Ni   (    (   R   RW   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR   e  s    c         C   s  t  |  j  r4 t j j |  j  r4 t |  j  n  t j d t j j |  j	   t j
 |  j  t |  j  } x| D] \ } } } t j j |  r t |  r qy n  t j j |  j |  } t j j |  } t j j |  s t j
 |  n  | d
 k r8t | d |  j d |  j o)t p)t d | } n  | d k rWt j | |  n  | d k ry t j | d  qy qy Wt |  j	 |  j |  j |  j |  j f  d	 S(   Ns   building COLLECT %sRK   R   Ri   R  R.  RL   i  i   (   s	   EXTENSIONs   BINARY(   s	   EXTENSIONs   BINARY(   Rb   Rz   R   R   t   isdirRn   R;   RQ   R   R   R   RP   R@   Rv   R|   R4   R   R   R  RN  RO  R   R   Rk   R  R   R   (   R   R@   RN   R)   RD   t   tofnmt   todir(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR   j  s.    $	(   R   R   R  R2   RX   R   R   R   (    (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR  /  s   	,				t   BUNDLEc           B   s2   e  Z d    Z d e f f Z d   Z d   Z RS(   c         O   s  t  s
 d  S| j d t j j t j j t  d d d d   |  _ t j	 |   | j d d   |  _ t j j |  j  } t j j t |  |  _ t j j |  d |  _ | j d d	  |  _ t   |  _ t |  _ t |  _ x | D] } t | t  rV|  j j t j j | j  | j | j f  |  j j | j  | j |  _ | j |  _ q t | t  rx|  j j |  q t | t  r|  j j | j  | j |  _ | j |  _ q t j  d
 | j! j"  q Wx |  j D] \ } } } | d k r| |  _# |  j d  k rNd t j j |  d f |  _ t j j t$ |  j d  |  _ n t j j t$ |  j  |  _ PqqW|  j%   d  S(   NR]  s   ..Ri  t   imagess   icon-windowed.icnsRz   i    R   s   0.0.0s   unsupported entry %sRJ  s   Mac%ss   .app(&   R
   R  R   R   R4   R   R   R]  R}   R2   R   Rz   R   R`  R>   t   appnameR   RM   R@   RS   Ri   R  R   RZ  R6   RD   R   R   R  RN  RO  R;   RQ   R~   R   t   exenameR^   R   (   R   R   R  Rd  Re  RN   Rz   RD   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR2     sF    !		.	 "R@   c         C   s   d S(   Ni   (    (   R   RW   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR     s    c      
   C   s  t  |  j  r4 t j j |  j  r4 t |  j  n  t j d t j j |  j	   t j
 t j j |  j d d   t j
 t j j |  j d d   t j
 t j j |  j d d   t j j |  j  r t j |  j t j j |  j d d   n t j d |  j  i |  j d 6|  j d 6d	 t j j |  j  d
 6t j j |  j  d 6d d 6d d 6|  j d 6d d 6} d } x. | j   D]  \ } } | d | | f 7} qW| d 7} t t j j |  j d d  d  } | j |  | j   t |  j  } x | D] \ } } }	 |	 d k rJt | d |  j d |  j d | } n  t j j |  j d d |  }
 t j j |
  } t j j |  st j
 |  n  t j | |
  qWt j j |  j d d d  } t j j |  j d d d  } t j j |  rt j | |  n  d S(    Ns   building BUNDLE %st   Contentst   MacOSt	   Resourcest
   Frameworkss   icon not found %st   CFBundleDisplayNamet   CFBundleNames   MacOS/%st   CFBundleExecutablet   CFBundleIconFiles   6.0t   CFBundleInfoDictionaryVersiont   APPLt   CFBundlePackageTypet   CFBundleShortVersionStringt   1t   LSBackgroundOnlys   <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>s"   <key>%s</key>
<string>%s</string>
s   </dict>
</plist>s
   Info.plistR   RK   R   Ri   R  R.  s   qt_menu.nibi   (   s	   EXTENSIONs   BINARY(    Rb   Rz   R   R   R  Rn   R;   RQ   R   R   R   R4   R   R]  Rk   Rx  R   R  R  R   R   R   R   R   RP   R@   R  Ri   R  R   R  t   copytree(   R   t   info_plist_dictt
   info_plistt   kt   vR&   R@   RN   R)   RD   R  R  t   qt_menu_dirt   qt_menu_dest(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR     sN    $"""+


$
'(   R   R   R2   RX   R   R   R   (    (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR    s   	5	RM   c           B   sb   e  Z d  Z d
 d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z RS(   s  
    TOC (Table of Contents) class is a list of tuples of the form (name, path, tytecode).

    typecode    name                   path                        description
    --------------------------------------------------------------------------------------
    EXTENSION   Python internal name.  Full path name in build.    Extension module.
    PYSOURCE    Python internal name.  Full path name in build.    Script.
    PYMODULE    Python internal name.  Full path name in build.    Pure Python module (including __init__ modules).
    PYZ         Runtime name.          Full path name in build.    A .pyz archive (ZlibArchive data structure).
    PKG         Runtime name.          Full path name in build.    A .pkg archive (Carchive data structure).
    BINARY      Runtime name.          Full path name in build.    Shared library.
    DATA        Runtime name.          Full path name in build.    Arbitrary files.
    OPTION      The option.            Unused.                     Python runtime option (frozen into executable).

    A TOC contains various types of files. A TOC contains no duplicates and preserves order.
    PyInstaller uses TOC data type to collect necessary files bundle them into an executable.
    c         C   sD   t  j  j |   i  |  _ | r@ x | D] } |  j |  q& Wn  d  S(   N(   t   UserListR2   t   fltrR6   (   R   t   initlistt   tpl(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR2     s
    	c         C   s   ye | d } | d d k r2 t  j j |  } n  |  j j |  sd |  j j |  d |  j | <n  Wn$ t k
 r t j	 d |    n Xd  S(   Ni    i   R   i   s   TOC found a %s, not a tuple(
   R   R   R  R  R  R   R6   t	   TypeErrorR;   RQ   (   R   R  t   fn(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR6   "  s    
c         C   sh   | d } | d d k r/ t  j j |  } n  |  j j |  sd |  j j | |  d |  j | <n  d  S(   Ni    i   R   i   (   R   R   R  R  R  R   R   (   R   t   posR  R  (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR   2  s    
c         C   s    t  |  j  } | j |  | S(   N(   RM   R   R   (   R   t   otherR	  (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   __add__:  s    c         C   s    t  |  } | j |  j  | S(   N(   RM   R   R   (   R   R  R	  (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   __radd__?  s    c         C   s"   x | D] } |  j  |  q Wd  S(   N(   R6   (   R   R  R  (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR   D  s    c         C   s   |  j  j   } x2 | D]* } | j | d d  r | | d =q q Wt   } x7 |  j D], } | j | d d  rW | j |  qW qW W| S(   Ni    (   R  Rx  R  RM   R   R6   (   R   R  t   fdR  R	  (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   __sub__H  s    	c         C   s   t  |  } | j |   S(   N(   RM   R  (   R   R  R	  (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   __rsub__U  s    c         C   sG   t    } x7 | D]/ } |  j j | d d  r | j |  q q W| S(   Ni    (   RM   R  R  R6   (   R   R  R	  R  (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt	   intersectY  s
    	N(   R   R   R  R   R2   R6   R   R  R  R   R  R  R  (    (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyRM   	  s   							t   Treec           B   sV   e  Z d  Z d d d d  Z d e f d e f d e f d	 f Z d   Z d   Z RS(
   s   
    This class is a way of creating a TOC (Table of Contents) that describes
    some or all of the files within a directory.
    c         C   s[   t  j |   t j |   | |  _ | |  _ | |  _ | d k rM g  |  _ n  |  j   d S(   s  
        root
                The root of the tree (on the build system).
        prefix
                Optional prefix to the names of the target system.
        excludes
                A list of names to exclude. Two forms are allowed:

                    name
                        Files with this basename will be excluded (do not
                        include the path).
                    *.ext
                        Any file with the given extension will be excluded.
        N(   R}   R2   RM   t   roott   prefixR   R   R   (   R   R  R  R   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR2   f  s    			R  R  R   R@   c         C   s   t  j |  |  } | s t S| d g } | d } x | r | j   } t |  | k rt t j d |  j |  t SxN t j	 |  D]= } t j
 j | |  } t j
 j |  r | j |  q q Wq6 W| |  _ t S(   Ni    i   s(   building %s because directory %s changed(   R}   R   RR   t   popR*   R;   RQ   R   R   t   listdirR   R4   R  R6   R   RS   (   R   RW   R   t   stackR@   R   RC   R   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR     s"    
			c         C   s  t  j d t j j |  j   |  j |  j f g } i  } i  } x< |  j D]1 } | d d k rq d | | d <qJ d | | <qJ Wg  } x | r}| j	   \ } } x t j
 |  D] } | j | d  d k r t j j |  d }	 | j |	 d  d k rvt j j | |  }
 | r,t j j | |  p/| } t j j |
  rZ| j |
 | f  qs| j | |
 d f  qvq q Wq W| |  _ y t |  j  } Wn d  } n X|  j |  j |  j |  j f } | | k rt |  j |  d St  j d |  j  d S(   Ns   building Tree %si    Ro  i   RH  s   %s no change!(   R;   RQ   R   R   R   R   R  R  R   R  R  R  R>   R4   R  R6   R   R!   R   R   (   R   R  R   t	   xexcludesRC   R	  t   dirR  R)   RG   t   fullfnmt   rfnmR   R   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR     s>    	!$	
N(   s   tocN(	   R   R   R  R   R2   RX   R   R   R   (    (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR  a  s   					t   MERGEc           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s   
    Merge repeated dependencies from other executables into the first
    execuable. Data and binary files are then present only once and some
    disk space is thus reduced.
    c         G   s   d |  _ i  |  _ i  |  _ x$ | D] \ } } } | |  j | <q" Wt j j t j j g  | D], \ } } } t j j | j	 d d  ^ q[   |  _
 |  j
 d t j k r |  j
 t j 7_
 n  t j d |  j
  |  j |  d S(   s|  
        Repeated dependencies are then present only once in the first
        executable in the 'args' list. Other executables depend on the
        first one. Other executables have to extract necessary files
        from the first executable.

        args  dependencies in a list of (Analysis, id, filename) tuples.
              Replace id with the correct filename.
        ii   s   Common prefix: %sN(   R   t   _maint   _dependenciest   _id_to_pathR   R   R   t   commonprefixR+   R   t   _common_prefixRq   R;   RQ   t   _merge_dependencies(   R   R   t   _Ry   t   pRF  (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR2     s    			Tc         C   s   x | D] \ } } } t  j j | j d d  j |  j d d  } t  j j |  d } | |  j k rz |  j | } n  |  j | |  q Wd S(   sL   
        Filter shared dependencies to be only in first executable.
        ii   R   i    N(	   R   R   R+   R   Rp   R  R>   R  t   _set_dependencies(   R   R   t   analysisR  R   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR    s    /c         C   s!  x| j  | j f D]} x t |  D] \ } } | d |  j j   k rz t j d | d | f  | |  j | d <q& |  j | |  j | d  } t j d | d | | f  | j j	 d j
 | | d f  | d d f  d | | <q& Wg  | D] } | d	 k r | ^ q | (q Wd S(
   sN   
        Syncronize the Analysis result with the needed dependencies.
        i   s"   Adding dependency %s located in %ss6   Referencing %s to be a dependecy for %s, located in %sR  i    RL   N(   NNN(   NNN(   R   R   R   R  R   R;   R<   t   _get_relative_pathR   R6   R4   R   (   R   R  R   R@   Ry   R  t   dep_path(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR    s    0c         C   sT   | j  t j  d  } d g t |  } | rL | j |  t j j |  S| Sd  S(   Nis   ..(   R?   R   Rq   Rt   R6   R4   (   R   t	   startpatht   topatht   start(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR    s    (   R   R   R  R2   R  R  R  (    (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR    s
   			c           C   s   t  d   d  S(   Ns   TkTree has been removed in PyInstaller 2.0. Please update your spec-file. See http://www.pyinstaller.org/wiki/MigrateTo2.0 for details(   R_   (    (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   TkTree  s    c           C   s   t  d   d  S(   Ns   TkPKG has been removed in PyInstaller 2.0. Please update your spec-file. See http://www.pyinstaller.org/wiki/MigrateTo2.0 for details(   R_   (    (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   TkPKG  s    c         C   s
  t  t j j t d d d   a t j |  } t j |  } t j |   a t j j	 |   \ a
 a t j j t  d a t j j |  t k r t j j t t t j j |   } n  | a t j j |  t k rt j j t t t j j |  t  a n t j j | t  a t j j t d t  a | rt j d t  xy t t f D]h } t j j |  rTxM t j | d  D]5 } t j j |  rt j |  qt j |  qWqTqTWn  x6 t t f D]( } t j j t  st j t  qqWt |   d S(	   sB   
    Build the executable according to the created SPEC file.
    R   R   s   rthooks.dati    s
   warn%s.txts1   Removing temporary files and cleaning cache in %ss   /*N(   R!   R   R   R4   R   R   R#   t   expand_pathR`   R?   R^   R   R>   R   R   R`  R5   R   R;   RQ   R   R   R   R  Rk   Rl   R  R   t   execfile(   t   spect   distpathR   t   clean_buildRw   R&   (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyR    s2    !'*c         C   s   |  j  d d d d t d d |  j  d d t d d |  j  d	 d
 d d d t d d t j j d d d  |  j  d d d  d d |  j  d d d d d d |  j  d d d d d d t d d d  S(   Ns
   --distpatht   metavart   DIRt   defaultt   helps0   Where to put the bundled app (default: %default)s
   --workpathsR   Where to put all the temporary work files, .log, .pyz and etc. (default: %default)s   -ys   --noconfirmt   actiont
   store_truesF   Replace output directory (default: %s) without asking for confirmationR^   t   distt   SPECNAMEs	   --upx-dirs8   Path to UPX utility (default: search the execution path)s   -as   --asciisH   Do not include unicode encoding support (default: included if available)s   --cleant   destR  sC   Clean PyInstaller cache and remove temporary files before building.(   t
   add_optionR   R   RS   R   R   R4   R   (   t   parser(    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   __add_optionsF  s    c         K   s   | a  | s" t j t j    n  |  d  k rX d d  l j } | j | j	 d   a
 n |  a
 t
 d r d d l m a m a m a t j t j  a n d  a t
 d r t   n  t | | j	 d  | j	 d  | j	 d   d  S(	   NiR  Rg  (   R]  Rs  R#  R  R  R   R  (   Rd   R   R   R   t   get_unicode_modulesR   t   PyInstaller.configuret	   configuret
   get_configR  R  t   PyInstaller.utilsR]  Rs  R#  R   t   getAssembliesRe   R   R!  R'   R  (   t
   pyi_configt   specfilet	   noconfirmt   asciit   kwR  (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   mainZ  s    


([   R  R   R7   R   R   R9   Rk   Re   Rp  R  t   PyInstaller.loaderR    R   t   PyInstaller.depend.imptrackerR   t   PyInstaller.depend.modulesR   R   R   R   R   t   PyInstaller.compatR   R   R	   R
   R   R#   t   PyInstaller.bindependR   R   t   PyInstaller.dependR   R  R   t   PyInstaller.logt   logt   loggingR   t	   getLoggerR   R;   t   typet
   STRINGTYPER   t	   TUPLETYPERs   t   UNCOMPRESSEDRP  R`   R^   R`  R5   R   Rd   R   R   R   R!   R'   R*   R.   RJ   RP   RX   RZ   R[   Rb   Rn   R|   t   objectR}   R   R   R
  R  RS   R  RA  RZ  R  R  R  RM   R  R  R  R  R  R  R  (    (    (    sT   C:\Users\Salopaasi\My Documents\pyinstaller-pyinstaller-275d4c9\PyInstaller\build.pyt   <module>   s   ((							?		
			- 	4	yVXZJ			5	