
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
ÝPfKi  ã               @   s   d Z ddlZddlZddlZddlZddlmZmZ yddlZW n e	k
r\   ddl
ZY nX dddddd	d
ddddgZdd„ ZejršejjeejƒƒZneejƒ ƒZejdkrÖdedEd… jƒ krÖeejjeeƒƒZejdkoòdedFd… jƒ k�r
eejjeeeƒƒZejdk�r@dedGd… jƒ k�r@eejjeeeƒƒZdd„ Zeƒ Zdadd„ Zejƒ ZejdƒZdd„ Zejjƒ d Z ejdd … Z!e d e d!  Z"ejj#ej$ƒZ%ejj#ej&ƒZ'da(dZ)d"d#„ Z*d$d%„ Z+d&d'„ Z,d(d)„ Z-d*d+„ Z.d,d-„ Z/dHd.d/„Z0d0d„ Z1d1d2„ Z2d3d4„ Z3dId5d„Z4d6d„ Z5d7d„ Z6d8d	„ Z7e.ƒ dd9fd:d
„Z8e.ƒ dd9fd;d„Z9d<d„ Z:d=d„ Z;d>d„ Z<d?d„ Z=d@dA„ Z>dBdC„ Z?e@dDk�rœe?ƒ  dS )Jz-Access to Python's configuration information.é    N)ÚpardirÚrealpathÚget_config_h_filenameÚget_config_varÚget_config_varsÚget_makefile_filenameÚget_pathÚget_path_namesÚ	get_pathsÚget_platformÚget_python_versionÚget_scheme_namesÚparse_config_hc             C   s"   yt | ƒS  tk
r   | S X d S )N)r   ÚOSError)Úpath© r   ú/usr/lib/python3.6/sysconfig.pyÚ_safe_realpath"   s    r   ÚntZpcbuildé   z\pc\vé
   z\pcbuild\amd64é   c              C   s.   x(dD ] } t jjt jjtd| ƒƒrdS qW dS )Nú
Setup.distúSetup.localÚModulesTF)r   r   )Úosr   ÚisfileÚjoinÚ_PROJECT_BASE)Úfnr   r   r   Úis_python_build:   s    
r    Fc              C   s’   t sŽddlm}  tjddƒd }| |ƒ}|jdƒ}|s>tdƒ‚|jƒ �}tj	|ƒ W d Q R X t
rŠx(dD ] }tj|d
dƒ tj|ddƒ qfW da d S )Né   )ÚfinderÚ.é   r   zsysconfig.cfgzsysconfig.cfg existsÚposix_prefixÚ
posix_homeÚincludez{srcdir}/IncludeÚplatincludez{projectbase}/.T)r%   r&   )Ú	_cfg_readZ	resourcesr"   Ú__name__ÚrsplitÚfindÚAssertionErrorZ	as_streamÚ_SCHEMESZreadfpÚ_PYTHON_BUILDÚset)r"   Zbackport_packageZ_finderZ_cfgfileÚsÚschemer   r   r   Ú_ensure_cfg_readD   s    


r3   z\{([^{]*?)\}c                sØ   t ƒ  | jdƒr| jdƒ}ntƒ }| jƒ }xD|D ]<}|dkr>q0x,|D ]$\}}| j||ƒrZqD| j|||ƒ qDW q0W | jdƒ xX| jƒ D ]L}t| j|ƒƒ‰ ‡ fdd„}x,| j|ƒD ]\}}| j||t	j
||ƒƒ q®W q„W d S )NÚglobalsc                s$   | j dƒ}|ˆ krˆ | S | j dƒS )Nr$   r   )Úgroup)ÚmatchobjÚname)Ú	variablesr   r   Ú	_replacero   s    
z"_expand_globals.<locals>._replacer)r3   Zhas_sectionÚitemsÚtupleÚsectionsZ
has_optionr0   Zremove_sectionÚdictÚ	_VAR_REPLÚsub)Úconfigr4   r<   ZsectionZoptionÚvaluer9   r   )r8   r   Ú_expand_globalsY   s$    


rB   é   r!   c                s   ‡ fdd„}t j|| ƒS )z»In the string `path`, replace tokens like {some.thing} with the
    corresponding value from the map `local_vars`.

    If there is no corresponding value, leave the token unchanged.
    c                s8   | j dƒ}|ˆ krˆ | S |tjkr.tj| S | j dƒS )Nr$   r   )r5   r   Úenviron)r6   r7   )Ú
