15
15
from itertools import product
16
16
from os .path import splitext
17
17
from pathlib import Path
18
- from tempfile import TemporaryDirectory
19
18
from types import TracebackType
20
- from typing import Any , ClassVar
21
19
22
20
from packaging .utils import parse_wheel_filename
23
21
@@ -100,13 +98,8 @@ class InWheel(InTemporaryDirectory):
100
98
On entering, you'll find yourself in the root tree of the wheel. If you've
101
99
asked for an output wheel, then on exit we'll rewrite the wheel record and
102
100
pack stuff up for you.
103
-
104
- If `out_wheel` is None, we assume the wheel won't be modified and we can
105
- cache the unpacked wheel for future use.
106
101
"""
107
102
108
- _whl_cache : ClassVar [dict [Path , TemporaryDirectory [Any ]]] = {}
109
-
110
103
def __init__ (self , in_wheel : Path , out_wheel : Path | None = None ) -> None :
111
104
"""Initialize in-wheel context manager
112
105
@@ -120,35 +113,9 @@ def __init__(self, in_wheel: Path, out_wheel: Path | None = None) -> None:
120
113
"""
121
114
self .in_wheel = in_wheel .absolute ()
122
115
self .out_wheel = None if out_wheel is None else out_wheel .absolute ()
123
- self .read_only = out_wheel is None
124
- self .use_cache = self .in_wheel in self ._whl_cache
125
- if self .use_cache and not Path (self ._whl_cache [self .in_wheel ].name ).exists ():
126
- self .use_cache = False
127
- logger .debug (
128
- "Wheel ctx %s for %s is no longer valid" ,
129
- self ._whl_cache .pop (self .in_wheel ),
130
- self .in_wheel ,
131
- )
132
-
133
- if self .use_cache :
134
- logger .debug (
135
- "Reuse %s for %s" , self ._whl_cache [self .in_wheel ], self .in_wheel
136
- )
137
- self ._tmpdir = self ._whl_cache [self .in_wheel ]
138
- if not self .read_only :
139
- self ._whl_cache .pop (self .in_wheel )
140
- else :
141
- super ().__init__ ()
142
- if self .read_only :
143
- self ._whl_cache [self .in_wheel ] = self ._tmpdir
116
+ super ().__init__ ()
144
117
145
118
def __enter__ (self ) -> Path :
146
- if self .use_cache or self .read_only :
147
- if not self .use_cache :
148
- zip2dir (self .in_wheel , self .name )
149
- self ._pwd = Path .cwd ()
150
- os .chdir (self .name )
151
- return Path (self .name )
152
119
zip2dir (self .in_wheel , self .name )
153
120
return super ().__enter__ ()
154
121
@@ -165,16 +132,6 @@ def __exit__(
165
132
if timestamp :
166
133
date_time = datetime .fromtimestamp (int (timestamp ), tz = timezone .utc )
167
134
dir2zip (self .name , self .out_wheel , date_time )
168
- if self .use_cache or self .read_only :
169
- logger .debug (
170
- "Exiting reused %s for %s" ,
171
- self ._whl_cache [self .in_wheel ],
172
- self .in_wheel ,
173
- )
174
- os .chdir (self ._pwd )
175
- if not self .read_only :
176
- super ().__exit__ (exc , value , tb )
177
- return None
178
135
return super ().__exit__ (exc , value , tb )
179
136
180
137
0 commit comments