a Reu4@s ddlZddlmZddlZddlmZmZddlZddl m Z m Z m Z ddl Z ddlmZddlmZddlmZgd Zed d ZGd d d eZGdddeZGdddeZGdddeZdddZdddZddZGdddeZGdddej Z!dS) N)contextmanager)abspathjoin) check_call check_outputSTDOUT)mkdtemp)compat)_in_proc_script_path)BackendUnavailableBackendInvalid HookMissingUnsupportedOperationdefault_subprocess_runnerquiet_subprocess_runnerPep517HookCallerc cs,t}z|VWt|n t|0dSN)rshutilrmtree)tdr/builddir/build/BUILDROOT/alt-python39-pip-21.3.1-2.el8.x86_64/opt/alt/python39/lib/python3.9/site-packages/pip/_vendor/pep517/wrappers.pytempdirsrc@seZdZdZddZdS)r zEWill be raised if the backend cannot be imported in the hook process.cCs ||_dSr tracebackselfrrrr__init__#szBackendUnavailable.__init__N__name__ __module__ __qualname____doc__rrrrrr !sr c@seZdZdZddZdS)r z)Will be raised if the backend is invalid.cCs||_||_||_dSr backend_name backend_pathmessage)rr%r&r'rrrr)szBackendInvalid.__init__Nrrrrrr 'sr cs eZdZdZfddZZS)rz Will be raised on missing hooks.cstt||||_dSr)superrr hook_name)rr) __class__rrr1szHookMissing.__init__)r r!r"r#r __classcell__rrr*rr/src@seZdZdZddZdS)rzDMay be raised by build_sdist if the backend indicates that it can't.cCs ||_dSrrrrrrr8szUnsupportedOperation.__init__Nrrrrrr6srcCs*tj}|r||t|||ddS)z5The default method of calling the wrapper subprocess.)cwdenvN)osenvironcopyupdatercmdr- extra_environr.rrrr<s  rcCs,tj}|r||t|||tddS)zDA method of calling the wrapper subprocess while suppressing output.)r-r.stderrN)r/r0r1r2rrr3rrrrEs  rcCsntj|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) source_tree requested abs_source abs_requested norm_sourcenorm_requestedrrrnorm_and_checkNs    rCc@seZdZdZdddZeddZddZdd d Zdd d Z dddZ d ddZ d!ddZ d"ddZ d#ddZd$ddZddZdS)%raA wrapper around a source directory to be built with a PEP 517 backend. :param source_dir: The path to the source directory, containing pyproject.toml. :param build_backend: The build backend spec, as per PEP 517, from pyproject.toml. :param backend_path: The backend path, as per PEP 517, from pyproject.toml. :param runner: A callable that invokes the wrapper subprocess. :param python_executable: The Python executable used to invoke the backend 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. NcsR|dur t}t|_|_|r2fdd|D}|_|_|sHtj}|_dS)Ncsg|]}tj|qSr)rC source_dir).0prrr sz-Pep517HookCaller.__init__..) rrrD build_backendr&_subprocess_runnersys executablepython_executable)rrDrIr&runnerrMrrGrrzs  zPep517HookCaller.__init__ccs*|j}||_zdVW||_n||_0dS)z\A context manager for temporarily overriding the default subprocess runner. N)rJ)rrNprevrrrsubprocess_runners z"Pep517HookCaller.subprocess_runnercCs |diS)z>Return the list of optional features supported by the backend._supported_features _call_hookrGrrrrQsz$Pep517HookCaller._supported_featurescCs|dd|iS)aIIdentify 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_settingsrRrrUrrrrTs z-Pep517HookCaller.get_requires_for_build_wheelTcCs|dt|||dS)auPrepare 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_wheelmetadata_directoryrU_allow_fallbackrSrrrYrUrZrrrrWs z1Pep517HookCaller.prepare_metadata_for_build_wheelcCs(|durt|}|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_wheelwheel_directoryrUrYrrSrr_rUrYrrrr]s zPep517HookCaller.build_wheelcCs|dd|iS)aSIdentify packages required for building an editable 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_editablerUrRrVrrrrbs z0Pep517HookCaller.get_requires_for_build_editablecCs|dt|||dS)aPrepare 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 an editable wheel, and the dist-info extracted from that (unless _allow_fallback is False). #prepare_metadata_for_build_editablerXr[r\rrrrcs z4Pep517HookCaller.prepare_metadata_for_build_editablecCs(|durt|}|dt|||dS)aBuild an editable wheel from this project. Returns the name of the newly created file. In general, this will call the 'build_editable' hook in the backend. However, if that was previously called by 'prepare_metadata_for_build_editable', and the same metadata_directory is used, the previously built wheel will be copied to wheel_directory. Nbuild_editabler^r`rarrrrds zPep517HookCaller.build_editablecCs|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_sdistrUrRrVrrrre s 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_directoryrUr[)rrgrUrrrrfszPep517HookCaller.build_sdistc Cstjddkr|jd}n|j}d|i}|jrbtj|j}tjddkrZ|t}||d<t }d|i}t j |t |dddt 8}|j} |j| tt|||g|j|d Wdn1s0Yt t |d } | d rt| d d | dr t| d d | drFt|j|j| dd d| drft| dpb|| dWdS1s0YdS)NrASCIIPEP517_BUILD_BACKENDPEP517_BACKEND_PATHkwargsz input.json)indent)r-r5z output.json unsupportedr no_backendbackend_invalid backend_errorr$ hook_missingmissing_hook_name return_val)rK version_inforIencoder&r/pathseprgetfilesystemencodingrr write_jsonpjoinr rMrJrstrrD read_jsongetrr r r) rr)rlrIr5r&r hook_inputscriptpythondatarrrrS&sF $     zPep517HookCaller._call_hook)NNN)N)NT)NN)N)NT)NN)N)N)r r!r"r#rrrPrQrTrWr]rbrcrdrerfrSrrrrrfs2          rc@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) threadingThreadrdaemonloggerlevelr/pipefd_readfd_writefdopenreaderstart)rrrrrrr^s zLoggerWrapper.__init__cCs|jSr)rrGrrrfilenokszLoggerWrapper.filenocCs|tjr|ddS|S)N)endswithr/linesep)msgrrrremove_newlinenszLoggerWrapper.remove_newlinecCs |jD]}|||qdSr)r_writer)rlinerrrrunrs zLoggerWrapper.runcCs|j|j|dSr)rlogr)rr'rrrrvszLoggerWrapper._writeN) r r!r"r#rr staticmethodrrrrrrrrXs  r)NN)NN)"r contextlibrr/os.pathrrr{r subprocessrrrrKtempfilerror in_processr __all__r Exceptionr r rrrrrCobjectrrrrrrrs,       s