From 2e5b100f151c800bd4361d3b57e8fd9c0cc83827 Mon Sep 17 00:00:00 2001 From: Romain Janvier Date: Sat, 11 Jul 2026 16:33:05 +0200 Subject: [PATCH 1/2] Create venv with ensurepip on Windows --- src/PythonRuntimeSettings.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/PythonRuntimeSettings.cpp b/src/PythonRuntimeSettings.cpp index 3e8d401..6f2c5fb 100644 --- a/src/PythonRuntimeSettings.cpp +++ b/src/PythonRuntimeSettings.cpp @@ -36,6 +36,8 @@ #include +namespace py = pybind11; + /// Simple Dialog that displays a Line Edit with a button next to it /// to let the user select a path to a directory class PathVariableInputDialog final : public QDialog @@ -275,7 +277,17 @@ void PythonRuntimeSettings::handleCreateVenv() try { - const auto createVenvFn = pybind11::module_::import("venv").attr("create"); +// On Windows we create the venv with ensurepip, to allow users to use the "Package Manager" GUI with the newly created venv. +// ensurepip is only "sure" on Windows, Linux distro packages do not "ensure" ensurepip (sic.). +// On macOS it should be sure, but macOS bundle has some quirks, so we stay conservative for now. +#if defined(Q_OS_WINDOWS) + const py::module_ venvModule = py::module_::import("venv"); + const py::object envBuilder = venvModule.attr("EnvBuilder"); + const py::object builder = envBuilder(py::arg("with_pip") = true); + const auto createVenvFn = builder.attr("create"); +#else + const auto createVenvFn = py::module_::import("venv").attr("create"); +#endif createVenvFn(path); } catch (const std::exception &e) From bdbddf375b2e385f1a31b84e14d22b0fd7ba7b6a Mon Sep 17 00:00:00 2001 From: Romain Janvier Date: Sun, 12 Jul 2026 16:49:12 +0200 Subject: [PATCH 2/2] format --- src/PythonRuntimeSettings.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/PythonRuntimeSettings.cpp b/src/PythonRuntimeSettings.cpp index 6f2c5fb..a8e8f51 100644 --- a/src/PythonRuntimeSettings.cpp +++ b/src/PythonRuntimeSettings.cpp @@ -277,9 +277,10 @@ void PythonRuntimeSettings::handleCreateVenv() try { -// On Windows we create the venv with ensurepip, to allow users to use the "Package Manager" GUI with the newly created venv. -// ensurepip is only "sure" on Windows, Linux distro packages do not "ensure" ensurepip (sic.). -// On macOS it should be sure, but macOS bundle has some quirks, so we stay conservative for now. +// On Windows we create the venv with ensurepip, to allow users to use the "Package Manager" GUI +// with the newly created venv. ensurepip is only "sure" on Windows, Linux distro packages do not +// "ensure" ensurepip (sic.). On macOS it should be sure, but macOS bundle has some quirks, so we +// stay conservative for now. #if defined(Q_OS_WINDOWS) const py::module_ venvModule = py::module_::import("venv"); const py::object envBuilder = venvModule.attr("EnvBuilder");