3
;p_p                 @   s  d Z ddlZddlZyddlZW n ek
r<   ddlZY nX ye W n  ek
rf   ddlm	Z Y nX ej
ejgZdadadaeeddpeedd@kZeedZd	d
 Zdd Zdd Zdd Zdd Zdd ZdAddZej
ejfddZdd Zdd Zdd Zdd  ZG d!d" d"e Z!d#d$ Z"G d%d& d&e Z#d'd( Z$d)d* Z%d+d, Z&d-d. Z'd/d0 Z(d1d2 Z)d3d4 Z*d5d6 Z+d7d8 Z,erd9d: Z-d;d< Z.e.  d=d> Z/e0d?kre/  dS )Ba
  Append module search paths for third-party packages to sys.path.

****************************************************************
* This module is automatically imported during initialization. *
****************************************************************

In earlier versions of Python (up to 1.5a3), scripts or modules that
needed to use site-specific modules would place ``import site''
somewhere near the top of their code.  Because of the automatic
import, this is no longer necessary (but code that does it still
works).

This will append site-specific paths to the module search path.  On
Unix, it starts with sys.prefix and sys.exec_prefix (if different) and
appends lib/python<version>/site-packages as well as lib/site-python.
It also supports the Debian convention of
lib/python<version>/dist-packages.  On other platforms (mainly Mac and
Windows), it uses just sys.prefix (and sys.exec_prefix, if different,
but this is unlikely).  The resulting directories, if they exist, are
appended to sys.path, and also inspected for path configuration files.

FOR DEBIAN, this sys.path is augmented with directories in /usr/local.
Local addons go into /usr/local/lib/python<version>/site-packages
(resp. /usr/local/lib/site-python), Debian addons install into
/usr/{lib,share}/python<version>/dist-packages.

A path configuration file is a file whose name has the form
<package>.pth; its contents are additional directories (one per line)
to be added to sys.path.  Non-existing directories (or
non-directories) are never added to sys.path; no directory is added to
sys.path more than once.  Blank lines and lines beginning with
'#' are skipped. Lines starting with 'import' are executed.

For example, suppose sys.prefix and sys.exec_prefix are set to
/usr/local and there is a directory /usr/local/lib/python2.X/site-packages
with three subdirectories, foo, bar and spam, and two path
configuration files, foo.pth and bar.pth.  Assume foo.pth contains the
following:

  # foo package configuration
  foo
  bar
  bletch

and bar.pth contains:

  # bar package configuration
  bar

Then the following directories are added to sys.path, in this order:

  /usr/local/lib/python2.X/site-packages/bar
  /usr/local/lib/python2.X/site-packages/foo

Note that bletch is omitted because it doesn't exist; bar precedes foo
because bar.pth comes alphabetically before foo.pth; and spam is
omitted because it is not mentioned in either path configuration file.

After these path manipulations, an attempt is made to import a module
named sitecustomize, which can perform arbitrary additional
site-specific customizations.  If this import fails with an
ImportError exception, it is silently ignored.

    N)SetmaxsizeZmaxint       pypy_version_infoc              G   s(   t jj|  }t jj|}|t jj|fS )N)ospathjoinabspathZnormcase)pathsdir r   k/home/aldo/Documentos/tesis/tesis/device auto/pruebas pulsar/pruebaclonado/envClonado/lib/python3.6/site.pymakepath[   s    r   c              C   s<   x6t jj D ](} t| dd}|dkr&qtjj|| _qW dS )z6Set all module' __file__ attribute to an absolute path__file__N)sysmodulesvaluesgetattrr   r   r
   r   )mfr   r   r   abs__file__a   s
    r   c              C   sT   g } t  }x6tjD ],}t|\}}||kr| j| |j| qW | tjdd< |S )zK Remove duplicate entries from sys.path along with making them
    absoluteN)setr   r   r   appendadd)Lknown_pathsr   dircaser   r   r   removeduppathsj   s    
r   c              C   s^   ddl m}  dj|  ftj }ttdr2|d7 }tjjtjj	tjd |}tjj
| dS )	zbAppend ./build/lib.<platform> in case we're running in the build dir
    (especially for Guido :-)r   )get_platformzbuild/lib.{}-{}.{}Zgettotalrefcountz-pydebug   N)Zdistutils.utilr   formatr   version_infohasattrr   r   r	   dirnamer   )r   sr   r   r   addbuilddir   s    
