U o a @s`dZddlmZddlmZddlZddlZddlZddlmZddl Z ddl Z ddl Z ddl Z e j ddkrddZd d Znd dZd d ZGd ddeZGdddeZGdddeZddZddZddZddZdZddZddZd d!Zd/d"d#Zd$d%ZGd&d'd'eZGd(d)d)eZd*d+Z ddd#d%d+hZ!d,d-Z"e#d.kr\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)joinc Ks.t|ddd}tj||f|W5QRXdS)Nwutf-8encodingopenjsondumpobjpathkwargsfr_C:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-6mt8ur68\pip\_vendor\pep517\_in_process.py write_json!src Cs0t|ddd}t|W5QRSQRXdS)Nrrrr r loadrrrrr read_json%src Ks2t|d}tj||fddi|W5QRXdS)Nwbr rr rrrrr+s c Cs,t|d}t|W5QRSQRXdS)Nrbrrrrrr/s c@seZdZdZddZdS)BackendUnavailablez&Raised if we cannot import the backendcCs ||_dSN tracebackselfr rrr__init__6szBackendUnavailable.__init__N__name__ __module__ __qualname____doc__r#rrrrr4src@seZdZdZddZdS)BackendInvalidz Raised if the backend is invalidcCs ||_dSr)message)r"r*rrrr#<szBackendInvalid.__init__Nr$rrrrr):sr)c@seZdZdZdS) HookMissingzARaised if a hook is missing and we are not executing the fallbackNr%r&r'r(rrrrr+@sr+cCs<tjtj|}tjtj|}tj||g|kS)z5Test if a file is located within the given directory.)osrnormcaseabspath commonprefix)filename directoryrrr contained_inDsr3cstjd}|r*|tj}|tjdd<tjd}|d\}}}z t|Wn t k rpt t YnX|rt fdd|Dstd|r|d D]}t|qS) zFind and load the build backendPEP517_BACKEND_PATHNrPEP517_BUILD_BACKEND:c3s|]}tj|VqdSr)r3__file__).0rrrr [sz!_build_backend..z(Backend was not loaded from backend-path.)r-environgetsplitpathsepsysr partitionr ImportErrorrr format_excanyr)getattr) backend_pathZextra_pathitemsepZmod_path_Zobj_pathZ path_partrr9r_build_backendKs&      rIcCs6t}z |j}Wntk r(gYSX||SdSzfInvoke the optional get_requires_for_build_wheel hook Returns [] if the hook is not defined. N)rIget_requires_for_build_wheelAttributeErrorconfig_settingsbackendhookrrrrKgs   rKcCsJt}z |j}Wn*tk r:|s*tt|||YSX|||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)rI prepare_metadata_for_build_wheelrLr+_get_wheel_metadata_from_wheel)metadata_directoryrN_allow_fallbackrOrPrrrrQus  rQZPEP517_ALREADY_BUILT_WHEELcCs@g}|D]}td|}|r ||q |r4|StddS)z6Identify the .dist-info folder inside a wheel ZipFile.z[^/\\]+-[^/\\]+\.dist-info/z#No .dist-info folder found in wheelN)namelistrematchappend Exception)Zwhl_zipresrmrrr_dist_info_filess   r\c Csddlm}|||}ttj|tdW5QRXtj||}||}t|}|j ||dW5QRX|d 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)ZipFiler)rmembers/) zipfiler] build_wheelr r-rrWHEEL_BUILT_MARKERr\ extractallr>)rOrSrNr]Z whl_basenameZwhl_fileZzipfZ dist_inforrrrRs    rRcCsl|sdStj|}tjt|ts*dSttj|d}|sLtddSt |dkrdtddS|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-rdirnameisfilepjoinrbrrprintlen)rSZmetadata_parentZ whl_filesrrr_find_already_built_wheels  rjcCs4t|}|r$t||tj|St|||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. )rjshutilcopy2r-rbasenamerIra)wheel_directoryrNrSZ prebuilt_whlrrrras   racCs6t}z |j}Wntk r(gYSX||SdSrJ)rIget_requires_for_build_sdistrLrMrrrros   roc@seZdZdZdS)_DummyExceptionz(Nothing should ever raise this exceptionNr,rrrrrpsrpc@seZdZdZddZdS)GotUnsupportedOperationz9For internal use when backend raises UnsupportedOperationcCs ||_dSrrr!rrrr#sz GotUnsupportedOperation.__init__Nr$rrrrrqsrqc CsBt}z|||WSt|dtk r<ttYnXdS)z&Invoke the mandatory build_sdist hook.UnsupportedOperationN)rI build_sdistrErprqr rC)sdist_directoryrNrOrrrrss rsc CsJttjdkrtdtjd}tjd}|tkrBtd|t|}tt|d}ddd}z|f|d |d <Wntk r}zd |d <|j |d <W5d}~XYnt k r}zd |d<|j |d<W5d}~XYnRt k r}zd |d<|j |d <W5d}~XYnt k r0d |d<YnXt|t|ddddS)Nrz"Needs args: hook_name, control_dirrdzUnknown hook: %sz input.jsonF) unsupported return_valrrwT no_backendr backend_invalid backend_errorrv hook_missingz output.json)indent)rir@argvexit HOOK_NAMESglobalsrrgrr r)r*rqr+r) hook_nameZ control_dirrP hook_inputZjson_outerrrmains.     r__main__)N)$r(r importlibrr r-os.pathrrgrVrkr@r version_inforrrYrr)r+r3rIrKrQrbr\rRrjrarorprqrsrrr%rrrrsP