U e` @sdZddlmZddlmZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl m Z ddlmZddlmZddlmZe d e jjZd Zd d ZGd ddZdS)zWheels support.) get_platform)logN) parse_version)sys_tags)canonicalize_name)write_requirementsz^(?P.+?)-(?P\d.*?) ((-(?P\d.*?))?-(?P.+?)-(?P.+?)-(?P.+?) )\.whl$z8__import__('pkg_resources').declare_namespace(__name__) c Cst|D]\}}}tj||}|D].}tj||}tj|||}t||q&ttt|D]D\} } tj|| }tj||| }tj |sft|||| =qfq tj|ddD]\}}}|rt t |qdS)zDMove everything under `src_dir` to `dst_dir`, and delete the former.T)topdownN) oswalkpathrelpathjoinrenamesreversedlist enumerateexistsAssertionErrorrmdir) src_dirZdst_dirdirpathdirnames filenamessubdirfsrcdstndr>/opt/hc_python/lib/python3.8/site-packages/setuptools/wheel.pyunpacks   r!c@sheZdZddZddZddZddZd d Zd d Zd dZ e ddZ e ddZ e ddZ dS)WheelcCsPttj|}|dkr$td|||_|D]\}}t|||q6dS)Nzinvalid wheel name: %r) WHEEL_NAMEr r basename ValueErrorfilename groupdictitemssetattr)selfr&matchkvrrr __init__6s  zWheel.__init__cCs&t|jd|jd|jdS)z>List tags (py_version, abi, platform) supported by this wheel..) itertoolsproduct py_versionsplitabiplatformr*rrr tags>s    z Wheel.tagscs0tddtDtfdd|DdS)z5Is the wheel is compatible with the current platform?css|]}|j|j|jfVqdSN) interpreterr4r5.0trrr Hsz&Wheel.is_compatible..c3s|]}|krdVqdS)TNrr:supported_tagsrr r=JsF)setrnextr7r6rr>r is_compatibleFszWheel.is_compatiblecCs,tj|j|j|jdkrdntddS)Nany) project_nameversionr5z.egg) pkg_resources DistributionrDrEr5regg_namer6rrr rHLszWheel.egg_namecCsJ|D]4}t|}|drt|t|jr|SqtddS)Nz .dist-infoz.unsupported wheel format. .dist-info not found)namelist posixpathdirnameendswithr startswithrDr%)r*zfmemberrKrrr get_dist_infoRs    zWheel.get_dist_infoc Cs(t|j}|||W5QRXdS)z"Install wheel as an egg directory.N)zipfileZipFiler&_install_as_egg)r*destination_eggdirrNrrr install_as_egg\szWheel.install_as_eggcCs\d|j|jf}||}d|}tj|d}|||||||||||dS)Nz%s-%sz%s.dataEGG-INFO) rDrErPr r r _convert_metadata_move_data_entries_fix_namespace_packages)r*rTrNZ dist_basename dist_info dist_dataegg_inforrr rSas  zWheel._install_as_eggc sLfdd}|d}t|d}td|ko>tdkn}|sTtd|t||tj|tj j |t |dd d t t tfd d jD}t|ttj|d tj|dtj t|dd} tjj} ttjz t| ddtj|dW5t| XdS)Nc sHt|,}|d}tj|W5QRSQRXdS)Nzutf-8) openrJr readdecodeemailparserParserparsestr)namefpvalue)rZrNrr get_metadatamsz-Wheel._convert_metadata..get_metadataZWHEELz Wheel-Versionz1.0z2.0dev0z$unsupported wheel format version: %s)metadatacSsd|_t|Sr8)markerstr)reqrrr raw_reqsz(Wheel._convert_metadata..raw_reqc s2i|]*}|tfddt|fDqS)c3s|]}|kr|VqdSr8r)r;rk)install_requiresrr r=sz5Wheel._convert_metadata...)sortedmaprequires)r;extra)distrmrlrr s  z+Wheel._convert_metadata..METADATAzPKG-INFO)rmextras_require)attrsr\z requires.txt)rgetr%r mkdir extractallr r rFrG from_location PathMetadatarrnrorpextrasrename setuptoolsdictr _global_log threshold set_thresholdWARNrget_command_obj) rNrTrZr\rgwheel_metadata wheel_versionZwheel_v1ruZ setup_distZ log_thresholdr)rrrZrmrlrNr rWksT        zWheel._convert_metadatacstj|tjd}tj|rtj|dd}t|t|D]D}|drpttj||qLttj||tj||qLt |t tjjfdddDD]}t ||qtjrt dS)z,Move data entries to their correct location.scriptsrVz.pycc3s|]}tj|VqdSr8)r r r )r;rr[rr r=sz+Wheel._move_data_entries..)dataheaderspurelibplatlibN) r r r rrxlistdirrLunlinkr}rfilterr!)rTr[Zdist_data_scriptsZegg_info_scriptsentryrrrr rXs.         zWheel._move_data_entriesc Cstj|d}tj|rt|}|}W5QRX|D]l}tjj|f|d}tj|d}tj|s~t|tj|s>t|d}|t W5QRXq>dS)Nznamespace_packages.txtr/z __init__.pyw) r r r rr]r^r3rxwriteNAMESPACE_PACKAGE_INIT)r\rTnamespace_packagesremodZmod_dirZmod_initrrr rYs      zWheel._fix_namespace_packagesN)__name__ __module__ __qualname__r.r7rBrHrPrUrS staticmethodrWrXrYrrrr r"4s   ? r")__doc__distutils.utilr distutilsrr`r0r rJrerQrFr~rZ setuptools.extern.packaging.tagsrZ!setuptools.extern.packaging.utilsrZsetuptools.command.egg_inforcompileVERBOSEr+r#rr!r"rrrr s,