Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,17 @@ jobs:
$FFMPEG_ROOT_PATH/bin/ffmpeg -version | head -n 1
$FFMPEG_ROOT_PATH/bin/ffmpeg -encoders 2>/dev/null | grep -E "libx264|libx265" || echo "Warning: x264/x265 not found"

- name: Checkout BMF repository(specific branch)
- name: Checkout BMF repository and prepare python support
run: |
git clone https://github.com/OpenConverterLab/bmf.git
sed -i '' '77 i\
-DPython_ROOT_DIR="$HOME/Library/Application Support/OpenConverter/Python.framework" \\\
-DPython_FIND_FRAMEWORK=ONLY \\\
' ./bmf/build_osx.sh

mkdir -p "$HOME/Library/Application Support/OpenConverter/Python.framework"
wget https://github.com/astral-sh/python-build-standalone/releases/download/20251031/cpython-3.9.25+20251031-aarch64-apple-darwin-install_only.tar.gz
tar xzvf cpython-3.9.25+20251031-aarch64-apple-darwin-install_only.tar.gz --strip-components=1 -C "$HOME/Library/Application Support/OpenConverter/Python.framework"

# wget https://invisible-island.net/archives/ncurses/ncurses-6.5.tar.gz
# wget https://ftp.gnu.org/gnu/binutils/binutils-2.43.1.tar.bz2
Expand Down
9 changes: 0 additions & 9 deletions src/builder/include/open_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class OpenConverter : public QMainWindow, public ProcessObserver {
private slots:
void SlotLanguageChanged(QAction *action);
void SlotTranscoderChanged(QAction *action);
void SlotPythonChanged(QAction *action);
void OnNavigationButtonClicked(int pageIndex);
void OnQueueButtonClicked();

Expand All @@ -109,8 +108,6 @@ private slots:
QMessageBox *displayResult;
QActionGroup *transcoderGroup;
QActionGroup *languageGroup;
QActionGroup *pythonGroup;
QString customPythonPath;

// Navigation and page management
QButtonGroup *navButtonGroup;
Expand Down Expand Up @@ -139,12 +136,6 @@ private slots:

// Get current transcoder name
QString GetCurrentTranscoderName() const;

// Get current Python path setting
QString GetPythonSitePackagesPath() const;

// Static method for transcoder_bmf to get Python path
static QString GetStoredPythonPath();
};

#endif // OPEN_CONVERTER_H
97 changes: 0 additions & 97 deletions src/builder/src/open_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,27 +133,6 @@ OpenConverter::OpenConverter(QWidget *parent)
languageGroup->addAction(action);
}

// Setup Python menu
pythonGroup = new QActionGroup(this);
pythonGroup->setExclusive(true);
QList<QAction*> pythonActions = ui->menuPython->actions();
for (QAction* action : pythonActions) {
action->setCheckable(true);
pythonGroup->addAction(action);
}

// Load saved Python setting or default to App Python
QSettings settings("OpenConverter", "OpenConverter");
QString savedPython = settings.value("python/mode", "pythonAppSupport").toString();
customPythonPath = settings.value("python/customPath", "").toString();

for (QAction* action : pythonActions) {
if (action->objectName() == savedPython) {
action->setChecked(true);
break;
}
}

// Initialize language - default to English (no translation file needed)
m_currLang = "english";
m_langPath = ":/";
Expand Down Expand Up @@ -190,9 +169,6 @@ OpenConverter::OpenConverter(QWidget *parent)

connect(ui->menuTranscoder, SIGNAL(triggered(QAction *)), this,
SLOT(SlotTranscoderChanged(QAction *)));

connect(ui->menuPython, SIGNAL(triggered(QAction *)), this,
SLOT(SlotPythonChanged(QAction *)));
}

void OpenConverter::dragEnterEvent(QDragEnterEvent *event) {
Expand Down Expand Up @@ -255,48 +231,6 @@ void OpenConverter::SlotTranscoderChanged(QAction *action) {
}
}

// Called every time, when a menu entry of the Python menu is called
void OpenConverter::SlotPythonChanged(QAction *action) {
if (!action) return;

QString pythonMode = action->objectName();
QSettings settings("OpenConverter", "OpenConverter");

if (pythonMode == "pythonCustom") {
// Show file dialog to select site-packages path
QString dir = QFileDialog::getExistingDirectory(
this,
tr("Select Python site-packages Directory"),
customPythonPath.isEmpty() ? "/opt/homebrew/lib/python3.9/site-packages" : customPythonPath,
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks
);

if (!dir.isEmpty()) {
customPythonPath = dir;
settings.setValue("python/mode", pythonMode);
settings.setValue("python/customPath", customPythonPath);
ui->statusBar->showMessage(
tr("Python path set to: %1").arg(customPythonPath));
} else {
// User cancelled, revert to previous selection
QString savedPython = settings.value("python/mode", "pythonAppSupport").toString();
QList<QAction*> pythonActions = ui->menuPython->actions();
for (QAction* act : pythonActions) {
if (act->objectName() == savedPython) {
act->setChecked(true);
break;
}
}
return;
}
} else {
settings.setValue("python/mode", pythonMode);
if (pythonMode == "pythonAppSupport") {
ui->statusBar->showMessage(tr("Using App Python"));
}
}
}

