a Re@sddlZddlZddlZddlZddlmZddlmZmZm Z m Z m Z m Z ddl mZddlmZddlmZeeZejeedddd Zejed d d d ZGdd d ZdS)N) TracebackType)DictIteratorOptionalSetTypeUnion)Link)InstallRequirement) TempDirectory)changesreturnc kstj}t}i}|D]<\}}z||||<WntyJ|||<Yn0|||<qzBdVW|D].\}}||ur||=qht|tsJ|||<qhn:|D].\}}||ur||=qt|tsJ|||<q0dSN)osenvironobjectitemsKeyError isinstancestr)r targetnon_existent_marker saved_valuesname new_valueoriginal_valuer/builddir/build/BUILDROOT/alt-python39-pip-21.3.1-2.el8.x86_64/opt/alt/python39/lib/python3.9/site-packages/pip/_internal/req/req_tracker.pyupdate_env_context_managers*   rRequirementTrackerr c cstjd}tt}|durL|tddj}|t|dt d|t |}|VWdn1sp0YWdn1s0YdS)NPIP_REQ_TRACKERz req-tracker)kind)r!z Initialized build tracking at %s) rrget contextlib ExitStack enter_contextr pathrloggerdebugr)rootctxtrackerrrrget_requirement_tracker)s    r-c@seZdZeddddZddddZeeeeeee ddd d Z e ed d d Z e ddddZe ddddZddddZeje eddddZdS)rN)r*r cCs ||_t|_td|jdS)NzCreated build tracker: %s)_rootset_entriesr(r))selfr*rrr__init__7szRequirementTracker.__init__r cCstd|j|S)NzEntered build tracker: %s)r(r)r.)r1rrr __enter__<szRequirementTracker.__enter__)exc_typeexc_valexc_tbr cCs |dSr)cleanup)r1r4r5r6rrr__exit__@szRequirementTracker.__exit__)linkr cCs$t|j}tj|j|Sr) hashlibsha224url_without_fragmentencode hexdigestrr'joinr.)r1r9hashedrrr _entry_pathHszRequirementTracker._entry_path)reqr cCs|js J||j}z4t|}|}Wdn1s>0YWnty\Yn0d|j|}t|||jvsJt|ddd}|t |Wdn1s0Y|j |t d||j dS)z,Add an InstallRequirement to build tracking.Nz{} is already being built: {}wzutf-8)encodingzAdded %s to build tracker %r)r9rAopenreadFileNotFoundErrorformat LookupErrorr0writeraddr(r)r.)r1rB entry_pathfpcontentsmessagerrrrKLs   * , zRequirementTracker.addcCs<|js Jt||j|j|td||jdS)z1Remove an InstallRequirement from build tracking.z Removed %s from build tracker %rN) r9runlinkrAr0remover(r)r.r1rBrrrrQhs  zRequirementTracker.removecCs,t|jD]}||q td|jdS)NzRemoved build tracker: %r)r/r0rQr(r)r.rRrrrr7rs zRequirementTracker.cleanupccs||dV||dSr)rKrQrRrrrtrackxs zRequirementTracker.track)__name__ __module__ __qualname__rr2r3rr BaseExceptionrr8r rAr rKrQr7r$contextmanagerrrSrrrrr6s   )r$r:loggingrtypesrtypingrrrrrrpip._internal.models.linkr Zpip._internal.req.req_installr pip._internal.utils.temp_dirr getLoggerrTr(rXrrr-rrrrrs