|
15 | 15 | from setuptools.extern.packaging.tags import sys_tags
|
16 | 16 | from setuptools.extern.packaging.utils import canonicalize_name
|
17 | 17 | from setuptools.command.egg_info import write_requirements
|
| 18 | +from setuptools.archive_util import _unpack_zipfile_obj |
18 | 19 |
|
19 | 20 |
|
20 | 21 | WHEEL_NAME = re.compile(
|
|
27 | 28 | "__import__('pkg_resources').declare_namespace(__name__)\n"
|
28 | 29 |
|
29 | 30 |
|
30 |
| -class ZipFilePreserveMode(zipfile.ZipFile): |
31 |
| - """ Extended ZipFile class to preserve file mode """ |
32 |
| - def _extract_member(self, member, targetpath, pwd): |
33 |
| - if not isinstance(member, zipfile.ZipInfo): |
34 |
| - member = self.getinfo(member) |
35 |
| - |
36 |
| - targetpath = super()._extract_member(member, targetpath, pwd) |
37 |
| - |
38 |
| - attr = member.external_attr >> 16 |
39 |
| - if attr != 0: |
40 |
| - os.chmod(targetpath, attr) |
41 |
| - return targetpath |
42 |
| - |
43 |
| - |
44 | 31 | def unpack(src_dir, dst_dir):
|
45 | 32 | '''Move everything under `src_dir` to `dst_dir`, and delete the former.'''
|
46 | 33 | for dirpath, dirnames, filenames in os.walk(src_dir):
|
@@ -105,7 +92,7 @@ def get_dist_info(self, zf):
|
105 | 92 |
|
106 | 93 | def install_as_egg(self, destination_eggdir):
|
107 | 94 | '''Install wheel as an egg directory.'''
|
108 |
| - with ZipFilePreserveMode(self.filename) as zf: |
| 95 | + with zipfile.ZipFile(self.filename) as zf: |
109 | 96 | self._install_as_egg(destination_eggdir, zf)
|
110 | 97 |
|
111 | 98 | def _install_as_egg(self, destination_eggdir, zf):
|
@@ -135,8 +122,7 @@ def get_metadata(name):
|
135 | 122 | raise ValueError(
|
136 | 123 | 'unsupported wheel format version: %s' % wheel_version)
|
137 | 124 | # Extract to target directory.
|
138 |
| - os.mkdir(destination_eggdir) |
139 |
| - zf.extractall(destination_eggdir) |
| 125 | + _unpack_zipfile_obj(zf, destination_eggdir) |
140 | 126 | # Convert metadata.
|
141 | 127 | dist_info = os.path.join(destination_eggdir, dist_info)
|
142 | 128 | dist = pkg_resources.Distribution.from_location(
|
|
0 commit comments