9
9
import os
10
10
import re
11
11
import shutil
12
- import stat
13
12
import struct
14
13
import sys
15
14
import sysconfig
18
17
from email .generator import BytesGenerator , Generator
19
18
from email .policy import EmailPolicy
20
19
from glob import iglob
21
- from shutil import rmtree
22
- from typing import TYPE_CHECKING , Callable , Literal , cast
20
+ from typing import Literal , cast
23
21
from zipfile import ZIP_DEFLATED , ZIP_STORED
24
22
25
23
from packaging import tags , version as _packaging_version
26
24
from wheel .metadata import pkginfo_to_metadata
27
25
from wheel .wheelfile import WheelFile
28
26
29
- from .. import Command , __version__
27
+ from .. import Command , __version__ , _shutil
30
28
from ..warnings import SetuptoolsDeprecationWarning
31
29
from .egg_info import egg_info as egg_info_cls
32
30
33
31
from distutils import log
34
32
35
- if TYPE_CHECKING :
36
- from _typeshed import ExcInfo
37
-
38
33
39
34
def safe_name (name : str ) -> str :
40
35
"""Convert an arbitrary string to a standard distribution name
@@ -148,21 +143,6 @@ def safer_version(version: str) -> str:
148
143
return safe_version (version ).replace ("-" , "_" )
149
144
150
145
151
- def remove_readonly (
152
- func : Callable [..., object ],
153
- path : str ,
154
- excinfo : ExcInfo ,
155
- ) -> None :
156
- remove_readonly_exc (func , path , excinfo [1 ])
157
-
158
-
159
- def remove_readonly_exc (
160
- func : Callable [..., object ], path : str , exc : BaseException
161
- ) -> None :
162
- os .chmod (path , stat .S_IWRITE )
163
- func (path )
164
-
165
-
166
146
class bdist_wheel (Command ):
167
147
description = "create a wheel distribution"
168
148
@@ -458,7 +438,7 @@ def run(self):
458
438
shutil .copytree (self .dist_info_dir , distinfo_dir )
459
439
# Egg info is still generated, so remove it now to avoid it getting
460
440
# copied into the wheel.
461
- shutil .rmtree (self .egginfo_dir )
441
+ _shutil .rmtree (self .egginfo_dir )
462
442
else :
463
443
# Convert the generated egg-info into dist-info.
464
444
self .egg2dist (self .egginfo_dir , distinfo_dir )
@@ -483,10 +463,7 @@ def run(self):
483
463
if not self .keep_temp :
484
464
log .info (f"removing { self .bdist_dir } " )
485
465
if not self .dry_run :
486
- if sys .version_info < (3 , 12 ):
487
- rmtree (self .bdist_dir , onerror = remove_readonly )
488
- else :
489
- rmtree (self .bdist_dir , onexc = remove_readonly_exc )
466
+ _shutil .rmtree (self .bdist_dir )
490
467
491
468
def write_wheelfile (
492
469
self , wheelfile_base : str , generator : str = f"setuptools ({ __version__ } )"
@@ -570,7 +547,7 @@ def egg2dist(self, egginfo_path: str, distinfo_path: str) -> None:
570
547
def adios (p : str ) -> None :
571
548
"""Appropriately delete directory, file or link."""
572
549
if os .path .exists (p ) and not os .path .islink (p ) and os .path .isdir (p ):
573
- shutil .rmtree (p )
550
+ _shutil .rmtree (p )
574
551
elif os .path .exists (p ):
575
552
os .unlink (p )
576
553
0 commit comments