3 ig/@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/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6ej7e8Z9ej: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_.!+-]+))sreturncCsttj|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%:/tmp/pip-build-88gy_88q/pip/pip/_internal/wheel_builder.py_contains_egg_info&sr')req need_wheelcheck_binary_allowedr!cCs|jr dS|jr&|r"tjd|jdS|r.dS|js8dS|jrF|jS|jrPdS||sjtjd|jdSt stjd|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.) constraintis_wheelloggerinfoname source_direditableZsupports_pyproject_editable use_pep517r)r(r)r*r%r%r& _should_build.s6r3)r(r!cCst|dtdS)NT)r)r*)r3 _always_true)r(r%r%r&should_build_for_wheel_commandcsr5)r(r*r!cCst|d|dS)NF)r)r*)r3)r(r*r%r%r& should_build_for_install_commandisr6cCs|js|j rdS|jrf|jjrf|j s,t|js6ttj|jj}|sLt|j|jj |jrbdSdS|jspt|jj \}}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) r1r0linkZis_vcsAssertionErrorrZget_backend_for_schemeschemeZis_immutable_rev_checkouturlsplitextr')r( vcs_backendbaseextr%r%r& _should_cachers   r?)r( wheel_cacher!cCs>t|j}|jst|r.t|r.|j|j}n |j|j}|S)zdReturn the persistent or temporary cache directory where the built wheel need to be stored. )r" cache_dirr7r8r?Zget_path_for_linkZget_ephem_path_for_link)r(r@Zcache_availablerAr%r%r&_get_cache_dirs     rB)_r!cCsdS)NTr%)rCr%r%r&r4sr4)r( wheel_pathr!c Cst|jp d}ttjj|}t|j|kr>tdj||jtt ||}t |j }t |t |j krztdj||j |j }|dkrtdy t|}Wn&tk rd|}t|YnX|tdkrt|j t rtdj|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(rDcanonical_namewdistZ dist_verstrZmetadata_version_valuerLmsgr%r%r& _verify_ones0     rR)r( output_dirverify build_optionsglobal_optionsr1r!c &Cs|rdnd}y t|Wn2tk rJ}ztjd||j|dSd}~XnX|jt|||||}WdQRX|r|ryt||Wn6tt fk r}ztjd||j|dSd}~XnX|S)zaBuild one wheel. :return: The filename of the built wheel, or None if the build failed. r1wheelzBuilding %s for %s failed: %sNzBuilt %s for %s is invalid: %s) rOSErrorr-warningr/Z build_env_build_one_inside_envrRr r) r(rSrTrUrVr1ZartifacterDr%r%r& _build_ones(  r\)r(rSrUrVr1r!c CsdtddN}|jst|jr|js(t|js2t|rDtjd|j|rVtjd|j|rtt|j|j|j|j d}qt |j|j|j|j d}nt |j|j |j |||j d}|dk rDtj j|}tj j||}y@t|\} } tj||tjd|j|| | jtjd||Stk rB} ztjd |j| WYdd} ~ XnX|jsVt||dSQRXdS) NrW)kindz7Ignoring --global-option when building %s using PEP 517z6Ignoring --build-option when building %s using PEP 517)r/backendmetadata_directorytempd)r/ setup_py_pathr0rVrUr`z3Created wheel for %s: filename=%s size=%d sha256=%szStored in directory: %sz Building wheel for %s failed: %s)rr/r8r2r_Zpep517_backendr-rYrrGrrraZunpacked_source_directoryrFrHjoinrshutilmover. hexdigest Exception_clean_one_legacy) r(rSrUrVr1temp_dirrD wheel_nameZ dest_pathZ wheel_hashlengthr[r%r%r&rZsf               rZ)r(rVr!c CsVt|j|d}tjd|jyt||jddStk rPtjd|jdSXdS)N)rVzRunning setup.py clean for %s)cwdTz Failed cleaning build dir for %sF) rrar-r.r/rr0rferror)r(rV clean_argsr%r%r&rg1srg) requirementsr@rTrUrVr!c Cs|s ggfStjddjdd|Dtgg}}xx|D]p}|jsNtt||}t||||||jon|j } | rt t | |_ |j j |_|j jst|j|q@|j|q@WWdQRX|rtjddjdd |D|rtjd djd 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)N)r/).0r(r%r%r& Rszbuild..NzSuccessfully built %s cSsg|] }|jqSr%)r/)ror(r%r%r& oszbuild..zFailed to build %scSsg|] }|jqSr%)r/)ror(r%r%r&rrts)r-r.rbrr/r8rBr\r1Zpermit_editable_wheelsrrr7 file_pathZlocal_file_pathr,append) rnr@rTrUrVZbuild_successesZbuild_failuresr(rA wheel_filer%r%r&build@s@        rv)M__doc__loggingos.pathrFrercZtypingrrrrrrpip._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.vcsr getLogger__name__r-compile IGNORECASEr#r"ZBinaryAllowedPredicateZ BuildResultrJr'r3r5r6r?rBr4rRr\rZrgrvr%r%r%r&s                2  A