r'   c              C   sX   t  } xLtjD ]B}y&tjj|r6t|\}}| j| W q tk
rN   wY qX qW | S )zDReturn a set containing all existing directory entries from sys.path)r   r   r   r   isdirr   r   	TypeError)dr   r   r   r   r   _init_pathinfo   s    r+   c       	      C   s   |dkrt   d}nd}tjj| |}yt|d}W n tk
rH   dS X zrxl|D ]d}|jdrbqR|jdrvt| qR|j }t	| |\}}||krRtjj
|rRtjj| |j| qRW W d|j  X |rd}|S )zoAdd a new path to known_paths by combining sitedir and 'name' or execute
    sitedir if it starts with 'import'Nr    r   r#Zimport)r+   r   r   r	   openIOError
startswithexecrstripr   existsr   r   r   close)	sitedirnamer   resetfullnamer   liner   r   r   r   r   
addpackage   s2    



r:   c             C   s   |dkrt  }d}nd}t| \} }||kr8tjj|  ytj| }W n tjk
r\   dS X |j  x(|D ] }|j	tj
d rlt| || qlW |rd}|S )zTAdd 'sitedir' argument to sys.path if missing and handle .pth files in
    'sitedir'Nr    r   Zpth)r+   r   r   r   r   r   listdirerrorsortendswithZextsepr:   )r5   r   r7   ZsitedircaseZnamesr6   r   r   r   
addsitedir   s$    
r?   c       	      C   s  t jj|d|g}||kr.|jt jj|d x|D ]}|r6tjd!kr`t jj|ddg}ntrxt jj|dg}ntjdkr||kr|jdrt jjdd	jtj	 dt jj|d
ddg}nt jj|ddjtj	 dg}nt j
dkrXt jj|ddjtj	 dt jj|ddt jj|djtj	 dg}t jj|ddjtj	 d}t jj|rt jj|dd |D krtr|jd| n
|j| y$tj |jdt jj|d d W n tk
r   Y nX |jt jj|ddjtj	 d tj	d dkr|jt jj|ddjtj	 d n$|jt jj|ddjtj	d d |jt jj|dd n|t jj|ddg}tjdkrd|ksd|krt jjd}|r|jt jj|ddd	jtj	 d x&|D ]}t jj|rt||  qW q6W d S )"z8Add site-packages (and possibly site-python) to sys.pathZlocalos2emxriscosLibzsite-packagesdarwinz/System/Library/Frameworks/z/Library/Pythonz{}.{}ZExtraslibZpythonzpython{}.{}/zsite-pythonzlib-dynloadlib64c             S   s   g | ]}t jj|qS r   )r   r   realpath).0pr   r   r   
<listcomp>   s    z#addsitepackages.<locals>.<listcomp>r   debugz	local/libzdist-packagesr   zpython{}zdist-pythonzPython.frameworkzPython3.frameworkZHOMEZLibraryPythonN)r@   rA   )r   r   r	   r   r   platform_is_pypyr0   r"   r#   sepr3   rG   	_is_64bitinsertZ
getobjectsAttributeErrorenvirongetr(   r?   )	r   
sys_prefixexec_prefixZprefixesprefixZsitedirsZ	lib64_dirZhomer5   r   r   r   addsitepackages   s`    

 
 
rX   c               C   sp   t tdrttjddrdS t tdrDt tdrDtj tj krDdS t tdrlt tdrltj tj krldS d	S )
a,  Check if user site directory is safe for inclusion

    The function tests for the command line flag (including environment var),
    process uid/gid equal to effective uid/gid.

    None: Disabled for security reasons
    False: Disabled by user (command line option)
    True: Safe and enabled
    flagsno_user_siteFgetuidgeteuidNgetgidgetegidT)	r$   r   r   rY   r   r\   r[   r^   r]   r   r   r   r   check_enableusersite  s    
r_   c             C   s   t jjdd}dd }t jdkr^t jjdp.d}|r:|an
||dat jjtd	jtj	 d
a
n.|rh|an
|ddat jjtddjtj	 d
a
trt jjt
rtt
|  trx<dD ]4}t jjt|djtj	 d}t jj|rt||  qW | S )a'  Add a per user site-package to sys.path

    Each user has its own python directory with site-packages in the
    home directory.

    USER_BASE is the root directory for all Python versions

    USER_SITE is the user specific site-packages directory

    USER_SITE/.. can be used for data.
    ZPYTHONUSERBASENc              W   s   t jjt jj|  S )N)r   r   
