Re* @sddlZddlmZddlZddlmZmZmZddl Z ddl m Z m Z m Z ddlZddlmZddlmZyddljZdd ZWn$ek red d ZYnXed d ZGd ddeZGdddeZGdddeZGdddeZddddZddddZddZGddde Z!Gdddej"Z#dS)N)contextmanager)dirnameabspathjoin) check_call check_outputSTDOUT)mkdtemp)compatcCstjtdS)Nz_in_process.py) resourcespath __package__rr/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-5.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/pep517/wrappers.py_in_proc_script_pathsrccsttttdVdS)Nz_in_process.py)pjoinrr__file__rrrrrsc cs't}z |VWdtj|XdS)N)r shutilrmtree)tdrrrtempdirs  rc@s"eZdZdZddZdS)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!s rc@s"eZdZdZddZdS)BackendInvalidz)Will be raised if the backend is invalid.cCs||_||_||_dS)N) backend_name backend_pathmessage)rr!r"r#rrrr)s  zBackendInvalid.__init__N)rrrrrrrrrr 's r cs(eZdZdZfddZS) HookMissingz Will be raised on missing hooks.cs#tt|j|||_dS)N)superr$r hook_name)rr&) __class__rrr1szHookMissing.__init__)rrrrrrr)r'rr$/s r$c@s"eZdZdZddZdS)UnsupportedOperationzDMay be raised by build_sdist if the backend indicates that it can't.cCs ||_dS)N)r)rrrrrr8szUnsupportedOperation.__init__N)rrrrrrrrrr(6s r(cCs<tjj}|r"|j|t|d|d|dS)z5The default method of calling the wrapper subprocess.cwdenvN)osenvironcopyupdater)cmdr) extra_environr*rrrdefault_subprocess_runner<s r1cCsBtjj}|r"|j|t|d|d|dtdS)zDA method of calling the wrapper subprocess while suppressing output.r)r*stderrN)r+r,r-r.rr)r/r)r0r*rrrquiet_subprocess_runnerEs r3cCstjj|rtdtjj|}tjjtjj||}tjj|}tjj|}tjj||g|krtd|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+r isabs ValueErrorrnormpathrnormcase commonprefix) source_tree requested abs_source abs_requested norm_sourcenorm_requestedrrrnorm_and_checkNs ! r?c@seZdZdZddddZeddZdddZdd d d Zddd 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. Ncs_|dkrt}t|_|_|rIfdd|D}|_|_dS)Ncs"g|]}tj|qSr)r? source_dir).0p)rrr s z-Pep517HookCaller.__init__..)r1rrA build_backendr"_subprocess_runner)rrArEr"runnerr)rrrws   zPep517HookCaller.__init__c cs,|j}||_z dVWd||_XdS)z\A context manager for temporarily overriding the default subprocess runner. N)rF)rrGprevrrrsubprocess_runners    z"Pep517HookCaller.subprocess_runnercCs|jdd|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_hook)rrKrrrrJs z-Pep517HookCaller.get_requires_for_build_wheelTcCs(|jddt|d|d|iS)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_wheelmetadata_directoryrK_allow_fallback)rLr)rrNrKrOrrrrMs  z1Pep517HookCaller.prepare_metadata_for_build_wheelcCs@|dk rt|}|jddt|d|d|iS)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_directoryrKrN)rrL)rrQrKrNrrrrPs    zPep517HookCaller.build_wheelcCs|jdd|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_sdistrK)rL)rrKrrrrRs z-Pep517HookCaller.get_requires_for_build_sdistcCs"|jddt|d|iS)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_sdistsdist_directoryrK)rLr)rrTrKrrrrSs  zPep517HookCaller.build_sdistc Cstjddkr(|jjd}n |j}d|i}|jrtjj|j}tjddkr|jtj}||d           zPep517HookCaller._call_hook) rrrrrrrIrJrMrPrRrSrLrrrrr@fs   r@c@sXeZdZdZddZddZeddZdd Zd d Z d S) LoggerWrapperzd Read messages from a pipe and redirect them to a logger (see python's logging module). cCsftjj|d|_||_||_tj\|_|_ tj |j|_ |j dS)NT) threadingThreadrdaemonloggerlevelr+pipefd_readfd_writefdopenreaderstart)rrsrtrrrrs   zLoggerWrapper.__init__cCs|jS)N)rw)rrrrfileno(szLoggerWrapper.filenocCs$|jtjr |ddS|S)Nr )endswithr+linesep)msgrrrremove_newline+szLoggerWrapper.remove_newlinecCs.x'|jD]}|j|j|q WdS)N)ry_writer)rlinerrrrun/szLoggerWrapper.runcCs|jj|j|dS)N)rslogrt)rr#rrrr3szLoggerWrapper._writeN) rrrrrr{ staticmethodrrrrrrrros   ro)$rp contextlibrr+os.pathrrrrr subprocessrrrrbtempfiler r\r Zimportlib.resourcesr r ImportErrorr Exceptionrr r$r(r1r3r?objectr@rqrorrrrs.