Re @sddlmZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z ddlmZmZddlmZerddlmZmZmZmZmZmZed d d ZejeZed d ddddZdae ddZ Gddde!Z"da#e ddZ$Gddde!Z%e%Z&Gdd d e!Z'Gddde'Z(dS))absolute_importN)contextmanager) ExitStack) ensure_text)enumrmtree)MYPY_CHECK_RUNNING)AnyDictIteratorOptionalTypeVarUnion_TZbound TempDirectory BUILD_ENVz build-envEPHEM_WHEEL_CACHEzephem-wheel-cache REQ_BUILDz req-buildccs7t'}t|}az dVWd|aXWdQRXdS)N)r_tempdir_manager)stackold_tempdir_managerr/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-5.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/temp_dir.pyglobal_tempdir_manager%s    rc@s:eZdZdZddZddZddZdS) TempDirectoryTypeRegistryz$Manages temp directory behavior cCs i|_dS)N)_should_delete)selfrrr__init__5sz"TempDirectoryTypeRegistry.__init__cCs||j|)r7r6r#r4)rrrr__repr__szTempDirectory.__repr__cCs|S)Nr)rrrr __enter__szTempDirectory.__enter__cCsP|jdk r|j}n!tr6tj|j}nd}|rL|jdS)NT)r1r'r"rcleanup)rexcrtbr1rrr__exit__s zTempDirectory.__exit__cCs;tjjtjddj|}tjd||S)zECreate a temporary directory and store its path in self.path prefixzpip-{}-zCreated temporary directory: %s)osr4realpathtempfilemkdtempr7loggerdebug)rrr4rrrr.s zTempDirectory._createcCs5d|_tjj|jr1tt|jdS)z?Remove the temporary directory created and reset state TN)r0r?r4existsr/rr)rrrrr:s zTempDirectory.cleanup) r#r$r%r&r-rpropertyr4r8r9r=r.r:rr)r6rras    csOeZdZdZdZdfddZeddZdd ZS) AdjacentTempDirectoryaHelper class that creates a temporary directory adjacent to a real one. Attributes: original The original directory to create a temp directory for. path After calling create() or entering, contains the full path to the temporary directory. delete Whether the directory should be deleted when exiting (when used as a contextmanager) z-~.=%0123456789Ncs/|jd|_tt|jd|dS)Nz/\r1)rstriporiginalr,rGr)rrIr1)r6rrrszAdjacentTempDirectory.__init__ccsxstdt|D]\}xStj|j|dD]8}ddj|||d}||kr6|Vq6WqWxett|jD]N}xEtj|j|D].}ddj||}||kr|VqWqWdS)a Generates a series of temporary names. The algorithm replaces the leading characters in the name with ones that are valid filesystem characters, but are not valid package names (for both Python and pip definitions of package). ~N)rangelen itertoolscombinations_with_replacement LEADING_CHARSjoin)clsnamei candidatenew_namerrr_generate_namess  !    z%AdjacentTempDirectory._generate_namescCstjj|j\}}x|j|D]|}tjj||}ytj|Wn:tk r}z|jtj krWYdd}~Xq+Xtjj |}Pq+Wtjj t j ddj |}tjd||S)Nr>zpip-{}-zCreated temporary directory: %s)r?r4splitrIrXrRmkdirOSErrorerrnoEEXISTr@rArBr7rCrD)rrrootrTrVr4exrrrr.s zAdjacentTempDirectory._create) r#r$r%r&rQr classmethodrXr.rr)r6rrGs rG)) __future__rr\rOloggingos.pathr?rA contextlibrpip._vendor.contextlib2rZpip._vendor.sixrpip._internal.utils.miscrrpip._internal.utils.typingrtypingr r r r r rr getLoggerr#rC tempdir_kindsrrobjectrr'r)r*r-rrGrrrrs6     .   i