local_varsr   r   r9   ‹   s    


z_subst_vars.<locals>._replacer)r>   r?   )r   rE   r9   r   )rE   r   Ú_subst_vars…   s    rF   c             C   s4   | j ƒ }x&|jƒ D ]\}}||kr$q|| |< qW d S )N)Úkeysr:   )Útarget_dictÚ
other_dictÚtarget_keysÚkeyrA   r   r   r   Ú_extend_dict•   s
    rL   c             C   sd   i }|d kri }t |tƒ ƒ xBtj| ƒD ]4\}}tjdkrFtjj|ƒ}tjjt	||ƒƒ||< q(W |S )NÚposixr   )rM   r   )
rL   r   r.   r:   r   r7   r   Ú
expanduserÚnormpathrF   )r2   ÚvarsÚresrK   rA   r   r   r   Ú_expand_vars�   s    
rR   c                s   ‡ fdd„}t j|| ƒS )Nc                s$   | j dƒ}|ˆ krˆ | S | j dƒS )Nr$   r   )r5   )r6   r7   )rP   r   r   r9   «   s    
zformat_value.<locals>._replacer)r>   r?   )rA   rP   r9   r   )rP   r   Úformat_valueª   s    rS   c               C   s   t jdkrdS t jS )NrM   r%   )r   r7   r   r   r   r   Ú_get_default_scheme³   s    
rT   c              C   s’   t jjdd ƒ} dd„ }t jdkrBt jjdƒp.d}| r8| S ||dƒS tjdkr|td	ƒ}|r|| r`| S |dd
|dtjd d…  ƒS | r„| S |ddƒS d S )NÚPYTHONUSERBASEc              W   s   t jjt jj| Ž ƒS )N)r   r   rN   r   )Úargsr   r   r   Újoinuser½   s    z_getuserbase.<locals>.joinuserr   ÚAPPDATAú~ÚPythonÚdarwinÚPYTHONFRAMEWORKÚLibraryz%d.%dr!   z.local)r   rD   Úgetr7   ÚsysÚplatformr   Úversion_info)Úenv_baserW   ÚbaseÚ	frameworkr   r   r   Ú_getuserbaseº   s"    



re   c             C   s"  t jdƒ}t jdƒ}t jdƒ}|dkr*i }i }i }tj| ddd��}|jƒ }W dQ R X x¢|D ]š}	|	jdƒs\|	jƒ d	krxq\|j|	ƒ}
|
r\|
jd
dƒ\}}|jƒ }|j	dd	ƒ}d|kr¼|||< q\yt
|ƒ}W n$ tk
rì   |j	ddƒ||< Y q\X |||< q\W t|jƒ ƒ}d}�xÖt|ƒdk�râ�x¾t|ƒD �]°}|| }|j|ƒ�pJ|j|ƒ}
|
dk	�rÆ|
jd
ƒ}d}||k�r|t|| ƒ}nˆ||k�rŒd}nx|tjk�r¤tj| }n`||k�rø|jdƒ�rÒ|dd… |k�rÒd	}n$d| |k�ræd}nt|d|  ƒ}nd	 ||< }|�rØ||
jƒ d… }|d|
jƒ … | | }d|k�rF|||< n~yt
|ƒ}W n" tk
�rt   |jƒ ||< Y n
X |||< |j|ƒ |jdƒ�rØ|dd… |k�rØ|dd… }||k�rØ|||< n|||< |j|ƒ �q(W �qW x.|jƒ D ]"\}}t|tƒ�rî|jƒ ||< �qîW |j|ƒ |S )zÌParse a Makefile-style file.

    A dictionary containing name/value pairs is returned.  If an
    optional dictionary is passed in as the second argument, it is
    used instead of a new dictionary.
    z"([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)z\$\(([A-Za-z][A-Za-z0-9_]*)\)z\${([A-Za-z][A-Za-z0-9_]*)}Nzutf-8Úsurrogateescape)ÚencodingÚerrorsú#Ú r$   r!   z$$ú$ÚCFLAGSÚLDFLAGSÚCPPFLAGSr   TFÚPY_rC   )rl   rm   rn   )ÚreÚcompileÚcodecsÚopenÚ	readlinesÚ
