o
    ªZhLB  ã                   @  sp  U d Z ddlm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mZ ddlmZmZ ddlmZ ddlmZ d	d
lmZmZ ddlmZ ddlmZmZ er]ddlmZ ed Zded< dd„ Z dd„ Z!dd„ Z"d;dd„Z#G dd„ deƒZ$e% &d '¡ ¡Z(ded< d d!„ Z)d"d#„ Z*d;d$d%„Z+d&d'd(œZ,d)d*„ Z-d+d,„ Z.d<d.d/„Z/g d0¢Z0	1	1	2	3d=d>d9d:„Z1dS )?z6setuptools.command.bdist_egg

Build .egg distributionsé    )ÚannotationsN)Úget_pathÚget_python_version)ÚCodeType)ÚTYPE_CHECKINGÚLiteral)ÚCommand)ÚLibraryé   )ÚStrPathTÚensure_directory)Úlog)ÚmkpathÚremove_tree)Ú	TypeAlias)ÚrÚwÚxÚar   Ú_ZipFileModec                   C  s   t dƒS )NÚpurelib)r   © r   r   úS/var/www/html/lang_env/lib/python3.10/site-packages/setuptools/command/bdist_egg.pyÚ_get_purelib   ó   r   c                 C  s2   d| v rt j | ¡d } |  d¡r| d d… } | S )NÚ.r   Úmoduleiúÿÿÿ)ÚosÚpathÚsplitextÚendswith)Úfilenamer   r   r   Ústrip_module#   s
   
r"   c                 c  s8    t  | ¡D ]\}}}| ¡  | ¡  |||fV  qdS )zbDo os.walk in a reproducible way,
    independent of indeterministic filesystem readdir order
    N)r   ÚwalkÚsort)ÚdirÚbaseÚdirsÚfilesr   r   r   Úsorted_walk+   s   €ýr)   ÚreturnÚNonec                 C  sP   t  d¡ ¡ }t|ddd}| ||  ¡ W d   ƒ d S 1 s!w   Y  d S )NaÛ  
        def __bootstrap__():
            global __bootstrap__, __loader__, __file__
            import sys, pkg_resources, importlib.util
            __file__ = pkg_resources.resource_filename(__name__, %r)
            __loader__ = None; del __bootstrap__, __loader__
            spec = importlib.util.spec_from_file_location(__name__,__file__)
            mod = importlib.util.module_from_spec(spec)
            spec.loader.exec_module(mod)
        __bootstrap__()
        r   úutf-8©Úencoding)ÚtextwrapÚdedentÚlstripÚopenÚwrite)ÚresourceÚpyfileZ_stub_templateÚfr   r   r   Ú
write_stub5   s   ÿô"ÿr7   c                   @  s€   e Zd ZdZg d¢Zg d¢Zdd„ Zddd	„Zdd
d„Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zddd„Zddd„Zdd„ ZdS ) Ú	bdist_eggzcreate an "egg" distribution))z
bdist-dir=Úbz1temporary directory for creating the distribution)z
plat-name=Úpzdplatform name to embed in generated filenames (by default uses `pkg_resources.get_build_platform()`))úexclude-source-filesNz+remove all .py files from the generated egg)ú	keep-tempÚkzPkeep the pseudo-installation tree around after creating the distribution archive)z	dist-dir=Údz-directory to put final built distributions in)ú
skip-buildNz2skip rebuilding everything (for testing/debugging))r<   r?   r;   c                 C  s.   d | _ d | _d| _d | _d| _d | _d | _d S )NF)Ú	bdist_dirÚ	plat_nameÚ	keep_tempÚdist_dirÚ
skip_buildÚ
egg_outputÚexclude_source_files©Úselfr   r   r   Úinitialize_options_   s   
zbdist_egg.initialize_optionsr*   r+   c                 C  s¬   |   d¡ }| _|j| _| jd u r|   d¡j}tj |d¡| _| jd u r.ddl	m
} |ƒ | _|  dd¡ | jd u rT|jtƒ | j ¡ oD| jd}tj | j|d ¡| _d S d S )	NÚegg_infoZbdistÚeggr   )Úget_build_platform)rC   rC   )Ú
py_versionÚplatformz.egg)Úget_finalized_commandÚei_cmdrJ   r@   Ú
bdist_baser   r   ÚjoinrA   Úpkg_resourcesrL   Zset_undefined_optionsrE   Z_get_egg_basenamer   ÚdistributionÚhas_ext_modulesrC   )rH   rP   rQ   rL   Úbasenamer   r   r   Úfinalize_optionsh   s    


