|
34 | 34 | from collections.abc import Iterable
|
35 | 35 | from glob import glob
|
36 | 36 | from sysconfig import get_path
|
37 |
| -from typing import TYPE_CHECKING, Callable, NoReturn, TypedDict, TypeVar |
| 37 | +from typing import TYPE_CHECKING, NoReturn, TypedDict |
38 | 38 |
|
39 | 39 | from jaraco.text import yield_lines
|
40 | 40 |
|
|
63 | 63 | from setuptools.wheel import Wheel
|
64 | 64 |
|
65 | 65 | from .._path import ensure_directory
|
66 |
| -from ..compat import py39, py311, py312 |
| 66 | +from .._shutil import attempt_chmod_verbose as chmod, rmtree as _rmtree |
| 67 | +from ..compat import py39, py312 |
67 | 68 |
|
68 | 69 | from distutils import dir_util, log
|
69 | 70 | from distutils.command import install
|
|
89 | 90 | 'get_exe_prefixes',
|
90 | 91 | ]
|
91 | 92 |
|
92 |
| -_T = TypeVar("_T") |
93 |
| - |
94 | 93 |
|
95 | 94 | def is_64bit():
|
96 | 95 | return struct.calcsize("P") == 8
|
@@ -1789,16 +1788,6 @@ def _first_line_re():
|
1789 | 1788 | return re.compile(first_line_re.pattern.decode())
|
1790 | 1789 |
|
1791 | 1790 |
|
1792 |
| -# Must match shutil._OnExcCallback |
1793 |
| -def auto_chmod(func: Callable[..., _T], arg: str, exc: BaseException) -> _T: |
1794 |
| - """shutils onexc callback to automatically call chmod for certain functions.""" |
1795 |
| - # Only retry for scenarios known to have an issue |
1796 |
| - if func in [os.unlink, os.remove] and os.name == 'nt': |
1797 |
| - chmod(arg, stat.S_IWRITE) |
1798 |
| - return func(arg) |
1799 |
| - raise exc |
1800 |
| - |
1801 |
| - |
1802 | 1791 | def update_dist_caches(dist_path, fix_zipimporter_caches):
|
1803 | 1792 | """
|
1804 | 1793 | Fix any globally cached `dist_path` related data
|
@@ -2021,24 +2010,6 @@ def is_python_script(script_text, filename):
|
2021 | 2010 | return False # Not any Python I can recognize
|
2022 | 2011 |
|
2023 | 2012 |
|
2024 |
| -try: |
2025 |
| - from os import ( |
2026 |
| - chmod as _chmod, # pyright: ignore[reportAssignmentType] # Losing type-safety w/ pyright, but that's ok |
2027 |
| - ) |
2028 |
| -except ImportError: |
2029 |
| - # Jython compatibility |
2030 |
| - def _chmod(*args: object, **kwargs: object) -> None: # type: ignore[misc] # Mypy reuses the imported definition anyway |
2031 |
| - pass |
2032 |
| - |
2033 |
| - |
2034 |
| -def chmod(path, mode): |
2035 |
| - log.debug("changing mode of %s to %o", path, mode) |
2036 |
| - try: |
2037 |
| - _chmod(path, mode) |
2038 |
| - except OSError as e: |
2039 |
| - log.debug("chmod failed: %s", e) |
2040 |
| - |
2041 |
| - |
2042 | 2013 | class _SplitArgs(TypedDict, total=False):
|
2043 | 2014 | comments: bool
|
2044 | 2015 | posix: bool
|
@@ -2350,10 +2321,6 @@ def load_launcher_manifest(name):
|
2350 | 2321 | return manifest.decode('utf-8') % vars()
|
2351 | 2322 |
|
2352 | 2323 |
|
2353 |
| -def _rmtree(path, ignore_errors: bool = False, onexc=auto_chmod): |
2354 |
| - return py311.shutil_rmtree(path, ignore_errors, onexc) |
2355 |
| - |
2356 |
| - |
2357 | 2324 | def current_umask():
|
2358 | 2325 | tmp = os.umask(0o022)
|
2359 | 2326 | os.umask(tmp)
|
|
0 commit comments