a c!@sdZddlmZddlmZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl m Z ddlmZddlmZddlmZdd lmZeZe d e jjZd Zd d ZGdddZdS)zWheels support.) get_platform)logN) parse_version)sys_tags)canonicalize_name)PY3)write_requirementsz^(?P.+?)-(?P\d.*?) ((-(?P\d.*?))?-(?P.+?)-(?P.+?)-(?P.+?) )\.whl$ztry: __import__('pkg_resources').declare_namespace(__name__) except ImportError: __path__ = __import__('pkgutil').extend_path(__path__, __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]/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/setuptools/wheel.pyunpack&s   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__>s  zWheel.__init__cCs&t|jd|jd|jdS)z>List tags (py_version, abi, platform) supported by this wheel..) itertoolsproduct py_versionsplitabiplatformr*rrr tagsFs    z Wheel.tagscs0tddtDtfdd|DdS)z5Is the wheel is compatible with the current platform?css|]}|j|j|jfVqdSN) interpreterr4r5.0trrr Pz&Wheel.is_compatible..c3s|]}|vrdVqdS)TNrr:supported_tagsrr r=Qr>F)setrnextr7r6rr?r is_compatibleNszWheel.is_compatiblecCs,tj|j|j|jdkrdntddS)Nany) project_nameversionr5z.egg) pkg_resources DistributionrErFr5regg_namer6rrr rISs zWheel.egg_namecCsJ|D]4}t|}|drt|t|jr|SqtddS)Nz .dist-infoz.unsupported wheel format. .dist-info not found)namelist posixpathdirnameendswithr startswithrEr%)r*zfmemberrLrrr get_dist_infoYs    zWheel.get_dist_infocCs<t|j}|||Wdn1s.0YdS)z"Install wheel as an egg directory.N)zipfileZipFiler&_install_as_egg)r*destination_eggdirrOrrr install_as_eggcszWheel.install_as_eggcCs\d|j|jf}||}d|}tj|d}|||||||||||dS)Nz%s-%sz%s.dataEGG-INFO) rErFrQr r r_convert_metadata_move_data_entries_fix_namespace_packages)r*rUrOZ dist_basename dist_info dist_dataegg_inforrr rThs  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)Ncs`t|:}tr&|dn|}tj |WdS1sR0YdS)Nzutf-8) openrKrrreaddecodeemailparserParserparsestr)namefpvalue)r[rOrr get_metadatatsz-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|]}|vr|VqdSr8r)r;rl)install_requiresrr r=sz5Wheel._convert_metadata...)sortedmaprequires)r;extra)distrnrmrr sz+Wheel._convert_metadata..METADATAzPKG-INFO)rnextras_require)attrsr]z requires.txt)rgetr%r mkdir extractallr rrGrH from_location PathMetadatarrorprqextrasrename setuptoolsdictr _global_log threshold set_thresholdWARNrget_command_obj) rOrUr[r]rhwheel_metadata wheel_versionZwheel_v1rvZ setup_distZ log_thresholdr)rsr[rnrmrOr rXrsR        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.scriptsrWz.pycc3s|]}tj|VqdSr8)r r r)r;rr\rr r=sz+Wheel._move_data_entries..)dataheaderspurelibplatlibN) r r rrrylistdirrMunlinkr~rfilterr!)rUr\Zdist_data_scriptsZegg_info_scriptsentryrrrr rYs*         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 rrr^r_r3rywriteNAMESPACE_PACKAGE_INIT)r]rUZnamespace_packagesrfmodZmod_dirZmod_initrrr rZs  *    zWheel._fix_namespace_packagesN)__name__ __module__ __qualname__r.r7rCrIrQrVrT staticmethodrXrYrZrrrr r"<s   ? r")__doc__distutils.utilr distutilsrrar0r rKrerRrGrrZ setuptools.extern.packaging.tagsrZ!setuptools.extern.packaging.utilsrZsetuptools.extern.sixrZsetuptools.command.egg_infortype __metaclass__compileVERBOSEr+r#rr!r"rrrr s.