a [f/@sdZddlZddlZddlZddlZddlmZmZm Z m Z m Z m Z ddl mZmZddlmZmZddlmZddlmZmZddlmZmZdd lmZdd lmZdd lm Z dd l!m"Z"dd l#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*m+Z+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6e7e8Z9e:dej;Ze e e&e e&fZ?e@e=dddZAe&e=e>e=dddZBe&e=dddZCe&e>e=d d!d"ZDe&e e=dd#d$ZEe&ee@d%d&d'ZFee=d(d)d*ZGe&e@dd+d,d-ZHe&e@e=e e@e e@e=e e@d.d/d0ZIe&e@e e@e e@e=e e@d1d2d3ZJe&e e@e=d4d5d6ZKe e&ee=e e@e e@e?d7d8d9ZLdS):z;Orchestrator for building wheels from InstallRequirements. N)AnyCallableIterableListOptionalTuple)canonicalize_namecanonicalize_version)InvalidVersionVersion) WheelCache)InvalidWheelFilenameUnsupportedWheel)FilesystemWheelget_wheel_distribution)Link)Wheel)build_wheel_pep517)build_wheel_editable)build_wheel_legacy)InstallRequirement) indent_log) ensure_dir hash_fileis_wheel_installed)make_setuptools_clean_args)call_subprocess) TempDirectory) path_to_url)vcsz([a-z0-9_.]+)-([a-z0-9_.!+-]+))sreturncCstt|S)zjDetermine whether the string looks like an egg_info. :param s: The string to parse. E.g. foo-2.1 )bool _egg_info_research)r r%?/usr/lib/python3.9/site-packages/pip/_internal/wheel_builder.py_contains_egg_info&sr')req need_wheelcheck_binary_allowedr!cCs|jr dS|jr&|r"td|jdS|r.dS|js8dS|jrF|S|jrPdS||sjtd|jdSt std|jdSdS)zBReturn whether an InstallRequirement should be built into a wheel.Fz(Skipping %s, due to already being wheel.TzCSkipping wheel build for %s, due to binaries being disabled for it.zOUsing legacy 'setup.py install' for %s, since package 'wheel' is not installed.) Z constraintis_wheelloggerinfoname source_direditableZsupports_pyproject_editable use_pep517r)r(r)r*r%r%r& _should_build.s<r2)r(r!cCst|dtdS)NTr)r*)r2 _always_true)r(r%r%r&should_build_for_wheel_commandcsr5)r(r*r!cCst|d|dS)NFr3)r2)r(r*r%r%r& should_build_for_install_commandisr6cCs|js |jsdS|jrb|jjrb|jr(J|js2Jt|jj}|sHJ||jj|jr^dSdS|jslJ|j \}}t |rdSdS)z Return whether a built InstallRequirement can be stored in the persistent wheel cache, assuming the wheel cache is available, and _should_build() has determined a wheel needs to be built. FT) r0r/linkZis_vcsrZget_backend_for_schemeschemeZis_immutable_rev_checkouturlsplitextr')r(Z vcs_backendbaseextr%r%r& _should_cachers    r=)r( wheel_cacher!cCs>t|j}|jsJ|r.t|r.||j}n ||j}|S)zdReturn the persistent or temporary cache directory where the built wheel need to be stored. )r" cache_dirr7r=Zget_path_for_linkZget_ephem_path_for_link)r(r>Zcache_availabler?r%r%r&_get_cache_dirs     r@)_r!cCsdS)NTr%)rAr%r%r&r4sr4)r( wheel_pathr!c Cst|jp d}ttj|}t|j|kr>td||jtt ||}t |j }t |t |j krztd||j |j }|durtdz t|}Wn$tyd|}t|Yn0|tdkrt|j tstd|dS)Nz7Wheel has unexpected file name: expected {!r}, got {!r}zMissing Metadata-VersionzInvalid Metadata-Version: z1.2z6Metadata 1.2 mandates PEP 440 version, but {!r} is not)rr.rospathbasenamer formatrrstrversionr metadata_versionrr r isinstance) r(rBZcanonical_namewZdistZ dist_verstrZmetadata_version_valuerJmsgr%r%r& _verify_ones<    rN)r( output_dirverify build_optionsglobal_optionsr0r!c Cs|rdnd}z t|Wn8tyP}z td||j|WYd}~dSd}~00|j t|||||}Wdn1s~0Y|r|rzt||Wn<tt fy}z td||j|WYd}~dSd}~00|S)zaBuild one wheel. :return: The filename of the built wheel, or None if the build failed. r0wheelzBuilding %s for %s failed: %sNzBuilt %s for %s is invalid: %s) rOSErrorr,warningr.Z build_env_build_one_inside_envrNr r) r(rOrPrQrRr0ZartifacterBr%r%r& _build_ones,   "rX)r(rOrQrRr0r!c Cstddl}|jsJ|jr|js(J|js2J|rDtd|j|rVtd|j|rtt|j|j|j|jd}qt |j|j|j|jd}nt |j|j |j |||jd}|durVt j|}t j||}zPt|\} } t||td|j|| | td||WWdStyT} ztd |j| WYd} ~ n d} ~ 00|jsht||WddS1s0YdS) NrS)kindz7Ignoring --global-option when building %s using PEP 517z6Ignoring --build-option when building %s using PEP 517)r.Zbackendmetadata_directorytempd)r. setup_py_pathr/rRrQr[z3Created wheel for %s: filename=%s size=%d sha256=%szStored in directory: %sz Building wheel for %s failed: %s)rr.r1rZZpep517_backendr,rUrrErrr\Zunpacked_source_directoryrDrFjoinrshutilmover-Z hexdigest Exception_clean_one_legacy) r(rOrQrRr0Ztemp_dirrBZ wheel_nameZ dest_pathZ wheel_hashlengthrWr%r%r&rVst         rV)r(rRr!cCsXt|j|d}td|jzt||jdWdStyRtd|jYdS0dS)N)rRzRunning setup.py clean for %s)cwdTz Failed cleaning build dir for %sF) rr\r,r-r.rr/r`error)r(rRZ clean_argsr%r%r&ra1s ra) requirementsr>rPrQrRr!c Cs|s ggfStdddd|Dtgg}}|D]p}|jsLJt||}t||||||jol|j} | rt t | |_ |j j |_ |j jsJ||q>||q>Wdn1s0Y|rtdddd |D|rtd dd d |D||fS) zBuild wheels. :return: The list of InstallRequirement that succeeded to build and the list of InstallRequirement that failed to build. z*Building wheels for collected packages: %sz, css|] }|jVqdS)Nr..0r(r%r%r& Rzbuild..NzSuccessfully built %s cSsg|] }|jqSr%rfrgr%r%r& orjzbuild..zFailed to build %scSsg|] }|jqSr%rfrgr%r%r&rltrj)r,r-r]rr.r@rXr0Zpermit_editable_wheelsrrr7Z file_pathZlocal_file_pathr+append) rer>rPrQrRZbuild_successesZbuild_failuresr(r?Z wheel_filer%r%r&build@sH        *rn)M__doc__ZloggingZos.pathrDrer^typingrrrrrrZpip._vendor.packaging.utilsrr Zpip._vendor.packaging.versionr r Zpip._internal.cacher Zpip._internal.exceptionsr rZpip._internal.metadatarrZpip._internal.models.linkrZpip._internal.models.wheelrZ$pip._internal.operations.build.wheelrZ-pip._internal.operations.build.wheel_editablerZ+pip._internal.operations.build.wheel_legacyrZpip._internal.req.req_installrZpip._internal.utils.loggingrZpip._internal.utils.miscrrrZ$pip._internal.utils.setuptools_buildrZpip._internal.utils.subprocessrZpip._internal.utils.temp_dirrZpip._internal.utils.urlsrZpip._internal.vcsrZ getLogger__name__r,compile IGNORECASEr#r"ZBinaryAllowedPredicateZ BuildResultrHr'r2r5r6r=r@r4rNrXrVrarnr%r%r%r&s                 6   !  ' G