expanduserr	   )argsr   r   r   joinuserC  s    z%addusersitepackages.<locals>.joinuserntZAPPDATA~rL   z
Python{}{}zsite-packagesz.localrD   zpython{}.{}	local/libzdist-packages)rD   re   )r   rS   rT   r6   	USER_BASEr   r	   r"   r   r#   	USER_SITEENABLE_USER_SITEr(   r?   )r   Zenv_baserb   baseZdist_libdirZ	user_siter   r   r   addusersitepackages4  s(    




rj   c              C   sR   t jjtjdd} t jd jd}|d r6|j|  n| |d< dj|t jd< dS )	aE  The OS/2 EMX port has optional extension modules that do double duty
    as DLLs (and must use the .DLL file extension) for other extensions.
    The library search path needs to be amended so these will be found
    during module import.  Use BEGINLIBPATH so that these are at the start
    of the library search path.

    rB   zlib-dynloadZBEGINLIBPATH;r    Nr!   r!   )r   r   r	   r   rW   rS   splitr   )ZdllpathZlibpathr   r   r   setBEGINLIBPATHb  s    rm   c                 sP   t jdkrd nt jdkr d nd G  fdddt} | dt_| d	t_d
S )znDefine new built-ins 'quit' and 'exit'.
    These are simply strings that display a hint on how to exit.

    :zCmd-Q\zCtrl-Z plus ReturnzCtrl-D (i.e. EOF)c                   s*   e Zd Zdd Z fddZdddZdS )	zsetquit.<locals>.Quitterc             S   s
   || _ d S )N)r6   )selfr6   r   r   r   __init__  s    z!setquit.<locals>.Quitter.__init__c                s   dj | j S )NzUse {}() or {} to exit)r"   r6   )rp   )eofr   r   __repr__  s    z!setquit.<locals>.Quitter.__repr__Nc          	   S   s(   yt jj  W n   Y nX t|d S )N)r   stdinr4   
SystemExit)rp   coder   r   r   __call__  s
    z!setquit.<locals>.Quitter.__call__)N)__name__
__module____qualname__rq   rs   rw   r   )rr   r   r   Quitter  s   r{   quitexitN)r   rO   objectbuiltinsr|   r}   )r{   r   )rr   r   setquits  s    


r   c               @   s:   e Zd ZdZdZf f fddZdd Zdd Zd	d
 ZdS )_Printerzninteractive prompt objects for printing the license text, a list of
    contributors and the copyright notice.   c             C   s"   || _ || _|| _|| _d | _d S )N)_Printer__name_Printer__data_Printer__files_Printer__dirs_Printer__lines)rp   r6   dataZfilesZdirsr   r   r   rq     s
    z_Printer.__init__c             C   s   | j r
d S d }xh| jD ]^}xR| jD ]H}tjj||}y t|d}|j }|j  P W q" t	k
rh   Y q"X q"W |rP qW |s| j
}|jd| _ t| j | _d S )Nr,   
)r   r   r   r   r   r	   r.   readr4   r/   r   rl   lenZ_Printer__linecnt)rp   r   r   filenameZfpr   r   r   Z__setup  s&    