startswithÚstripÚmatchr5   ÚreplaceÚintÚ
ValueErrorÚlistrG   Úlenr;   ÚsearchÚstrr   rD   ÚendÚstartÚremover:   Ú
isinstanceÚupdate)ÚfilenamerP   Ú_variable_rxÚ_findvar1_rxÚ_findvar2_rxÚdoneÚnotdoneÚfÚlinesÚlineÚmÚnÚvÚtmpvr8   Úrenamed_variablesr7   rA   ÚfoundÚitemÚafterÚkr   r   r   Ú_parse_makefile×   sŒ    	
















r–   c              C   sD   t rtjjtdƒS ttdƒr,dttjf } nd} tjjt	dƒ| dƒS )z Return the path of the Makefile.ÚMakefileÚabiflagszconfig-%s%sr@   Ústdlib)
r/   r   r   r   r   Úhasattrr_   Ú_PY_VERSION_SHORTr˜   r   )Úconfig_dir_namer   r   r   r   M  s    
c             C   sè   t ƒ }yt|| ƒ W nJ tk
r^ } z.d| }t|dƒrF|d|j  }t|ƒ‚W Y dd}~X nX tƒ }y"t|ƒ�}t|| ƒ W dQ R X W nJ tk
rÒ } z.d| }t|dƒrº|d|j  }t|ƒ‚W Y dd}~X nX trä| d | d< dS )z7Initialize the module as appropriate for POSIX systems.z.invalid Python installation: unable to open %sÚstrerrorz (%s)NÚ	BLDSHAREDÚLDSHARED)	r   r–   ÚIOErrorrš   r�   r   rs   r   r/   )rP   ÚmakefileÚeÚmsgÚconfig_hrŠ   r   r   r   Ú_init_posixX  s&    


r¥   c             C   sV   t dƒ| d< t dƒ| d< t dƒ| d< d| d< d	| d
< t| d< tjjttjƒƒ| d< dS )z+Initialize the module as appropriate for NTr™   ÚLIBDESTÚ
platstdlibÚ
BINLIBDESTr'   Ú	INCLUDEPYz.pydÚSOz.exeÚEXEÚVERSIONÚBINDIRN)r   Ú_PY_VERSION_SHORT_NO_DOTr   r   Údirnamer   r_   Ú
executable)rP   r   r   r   Ú_init_non_posixt  s    r±   c             C   sž   |dkri }t jdƒ}t jdƒ}xx| jƒ }|s0P |j|ƒ}|rz|jddƒ\}}yt|ƒ}W n tk
rn   Y nX |||< q"|j|ƒ}|r"d||jdƒ< q"W |S )zÌParse a config.h-style file.

    A dictionary containing name/value pairs is returned.  If an
    optional dictionary is passed in as the second argument, it is
    used instead of a new dictionary.
    Nz"#define ([A-Z][A-Za-z0-9_]+) (.*)
z&/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/
r$   r!   r   )rp   rq   Úreadlinerw   r5   ry   rz   )ÚfprP   Ú	define_rxÚundef_rxrŒ   r�   rŽ   r�   r   r   r   r   „  s(    




c              C   s:   t r$tjdkrtjjtdƒ} q,t} ntdƒ} tjj| dƒS )zReturn the path of pyconfig.h.r   ÚPCr(   z
pyconfig.h)r/   r   r7   r   r   r   r   )Úinc_dirr   r   r   r   £  s    
c               C   s   t ttjƒ ƒƒS )z,Return a tuple containing the schemes names.)r;   Úsortedr.   r<   r   r   r   r   r   ¯  s    c               C   s
   t jdƒS )z*Return a tuple containing the paths names.r%   )r.   Zoptionsr   r   r   r   r	   ´  s    Tc             C   s&   t ƒ  |rt| |ƒS ttj| ƒƒS dS )z°Return a mapping containing an install scheme.

    ``scheme`` is the install scheme name. If not provided, it will
    return the default scheme for the current platform.
    N)r3   rR   r=   r.   r:   )r2   rP   Úexpandr   r   r   r
   º  s    
