Opened 4 months ago

Closed 4 months ago

Last modified 4 months 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 months ago.
potential patch for hardcoded python2.6
python.26.hard.code.patch (2.4 KB) - added by John Hoyt 4 months ago.
Modified patch for hard code

Download all attachments as: .zip

Change History (6)

Changed 4 months ago by John Hoyt

Attachment: macos.python26hardcode.diff added

potential patch for hardcoded python2.6

comment:1 Changed 4 months 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"

The following assumes that the --python switch has the version of interest, not just python 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..ddbef2fa53 100644
--- a/mythtv/programs/mythbackend/main.cpp
+++ b/mythtv/programs/mythbackend/main.cpp
@@ -96,8 +96,9 @@ int main(int argc, char **argv)
 #ifdef Q_OS_MAC
     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(QFileInfo(PYTHON_EXE).fileName())
            .arg(QProcessEnvironment::systemEnvironment().value("PYTHONPATH"))
            .toUtf8().constData(), 1);
 #endif
Last edited 4 months ago by Bill Meek (previous) (diff)

Changed 4 months ago by John Hoyt

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

Modified patch for hard code

comment:2 Changed 4 months 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 months 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 months 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.