z_Printer.__setupc             C   s8   | j   t| j| jkr$dj| jS d| jfd  S d S )Nr   z!Type %s() to see the full %s textr   )_Printer__setupr   r   MAXLINESr	   r   )rp   r   r   r   rs     s    z_Printer.__repr__c             C   s   | j   d}d}xy,x&t||| j D ]}t| j|  q&W W n tk
rT   P Y qX || j7 }d }xB|d kryt|}W n tk
r   t|}Y nX |dkrfd }qfW |dkrP qW d S )Nz0Hit Return for more, or q (and Return) to quit: r    q)r   r   )	r   ranger   printr   
IndexErrorZ	raw_input	NameErrorinput)rp   Zpromptlinenoikeyr   r   r   rw     s(    

z_Printer.__call__N)	rx   ry   rz   __doc__r   rq   r   rs   rw   r   r   r   r   r     s   r   c              C   sj   t dtjt_tr t ddt_nt ddt_tjjtj	} t ddddgtj
tjj| tj| tjgt_d	S )
z,Set 'copyright' and 'credits' in __builtin__	copyrightcreditsz;PyPy is maintained by the PyPy developers: http://pypy.org/z    Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
    for supporting Python development.  See www.python.org for more information.licensez'See https://www.python.org/psf/license/zLICENSE.txtZLICENSEN)r   r   r   r   rN   r   r   r   r%   r   rW   r	   ZpardirZcurdirr   )Zherer   r   r   setcopyright  s    r   c               @   s    e Zd ZdZdd Zdd ZdS )_HelperzYDefine the built-in 'help'.
    This is a wrapper around pydoc.help (with a twist).

    c             C   s   dS )NzHType help() for interactive help, or help(object) for help about object.r   )rp   r   r   r   rs     s    z_Helper.__repr__c             O   s   dd l }|j||S )Nr   )pydochelp)rp   ra   kwdsr   r   r   r   rw     s    z_Helper.__call__N)rx   ry   rz   r   rs   rw   r   r   r   r   r     s   r   c               C   s   t  t_d S )N)r   r   r   r   r   r   r   	sethelper  s    r   c              C   sx   t jdkrtddl} ddl}| j d }|jdrty|j| W n4 tk
rr   ddl}|j	|j
|< d|jj|< Y nX dS )zOn Windows, some default encodings are not provided by Python,
    while they are always available as "mbcs" in each locale. Make
    them usable by aliasing to "mbcs" in such a case.win32r   Nr    Zcpmbcs)r   rM   localecodecsZgetdefaultlocaler0   lookupLookupError	encodings_unknown_cachealiases)r   r   Zencr   r   r   r   	aliasmbcs  s    

r   c              C   s   d} | dkrt j|  dS )zSet the string encoding used by the Unicode implementation.  The
    default is 'ascii', but if you're willing to experiment, you can
    change this.asciiN)r   setdefaultencoding)encodingr   r   r   setencoding  s    r   c              C   s&   yddl } W n tk
r    Y nX dS )z,Run custom site specific code, if available.r   N)sitecustomizeImportError)r   r   r   r   execsitecustomize#  s    r   c              C   s  t tjjtjjtd} | j j t_	| j
  d}g }tjd dkrN|d7 }tr<tjdkrndtjd  }n0tjdkrd	tjd d  }nd
tjd d  }tjjtj	dtjjtj	d|g}tjdk r|jdtjjtj	dd|  |d d  }xB|d d  D ]2}tjj|dtj }tjj|r|j| qW ntjdkrjtjjtj	dtjjtj	dg}ntjjtj	ddjtj g}|d d  }tjjtj	ddjtj }tjj|rtr|jd| n
|j| yttdtj}W n tk
r   tj}Y nX tjjtj	ddjtj d| }tjj|r@|j| x8t|D ],}tjj|d}	tjj|	rJ|j|	 qJW tjdkrdd |D }
x&|
D ]}tjj|r|j| qW tjj| d S )Nzorig-prefix.txtr   r   r   r       z%d   z%d.%dz%d.%d.%dZlib_pypyz
lib-python	   zmodified-%szplat-%sr   rB   ZDLLsrD   zpython{}.{}rF   implementationzlib-tkrC   c             S   s$   g | ]}dD ]}t jj||qqS )plat-darwinplat-macplat-mac/lib-scriptpackages)r   r   r   )r   r   r	   )rH   Zrelative_dirmoduler   r   r   rJ   g  s   z1virtual_install_main_packages.<locals>.<listcomp>)r   r   )r    r   )r    r   )r.   r   r   r	   r%   r   r   stripr   real_prefixr4   rN   r#   r   rQ   rM   r3   r   r"   rP   r   
_multiarchrR   listextend)r   ZposZhardcoded_relative_dirsZcpyverr   r   Z	plat_pathZ
lib64_pathZarchZtk_dirZhardcoded_pathsr   r   r   virtual_install_main_packages+  s`    

"
"
 

r   c              C   sJ   t tdd} x.ttjD ] \}}|| kr|jtjr|} qW | d t_dS )a  
    Force easy_installed eggs in the global environment to get placed
    in sys.path after all packages inside the virtualenv.  This
    maintains the "least surprise" result that packages in the
    virtualenv always mask global packages, never the other way
    around.

    __egginsertr   r    N)r   r   	enumerater   r0   rW   r   )Z	egginsertr   r   r   r   r   +force_global_eggs_after_local_site_packagess  s
    	r   c             C   s   t   t| tjdS )N)rU   )r   rX   r   r   )r   r   r   r   virtual_addsitepackages  s    r   c              C   s&   yddl } W n tk
r    Y nX dS )z,Run custom user specific code, if available.r   N)usercustomizer   )r   r   r   r   execusercustomize  s    r   c              C   s   dd } | t _dS )ai  Enable default readline configuration on interactive prompts, by
    registering a sys.__interactivehook__.
    If the readline module can be imported, the hook will set the Tab key
    as completion key and register ~/.python_history as history file.
    This can be overridden in the sitecustomize or usercustomize module,
    or in a PYTHONSTARTUP file.
    c                 s   dd l } ydd ldd l}W n tk
r0   d S X tdd}|d k	rZd|krZjd n
jd yj  W n tk
r   Y nX j dkrt	j
jt	j
jdd yj  W n tk
r   Y nX  fd	d
}| j| d S )Nr   r   r   Zlibeditzbind ^I rl_completeztab: completerd   z.python_historyc                  s,   yj   W n ttfk
r&   Y nX d S )N)Zwrite_history_fileFileNotFoundErrorPermissionErrorr   )historyreadliner   r   write_history  s    zCenablerlcompleter.<locals>.register_readline.<locals>.write_history)atexitr   rlcompleterr   r   Zparse_and_bindZread_init_fileOSErrorZget_current_history_lengthr   r   r	   r`   Zread_history_fileregister)r   r   Zreadline_docr   r   )r   r   r   register_readline  s,    
z,enablerlcompleter.<locals>.register_readlineN)r   Z__interactivehook__)r   r   r   r   enablerlcompleter  s    	0r   c              C   s0   ddl } dtjkrddl}dtjkr,ddl}dS )zPyPy specific: some built-in modules should be pre-imported because
        some programs expect them to be in sys.modules on startup. This is ported
        from PyPy's site.py.
        r   N
