a Re&@sddZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z ddlmZmZmZmZmZmZmZmZddlmZddlmZdd lmZdd lmZdd l m!Z!dd l"m#Z#m$Z$m%Z%dd l&m'Z'ddl(m)Z)ddl*m+Z+m,Z,erddl-m.Z.e/e0Z1GdddZ2ej3ee4dddZ5GdddZ6Gddde6Z7dS)z;Build Environment used for isolation during sdist building N) OrderedDict) get_paths) TracebackType) TYPE_CHECKINGIterableIteratorListOptionalSetTupleType)where) Requirement)Version)__file__) open_spinner) get_platlibget_prefixed_libs get_purelib)get_environment)call_subprocess) TempDirectory tempdir_kinds) PackageFinderc@seZdZeddddZdS)_PrefixN)pathreturncCs@||_d|_ttjdkrdnd||ddd|_t||_dS)NFnt posix_prefix)baseplatbase)varsscripts)rsetuprosnamebin_dirrlib_dirs)selfrr)/builddir/build/BUILDROOT/alt-python39-pip-21.3.1-2.el8.x86_64/opt/alt/python39/lib/python3.9/site-packages/pip/_internal/build_env.py__init__"sz_Prefix.__init__)__name__ __module__ __qualname__strr+r)r)r)r*r!srrc csttj}|s&t|VdStdd}tj |j d}i}t j dkrXd|d<t j|dfi|8}|d D]}||||jqxWdn1s0Ytj |d VWdn1s0YdS) zCreate a "standalone pip" zip file. The zip file's content is identical to the currently-running pip. It will be used to install requirements into the build environment. Nzstandalone-pip)kindz__env_pip__.zip)Fstrict_timestampsw*pip)pathlibPath pip_locationresolveparentis_dirr/rr$rjoinsys version_infozipfileZipFilerglobwrite relative_toas_posix)sourcetmp_dirpip_zipkwargszfchildr)r)r*_create_standalone_pip,s   8rMc@seZdZdZddddZddddZeeeeeee ddd d Z e e e ee e e fee fd d d Zde e e e ddddZee de e ee ddddZdS)BuildEnvironmentzACreates and manages an isolated environment to install build depsNr0csttjddtfdddD|_g|_g|_tt|j D] }|j |j |j |j qDddttfD}tjjd|_tj|jst|jttj|jd d ,}|td j||jd Wdn1s0YdS) NT)r1globally_managedc3s&|]}|ttjj|fVqdSN)rr$rr>.0r%temp_dirr)r* Lsz,BuildEnvironment.__init__..)normaloverlaycSsh|]}tj|qSr))r$rnormcase)rRsiter)r)r* Zsz,BuildEnvironment.__init__..rYzsitecustomize.pyr5a import os, site, sys # First, drop system-sites related paths. original_sys_path = sys.path[:] known_paths = set() for path in {system_sites!r}: site.addsitedir(path, known_paths=known_paths) system_paths = set( os.path.normcase(path) for path in sys.path[len(original_sys_path):] ) original_sys_path = [ path for path in original_sys_path if os.path.normcase(path) not in system_paths ] sys.path = original_sys_path # Second, add lib directories. # ensuring .pth file are processed. for path in {lib_dirs!r}: assert not path in sys.path site.addsitedir(path) ) system_sitesr')rr BUILD_ENVr _prefixes _bin_dirs _lib_dirsreversedlistvaluesappendr&extendr'rrr$rr> _site_direxistsmkdiropenrDtextwrapdedentformat)r(prefixr[fpr)rSr*r+Is.    zBuildEnvironment.__init__cCsndddD|_|jdd}|jd}|r>||tj|jg}tjtj |dtj |ddS)NcSsi|]}|tj|dqSrP)r$environgetrQr)r)r* sz.BuildEnvironment.__enter__..)PATHPYTHONNOUSERSITE PYTHONPATHrq1) _save_envr^rdsplitr$pathseprernupdater>)r(rold_path pythonpathr)r)r* __enter__~s   zBuildEnvironment.__enter__exc_typeexc_valexc_tbrcCs:|jD]*\}}|dur*tj|dq |tj|<q dSrP)ruitemsr$rnpop)r(r}r~rvarname old_valuer)r)r*__exit__szBuildEnvironment.__exit__)reqsrc Cst}t}|rt|j}|D]t}t|}||j}|sF||qt|jt rf|jd|j}n|jd|j}|j|j vr|||fq||fS)zReturn 2 sets: - conflicting requirements: set of (installed, wanted) reqs tuples - missing requirements: set of reqs z==z===) setrr_rget_distributionr%add isinstanceversionr specifier) r(rmissing conflictingenvreq_strreqdistinstalled_req_strr)r)r*check_requirementss      z#BuildEnvironment.check_requirementsrfinder requirementsprefix_as_stringmessagercCs|j|}|jrJd|_|s"dStF}tjdkrDtjt }n | t }| |||||Wdn1sv0YdS)NT)r2) r]r# contextlib ExitStackr?r@r$rdirnamer: enter_contextrM_install_requirements)r(rrrrrlctx pip_runnabler)r)r*install_requirementss      z%BuildEnvironment.install_requirements)rrrrlrrcCshtj|dddd|jdg}ttjkr0|ddD]:}t|j |}| d| d d d t |pdd hfq4|j}|r| d |dg|ddD]} | d| gqn |d|jD]} | d| gq|jD]} | d| gq|jr|d|jr|d|d| |dti} t|} t|| | dWdn1sZ0YdS)Ninstallz--ignore-installedz --no-userz--prefixz--no-warn-script-locationz-v) no_binary only_binaryz--_-,z:none:z-irz--extra-index-urlz --no-indexz --find-linksz--trusted-hostz--prez--prefer-binary_PIP_STANDALONE_CERT)spinner extra_environ)r? executablerloggergetEffectiveLevelloggingDEBUGrcgetattrformat_controlrdreplacer>sorted index_urls find_links trusted_hostsallow_all_prereleases prefer_binaryr rr)rrrrlrargsrformatsr extra_indexlinkhostrrr)r)r*rsJ             z&BuildEnvironment._install_requirements)r,r-r.__doc__r+r{r r BaseExceptionrrrr/r r rr staticmethodrrr)r)r)r*rNFs25    rNc@sxeZdZdZddddZddddZeeeeeee ddd d Z ddd d Z d e e e e ddddZdS)NoOpBuildEnvironmentz0A no-op drop-in replacement for BuildEnvironmentNr0cCsdSrPr)r(r)r)r*r+ szNoOpBuildEnvironment.__init__cCsdSrPr)rr)r)r*r{szNoOpBuildEnvironment.__enter__r|cCsdSrPr))r(r}r~rr)r)r*rszNoOpBuildEnvironment.__exit__cCsdSrPr)rr)r)r*cleanupszNoOpBuildEnvironment.cleanuprrcCs tdSrP)NotImplementedError)r(rrrrr)r)r*rsz)NoOpBuildEnvironment.install_requirements)r,r-r.rr+r{r r rrrrrr/rr)r)r)r*r s  r)8rrrr$r8r?rirA collectionsr sysconfigrtypesrtypingrrrrr r r r pip._vendor.certifir Z"pip._vendor.packaging.requirementsrZpip._vendor.packaging.versionrr7rr:pip._internal.cli.spinnersrpip._internal.locationsrrrpip._internal.metadatarpip._internal.utils.subprocessrpip._internal.utils.temp_dirrr"pip._internal.index.package_finderr getLoggerr,rrcontextmanagerr/rMrNrr)r)r)r*s:   (          E