3 ”Reö ã@s`dZddlmZddlmZddlZddlZddlZddlmZddl Z ddl Z ddl Z ddl Z e j ddkr€dd„Zd d „Znd d„Zd d „ZGd d„deƒZGdd„deƒZGdd„deƒZdd„Zdd„Zdd„Zdd„ZdZdd„Zdd„Zd d!„Zd/d"d#„Zd$d%„ZGd&d'„d'eƒZGd(d)„d)eƒZd*d+„Z ddd#d%d+hZ!d,d-„Z"e#d.k�r\e"ƒdS)0agThis is invoked in a subprocess to call the build backend hooks. It expects: - Command line args: hook_name, control_dir - Environment variables: PEP517_BUILD_BACKEND=entry.point:spec PEP517_BACKEND_PATH=paths (separated with os.pathsep) - control_dir/input.json: - {"kwargs": {...}} Results: - control_dir/output.json - {"return_val": ...} é)Úglob)Ú import_moduleN)Újoinéc Ks.t|ddd��}tj||f|ŽWdQRXdS)NÚwzutf-8)Úencoding)ÚopenÚjsonÚdump)ÚobjÚpathÚkwargsÚf©rú�/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.pyÚ write_json!src Cs$t|ddd�� }tj|ƒSQRXdS)NÚrzutf-8)r)rr Úload)r rrrrÚ read_json%src Ks2t|dƒ�}tj||fddi|—ŽWdQRXdS)NÚwbrzutf-8)rr r )r r r rrrrr+s c Cs t|dƒ� }tj|ƒSQRXdS)NÚrb)rr r)r rrrrr/s c@seZdZdZdd„ZdS)ÚBackendUnavailablez&Raised if we cannot import the backendcCs ||_dS)N)Ú traceback)ÚselfrrrrÚ__init__6szBackendUnavailable.__init__N)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrr4src@seZdZdZdd„ZdS)ÚBackendInvalidz Raised if the backend is invalidcCs ||_dS)N)Úmessage)rr rrrr<szBackendInvalid.__init__N)rrrrrrrrrr:src@seZdZdZdS)Ú HookMissingzARaised if a hook is missing and we are not executing the fallbackN)rrrrrrrrr!@sr!cCs<tjjtjj|ƒƒ}tjjtjj|ƒƒ}tjj||gƒ|kS)z5Test if a file is located within the given directory.)Úosr ÚnormcaseÚabspathÚ commonprefix)ÚfilenameÚ directoryrrrÚ contained_inDsr(c sºtjjdƒ}|r*|jtjƒ}|tjdd…<tjd}|jdƒ\}}}y t|ƒ‰Wn t k rpt t j ƒƒ‚YnX|r”t ‡fdd„|Dƒƒs”tdƒ‚|r¶x|jd ƒD]}tˆ|ƒ‰q¤WˆS) zFind and load the build backendÚPEP517_BACKEND_PATHNrÚPEP517_BUILD_BACKENDú:c3s|]}tˆj|ƒVqdS)N)r(Ú__file__)Ú.0r )r rrú \sz!_build_backend..z(Backend was not loaded from backend-pathÚ.)r"ÚenvironÚgetÚsplitÚpathsepÚsysr Ú partitionrÚ ImportErrorrrÚ format_excÚanyrÚgetattr)Ú backend_pathZextra_pathitemsÚepZmod_pathÚ_Zobj_pathZ path_partr)r rÚ_build_backendKs&      r=c Cs2tƒ}y |j}Wntk r$gSX||ƒSdS)zfInvoke the optional get_requires_for_build_wheel hook Returns [] if the hook is not defined. N)r=Úget_requires_for_build_wheelÚAttributeError)Úconfig_settingsÚbackendÚhookrrrr>gs  r>c CsFtƒ}y |j}Wn&tk r6|s*tƒ‚t|||ƒSX|||ƒSdS)zÈInvoke optional prepare_metadata_for_build_wheel Implements a fallback by building a wheel if the hook isn't defined, unless _allow_fallback is False in which case HookMissing is raised. N)r=Ú prepare_metadata_for_build_wheelr?r!Ú_get_wheel_metadata_from_wheel)Úmetadata_directoryr@Ú_allow_fallbackrArBrrrrCus rCZPEP517_ALREADY_BUILT_WHEELcCsDg}x*|jƒD]}tjd|ƒ}|r|j|ƒqW|r8|Stdƒ‚dS)z6Identify the .dist-info folder inside a wheel ZipFile.z[^/\\]+-[^/\\]+\.dist-info/z#No .dist-info folder found in wheelN)ÚnamelistÚreÚmatchÚappendÚ Exception)Zwhl_zipÚresr ÚmrrrÚ_dist_info_files‹s rNcCs‚ddlm}|j||ƒ}ttjj|tƒdƒ�WdQRXtjj||ƒ}||ƒ�}t|ƒ}|j ||d�WdQRX|dj dƒdS)z�Build a wheel and extract the metadata from it. Fallback for when the build backend does not define the 'get_wheel_metadata' hook. r)ÚZipFilerN)r Úmembersú/) ÚzipfilerOÚ build_wheelrr"r rÚWHEEL_BUILT_MARKERrNÚ extractallr2)rArEr@rOZ whl_basenameZwhl_fileZzipfZ dist_inforrrrD—s    rDcCsl|sdStjj|ƒ}tjjt|tƒƒs*dSttjj|dƒƒ}|sLtdƒdSt |ƒdkrdtdƒdS|dS)zHCheck for a wheel already built during the get_wheel_metadata hook. Nz*.whlz+Found wheel built marker, but no .whl filesézHFound multiple .whl files; unspecified behaviour. Will call build_wheel.r) r"r ÚdirnameÚisfileÚpjoinrTrrÚprintÚlen)rEZmetadata_parentZ whl_filesrrrÚ_find_already_built_wheelªs  r\cCs4t|ƒ}|r$tj||ƒtjj|ƒStƒj|||ƒS)z»Invoke the mandatory build_wheel hook. If a wheel was already built in the prepare_metadata_for_build_wheel fallback, this will copy it rather than rebuilding the wheel. )r\ÚshutilÚcopy2r"r Úbasenamer=rS)Úwheel_directoryr@rEZ prebuilt_whlrrrrSÀs    rSc Cs2tƒ}y |j}Wntk r$gSX||ƒSdS)zfInvoke the optional get_requires_for_build_wheel hook Returns [] if the hook is not defined. N)r=Úget_requires_for_build_sdistr?)r@rArBrrrraÐs  rac@seZdZdZdS)Ú_DummyExceptionz(Nothing should ever raise this exceptionN)rrrrrrrrrbÞsrbc@seZdZdZdd„ZdS)ÚGotUnsupportedOperationz9For internal use when backend raises UnsupportedOperationcCs ||_dS)N)r)rrrrrräsz GotUnsupportedOperation.__init__N)rrrrrrrrrrcâsrccCs@tƒ}y |j||ƒSt|dtƒk r:ttjƒƒ‚YnXdS)z&Invoke the mandatory build_sdist hook.ÚUnsupportedOperationN)r=Ú build_sdistr9rbrcrr7)Úsdist_directoryr@rArrrreès  recCsJttjƒdkrtjdƒtjd}tjd}|tkrBtjd|ƒtƒ|}tt|dƒƒ}dddœ}y|f|d Ž|d <Wn¶tk r®}zd |d <|j |d <WYdd}~Xn„t k rà}zd |d<|j |d<WYdd}~XnRt k �r}zd |d<|j |d <WYdd}~Xnt k �r0d |d<YnXt|t|dƒdd�dS)Nrz"Needs args: hook_name, control_dirrVézUnknown hook: %sz input.jsonF)Ú unsupportedÚ return_valr riTÚ no_backendrÚbackend_invalidÚ backend_errorrhÚ hook_missingz output.json)Úindent)r[r4ÚargvÚexitÚ HOOK_NAMESÚglobalsrrYrrrr rcr!r)Ú hook_nameZ control_dirrBÚ hook_inputZjson_outÚerrrÚmainús.     rvÚ__main__)N)$rrÚ importlibrr r"Úos.pathrrYrHr]r4rÚ version_inforrrKrrr!r(r=r>rCrTrNrDr\rSrarbrcrerqrvrrrrrÚsN