Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/PythonRuntimeSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

#include <memory>

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
Expand Down Expand Up @@ -275,7 +277,18 @@ 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)
Expand Down
Loading