a Re@sdZddlZddlZddlZddlZddlmZddlZddlm Z ddl m Z ddl m Z ddlmZmZeeZd d ZGd d d eZdd dZdddZdS)zIBuild wheels/sdists by installing build deps to a temporary environment. N) check_call) get_paths)mkdtemp) toml_load)Pep517HookCaller LoggerWrappercCs^ttj|dd}t|}Wdn1s40Y|d}|d|d|dfS)Nzpyproject.tomlrbz build-systemrequiresz build-backendz backend-path)ioopenospathjoinrget) source_dirfZpyproject_dataZbuildsysr/builddir/build/BUILDROOT/alt-python39-pip-21.3.1-2.el8.x86_64/opt/alt/python39/lib/python3.9/site-packages/pip/_vendor/pep517/envbuild.py_load_pyprojects &rc@s6eZdZdZdZd ddZddZdd Zd d ZdS) BuildEnvironmentzContext 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)selfcleanuprrr__init__=szBuildEnvironment.__init__cCstdd|_td|jtjdd|_tjdd|_tj dkrHdnd}t ||j|jdd }|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: %sPATH PYTHONPATHnt posix_prefix)baseplatbase)varsscriptspurelibplatlib) rrloginfor environr save_pathsave_pythonpathnamerpathsepdefpath)rZinstall_schemeZ install_dirsr#lib_dirsrrr __enter__@s0      zBuildEnvironment.__enter__cCsT|sdStd|tjddddd|jgt|}t|tttj tttj ddS) zAInstall dependencies into this env by calling pip in a subprocessNzCalling pip to install %sz-mpipinstallz--ignore-installedz--prefix)stdoutstderr) r&r'sys executablerlistrrloggingINFOERROR)rreqscmdrrr pip_install`s    zBuildEnvironment.pip_installcCs~|jo|jduotj|j}|r.t|j|jdurHtjddn |jtjd<|j durntjddn |j tjd<dS)Nrr) rrr isdirshutilrmtreer)r(popr*)rexc_typeexc_valexc_tbZ needs_cleanuprrr__exit__ns     zBuildEnvironment.__exit__)T) __name__ __module__ __qualname____doc__rrr/r<rDrrrrr!s   rc Csz|dur i}t|\}}}t|||}t:}||||}|||||WdS1sl0YdS)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_dirconfig_settingsr backend backend_pathhooksenvr:rrrrJs     rJc Csz|dur i}t|\}}}t|||}t:}||||}|||||WdS1sl0YdS)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_dirrLr rMrNrOrPr:rrrrRs     rR)N)N)rHr r r7r> subprocessrr4 sysconfigrtempfilercompatrwrappersrr getLoggerrEr&robjectrrJrRrrrrs     a