c             C   s   t |||ƒ|  S )z[Return a path corresponding to the scheme.

    ``scheme`` is the install scheme name.
    )r
   )r7   r2   rP   r¹   r   r   r   r   Ç  s    c              G   s¼  t dk�r†i a tt d< tt d< tt d< tt d< td td  t d< tt d	< tt d
< tt d< ytjt d< W n tk
r„   dt d< Y nX t	j
d#kr˜tt ƒ t	j
dkrªtt ƒ tjdkr¾tƒ t d< dt krÐtt d< ntt d ƒt d< toìt	j
dk�r\t}yt	jƒ }W n tk
�r   d}Y nX t	jjt d ƒ �r\||k�r\t	jj|t d ƒ}t	jj|ƒt d< tjdk�r†t	jƒ d }t|jdƒd ƒ}|dk �rÎx:d$D ]2}t | }tjdd|ƒ}tjdd|ƒ}|t |< �q–W n¸dt	jk�rt	jd }x8d%D ]0}t | }tjdd|ƒ}|d | }|t |< �qêW t jddƒ}	tjd |	ƒ}
|
dk	�r†|
j d!ƒ}t	jj!|ƒ�s†x,d&D ]$}t | }tjd"d|ƒ}|t |< �q^W | �r´g }x| D ]}|j"t j|ƒƒ �q–W |S t S dS )'ay  With no arguments, return a dictionary of all configuration
    variables relevant for the current platform.

    On Unix, this means every variable defined in Python's installed Makefile;
    On Windows and Mac OS it's a much smaller set.

    With arguments, return a list of values that result from looking up
    each argument in the configuration variable dictionary.
    NÚprefixÚexec_prefixÚ
py_versionÚpy_version_shortr   r!   Úpy_version_nodotrc   ÚplatbaseÚprojectbaser˜   rj   r   Úos2rM   z2.6ÚuserbaseÚsrcdirr[   r#   r   rm   Ú
BASECFLAGSrl   Ú	PY_CFLAGSrž   z-arch\s+\w+\sú z-isysroot [^ 	]*Z	ARCHFLAGSz-isysroot\s+(\S+)r$   z-isysroot\s+\S+(\s|$))r   rÁ   )rm   rÄ   rl   rÅ   rž   )rm   rÄ   rl   rÅ   rž   )rm   rÄ   rl   rÅ   rž   )#Ú_CONFIG_VARSÚ_PREFIXÚ_EXEC_PREFIXÚ_PY_VERSIONr›   r   r_   r˜   ÚAttributeErrorr   r7   r±   r¥   Úversionre   r   r/   Úgetcwdr   r   Úisabsr   rO   r`   Úunamery   Úsplitrp   r?   rD   r^   r}   r5   ÚexistsÚappend)rV   rc   ÚcwdrÃ   Zkernel_versionZmajor_versionrK   ÚflagsZarchrl   r�   ZsdkÚvalsr7   r   r   r   r   Ï  s†    












