M3 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 Zdeded dfd Zded efdZededed ee fd Z ed ed ed Z e ej! Z!ded efdZ"ded efdZ#deded ee fdZ$ded ee%e&f fdZ'ded efdZ(ded ee%e&f fdZ)ded efdZ*dS ) N)contextmanager)NamedTemporaryFile)AnyBinaryIOIteratorListUnioncast)retrystop_after_delay wait_fixed)get_path_uid)format_sizepathreturnc t j dk st t d sdS t j | sJ d }| |k rt j | r^t j dk r( t | }n# t $ r Y dS w xY w|dk S t j | t j S | t j | } }| |k dS )Nwin32geteuidTr F) sysplatformhasattrosr isabslexistsr r OSErroraccessW_OKdirname)r previouspath_uids /builddir/build/BUILDROOT/alt-python311-pip-21.3.1-4.el9.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_internal/utils/filesystem.pycheck_path_ownerr" s |wgb)&<&<t 7==H ( 7??4 9z||q !+D11HH ! ! ! 55!1}$yrw///!27??4#8#8dH ( 5s B B&%B&srcdestc t j | | dS # t $ rC | |fD ]<} t | }|rt j d| d -# t $ r Y 9w xY w w xY 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_files r! copy2_fixedr- - s S$ t H HA H!*1 " H 12Fa2F2F2FGGGH s+ A&AA& A!A& A!!A&c X t j t j | j S N)statS_ISSOCKr lstatst_moder s r! r) r) D s =$/000 kwargsc + K t ddt j | t j | dd|5 }t t | } |V | t j | n?# | t j | w xY w ddd dS # 1 swxY w 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)deletedirprefixsuffixN ) r r r r basenamer r flushfsyncfileno)r r6 r+ results r! adjacent_tmp_filerB H s0 GOOD!!w%% & h"" &LLLLLNNNHV]]__%%%% LLNNNHV]]__%%%%%&