o ai @ s d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dl m Z d dlmZm Z mZmZmZmZ d dlmZmZmZ d dlmZ d dlmZ ded efd dZded ed dfddZded efddZededed ee fddZedededdZ e ej!Z!ded efddZ"ded efddZ#deded ee fddZ$ded ee%e&f fd d!Z'ded efd"d#Z(ded ee%e&f fd$d%Z)ded efd&d'Z*dS )( N)contextmanager)NamedTemporaryFile)AnyBinaryIOIteratorListUnioncast)retrystop_after_delay wait_fixed)get_path_uid)format_sizepathreturnc C s t jdks ttdsdS tj| sJ d }| |krNtj| rAt dkr:z t| }W |dkS t y9 Y dS w t | tjS | tj| }} | |ksdS )Nwin32geteuidTr F) sysplatformhasattrosr isabslexistsr r OSErroraccessW_OKdirname)r previouspath_uid r /builddir/build/BUILDROOT/alt-python310-pip-21.3.1-5.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_internal/utils/filesystem.pycheck_path_owner s" r! srcdestc C sh z t | | W dS ty3 | |fD ]}zt|}W n ty% Y qw |r1t d| dq w )zWrap shutil.copy2() but map errors copying socket files to SpecialFileError as expected. See also https://bugs.python.org/issue37700. `z ` is a socketN)shutilcopy2r is_socketSpecialFileError)r" r# fis_socket_filer r r copy2_fixed- s r+ c C s t t| jS N)statS_ISSOCKr lstatst_moder r r r r' D s r' kwargsc k s t ddtj| tj| dd|+}tt|}z|V W | t| n| t| w W d dS 1 sCw Y dS )a% Return a file-like object pointing to a tmp file next to path. The file is created securely and is ensured to be written to disk after the context reaches its end. kwargs will be passed to tempfile.NamedTemporaryFile to control the way the temporary file will be opened. Fz.tmp)deletedirprefixsuffixNr ) r r r r basenamer r flushfsyncfileno)r r2 r) resultr r r adjacent_tmp_fileH s$ "r<