c             C   s   t ƒ j| ƒS )z“Return the value of a single variable using the dictionary returned by
    'get_config_vars()'.

    Equivalent to get_config_vars().get(name)
    )r   r^   )r7   r   r   r   r   R  s    c              C   s`  t jdkrnd} tjj| ƒ}|d:kr(tjS tjjd|ƒ}tj|t| ƒ |… jƒ }|dkr\dS |dkrhdS tjS t jd	ks„tt d
ƒ rŠtjS t j	ƒ \}}}}}|jƒ j
ddƒ}|j
ddƒ}|j
ddƒ}|dd… dkràd||f S |dd… dk�r(|d dk�rRd}dt|d ƒd |dd… f }�n*|dd… dk�rFd||f S |dd… dk�rfd|||f S |dd… d k�r¢d }tjd!ƒ}	|	j|ƒ}
|
�rR|
jƒ }�n°|dd… d"k�rRtƒ }|jd#ƒ}|}ytd$ƒ}W n tk
�rê   Y nJX ztjd%|jƒ ƒ}
W d|jƒ  X |
dk	�r4d&j|
jdƒjd&ƒdd… ƒ}|�s>|}|�rR|}d'}|d& d(k�rd)tƒ jd*dƒjƒ k�rd+}tƒ jd*ƒ}tjd,|ƒ}ttt|ƒƒƒ}t|ƒdk�r¶|d }n^|d;k�rÆd+}nN|d<k�rÖd0}n>|d=k�ræd1}n.|d>k�röd3}n|d?k�rd4}ntd5|f ƒ‚n<|d-k�r2tjd@k�rRd/}n |dAk�rRtjdBk�rNd2}nd.}d9|||f S )Ca«  Return a string that identifies the current platform.

    This is used mainly to distinguish platform-specific build directories and
    platform-specific built distributions.  Typically includes the OS name
    and version and the architecture (as supplied by 'os.uname()'),
    although the exact information included depends on the OS; eg. for IRIX
    the architecture isn't particularly important (IRIX only runs on SGI
    hardware), but for Linux the kernel version isn't particularly
    important.

    Examples of returned values:
       linux-i586
       linux-alpha (?)
       solaris-2.6-sun4u
       irix-5.3
       irix64-6.2

    Windows will return one of:
       win-amd64 (64bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc)
       win-ia64 (64bit Windows on Itanium)
       win32 (all others - specifically, sys.platform is returned)

    For other non-POSIX platforms, currently just returns 'sys.platform'.
    r   z bit (r$   ú)Úamd64z	win-amd64Úitaniumzwin-ia64rM   rÏ   ú/rj   rÆ   Ú_ú-Né   Úlinuxz%s-%sÚsunosr   Ú5Úsolarisz%d.%srC   r!   é   ÚirixÚaixz%s-%s.%sé   Úcygwinz[\d.]+r[   ÚMACOSX_DEPLOYMENT_TARGETz0/System/Library/CoreServices/SystemVersion.plistz=<key>ProductUserVisibleVersion</key>\s*<string>(.*?)</string>r#   Zmacosxz10.4.z-archrl   Zfatz-arch\s+(\S+)Úi386ÚppcÚx86_64ZintelZfat3Úppc64Zfat64Z	universalz%Don't know machine value for archs=%ré    ÚPowerPCÚPower_Macintoshz%s-%s-%séÿÿÿÿ)rç   rè   )rç   ré   )rç   rè   ré   )rê   ré   )rç   rè   rê   ré   l        )rì   rí   l        ) r   r7   r_   rÌ   r,   r`   r|   Úlowerrš   rÏ   rx   ry   rp   rq   rw   r5   r   r^   rs   r    r}   ÚreadÚcloser   rÐ   rv   Úfindallr;   r¸   r0   rz   Úmaxsize)rº   ÚiÚjÚlookÚosnameÚhostÚreleaserÌ   ÚmachineÚrel_rer�   ZcfgvarsZmacverZ
macreleaserŠ   ZcflagsZarchsr   r   r   r   [  s¢    
$












c               C   s   t S )N)r›   r   r   r   r   r   ý  s    c             C   sJ   xDt t|jƒ ƒƒD ]0\}\}}|dkr2td|  ƒ td||f ƒ qW d S )Nr   z%s: z
	%s = "%s")Ú	enumerater¸   r:   Úprint)ÚtitleÚdataÚindexrK   rA   r   r   r   Ú_print_dict  s    r  c               C   sR   t dtƒ  ƒ t dtƒ  ƒ t dtƒ  ƒ t ƒ  tdtƒ ƒ t ƒ  tdtƒ ƒ dS )z*Display all information sysconfig detains.zPlatform: "%s"zPython version: "%s"z!Current installation scheme: "%s"ÚPathsÚ	VariablesN)rý   r   r   rT   r  r
   r   r   r   r   r   Ú_main  s    r  Ú__main__iøÿÿÿiöÿÿÿiòÿÿÿ)N)N)AÚ__doc__rr   r   rp   r_   Zos.pathr   r   ZconfigparserÚImportErrorZConfigParserÚ__all__r   r°   r   r¯   r   rÍ   r7   rï   r   r    r/   r)   r3   ZRawConfigParserr.   rq   r>   rB   rÌ   rÐ   rÊ   r›   r®   rO   rº   rÈ   r»   rÉ   rÇ   Ú
_USER_BASErF   rL   rR   rS   rT   re   r–   r   r¥   r±   r   r   r   r	   r
   r   r   r   r   r   r  r  r*   r   r   r   r   Ú<module>   sŒ    "
#	
v
 	 #
