a  ze'@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@seZdZddZdS)_PrefixcCs@||_d|_ttjdkrdnd||ddd|_t||_dS)NFnt posix_prefix)baseplatbase)varsscripts)pathsetuprosnamebin_dirrlib_dirs)selfr!r(Y/opt/bitninja-python-dojo/embedded/lib/python3.9/site-packages/pip/_internal/build_env.py__init__#sz_Prefix.__init__N)__name__ __module__ __qualname__r*r(r(r(r)r!sr)returnc 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_dirstrrr#r!joinsys version_infozipfileZipFilerglobwrite relative_toas_posix)sourcetmp_dirpip_zipkwargszfchildr(r(r)_create_standalone_pip.s   8rLc@sXeZdZdZddZddZddZdd Zd d Ze e d e e e e d dddZ d S)BuildEnvironmentzFCreates and manages an isolated environment to install build deps csttjddtfdddD|_g|_g|_tt|j D] }|j |j |j |j qDddttfD}tjjd|_tj|jst|jttj|jd d ,}|td j||jd Wdn1s0YdS) NT)r/globally_managedc3s&|]}|ttjj|fVqdSN)rr#r!r=.0r$temp_dirr(r) Rsz,BuildEnvironment.__init__..)normaloverlaycSsh|]}tj|qSr()r#r!normcase)rQsiter(r(r) `sz,BuildEnvironment.__init__..rXzsitecustomize.pyr3a 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#r!r= _site_direxistsmkdiropenrCtextwrapdedentformat)r'prefixrZfpr(rRr)r*Ls.    zBuildEnvironment.__init__cCsndddD|_|jdd}|jd}|r>||tj|jg}tjtj |dtj |ddS)NcSsi|]}|tj|dqSrO)r#environgetrPr(r(r) sz.BuildEnvironment.__enter__..)PATHPYTHONNOUSERSITE PYTHONPATHrp1) _save_envr]rcsplitr#pathseprdrmupdater=)r'r!old_path pythonpathr(r(r) __enter__s   zBuildEnvironment.__enter__cCs:|jD]*\}}|dur*tj|dq |tj|<q dSrO)rtitemsr#rmpop)r'exc_typeexc_valexc_tbvarname old_valuer(r(r)__exit__szBuildEnvironment.__exit__c 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'reqsmissing conflictingenvreq_strreqdistinstalled_req_strr(r(r)check_requirementss      z#BuildEnvironment.check_requirementscCs|j|}|jrJd|_|s"dStF}tjdkrDtjt }n | t }| |||||Wdn1sv0YdS)NT)r0) r\r" contextlib ExitStackr>r?r#r!dirnamer8 enter_contextrL_install_requirements)r'finder requirementsprefix_as_stringmessagerkctx pip_runnabler(r(r)install_requirementss      z%BuildEnvironment.install_requirementsrN)rrrrkrr.cCshtj|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> executabler!loggergetEffectiveLevelloggingDEBUGrbgetattrformat_controlrcreplacer=sorted index_urls find_links trusted_hostsallow_all_prereleases prefer_binaryr rr)rrrrkrargsrformatsr extra_indexlinkhostrrr(r(r)rs<             z&BuildEnvironment._install_requirements)r+r,r-__doc__r*rzrrr staticmethodr<rrrr(r(r(r)rMHs6 rMc@s8eZdZdZddZddZddZdd Zd d Zd S) NoOpBuildEnvironmentz5A no-op drop-in replacement for BuildEnvironment cCsdSrOr(r'r(r(r)r* szNoOpBuildEnvironment.__init__cCsdSrOr(rr(r(r)rz szNoOpBuildEnvironment.__enter__cCsdSrOr()r'r}r~rr(r(r)rszNoOpBuildEnvironment.__exit__cCsdSrOr(rr(r(r)cleanupszNoOpBuildEnvironment.cleanupcCs tdSrO)NotImplementedError)r'rrrrr(r(r)rsz)NoOpBuildEnvironment.install_requirementsN) r+r,r-rr*rzrrrr(r(r(r)rs  r)8rrrr#r6r>rhr@ collectionsr sysconfigrtypesrtypingrrrrr r r r pip._vendor.certifir Z"pip._vendor.packaging.requirementsrZpip._vendor.packaging.versionrr5rr8pip._internal.cli.spinnersrpip._internal.locationsrrrpip._internal.metadatarpip._internal.utils.subprocessrpip._internal.utils.temp_dirrr"pip._internal.index.package_finderr getLoggerr+rrcontextmanagerr<rLrMrr(r(r(r)s:   (          >