Skip to content

Commit f4b5e97

Browse files
committed
Polishing for macOS
1 parent 5e7adb8 commit f4b5e97

File tree

3 files changed

+55
-15
lines changed

3 files changed

+55
-15
lines changed

installer/src/InstallerWindow.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,8 @@ InstallerWindow::InstallerWindow(QWidget* parent) : QMainWindow(parent)
100100
hideGuiCheck_ = new QCheckBox(tr("Hide GUI/CLI after successful runs"), central);
101101
layout->addWidget(hideGuiCheck_);
102102

103-
#if defined(Q_OS_WIN)
104103
copyCliOnlyCheck_ = new QCheckBox(tr("Copy only the CLI version (reduces the size)"), central);
105104
layout->addWidget(copyCliOnlyCheck_);
106-
#endif
107105

108106
installButton_ = new QPushButton(tr("Install PyAppExec"), central);
109107
installButton_->setFixedWidth(220);
@@ -237,11 +235,9 @@ SettingsModel InstallerWindow::gatherSettings() const
237235
settings.iconPath = iconPathEdit_->text().trimmed();
238236
}
239237
settings.hideGuiAfterSuccess = hideGuiCheck_->isChecked();
240-
#if defined(Q_OS_WIN)
241238
if (copyCliOnlyCheck_) {
242239
settings.copyCliOnly = copyCliOnlyCheck_->isChecked();
243240
}
244-
#endif
245241
return settings;
246242
}
247243

@@ -304,11 +300,9 @@ void InstallerWindow::handleInstall()
304300

305301
logMessage(tr("Generated %1").arg(createdIni));
306302
logMessage(tr("Copied launcher as %1").arg(settings.launcherArtifactName()));
307-
#if defined(Q_OS_WIN)
308303
if (settings.copyCliOnly) {
309-
logMessage(tr("CLI-only mode: skipped copying Qt and other adjacent DLLs."));
304+
logMessage(tr("CLI-only mode: using the command-line launcher instead of the GUI binary."));
310305
}
311-
#endif
312306

313307
QDesktopServices::openUrl(QUrl::fromLocalFile(createdIni));
314308
QMessageBox::information(this, tr("Success"), tr("PyAppExec was installed for %1").arg(settings.appName));
@@ -433,16 +427,15 @@ void InstallerWindow::showAboutQtDialog()
433427
void InstallerWindow::updateActionButtons()
434428
{
435429
const bool hasProject = !projectPathEdit_->text().trimmed().isEmpty();
430+
const QString iniPath = hasProject
431+
? QDir(projectPathEdit_->text()).filePath(QStringLiteral("pyappexec.ini"))
432+
: QString();
433+
const bool hasIni = hasProject && QFileInfo::exists(iniPath);
434+
436435
if (installButton_) {
437436
installButton_->setEnabled(hasProject);
438437
}
439438

440-
#if defined(Q_OS_WIN)
441-
bool hasIni = false;
442-
if (hasProject) {
443-
const QString iniPath = QDir(projectPathEdit_->text()).filePath(QStringLiteral("pyappexec.ini"));
444-
hasIni = QFileInfo::exists(iniPath);
445-
}
446439
if (uninstallButton_) {
447440
uninstallButton_->setEnabled(hasProject && hasIni);
448441
if (!hasIni) {
@@ -451,7 +444,6 @@ void InstallerWindow::updateActionButtons()
451444
uninstallButton_->setToolTip(QString());
452445
}
453446
}
454-
#endif
455447
}
456448

457449
} // namespace installer

lib/ConfigLoader.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@ std::filesystem::path ConfigLoader::resolveConfigPath(const std::optional<std::s
3838
return primary;
3939
}
4040

41+
fs::path adjacent = binaryDir_ / "pyappexec.ini";
42+
if (fs::exists(adjacent, ec)) {
43+
spdlog::info("Found pyappexec.ini next to the launcher at {}", adjacent.string());
44+
return adjacent;
45+
}
46+
4147
throw std::runtime_error(
42-
"Unable to locate pyappexec.ini in the current directory.\n"
48+
"Unable to locate pyappexec.ini in the current directory or next to the launcher.\n"
4349
"Pass --config /path/to/pyappexec.ini to specify the configuration explicitly.");
4450
}
4551

scripts/create_dmg.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
if [[ $# -ne 1 ]]; then
6+
echo "Usage: $0 /path/to/AppName.app" >&2
7+
exit 1
8+
fi
9+
10+
APP_PATH="$1"
11+
if [[ ! -d "$APP_PATH" ]]; then
12+
echo "Error: $APP_PATH is not a directory (expected a .app bundle)" >&2
13+
exit 1
14+
fi
15+
16+
APP_ABS="$(cd "$(dirname "$APP_PATH")" && pwd)/$(basename "$APP_PATH")"
17+
APP_NAME="$(basename "$APP_PATH" .app)"
18+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
19+
DIST_DIR="${DIST_DIR:-${ROOT_DIR}/dist}"
20+
21+
mkdir -p "$DIST_DIR"
22+
23+
DMG_PATH="${DIST_DIR}/${APP_NAME}.dmg"
24+
25+
echo "Creating DMG:"
26+
echo " Source: $APP_ABS"
27+
echo " Output: $DMG_PATH"
28+
29+
STAGING_DIR="$(mktemp -d -t pyappexec_dmg)"
30+
cleanup() { rm -rf "$STAGING_DIR"; }
31+
trap cleanup EXIT
32+
33+
cp -R "$APP_ABS" "$STAGING_DIR/"
34+
ln -s /Applications "$STAGING_DIR/Applications"
35+
36+
if [[ -f "$DMG_PATH" ]]; then
37+
rm -f "$DMG_PATH"
38+
fi
39+
40+
hdiutil create -fs HFS+ -volname "$APP_NAME" -srcfolder "$STAGING_DIR" "$DMG_PATH"
41+
42+
echo "DMG created at $DMG_PATH"

0 commit comments

Comments
 (0)