3 ”Re*ã @s2ddlZddlmZddlZddlmZmZmZddl Z ddl m Z m Z m Z ddlZddlmZddlmZyddljZdd „ZWn ek r¢ed d „ƒZYnXed d „ƒZGd d„deƒZGdd„deƒZGdd„deƒZGdd„deƒZddd„Zd dd„Zdd„ZGdd„de ƒZ!Gdd„dej"ƒZ#dS)!éN)Úcontextmanager)ÚdirnameÚabspathÚjoin)Ú check_callÚ check_outputÚSTDOUT)Úmkdtempé)ÚcompatcCs tjtdƒS)Nz_in_process.py)Ú resourcesÚpathÚ __package__©rrúŠ/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/pep517/wrappers.pyÚ_in_proc_script_pathsrccsttttƒƒdƒVdS)Nz_in_process.py)ÚpjoinrrÚ__file__rrrrrsc cs"tƒ}z |VWdtj|ƒXdS)N)r ÚshutilÚrmtree)ÚtdrrrÚtempdirs rc@seZdZdZdd„ZdS)ÚBackendUnavailablezEWill be raised if the backend cannot be imported in the hook process.cCs ||_dS)N)Ú traceback)ÚselfrrrrÚ__init__#szBackendUnavailable.__init__N)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrr!src@seZdZdZdd„ZdS)ÚBackendInvalidz)Will be raised if the backend is invalid.cCs||_||_||_dS)N)Ú backend_nameÚ backend_pathÚmessage)rr!r"r#rrrr)szBackendInvalid.__init__N)rrrrrrrrrr 'sr cs eZdZdZ‡fdd„Z‡ZS)Ú HookMissingz Will be raised on missing hooks.cstt|ƒj|ƒ||_dS)N)Úsuperr$rÚ hook_name)rr&)Ú __class__rrr1szHookMissing.__init__)rrrrrÚ __classcell__rr)r'rr$/sr$c@seZdZdZdd„ZdS)ÚUnsupportedOperationzDMay be raised by build_sdist if the backend indicates that it can't.cCs ||_dS)N)r)rrrrrr8szUnsupportedOperation.__init__N)rrrrrrrrrr)6sr)cCs*tjjƒ}|r|j|ƒt|||d�dS)z5The default method of calling the wrapper subprocess.)ÚcwdÚenvN)ÚosÚenvironÚcopyÚupdater)Úcmdr*Ú extra_environr+rrrÚdefault_subprocess_runner<s  r2cCs,tjjƒ}|r|j|ƒt|||td�dS)zDA method of calling the wrapper subprocess while suppressing output.)r*r+ÚstderrN)r,r-r.r/rr)r0r*r1r+rrrÚquiet_subprocess_runnerEs  r4cCsntjj|ƒrtdƒ‚tjj|ƒ}tjjtjj||ƒƒ}tjj|ƒ}tjj|ƒ}tjj||gƒ|krjtdƒ‚|S)zèNormalise and check a backend path. Ensure that the requested backend path is specified as a relative path, and resolves to a location under the given source tree. Return an absolute version of the requested path. zpaths must be relativez paths must be inside source tree) r,r ÚisabsÚ ValueErrorrÚnormpathrÚnormcaseÚ commonprefix)Ú source_treeÚ requestedÚ abs_sourceÚ abs_requestedÚ norm_sourceÚnorm_requestedrrrÚnorm_and_checkNs    r@c@s`eZdZdZddd„Zedd„ƒZddd„Zdd d „Zdd d „Z ddd„Z ddd„Z dd„Z dS)ÚPep517HookCalleraeA wrapper around a source directory to be built with a PEP 517 backend. source_dir : The path to the source directory, containing pyproject.toml. build_backend : The build backend spec, as per PEP 517, from pyproject.toml. backend_path : The backend path, as per PEP 517, from pyproject.toml. runner : A callable that invokes the wrapper subprocess. The 'runner', if provided, must expect the following: cmd : a list of strings representing the command and arguments to execute, as would be passed to e.g. 'subprocess.check_call'. cwd : a string representing the working directory that must be used for the subprocess. Corresponds to the provided source_dir. extra_environ : a dict mapping environment variable names to values which must be set for the subprocess execution. NcsB|dkr t}t|ƒˆ_|ˆ_|r2‡fdd„|Dƒ}|ˆ_|ˆ_dS)Ncsg|]}tˆj|ƒ‘qSr)r@Ú source_dir)Ú.0Úp)rrrú …sz-Pep517HookCaller.__init__..)r2rrBÚ build_backendr"Ú_subprocess_runner)rrBrFr"Úrunnerr)rrrws zPep517HookCaller.__init__c cs$|j}||_z dVWd||_XdS)z\A context manager for temporarily overriding the default subprocess runner. N)rG)rrHÚprevrrrÚsubprocess_runnerŠs  z"Pep517HookCaller.subprocess_runnercCs|jdd|iƒS)aGIdentify packages required for building a wheel Returns a list of dependency specifications, e.g.: ["wheel >= 0.25", "setuptools"] This does not include requirements specified in pyproject.toml. It returns the result of calling the equivalently named hook in a subprocess. Úget_requires_for_build_wheelÚconfig_settings)Ú _call_hook)rrLrrrrK–s z-Pep517HookCaller.get_requires_for_build_wheelTcCs|jdt|ƒ||dœƒS)aqPrepare a *.dist-info folder with metadata for this project. Returns the name of the newly created folder. If the build backend defines a hook with this name, it will be called in a subprocess. If not, the backend will be asked to build a wheel, and the dist-info extracted from that (unless _allow_fallback is False). Ú prepare_metadata_for_build_wheel)Úmetadata_directoryrLÚ_allow_fallback)rMr)rrOrLrPrrrrN¤s z1Pep517HookCaller.prepare_metadata_for_build_wheelcCs(|dk rt|ƒ}|jdt|ƒ||dœƒS)avBuild a wheel from this project. Returns the name of the newly created file. In general, this will call the 'build_wheel' hook in the backend. However, if that was previously called by 'prepare_metadata_for_build_wheel', and the same metadata_directory is used, the previously built wheel will be copied to wheel_directory. NÚ build_wheel)Úwheel_directoryrLrO)rrM)rrRrLrOrrrrQ¶s zPep517HookCaller.build_wheelcCs|jdd|iƒS)a<Identify packages required for building a wheel Returns a list of dependency specifications, e.g.: ["setuptools >= 26"] This does not include requirements specified in pyproject.toml. It returns the result of calling the equivalently named hook in a subprocess. Úget_requires_for_build_sdistrL)rM)rrLrrrrSÊs z-Pep517HookCaller.get_requires_for_build_sdistcCs|jdt|ƒ|dœƒS)z£Build an sdist from this project. Returns the name of the newly created file. This calls the 'build_sdist' backend hook in a subprocess. Ú build_sdist)Úsdist_directoryrL)rMr)rrUrLrrrrTØszPep517HookCaller.build_sdistc CsJtjddkr|jjdƒ}n|j}d|i}|jrbtjj|jƒ}tjddkrZ|jtjƒƒ}||d<t ƒ�Ø}d|i}t j |t |dƒdd�t ƒ�&}|jtjt|ƒ||g|j|d �WdQRXt jt |d ƒƒ} | jd ƒrät| jd d ƒƒ‚| jdƒrþt| jd d ƒƒ‚| jdƒ�r$t|j|j| jdd ƒd�‚| jdƒ�r8t|ƒ‚| dSQRXdS)NréÚASCIIÚPEP517_BUILD_BACKENDÚPEP517_BACKEND_PATHÚkwargsz input.json)Úindent)r*r1z output.jsonÚ unsupportedrÚÚ no_backendÚbackend_invalidÚ backend_error)r!r"r#Ú hook_missingÚ return_val)ÚsysÚ version_inforFÚencoder"r,ÚpathseprÚgetfilesystemencodingrr Ú write_jsonrrrGÚ executableÚstrrBÚ read_jsonÚgetr)rr r$) rr&rZrFr1r"rÚ hook_inputÚscriptÚdatarrrrMäs>    zPep517HookCaller._call_hook)NN)N)NT)NN)N)N) rrrrrrrJrKrNrQrSrTrMrrrrrAfs      rAc@s<eZdZdZdd„Zdd„Zedd„ƒZdd „Zd d „Z d S) Ú LoggerWrapperzd Read messages from a pipe and redirect them to a logger (see python's logging module). cCsHtjj|ƒd|_||_||_tjƒ\|_|_ tj |jƒ|_ |j ƒdS)NT) Ú threadingÚThreadrÚdaemonÚloggerÚlevelr,ÚpipeÚfd_readÚfd_writeÚfdopenÚreaderÚstart)rrtrurrrrs zLoggerWrapper.__init__cCs|jS)N)rx)rrrrÚfileno(szLoggerWrapper.filenocCs|jtjƒr|dd…S|S)Nr éÿÿÿÿ)Úendswithr,Úlinesep)ÚmsgrrrÚremove_newline+szLoggerWrapper.remove_newlinecCs$x|jD]}|j|j|ƒƒqWdS)N)rzÚ_writer�)rÚlinerrrÚrun/s zLoggerWrapper.runcCs|jj|j|ƒdS)N)rtÚlogru)rr#rrrr‚3szLoggerWrapper._writeN) rrrrrr|Ú staticmethodr�r„r‚rrrrrps   rp)NN)NN)$rqÚ contextlibrr,Úos.pathrrrrrÚ subprocessrrrrcÚtempfiler r]r Zimportlib.resourcesr rÚ ImportErrorrÚ Exceptionrr r$r)r2r4r@ÚobjectrArrrprrrrÚs0       0