Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#13643 closed Patch - Bug Fix (fixed)

MacOS Python2.6 hard code breaks python bindings / metadatalookup

Reported by: John Hoyt Owned by: Bill Meek <billmeek@…>
Priority: minor Milestone: 31.1
Component: MythTV - General Version: Unspecified
Severity: medium Keywords: MacOS Python
Cc: Ticket locked: no

Description

There is a hard code to python2.6 in

  • mythtv/programs/mythbackend/main.cpp
  • mythtv/programs/mythfrontend/main.cpp
  • mythtv/programs/mythmetadatalookup/main.cpp

The suspect line in each file is

QString("%1/../Resources/lib/python2.6/site-packages:%2")

This should either be modified to python (per the attached path) or worked out to automatically extract the compile time python version.

Attachments (2)

macos.python26hardcode.diff (1.9 KB) - added by John Hoyt 4 years ago.
potential patch for hardcoded python2.6
python.26.hard.code.patch (2.4 KB) - added by John Hoyt 4 years ago.
Modified patch for hard code

Download all attachments as: .zip

Change History (6)

Changed 4 years ago by John Hoyt

Attachment: macos.python26hardcode.diff added

potential patch for hardcoded python2.6

comment:1 Changed 4 years ago by Bill Meek

Status: newinfoneeded_new

John,

I see in compileMythfrontendAnsible.zsh: --python=/opt/local/bin/python3.8

That should end up in libs/libmythbase/mythconfig.h as: #define PYTHON_EXE "/opt/local/bin/python3.8"

Please test this, which removes the leading path info:

diff --git a/mythtv/programs/mythbackend/main.cpp b/mythtv/programs/mythbackend/main.cpp
index 7cf7f5b644..1a6233a7ba 100644
--- a/mythtv/programs/mythbackend/main.cpp
+++ b/mythtv/programs/mythbackend/main.cpp
@@ -94,10 +94,13 @@ int main(int argc, char **argv)
     QCoreApplication::setApplicationName(MYTH_APPNAME_MYTHBACKEND);
 
 #ifdef Q_OS_MAC
+    QFileInfo fi(PYTHON_EXE);
+    QString python_executable = fi.fileName();
     QString path = QCoreApplication::applicationDirPath();
     setenv("PYTHONPATH",
-           QString("%1/../Resources/lib/python2.6/site-packages:%2")
+           QString("%1/../Resources/lib/%2/site-packages:%3")
            .arg(path)
+           .arg(python_executable)
            .arg(QProcessEnvironment::systemEnvironment().value("PYTHONPATH"))
            .toUtf8().constData(), 1);
 #endif
Version 0, edited 4 years ago by Bill Meek (next)

Changed 4 years ago by John Hoyt

Attachment: python.26.hard.code.patch added

Modified patch for hard code

comment:2 Changed 4 years ago by John Hoyt

I just tested this patch file successfully. I believe it still has your debug variable in it for all three files. I needed the mythtv/programs/mythmetadatalookup/main.cpp fix to test easily.

Verified the correct path is being generated by modifying the tmdb3.py script to print its sys.path to a file.

comment:3 Changed 4 years ago by Bill Meek <billmeek@…>

Owner: set to Bill Meek <billmeek@…>
Resolution: fixed
Status: infoneeded_newclosed

In 0add17779/mythtv:

MacOS: remove hard-coded python2.6 PYTHONPATH code

Based on a patch from John Hoyt, and thanks for testing
on MacOS.

This could prevent the location of Python packages in
the future if the OSX packaging sets --python=python
(for example). Currently the version is included in
the Python executable's file name:

--python=/opt/local/bin/python3.8

Fixes #13643

(cherry picked from commit d30fd541c74a37d589548eadb9d225b2a96563ab)

comment:4 Changed 4 years ago by Bill Meek <billmeek@…>

In d30fd541c/mythtv:

MacOS: remove hard-coded python2.6 PYTHONPATH code

Based on a patch from John Hoyt, and thanks for testing
on MacOS.

This could prevent the location of Python packages in
the future if the OSX packaging sets --python=python
(for example). Currently the version is included in
the Python executable's file name:

--python=/opt/local/bin/python3.8

Fixes #13643

Note: See TracTickets for help on using tickets.