From 524a1fb46a1a61065d210ef111e239eae741fe90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Wed, 12 Jun 2024 22:20:01 +0200 Subject: [PATCH] Do not replace manually installed sip when installing PyQt-builder. --- src/tasks/pyqt.cpp | 19 ++++++++++++++++++- src/tools/python.cpp | 22 +++++++++++++++++++--- src/tools/tools.h | 7 +++++++ 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/tasks/pyqt.cpp b/src/tasks/pyqt.cpp index cac90c9..0c02041 100644 --- a/src/tasks/pyqt.cpp +++ b/src/tasks/pyqt.cpp @@ -171,7 +171,24 @@ namespace mob::tasks { void pyqt::build_and_install_from_source() { // use pip to install the pyqt builder - run_tool(pip(pip::install).package("PyQt-builder").version(builder_version())); + if (python::build_type() == config::debug) { + // PyQt-builder has sip as a dependency, so installing it directly will + // replace the sip we have installed manually, but the installed sip will + // not work (see comment in sip::build() for details) + // + // the workaround is to install the dependencies manually (only packaging), + // and then use a --no-dependencies install with pip + // + run_tool(pip(pip::install).package("packaging")); + run_tool(pip(pip::install) + .package("PyQt-builder") + .no_dependencies() + .version(builder_version())); + } + else { + run_tool( + pip(pip::install).package("PyQt-builder").version(builder_version())); + } // patch for builder.py run_tool(patcher() diff --git a/src/tools/python.cpp b/src/tools/python.cpp index 255395f..46c79bc 100644 --- a/src/tools/python.cpp +++ b/src/tools/python.cpp @@ -49,7 +49,7 @@ namespace mob { execute_and_join(p); } - pip::pip(ops op) : basic_process_runner("pip"), op_(op) {} + pip::pip(ops op) : basic_process_runner("pip"), op_(op), no_deps_{false} {} pip& pip::package(const std::string& s) { @@ -69,6 +69,12 @@ namespace mob { return *this; } + pip& pip::no_dependencies() + { + no_deps_ = true; + return *this; + } + void pip::do_run() { switch (op_) { @@ -141,11 +147,21 @@ namespace mob { .arg("--no-warn-script-location") .arg("--disable-pip-version-check"); - if (!package_.empty()) - p.arg(package_ + "==" + version_); + if (!package_.empty()) { + if (version_.empty()) { + p.arg(package_); + } + else { + p.arg(package_ + "==" + version_); + } + } else if (!file_.empty()) p.arg(file_); + if (no_deps_) { + p.arg("--no-dependencies"); + } + p.env(this_env::get().set("PYTHONUTF8", "1")); execute_and_join(p); diff --git a/src/tools/tools.h b/src/tools/tools.h index 158cae1..3d16fef 100644 --- a/src/tools/tools.h +++ b/src/tools/tools.h @@ -703,6 +703,10 @@ namespace mob { pip& version(const std::string& s); pip& file(const fs::path& p); + // do not install dependencies for the package + // + pip& no_dependencies(); + protected: // runs pip // @@ -717,6 +721,9 @@ namespace mob { std::string version_; fs::path file_; + // no depndencies + bool no_deps_; + // runs `-m ensurepip`, then upgrades pip // void do_ensure();