Skip to content

Commit

Permalink
Do not replace manually installed sip when installing PyQt-builder.
Browse files Browse the repository at this point in the history
  • Loading branch information
Holt59 committed Jun 12, 2024
1 parent cad0eca commit 524a1fb
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
19 changes: 18 additions & 1 deletion src/tasks/pyqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
22 changes: 19 additions & 3 deletions src/tools/python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -69,6 +69,12 @@ namespace mob {
return *this;
}

pip& pip::no_dependencies()
{
no_deps_ = true;
return *this;
}

void pip::do_run()
{
switch (op_) {
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions src/tools/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand All @@ -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();
Expand Down

0 comments on commit 524a1fb

Please sign in to comment.