Skip to content

Commit

Permalink
fix: open python project crashed in v23
Browse files Browse the repository at this point in the history
Log:
Change-Id: I0e64493e703cf22c1d48c1e7f36369f3ece3d855
  • Loading branch information
deepin-mozart committed Mar 18, 2024
1 parent 28740e4 commit 46abe88
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/common/util/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ Version completion(Category category, Kit kit, const Version &version)
program += QString::number(version.major.value());
}
ProcessUtil::execute(program, {"-V"}, [&](const QByteArray &data){
QRegularExpression regExp {"Python\\s(?<" + RK_Major +">[0-9])"
+ "\\.(?<"+ RK_Minor +">[0-9])"
+ "\\.(?<"+ RK_Revision +">[0-9])"
+ "(\\.(?<"+ RK_Build + ">[0-9]))?"};
QRegularExpression regExp {"Python\\s(?<" + RK_Major +">[0-9]+)"
+ "\\.(?<"+ RK_Minor +">[0-9]+)"
+ "\\.(?<"+ RK_Revision +">[0-9]+)"
+ "(\\.(?<"+ RK_Build + ">[0-9]+))?"};
auto matchs = regExp.match(data);
if (matchs.hasMatch()) {
auto major = matchs.captured(RK_Major);
Expand Down Expand Up @@ -73,14 +73,16 @@ Program search(Category category, Kit kit, const Version &version)
if (executeVersion.major) {
program + QString::number(executeVersion.major.value());
}
ret.pkgsPath = QDir::homePath() + QDir::separator()
+ ".local" + QDir::separator()
+ "lib" + QDir::separator()
+ QString("python") + QString::number(executeVersion.major.value())
+ "."
+ QString::number(executeVersion.minor.value())
+ QDir::separator()
+ "site-packages";

if (executeVersion.major.has_value() && executeVersion.minor.has_value())
ret.pkgsPath = QDir::homePath() + QDir::separator()
+ ".local" + QDir::separator()
+ "lib" + QDir::separator()
+ QString("python") + QString::number(executeVersion.major.value())
+ "."
+ QString::number(executeVersion.minor.value())
+ QDir::separator()
+ "site-packages";
}
}
}
Expand Down

0 comments on commit 46abe88

Please sign in to comment.