þùzbdist_egg.finalize_optionsc                 C  sü   | j |  d¡_tj tj tƒ ¡¡}| jj	g }| j_	|D ]D}t
|tƒrZt|ƒdkrZtj |d ¡rZtj |d ¡}tj |¡}||ksL| |tj ¡rZ|t|ƒd d … |d f}| jj	 |¡ qzt d| j ¡ | jddd d W || j_	d S || j_	w )	NÚinstallr
   r   é   zinstalling package data to %sÚinstall_dataF)ÚforceÚroot)r@   rO   Úinstall_libr   r   ÚnormcaseÚrealpathr   rT   Ú
data_filesÚ
isinstanceÚtupleÚlenÚisabsÚ
startswithÚsepÚappendr   ÚinfoÚcall_command)rH   Úsite_packagesÚoldÚitemr_   Ú
normalizedr   r   r   Údo_install_data€   s"   ÿzbdist_egg.do_install_datac                 C  s   | j gS )N)rE   rG   r   r   r   Úget_outputs™   r   zbdist_egg.get_outputsc                 K  sT   t D ]	}| || j¡ q| d| j¡ | d| j¡ | j|fi |¤Ž}|  |¡ |S )z8Invoke reinitialized command `cmdname` with keyword argsrD   Údry_run)ÚINSTALL_DIRECTORY_ATTRSÚ
setdefaultr@   rD   rp   Zreinitialize_commandÚrun_command)rH   ZcmdnameÚkwÚdirnameÚcmdr   r   r   ri   œ   s   
zbdist_egg.call_commandc                 C  s´  |   d¡ t d| j¡ |  d¡}|j}d |_| j ¡ r$| js$|   d¡ | j	ddd}||_|  
¡ \}}g | _g }t|ƒD ]>\}}tj |¡\}	}
tj | jt|	ƒd ¡}| j |¡ t d	|¡ | jsmttj |¡|ƒ | |¡ | tjd
¡||< q=|rƒ| |¡ | jjr‹|  ¡  | j}tj |d¡}|  |¡ | jjr³tj |d¡}t d|¡ | j	d|dd |  |¡ tj |d¡}|rót d|¡ | jsòt|ƒ t|ddd}|  d |¡¡ |  d¡ W d   ƒ n1 síw   Y  ntj !|¡r	t d|¡ | js	t "|¡ t#tj |d¡|  $¡ ƒ tj %tj | j&d¡¡r't 'd¡ | j(r/|  )¡  t*| j+|| j,| j|  -¡ d | j.sIt/| j| jd t0| jdg ƒ dt1ƒ | j+f¡ d S )NrJ   zinstalling library code to %srX   Z
build_clibr]   F)Zwarn_dirú.pyzcreating stub loader for %sú/úEGG-INFOÚscriptszinstalling scripts to %sZinstall_scriptsT)Úinstall_dirZno_epznative_libs.txtz
writing %sÚwtr,   r-   Ú
zremoving %szdepends.txtzxWARNING: 'depends.txt' will not be used by setuptools 0.6!
Use the install_requires/extras_require setup() args instead.)Úverboserp   Úmode©rp   Z
dist_filesr8   )2rs   r   rh   r@   rO   r\   rT   Zhas_c_librariesrD   ri   Úget_ext_outputsÚstubsÚ	enumerater   r   r   rR   r"   rg   rp   r7   rV   Úreplacerf   Úbyte_compiler`   rn   r   rz   Úcopy_metadata_tor   r2   r3   ÚisfileÚunlinkÚwrite_safety_flagÚzip_safeÚexistsrJ   ÚwarnrF   Úzap_pyfilesÚmake_zipfilerE   r~   Ú
gen_headerrB   r   Úgetattrr   )rH   ZinstcmdZold_rootrv   Úall_outputsÚext_outputsZ
to_compiler:   Zext_namer!   Z_extr5   Zarchive_rootrJ   Z
script_dirZnative_libsZ	libs_filer   r   r   Úrun¦   sˆ   






þ€
ÿû
ýzbdist_egg.runc           
   
   C  sÜ   t  d¡ t| jƒD ]a\}}}|D ]Y}tj ||¡}| d¡r*t  d|¡ t 	|¡ | d¡rj|}d}t
 ||¡}tj |tj| d¡d ¡}	t  d|› d	|	› d
