Skip to content

Commit 923b1eb

Browse files
committed
Use a match for Windows executables in venv
1 parent b81cce9 commit 923b1eb

File tree

1 file changed

+88
-75
lines changed

1 file changed

+88
-75
lines changed

crates/uv-virtualenv/src/virtualenv.rs

Lines changed: 88 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ pub(crate) fn create(
268268
create_link_to_executable(targetw.as_path(), executable_target)
269269
.map_err(Error::Python)?;
270270
} else {
271+
// Always copy `python.exe`.
271272
copy_launcher_windows(
272273
WindowsExecutable::Python,
273274
interpreter,
@@ -276,81 +277,93 @@ pub(crate) fn create(
276277
python_home,
277278
)?;
278279

279-
if interpreter.markers().implementation_name() == "graalpy" {
280-
copy_launcher_windows(
281-
WindowsExecutable::GraalPy,
282-
interpreter,
283-
&base_python,
284-
&scripts,
285-
python_home,
286-
)?;
287-
copy_launcher_windows(
288-
WindowsExecutable::PythonMajor,
289-
interpreter,
290-
&base_python,
291-
&scripts,
292-
python_home,
293-
)?;
294-
} else {
295-
copy_launcher_windows(
296-
WindowsExecutable::Pythonw,
297-
interpreter,
298-
&base_python,
299-
&scripts,
300-
python_home,
301-
)?;
302-
}
303-
304-
if interpreter.markers().implementation_name() == "pypy" {
305-
copy_launcher_windows(
306-
WindowsExecutable::PythonMajor,
307-
interpreter,
308-
&base_python,
309-
&scripts,
310-
python_home,
311-
)?;
312-
copy_launcher_windows(
313-
WindowsExecutable::PythonMajorMinor,
314-
interpreter,
315-
&base_python,
316-
&scripts,
317-
python_home,
318-
)?;
319-
copy_launcher_windows(
320-
WindowsExecutable::PyPy,
321-
interpreter,
322-
&base_python,
323-
&scripts,
324-
python_home,
325-
)?;
326-
copy_launcher_windows(
327-
WindowsExecutable::PyPyMajor,
328-
interpreter,
329-
&base_python,
330-
&scripts,
331-
python_home,
332-
)?;
333-
copy_launcher_windows(
334-
WindowsExecutable::PyPyMajorMinor,
335-
interpreter,
336-
&base_python,
337-
&scripts,
338-
python_home,
339-
)?;
340-
copy_launcher_windows(
341-
WindowsExecutable::PyPyw,
342-
interpreter,
343-
&base_python,
344-
&scripts,
345-
python_home,
346-
)?;
347-
copy_launcher_windows(
348-
WindowsExecutable::PyPyMajorMinorw,
349-
interpreter,
350-
&base_python,
351-
&scripts,
352-
python_home,
353-
)?;
280+
match interpreter.implementation_name() {
281+
"graalpy" => {
282+
// For GraalPy, copy `graalpy.exe` and `python3.exe`.
283+
copy_launcher_windows(
284+
WindowsExecutable::GraalPy,
285+
interpreter,
286+
&base_python,
287+
&scripts,
288+
python_home,
289+
)?;
290+
copy_launcher_windows(
291+
WindowsExecutable::PythonMajor,
292+
interpreter,
293+
&base_python,
294+
&scripts,
295+
python_home,
296+
)?;
297+
}
298+
"pypy" => {
299+
// For PyPy, copy all versioned executables and all PyPy-specific executables.
300+
copy_launcher_windows(
301+
WindowsExecutable::PythonMajor,
302+
interpreter,
303+
&base_python,
304+
&scripts,
305+
python_home,
306+
)?;
307+
copy_launcher_windows(
308+
WindowsExecutable::PythonMajorMinor,
309+
interpreter,
310+
&base_python,
311+
&scripts,
312+
python_home,
313+
)?;
314+
copy_launcher_windows(
315+
WindowsExecutable::Pythonw,
316+
interpreter,
317+
&base_python,
318+
&scripts,
319+
python_home,
320+
)?;
321+
copy_launcher_windows(
322+
WindowsExecutable::PyPy,
323+
interpreter,
324+
&base_python,
325+
&scripts,
326+
python_home,
327+
)?;
328+
copy_launcher_windows(
329+
WindowsExecutable::PyPyMajor,
330+
interpreter,
331+
&base_python,
332+
&scripts,
333+
python_home,
334+
)?;
335+
copy_launcher_windows(
336+
WindowsExecutable::PyPyMajorMinor,
337+
interpreter,
338+
&base_python,
339+
&scripts,
340+
python_home,
341+
)?;
342+
copy_launcher_windows(
343+
WindowsExecutable::PyPyw,
344+
interpreter,
345+
&base_python,
346+
&scripts,
347+
python_home,
348+
)?;
349+
copy_launcher_windows(
350+
WindowsExecutable::PyPyMajorMinorw,
351+
interpreter,
352+
&base_python,
353+
&scripts,
354+
python_home,
355+
)?;
356+
}
357+
_ => {
358+
// For all other interpreters, copy `pythonw.exe`.
359+
copy_launcher_windows(
360+
WindowsExecutable::Pythonw,
361+
interpreter,
362+
&base_python,
363+
&scripts,
364+
python_home,
365+
)?;
366+
}
354367
}
355368
}
356369
}

0 commit comments

Comments
 (0)