U jaD/@sdZddlZddlZddlZddlZddlmZmZm Z m Z m Z m Z ddl mZmZddlmZmZddlmZddlmZmZddlmZdd lmZdd lmZdd lmZdd l m!Z!dd l"m#Z#ddl$m%Z%ddl&m'Z'm(Z(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/ddl0m1Z1ddl2m3Z3e4e5Z6e7dej8Z9ee#ge:fZ;e e e#e e#fZddZ?ddZ@ddZAd d!ZBd"d#ZCd$d%ZDd&d'ZEd(d)ZFd*d+ZGd,d-ZHdS).z;Orchestrator for building wheels from InstallRequirements. N)AnyCallableIterableListOptionalTuple)canonicalize_namecanonicalize_version)InvalidVersionVersion) WheelCache)InvalidWheelFilenameUnsupportedWheel)get_wheel_distribution)Link)Wheel)build_wheel_pep517)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_.!+-]+)cCstt|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)sr"s/private/var/folders/k6/_7fsz4ts3b78x3b3xwrxjh_c8s8xv7/T/pip-unpacked-wheel-bug3gbve/pip/_internal/wheel_builder.py_contains_egg_info%sr$cCs~|jr dS|jr&|r"td|jdS|r.dS|js:|js>dS|jrHdS||sbtd|jdStsztd|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_wheelloggerinfonameeditable source_dir use_pep517r)req need_wheelcheck_binary_allowedr"r"r# _should_build.s8 r0cCst|dtdS)NTr.r/)r0 _always_true)r-r"r"r#should_build_for_wheel_command^s r3cCst|d|dS)NFr1)r0)r-r/r"r"r# should_build_for_install_commandgs r4cCs|js |jsdS|jrb|jjrb|jr(t|js2tt|jj}|sHt||jj |jr^dSdS|jslt|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) r*r+linkis_vcsAssertionErrorrget_backend_for_schemeschemeis_immutable_rev_checkouturlsplitextr$)r- vcs_backendbaseextr"r"r# _should_cacheqs    r@cCs>t|j}|jst|r.t|r.||j}n ||j}|S)zdReturn the persistent or temporary cache directory where the built wheel need to be stored. )r cache_dirr5r7r@get_path_for_linkget_ephem_path_for_link)r- wheel_cachecache_availablerAr"r"r#_get_cache_dirs     rFcCsdS)NTr")_r"r"r#r2sr2c Cst|jp d}ttj|}t|j|kr>td||jt||}t |j }t |t |j krvtd||j |j }|dkrt dz t|}Wn&tk rd|}t |YnX|tdkrt|j tst d|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 formatrstrversionr metadata_versionrr r isinstance) r- wheel_pathcanonical_namewdistZ dist_verstrZmetadata_version_valuerOmsgr"r"r# _verify_onesD      rVc Csz t|Wn8tk rD}ztd|j|WYdSd}~XYnX|jt||||}W5QRX|r|rzt||Wn<tt fk r}ztd|j|WYdSd}~XYnX|S)zaBuild one wheel. :return: The filename of the built wheel, or None if the build failed. Building wheel for %s failed: %sNz!Built wheel for %s is invalid: %s) rOSErrorr'warningr) build_env_build_one_inside_envrVr r)r- output_dirverify build_optionsglobal_optionserQr"r"r# _build_ones.  rac Cs^tddH}|jst|jrp|js(t|js2t|rDtd|j|rVtd|jt|j|j|j|j d}nt |j|j |j |||j d}|dk r4t j |}t j ||}zNt|\}} t||td|j|| |td||WW5QRStk r2} ztd |j| W5d} ~ XYnX|jsFt||W5QRdSQRXdS) Nwheel)kindz7Ignoring --global-option when building %s using PEP 517z6Ignoring --build-option when building %s using PEP 517)r)backendmetadata_directorytempd)r) setup_py_pathr+r_r^rfz3Created wheel for %s: filename=%s size=%d sha256=%szStored in directory: %srW)rr)r7r,repep517_backendr'rYrrJrrgunpacked_source_directoryrIrKjoinrshutilmover( hexdigest Exception_clean_one_legacy) r-r\r^r_temp_dirrQ wheel_name dest_path wheel_hashlengthr`r"r"r#r[sh         r[cCsZt|j|d}td|jzt||jdWdStk rTtd|jYdSXdS)N)r_zRunning setup.py clean for %s)cwdTz Failed cleaning build dir for %sF) rrgr'r(r)rr+rnerror)r-r_ clean_argsr"r"r#ro&sroc Cs|s ggfStdddd|Dtrgg}}|D]\}t||}t|||||} | rtt| |_|jj |_ |jj st | |q>| |q>W5QRX|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# Iszbuild..zSuccessfully built %s cSsg|] }|jqSr"rxryr"r"r# `szbuild..zFailed to build %scSsg|] }|jqSr"rxryr"r"r#r}es)r'r(rjrrFrarrr5 file_pathlocal_file_pathr&r7append) requirementsrDr]r^r_build_successesbuild_failuresr-rA wheel_filer"r"r#build6sD      r)I__doc__loggingos.pathrIrerktypingrrrrrrpip._vendor.packaging.utilsrr pip._vendor.packaging.versionr r pip._internal.cacher pip._internal.exceptionsr rZpip._internal.metadatarpip._internal.models.linkrpip._internal.models.wheelr$pip._internal.operations.build.wheelr+pip._internal.operations.build.wheel_legacyrZpip._internal.req.req_installrpip._internal.utils.loggingrpip._internal.utils.miscrrr$pip._internal.utils.setuptools_buildrpip._internal.utils.subprocessrpip._internal.utils.temp_dirrpip._internal.utils.urlsrpip._internal.vcsr getLogger__name__r'compile IGNORECASErrZBinaryAllowedPredicateZ BuildResultr$r0r3r4r@rFr2rVrar[rorr"r"r"r#sL                0  ! #;