U .eg)@s ddlZddlmZddlZddlmZmZmZddl Z ddl m Z m Z m Z ddlZddlmZddlmZeeeedZed d ZGd d d eZGd ddeZGdddeZGdddeZdddZdddZddZGdddeZGdddej Z!dS)N)contextmanager)dirnameabspathjoin) check_call check_outputSTDOUT)mkdtemp)compatz_in_process.pyc cs"t}z |VW5t|XdSN)r shutilZrmtree)tdr?/usr/lib/python3.8/site-packages/pip/_vendor/pep517/wrappers.pytempdirs rc@seZdZdZddZdS)BackendUnavailablezEWill be raised if the backend cannot be imported in the hook process.cCs ||_dSr  tracebackselfrrrr__init__szBackendUnavailable.__init__N__name__ __module__ __qualname____doc__rrrrrrsrc@seZdZdZddZdS)BackendInvalidz)Will be raised if the backend is invalid.cCs||_||_||_dSr  backend_name backend_pathmessage)rrr r!rrrr szBackendInvalid.__init__Nrrrrrrsrcs eZdZdZfddZZS) HookMissingz Will be raised on missing hooks.cstt||||_dSr )superr"r hook_name)rr$ __class__rrr(szHookMissing.__init__)rrrrr __classcell__rrr%rr"&sr"c@seZdZdZddZdS)UnsupportedOperationzDMay be raised by build_sdist if the backend indicates that it can't.cCs ||_dSr rrrrrr/szUnsupportedOperation.__init__Nrrrrrr(-sr(cCs*tj}|r||t|||ddS)z5The default method of calling the wrapper subprocess.)cwdenvN)osenvironcopyupdatercmdr) extra_environr*rrrdefault_subprocess_runner3s  r2cCs,tj}|r||t|||tddS)zDA method of calling the wrapper subprocess while suppressing output.)r)r*stderrN)r+r,r-r.rrr/rrrquiet_subprocess_runner<s  r4cCsntj|rtdtj|}tjtj||}tj|}tj|}tj||g|krjtd|S)zNormalise 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+pathisabs ValueErrorrnormpathrnormcase commonprefix)Z source_treeZ requestedZ abs_sourceZ abs_requestedZ norm_sourceZnorm_requestedrrrnorm_and_checkEs    r;c@s`eZdZdZdddZeddZdddZdd d Zdd d Z dddZ dddZ ddZ 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|_|_|r2fdd|D}|_|_dS)Ncsg|]}tj|qSr)r; source_dir).0prrr {sz-Pep517HookCaller.__init__..)r2rr= build_backendr _subprocess_runner)rr=rBr runnerrr@rrns  zPep517HookCaller.__init__ccs|j}||_dV||_dS)z\A context manager for temporarily overriding the default subprocess runner. N)rC)rrDprevrrrsubprocess_runnersz"Pep517HookCaller.subprocess_runnercCs|dd|iS)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_wheelconfig_settings _call_hookrrHrrrrGs z-Pep517HookCaller.get_requires_for_build_wheelTcCs|dt|||dS)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_directoryrH_allow_fallbackrJr)rrMrHrNrrrrLs z1Pep517HookCaller.prepare_metadata_for_build_wheelcCs(|dk rt|}|dt|||dS)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_directoryrHrM)rrJ)rrQrHrMrrrrPs zPep517HookCaller.build_wheelcCs|dd|iS)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_sdistrHrIrKrrrrRs z-Pep517HookCaller.get_requires_for_build_sdistcCs|dt||dS)zBuild 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_directoryrHrO)rrTrHrrrrSszPep517HookCaller.build_sdistc Cs@tjddkr|jd}n|j}d|i}|jrbtj|j}tjddkrZ|t}||d<t }d|i}t j |t |ddd|j tjt||g|j|d t t |d }|d rt|d d |drt|d d |drt|j|j|dd d|dr"t||dW5QRSQRXdS)NrASCIIZPEP517_BUILD_BACKENDZPEP517_BACKEND_PATHkwargsz input.json)indent)r)r1z output.jsonZ unsupportedrZ no_backendZbackend_invalidZ backend_errorrZ hook_missingZ return_val)sys version_inforBencoder r+pathseprgetfilesystemencodingrr Z write_jsonpjoinrC executable_in_proc_scriptr=Z read_jsongetr(rrr") rr$rWrBr1r rZ hook_inputdatarrrrJsB      zPep517HookCaller._call_hook)NN)N)NT)NN)N)N) rrrrrrrFrGrLrPrRrSrJrrrrr<]s       r<c@s<eZdZdZddZddZeddZdd Zd d Z d S) LoggerWrapperzd Read messages from a pipe and redirect them to a logger (see python's logging module). cCsHtj|d|_||_||_t\|_|_ t |j|_ | dS)NT) threadingThreadrZdaemonloggerlevelr+pipeZfd_readfd_writefdopenreaderstart)rrgrhrrrrs zLoggerWrapper.__init__cCs|jSr )rjr@rrrfilenoszLoggerWrapper.filenocCs|tjr|ddS|S)N)endswithr+linesep)msgrrrremove_newline!szLoggerWrapper.remove_newlinecCs |jD]}|||qdSr )rl_writers)rlinerrrrun%s zLoggerWrapper.runcCs|j|j|dSr )rglogrh)rr!rrrrt)szLoggerWrapper._writeN) rrrrrrn staticmethodrsrvrtrrrrrd s  rd)NN)NN)"re contextlibrr+Zos.pathrrrr_r subprocessrrrrZZtempfiler rYr __file__rar Exceptionrrr"r(r2r4r;objectr<rfrdrrrrs*     /