// Called every time, when a menu entry of the language menu is called
void OpenConverter::SlotLanguageChanged(QAction *action) {
if (0 != action) {
Expand Down Expand Up @@ -567,35 +501,4 @@ QString OpenConverter::GetCurrentTranscoderName() const {
return "FFMPEG";
}

QString OpenConverter::GetPythonSitePackagesPath() const {
QAction *checkedAction = pythonGroup->checkedAction();
if (checkedAction) {
QString mode = checkedAction->objectName();
if (mode == "pythonCustom" && !customPythonPath.isEmpty()) {
return customPythonPath;
} else if (mode == "pythonAppSupport") {
// Python installed in ~/Library/Application Support/OpenConverter/
QString appSupportPath = QDir::homePath() +
"/Library/Application Support/OpenConverter/Python.framework/lib/python3.9/site-packages";
return appSupportPath;
}
}
// Default: Bundled or empty (transcoder will use bundled)
return QString();
}

QString OpenConverter::GetStoredPythonPath() {
// Static method that can be called from transcoder_bmf without GUI instance
QSettings settings("OpenConverter", "OpenConverter");
QString pythonMode = settings.value("python/mode", "pythonAppSupport").toString();

if (pythonMode == "pythonCustom") {
return settings.value("python/customPath", "").toString();
}
// Default to App Python (~/Library/Application Support/OpenConverter/)
QString appSupportPath = QDir::homePath() +
"/Library/Application Support/OpenConverter/Python.framework/lib/python3.9/site-packages";
return appSupportPath;
}

#include "open_converter.moc"
25 changes: 0 additions & 25 deletions src/builder/src/open_converter.ui
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,8 @@ QLabel {
<string>Transcoder</string>
</property>
</widget>
<widget class="QMenu" name="menuPython">
<property name="title">
<string>Python</string>
</property>
<addaction name="pythonAppSupport"/>
<addaction name="pythonCustom"/>
</widget>
<addaction name="menuLanguage"/>
<addaction name="menuTranscoder"/>
<addaction name="menuPython"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="english">
Expand All @@ -174,23 +166,6 @@ QLabel {
<string>Chinese</string>
</property>
</action>

<action name="pythonAppSupport">
<property name="objectName">
<string>pythonAppSupport</string>
</property>
<property name="text">
<string>App Python</string>
</property>
</action>
<action name="pythonCustom">
<property name="objectName">
<string>pythonCustom</string>
</property>
<property name="text">
<string>Custom Path...</string>
</property>
</action>
</widget>
<resources/>
<connections/>
Expand Down
8 changes: 5 additions & 3 deletions src/builder/src/python_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,14 @@ QString PythonManager::GetAppBundlePath() {

QString PythonManager::GetPythonFrameworkPath() {
// Install embedded Python into Application Support directory so
// the app bundle/installation remains immutable. Use QStandardPaths to get
// the per-user Application Support directory for the app.
// the app bundle/installation remains immutable.
// Use explicit app name "OpenConverter" to avoid issues with wrapper launchers
// (e.g., OpenConverter.real on macOS) affecting the path.
// macOS: ~/Library/Application Support/OpenConverter/Python.framework
// Linux: ~/.local/share/OpenConverter/Python.framework
// Windows: C:/Users/<USER>/AppData/Local/OpenConverter/Python.framework
QString appSupportBase = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
QString genericDataLocation = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
QString appSupportBase = genericDataLocation + "/OpenConverter";
// Ensure directory exists
QDir().mkpath(appSupportBase);
return appSupportBase + "/Python.framework";
Expand Down
Binary file modified src/resources/lang_chinese.qm
Binary file not shown.
24 changes: 0 additions & 24 deletions src/resources/lang_chinese.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1230,30 +1230,6 @@
<source>AI Processing</source>
<translation>AI 处理</translation>
</message>
<message>
<source>Select Python site-packages Directory</source>
<translation>选择 Python site-packages 目录</translation>
</message>
<message>
<source>Python path set to: %1</source>
<translation>Python 路径设置为:%1</translation>
</message>
<message>
<source>Using App Python</source>
<translation>使用应用内置 Python</translation>
</message>
<message>
<source>App Python</source>
<translation>应用内置 Python</translation>
</message>
<message>
<source>Custom Path...</source>
<translation>自定义路径...</translation>
</message>
<message>
<source>Python</source>
<translation>Python</translation>
</message>
</context>
<context>
<name>QObject</name>
Expand Down
13 changes: 13 additions & 0 deletions src/resources/macos_launcher.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
# Wrapper launcher for OpenConverter
# Sets up library paths before launching the real executable

# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"

# Set DYLD_LIBRARY_PATH for Python framework
export DYLD_LIBRARY_PATH="$HOME/Library/Application Support/OpenConverter/Python.framework/lib${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}"

# Execute the real binary
exec "$SCRIPT_DIR/OpenConverter.real" "$@"

Loading
Loading