exceptions	zipimport)r   r   builtin_module_namesr   r   )r   r   r   r   r   r   import_builtin_stuff  s
    

r   c              C   s   t   trt  t  t } tjdkrHtjrHtjj	tjd
 dkrHt
  tjjtjjtjjtd }|spdatd kr~t at| } t| } |rt| } tjdkrt  t  t  t  tjd dkrt  t  t  t  trt  ttd	rt` d S )Nposixr    ZModuleszno-global-site-packages.txtFr@   r   r   r   r!   )!r   rN   r   r   r   r   r6   r   r   Zbasenamer'   r3   r	   r%   r   rh   r_   rX   rj   r   rM   rm   r   r   r   r#   r   r   r   r   r   r$   r   )Zpaths_in_sysZGLOBAL_SITE_PACKAGESr   r   r   main  s<    & 

r   c              C   sB  d} t jdd  }|std xt jD ]}tdj| q&W td dd }tdjt|t td	jt|t td
t  t jd g }d|kr|j	t d|kr|j	t |rtt
jj| trt jd n4tdkrt jd n td krt jd n
t jd n0dd l}t|j| t jd t
jf  t jd d S )Na      %s [--user-base] [--user-site]

    Without arguments print some useful information
    With arguments print the value of USER_BASE and/or USER_SITE separated
    by '%s'.

    Exit codes with --user-base or --user-site:
      0 - user site directory is enabled
      1 - user site directory is disabled by user
      2 - uses site directory is disabled by super user
          or for security reasons
     >2 - unknown error
    r    zsys.path = [z	    {!r},]c             S   s   t jj| rdS dS d S )Nr3   zdoesn't exist)r   r   r(   )r   r   r   r   r3     s    z_script.<locals>.existszUSER_BASE: {!r} ({})zUSER_SITE: {!r} ({})zENABLE_USER_SITE: %rr   z--user-basez--user-siteFr   r   
   )r   Zargvr   r   r"   rf   rg   rh   r}   r   r   Zpathsepr	   textwrapZdedent)r   ra   r   r3   bufferr   r   r   r   _script  s:    



r   Z__main__l        )N)1r   r   r   Z__builtin__r   r   r   r   Zsetsr   rW   rV   ZPREFIXESrh   rg   rf   r   rP   r$   rN   r   r   r   r'   r+   r:   r?   rX   r_   rj   rm   r   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rx   r   r   r   r   <module>@   s^   
	 
K. AH<%8