¡ zt |	¡ W n	 tyc   Y nw t ||	¡ qq
d S )Nz+Removing .py files from temporary directoryrw   zDeleting %sÚ__pycache__z#(?P<name>.+)\.(?P<magic>[^.]+)\.pycÚnameú.pyczRenaming file from [z] to [ú])r   rh   Úwalk_eggr@   r   r   rR   r    Údebugrˆ   ÚreÚmatchÚpardirÚgroupÚremoveÚOSErrorÚrename)
rH   r&   r'   r(   r•   r   Zpath_oldÚpatternÚmZpath_newr   r   r   r   ú   s,   



ÿ€îÿzbdist_egg.zap_pyfilesc                 C  s2   t | jdd ƒ}|d ur|S t d¡ t| j| jƒS )NrŠ   z4zip_safe flag not set; analyzing archive contents...)r   rT   r   rŒ   Úanalyze_eggr@   r‚   )rH   Úsafer   r   r   rŠ     s
   
zbdist_egg.zip_safeúLiteral['w']c                 C  s   dS )Nr   r   rG   r   r   r   r     s   zbdist_egg.gen_headerc                 C  sh   t j | j¡}t j |d¡}| jjjD ]}| |¡r1t j ||t	|ƒd… ¡}t
|ƒ |  ||¡ qdS )z*Copy metadata (egg info) to the target_dirÚ N)r   r   ÚnormpathrJ   rR   rP   Úfilelistr(   re   rc   r   Ú	copy_file)rH   Ú
target_dirZnorm_egg_infoÚprefixr   Útargetr   r   r   r†     s   
€üzbdist_egg.copy_metadata_toc           	        sè   g }g }| j di‰t| j ƒD ]&\‰ }}| ‡ ‡fdd„|D ƒ¡ |D ]}ˆˆ  | d ˆtj ˆ |¡< q"q| j ¡ rp|  d¡}|j	D ]-}t
|tƒrJqB| |j¡}| |¡}tj |¡ d¡sotj tj | j |¡¡ro| |¡ qB||fS )zAGet a list of relative paths to C extensions in the output distror¦   c                 3  s4    | ]}t j |¡d   ¡ tv rˆˆ  | V  qdS )rY   N)r   r   r   ÚlowerÚNATIVE_EXTENSIONS)Ú.0r!   ©r&   Úpathsr   r   Ú	<genexpr>/  s   € 
þýz,bdist_egg.get_ext_outputs.<locals>.<genexpr>rx   Z	build_extzdl-)r@   r)   Úextendr   r   rR   rT   rU   rO   Ú
extensionsra   r	   Zget_ext_fullnamer•   Zget_ext_filenamerV   re   r‹   rg   )	rH   r‘   r’   r'   r(   r!   Z	build_cmdÚextÚfullnamer   r°   r   r   '  s,   
þ ÿ





€zbdist_egg.get_ext_outputsN©r*   r+   )r*   r¥   )Ú__name__Ú
__module__Ú__qualname__ÚdescriptionZuser_optionsZboolean_optionsrI   rW   rn   ro   ri   r“   r   rŠ   r   r†   r   r   r   r   r   r8   G   s    
	

T

