Re @sdZddlmZddlmZddlZddlZddlZddlmZddl Z ddl Z ddl Z ddl Z e j ddkrddZd d Znd dZd d ZGd ddeZGdddeZGdddeZddZddZddZddZdZddZddZd d!Zdd"d#Zd$d%ZGd&d'd'eZGd(d)d)eZd*d+Z ddd#d%d+hZ!d,d-Z"e#d.kre"dS)/agThis 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)joinc Ks6t|ddd}tj|||WdQRXdS)Nwencodingzutf-8)openjsondump)objpathkwargsfr/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-5.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/pep517/_in_process.py write_json!src Cs0t|ddd}tj|SWdQRXdS)Nrrzutf-8)rr load)r rrrr read_json%src Ks6t|d }tj||dd|WdQRXdS)Nwbrzutf-8)rr r )r r r rrrrr+sc Cs*t|d}tj|SWdQRXdS)Nrb)rr r)r rrrrr/sc@s"eZdZdZddZdS)BackendUnavailablez&Raised if we cannot import the backendcCs ||_dS)N) traceback)selfrrrr__init__6szBackendUnavailable.__init__N)__name__ __module__ __qualname____doc__rrrrrr4s rc@s"eZdZdZddZdS)BackendInvalidz Raised if the backend is invalidcCs ||_dS)N)message)rr rrrr<szBackendInvalid.__init__N)rrrrrrrrrr:s rc@seZdZdZdS) HookMissingzARaised if a hook is missing and we are not executing the fallbackN)rrrrrrrrr!@s r!cCsXtjjtjj|}tjjtjj|}tjj||g|kS)z5Test if a file is located within the given directory.)osr normcaseabspath commonprefix)filename directoryrrr contained_inDsr(c stjjd}|r=|jtj}|tjdd\sz!_build_backend..z(Backend was not loaded from backend-path.)r"environgetsplitpathsepsysr partitionr ImportErrorrr format_excanyrgetattr) backend_pathZextra_pathitemsepZmod_path_Zobj_pathZ path_partr)r r_build_backendKs&    r=c Cs=t}y |j}Wntk r.gSYn X||SdS)zfInvoke the optional get_requires_for_build_wheel hook Returns [] if the hook is not defined. N)r=get_requires_for_build_wheelAttributeError)config_settingsbackendhookrrrr>gs     r>c Cs[t}y |j}Wn1tk rI|s5tt|||SYnX|||SdS)zInvoke 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_WHEELcCs\g}x9|jD]+}tjd|}|r|j|qW|rL|StddS)z6Identify the .dist-info folder inside a wheel ZipFile.z[^/\\]+-[^/\\]+\.dist-info/z#No .dist-info folder found in wheelN)namelistrematchappend Exception)Zwhl_zipresr mrrr_dist_info_filessrNcCsddlm}|j||}ttjj|tdWdQRXtjj||}||)}t|}|j d|d|WdQRX|dj ddS)zBuild a wheel and extract the metadata from it. Fallback for when the build backend does not define the 'get_wheel_metadata' hook. r)ZipFilerNr members/) zipfilerO build_wheelrr"r rWHEEL_BUILT_MARKERrN extractallr2)rArEr@rOZ whl_basenameZwhl_fileZzipfZ dist_inforrrrDs rDcCs|s dStjj|}tjjt|ts;dSttjj|d}|sjtddSt |dkrtddS|dS)zHCheck for a wheel already built during the get_wheel_metadata hook. Nz*.whlz+Found wheel built marker, but no .whl fileszHFound multiple .whl files; unspecified behaviour. Will call build_wheel.r) r"r dirnameisfilepjoinrTrrprintlen)rEZmetadata_parentZ whl_filesrrr_find_already_built_wheels  r\cCsHt|}|r2tj||tjj|Stj|||S)zInvoke 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\shutilcopy2r"r basenamer=rS)wheel_directoryr@rEZ prebuilt_whlrrrrSs  rSc Cs=t}y |j}Wntk r.gSYn X||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@rArBrrrras     rac@seZdZdZdS)_DummyExceptionz(Nothing should ever raise this exceptionN)rrrrrrrrrbs rbc@s"eZdZdZddZdS)GotUnsupportedOperationz9For internal use when backend raises UnsupportedOperationcCs ||_dS)N)r)rrrrrrsz GotUnsupportedOperation.__init__N)rrrrrrrrrrcs rccCsTt}y|j||SWn0t|dtk rOttjYnXdS)z&Invoke the mandatory build_sdist hook.UnsupportedOperationN)r= build_sdistr9rbrcrr7)sdist_directoryr@rArrrres  recCsttjdkr"tjdtjd}tjd}|tkrYtjd|t|}tt|d}ddd di}y||d |d rCrTrNrDr\rSrarbrcrerqrvrrrrrsN