@@ -107,15 +107,13 @@ impl CachedEnvironment {
107
107
printer : Printer ,
108
108
preview : PreviewMode ,
109
109
) -> Result < Self , ProjectError > {
110
- // Resolve the "base" interpreter, which resolves to an underlying parent interpreter if the
111
- // given interpreter is a virtual environment.
112
- let base_interpreter = Self :: base_interpreter ( interpreter, cache) ?;
110
+ let interpreter = Self :: base_interpreter ( interpreter, cache) ?;
113
111
114
112
// Resolve the requirements with the interpreter.
115
113
let resolution = Resolution :: from (
116
114
resolve_environment (
117
115
spec,
118
- & base_interpreter ,
116
+ & interpreter ,
119
117
build_constraints. clone ( ) ,
120
118
& settings. resolver ,
121
119
network_settings,
@@ -138,34 +136,13 @@ impl CachedEnvironment {
138
136
hash_digest ( & distributions)
139
137
} ;
140
138
141
- // Construct a hash for the environment.
142
- //
143
- // Use the canonicalized base interpreter path since that's the interpreter we performed the
144
- // resolution with and the interpreter the environment will be created with.
145
- //
146
- // We also include the canonicalized `sys.prefix` of the non-base interpreter, that is, the
147
- // virtual environment's path. Originally, we shared cached environments independent of the
148
- // environment they'd be layered on top of. However, this causes collisions as the overlay
149
- // `.pth` file can be overridden by another instance of uv. Including this element in the key
150
- // avoids this problem at the cost of creating separate cached environments for identical
151
- // `--with` invocations across projects. We use `sys.prefix` rather than `sys.executable` so
152
- // we can canonicalize it without invalidating the purpose of the element — it'd probably be
153
- // safe to just use the absolute `sys.executable` as well.
154
- //
155
- // TODO(zanieb): Since we're not sharing these environmments across projects, we should move
156
- // [`CachedEvnvironment::set_overlay`] etc. here since the values there should be constant
157
- // now.
158
- //
159
- // TODO(zanieb): We should include the version of the base interpreter in the hash, so if
160
- // the interpreter at the canonicalized path changes versions we construct a new
161
- // environment.
162
- let environment_hash = cache_digest ( & (
163
- & canonicalize_executable ( base_interpreter. sys_executable ( ) ) ?,
164
- & interpreter. sys_prefix ( ) . canonicalize ( ) ?,
165
- ) ) ;
139
+ // Hash the interpreter based on its path.
140
+ // TODO(charlie): Come up with a robust hash for the interpreter.
141
+ let interpreter_hash =
142
+ cache_digest ( & canonicalize_executable ( interpreter. sys_executable ( ) ) ?) ;
166
143
167
144
// Search in the content-addressed cache.
168
- let cache_entry = cache. entry ( CacheBucket :: Environments , environment_hash , resolution_hash) ;
145
+ let cache_entry = cache. entry ( CacheBucket :: Environments , interpreter_hash , resolution_hash) ;
169
146
170
147
if cache. refresh ( ) . is_none ( ) {
171
148
if let Ok ( root) = cache. resolve_link ( cache_entry. path ( ) ) {
@@ -179,7 +156,7 @@ impl CachedEnvironment {
179
156
let temp_dir = cache. venv_dir ( ) ?;
180
157
let venv = uv_virtualenv:: create_venv (
181
158
temp_dir. path ( ) ,
182
- base_interpreter ,
159
+ interpreter ,
183
160
uv_virtualenv:: Prompt :: None ,
184
161
false ,
185
162
false ,
0 commit comments