r8   z.dll .so .dylib .pydzdict[str, None]r®   c                 c  sD    t | ƒ}t|ƒ\}}}d|v r| d¡ |||fV  |E dH  dS )z@Walk an unpacked egg's contents, skipping the metadata directoryry   N)r)   Únextrž   )Úegg_dirZwalkerr&   r'   r(   r   r   r   r˜   H  s   €
r˜   c           	      C  sž   t  ¡ D ]\}}tj tj | d|¡¡r|  S qtƒ sdS d}t| ƒD ](\}}}|D ] }| d¡s7| d¡r8q+| d¡sB| d¡rKt	| |||ƒoJ|}q+q$|S )Nry   FTrw   z.pywr–   z.pyo)
Úsafety_flagsÚitemsr   r   r‹   rR   Úcan_scanr˜   r    Úscan_module)	r½   r‚   ÚflagÚfnr¤   r&   r'   r(   r•   r   r   r   r£   R  s    ÿ€ûr£   c              	   C  sœ   t  ¡ D ]G\}}tj | |¡}tj |¡r%|d u st|ƒ|kr$t |¡ q|d urKt|ƒ|krKt|ddd}| 	d¡ W d   ƒ n1 sFw   Y  qd S )Nr|   r,   r-   r}   )
r¾   r¿   r   r   rR   r‹   Úboolrˆ   r2   r3   )r½   r¤   rÂ   rÃ   r6   r   r   r   r‰   d  s   
€ÿ€úr‰   zzip-safeznot-zip-safe)TFc                 C  sð   t j ||¡}|dd… |v rdS |t| ƒd d…  t jd¡}||r%dp&d t j |¡d  }d}t|d	ƒ}| |¡ t	 
|¡}	| ¡  d}
t t|	ƒ¡}d
D ]}||v r_t d||¡ d}
qPd|v rvdD ]}||v rut d||¡ d}
qf|
S )z;Check whether module possibly uses unsafe-for-zipfile stuffNéÿÿÿÿTrY   r   r¦   r   é   Úrb)Ú__file__Ú__path__z%s: module references %sFÚinspect)Ú	getsourceÚ
getabsfileÚgetfileÚgetsourcefileÚgetsourcelinesÚ
findsourceÚgetcommentsÚgetframeinfoÚgetinnerframesÚgetouterframesÚstackÚtracez"%s: module MAY be using inspect.%s)r   r   rR   rc   r„   rf   r   r2   ÚreadÚmarshalÚloadÚcloseÚdictÚfromkeysÚiter_symbolsr   rŒ   )r½   r&   r•   r‚   r!   Úpkgr   Úskipr6   Úcoder¤   ÚsymbolsÚbadr   r   r   rÁ   v  s0    


€€rÁ   c                 c  sH    | j E dH  | jD ]}t|tƒr|V  q
t|tƒr!t|ƒE dH  q
dS )zBYield names and strings used by `code` and its nested code objectsN)Úco_namesÚ	co_constsra   Ústrr   rÝ   )rà   Úconstr   r   r   rÝ   ž  s   €


€ürÝ   rÄ   c                   C  s2   t j d¡st jdkrdS t d¡ t d¡ dS )NÚjavaÚcliTz1Unable to analyze compiled code on this platform.zfPlease ask the author to include a 'zip_safe' setting (either True or False) in the package's setup.pyF)ÚsysrN   re   r   rŒ   r   r   r   r   rÀ   ¨  s   
ÿrÀ   )r]   r{   rZ   Zinstall_baseFTr   Úzip_filenamer   r~   rp   r   c                   s¬   ddl }ttj | ¡ˆd t d| ˆ ¡ ‡ ‡fdd„}|r!|jn|j}ˆsD|j	| ||d}	t
ˆ ƒD ]\}
}}||	|
|ƒ q2|	 ¡  | S t
ˆ ƒD ]\}
}}|d|
|ƒ qH| S )aq  Create a zip file from all the files under 'base_dir'.  The output
    zip file will be named 'base_dir' + ".zip".  Uses either the "zipfile"
    Python module (if available) or the InfoZIP "zip" utility (if installed
    and found on the default search path).  If neither tool is available,
    raises DistutilsExecError.  Returns the name of the output zip file.
    r   Nr€   z#creating '%s' and adding '%s' to itc                   s`   |D ]+}t j t j ||¡¡}t j |¡r-|tˆ ƒd d … }ˆs'|  ||¡ t d|¡ qd S )NrY   zadding '%s')	r   r   r§   rR   r‡   rc   r3   r   r™   )Úzru   Únamesr•   r   r:   ©Úbase_dirrp   r   r   ÚvisitÍ  s   €úzmake_zipfile.<locals>.visit)Úcompression)Úzipfiler   r   r   ru   r   rh   ÚZIP_DEFLATEDÚ
ZIP_STOREDÚZipFiler)   rÚ   )rê   rî   r~   rp   Úcompressr   rñ   rï   rð   rë   ru   r'   r(   r   rí   r   rŽ   º  s   	þrŽ   r·   )r*   rÄ   )FFTr   )
rê   r   r~   rÄ   rp   rÄ   r   r   r*   r   )2Ú__doc__Ú
__future__r   rØ   r   rš   ré   r/   Ú	sysconfigr   r   Útypesr   Útypingr   r   Ú
setuptoolsr   Zsetuptools.extensionr	   Ú_pathr   r   Ú	distutilsr   Zdistutils.dir_utilr   r   Útyping_extensionsr   r   Ú__annotations__r   r"   r)   r7   r8   rÛ   rÜ   Úsplitr®   r˜   r£   r‰   r¾   rÁ   rÝ   rÀ   rq   rŽ   r   r   r   r   Ú<module>   sP    

 

þ(

ú