3 ”Re™ã@sždZddlZddlZddlmZddlZddlmZddlZddl m Z ddl m Z ddl mZmZejeƒZd d „ZGd d „d eƒZdd d„Zddd„ZdS)zIBuild wheels/sdists by installing build deps to a temporary environment. éN)Útoml)Ú check_call)Ú get_paths)Úmkdtempé)ÚPep517HookCallerÚ LoggerWrapperc CsHttjj|dƒƒ�}tj|ƒ}WdQRX|d}|d|d|jdƒfS)Nzpyproject.tomlz build-systemÚrequiresz build-backendz backend-path)ÚopenÚosÚpathÚjoinrÚloadÚget)Ú source_dirÚfZpyproject_dataZbuildsys©rúŠ/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/pep517/envbuild.pyÚ_load_pyprojects rc@s6eZdZdZdZd dd„Zdd„Zdd „Zd d „ZdS) ÚBuildEnvironmentz‡Context manager to install build deps in a simple temporary environment Based on code I wrote for pip, which is MIT licensed. NTcCs ||_dS)N)Ú_cleanup)ÚselfÚcleanuprrrÚ__init__9szBuildEnvironment.__init__cCsútdd�|_tjd|jƒtjjddƒ|_tjjddƒ|_tj dkrHdnd}t ||j|jdœd �}|d }|jrˆ|tj |jtjd<n|tj tj tjd<|d |d kr¸|d }n|d tj |d }|jrì|tj |jtjd<n |tjd<|S) Nzpep517-build-env-)ÚprefixzTemporary build environment: %sÚPATHÚ PYTHONPATHÚntÚ posix_prefix)ÚbaseÚplatbase)ÚvarsÚscriptsÚpurelibÚplatlib) rr ÚlogÚinfor ÚenvironrÚ save_pathÚsave_pythonpathÚnamerÚpathsepÚdefpath)rZinstall_schemeZ install_dirsr"Úlib_dirsrrrÚ __enter__<s*     zBuildEnvironment.__enter__cCsT|sdStjd|ƒtjddddd|jgt|ƒ}t|tttj ƒtttj ƒd�dS) zAInstall dependencies into this env by calling pip in a subprocessNzCalling pip to install %sz-mÚpipÚinstallz--ignore-installedz--prefix)ÚstdoutÚstderr) r%r&ÚsysÚ executabler ÚlistrrÚloggingÚINFOÚERROR)rÚreqsÚcmdrrrÚ pip_install\s   zBuildEnvironment.pip_installcCs~|jo|jdk otjj|jƒ}|r.tj|jƒ|jdkrHtjjddƒn |jtjd<|j dkrntjjddƒn |j tjd<dS)Nrr) rr r ÚisdirÚshutilÚrmtreer(r'Úpopr))rÚexc_typeÚexc_valÚexc_tbZ needs_cleanuprrrÚ__exit__js     zBuildEnvironment.__exit__)T) Ú__name__Ú __module__Ú __qualname__Ú__doc__r rr.r;rCrrrrrs   rc Csb|dkr i}t|ƒ\}}}t|||ƒ}tƒ�,}|j|ƒ|j|ƒ}|j|ƒ|j||ƒSQRXdS)amBuild a wheel from a source directory using PEP 517 hooks. :param str source_dir: Source directory containing pyproject.toml :param str wheel_dir: Target directory to create wheel in :param dict config_settings: Options to pass to build backend This is a blocking function which will run pip in a subprocess to install build requirements. N)rrrr;Úget_requires_for_build_wheelÚ build_wheel) rÚ wheel_dirÚconfig_settingsr ÚbackendÚ backend_pathÚhooksÚenvr9rrrrI~s     rIc Csb|dkr i}t|ƒ\}}}t|||ƒ}tƒ�,}|j|ƒ|j|ƒ}|j|ƒ|j||ƒSQRXdS)amBuild an sdist from a source directory using PEP 517 hooks. :param str source_dir: Source directory containing pyproject.toml :param str sdist_dir: Target directory to place sdist in :param dict config_settings: Options to pass to build backend This is a blocking function which will run pip in a subprocess to install build requirements. N)rrrr;Úget_requires_for_build_sdistÚ build_sdist) rZ sdist_dirrKr rLrMrNrOr9rrrrQ”s     rQ)N)N)rGr r6Ú pip._vendorrr=Ú subprocessrr3Ú sysconfigrÚtempfilerÚwrappersrrÚ getLoggerrDr%rÚobjectrrIrQrrrrÚs      a