a (Re` @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]\}}}|rJt |qdS)zDMove everything under `src_dir` to `dst_dir`, and delete the former.T)topdownN) oswalkpathrelpathjoinrenamesreversedlist enumerateexistsrmdir) src_dirZdst_dirdirpathdirnames filenamessubdirfsrcdstndr/builddir/build/BUILDROOT/alt-python39-setuptools-58.3.0-2.el8.x86_64/opt/alt/python39/lib/python3.9/site-packages/setuptools/wheel.pyunpacks   r c@sheZdZddZddZddZddZd d Zd d Zd dZ e ddZ e ddZ e ddZ dS)WheelcCsPttj|}|dur$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)rrrtags>s    z Wheel.tagscs0tddtDtfdd|DdS)z5Is the wheel is compatible with the current platform?css|]}|j|j|jfVqdSN) interpreterr3r4.0trrr Hsz&Wheel.is_compatible..c3s|]}|vrdVqdS)TNrr9supported_tagsrrr<JF)setrnextr6r5rr=r is_compatibleFszWheel.is_compatiblecCs,tj|j|j|jdkrdntddS)Nany) project_nameversionr4z.egg) pkg_resources DistributionrDrEr4regg_namer5rrrrHLs zWheel.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_infocCs<t|j}|||Wdn1s.0YdS)z"Install wheel as an egg directory.N)zipfileZipFiler%_install_as_egg)r)destination_eggdirrNrrrinstall_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_inforrrrSas  zWheel._install_as_eggc sVfdd}|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|dWt| n t| 0dS)NcsTt|.}|d}tj|WdS1sF0YdS)Nzutf-8) openrJr readdecodeemailparserParserparsestr)namefpvalue)rZrNrr get_metadatamsz-Wheel._convert_metadata..get_metadataZWHEELz Wheel-Versionz1.0z2.0dev0z$unsupported wheel format version: %s)metadatacSsd|_t|Sr7)markerstr)reqrrrraw_reqsz(Wheel._convert_metadata..raw_reqc s2i|]*}|tfddt|fDqS)c3s|]}|vr|VqdSr7r)r:rk)install_requiresrrr<sz5Wheel._convert_metadata...)sortedmaprequires)r:extra)distrmrlrr sz+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)rrrZrmrlrNrrWksR        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|VqdSr7)r r r )r:rr[rrr<sz+Wheel._move_data_entries..)dataheaderspurelibplatlibN) r r r rrxlistdirrLunlinkr}rfilterr )rTr[Zdist_data_scriptsZegg_info_scriptsentryrrrrrXs*         zWheel._move_data_entriesc Cstj|d}tj|rt|}|}Wdn1sD0Y|D]}tjj|g|dR}tj|d}tj|st|tj|sRt|d}|t WdqR1s0YqRdS)Nznamespace_packages.txtr.z __init__.pyw) r r r rr]r^r2rxwriteNAMESPACE_PACKAGE_INIT)r\rTZnamespace_packagesremodZmod_dirZmod_initrrrrYs  *    zWheel._fix_namespace_packagesN)__name__ __module__ __qualname__r-r6rBrHrPrUrS staticmethodrWrXrYrrrrr!4s   ? r!)__doc__distutils.utilr distutilsrr`r/r rJrerQrFr~rZ setuptools.extern.packaging.tagsrZ!setuptools.extern.packaging.utilsrZsetuptools.command.egg_inforcompileVERBOSEr*r"rr r!rrrrs,