3 f4O @sddlZddlZddlZddlZddlmZejjejZ ejjej Z ejjej Z ejjejZdejkrejjejdZnejjejjejZejdkrejjd+rejjejjeZdd Zeed dZeoejdkoejjd,r ejjejjeZd d ZeZd Zyes*ejZWnek rBYnXddZ d-ddZ!d.ddZ"ddZ#ddZ$ddZ%d/ddZ&ej'dZ(ej'dZ)ej'dZ*d0dd Z+d!d"Z,da-d#d$Z.d%d&Z/d'd(Z0d)d*Z1dS)1N)DistutilsPlatformErrorZ_PYTHON_PROJECT_BASEnt\pcbuild\win32\pcbuild\amd64cCs.x(dD] }tjjtjj|d|rdSqWdS)N Setup.dist Setup.localModulesTF)rr)ospathisfilejoin)dfnr+/usr/lib64/python3.6/distutils/sysconfig.py_is_python_source_dir)s r_homecCstr ttSttS)N) _sys_homer project_baserrrr _python_build2srcCsdtjddS)Nz%d.%d)sys version_inforrrrget_python_versionDsrcCs|dkr|rtpt}tjdkrjtrL|r.tp,tStjjt dd}tjj |Sdt t }tjj|d|Stjdkrtjj|dSt dtjdS)NposixsrcdirZIncludepythonincluderzFI don't know where Python installs its C header files on platform '%s')BASE_EXEC_PREFIX BASE_PREFIXr name python_buildrrr r get_config_varnormpathr build_flagsr) plat_specificprefixZincdirZ python_dirrrrget_python_incLs     r)cCs|dkr&|r|rtpt}n |r"tp$t}tjdkrp|s8|r>d}nd}tjj||dt}|r`|Stjj|dSnrAZccZcxxoptZcflagsZccsharedZldsharedZ shlib_suffixarZar_flagsZnewccZcppr?Zcc_cmdrrrrBs\                         rBcCsDtr,tjdkr"tjjtptd}q6tp(t}n tdd}tjj|dS)NrPCr)r'z pyconfig-64.h)r#r r"r r rrr))inc_dirrrrget_config_h_filenames    rLcCs\trtjjtptdStddd}djtt }t t j drL|dt j j 7}tjj||dS)NMakefilerr)r'r.z config-{}{} _multiarchz-%s)r#r r r rrr/formatrr&hasattrrimplementationrN)Zlib_dirZ config_filerrrget_makefile_filenames  rRc Cs|dkr i}tjd}tjd}xx|j}|s0P|j|}|rz|jdd\}}y t|}Wntk rnYnX|||<q"|j|}|r"d||jd<q"W|S)Nz"#define ([A-Z][A-Za-z0-9_]+) (.*) z&/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/ rrr)recompilereadlinematchgroupint ValueError)fpg define_rxundef_rxlinemnvrrrparse_config_hs(      rbz"([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_]*)}c Csddlm}||ddddd}|dkr*i}i}i}x|j}|dkrFPtj|}|r4|jdd\}} | j} | jdd} d | kr| ||<q4y t| } Wn$t k r| jdd ||<Yq4X| ||<q4Wd} x|rxt |D]} || } t j | pt j | }|r|jd}d }||kr2t||}n||krBd}nx|tjkrZtj|}n`|| kr| jdr| dd| krd}n$d||krd}nt|d|}n d||<}|r| |jd}| d|j} |j| kr| |7} | |7} d |kr| || <nzy t| } Wn"t k r@| j|| <Yn X| || <|| =| jdr| dd| kr| dd} | |kr| || <q|| =qWqW|jx.|jD]"\}} t| tr| j||<qW|j||S)Nr)TextFilersurrogateescape)Zstrip_commentsZ skip_blanksZ join_lineserrorsrz$$r$r5r;r=TFPY_)r5r;r=)Zdistutils.text_filercrU _variable_rxrVrWstripreplacerXrYlist _findvar1_rxsearch _findvar2_rxstrr rErFendstartcloseitems isinstanceupdate)rr[rcrZdonenotdoner^r_r`ratmpvrenamed_variablesr"valuefounditemafterkrrrparse_makefiles                       rcCsZxTtj|ptj|}|rP|j\}}|d||j|jd||d}qPqW|S)Nrr)rmrnrospangetrW)svarsr_Zbegrqrrrexpand_makefile_varss *rc CsVtjjddjtjtjttjddd}t |t t dgd}|j }ia t j|dS)N_PYTHON_SYSCONFIGDATA_NAMEz+_sysconfigdata_{abi}_{platform}_{multiarch}rNr)abir@ multiarchbuild_time_varsr)r rErrOrabiflagsr@getattrrQ __import__globalslocalsrrCrv)r"_temprrrr _init_posixsrcCs~i}tddd|d<tddd|d<tdd|d<tjd|d<d |d <tjd d |d <tjjtjj t j |d<|a dS)Nrr)r'r.LIBDEST BINLIBDEST)r' INCLUDEPY EXT_SUFFIXz.exeEXE.rVERSIONBINDIR) r/r)_impextension_suffixesrrkr r dirnameabspathr executablerC)r[rrr_init_ntsrcGs^tdkr(tjdtj}|r(|niattd<ttd<tjd}|dk rV|td<tjdt}tjdkrtrtj j t }tj j ||}ntj j t }tj j tj j|td<totjdkr t}tj jtd o|tjkr tj j |td}tj j|td<tjdkr(d dl}|jt|rVg}x|D]}|jtj|q8W|StSdS) NZ_init_r( exec_prefixrSOrrr0r)rCrrr r"r-r,rr#r rrRr rr%isabsgetcwdrr@rAcustomize_config_varsappend)argsfuncrrbaserAvalsr"rrrrDs@       rDcCs*|dkrddl}|jdtdtj|S)Nrrz SO is deprecated, use EXT_SUFFIXr)warningswarnDeprecationWarningrDr)r"rrrrr$sr$)rr)rr)rN)rrN)N)N)2rr rSrrerr r%r(r-rr, base_prefixr!base_exec_prefixr rErrrrr"lowerendswithrrrrr#r&rAttributeErrorrr)r/rBrLrRrbrTrirmrorrrCrrrDr$rrrr sX      # +I      mJ