o ƚ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|}Wdn1swY|d}|d|d|dfS)Nzpyproject.tomlrbz build-systemrequiresz build-backendz backend-path)ioopenospathjoinrget) source_dirfZpyproject_dataZbuildsysr/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-3.el8.x86_64/opt/alt/python310/lib/python3.10/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 ||_dSN)_cleanup)selfcleanuprrr__init__=s zBuildEnvironment.__init__cCstdd|_td|jtjdd|_tjdd|_tj dkr$dnd}t ||j|jdd }|d }|jrD|tj |jtjd<n |tj tj tjd<|d |d kr\|d }n |d tj |d }|jrw|tj |jtjd<|S|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__@s2      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}|rt|j|jdur$tjddn|jtjd<|j dur8tjdddS|j tjd<dS)Nrr) rrr isdirshutilrmtreer*r)popr+)rexc_typeexc_valexc_tbZ needs_cleanuprrr__exit__ns     zBuildEnvironment.__exit__)T) __name__ __module__ __qualname____doc__rrr0r=rErrrrr!s  rc Cz|duri}t|\}}}t|||}t}||||}|||||WdS1s6wYdS)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;rrrrL      $rLc CrJ)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_dirrNr rOrPrQrRr;rrrrUrSrUr)rIr r r8r? subprocessrr5 sysconfigrtempfilercompatrwrappersrr getLoggerrFr'robjectrrLrUrrrrs       a