Opened 11 years ago

Closed 11 years ago

#36783 closed defect (fixed)

mythtv-core.25 00.25.2-Fixes-20120918 Python paths wrong for site-packages/MythTV

Reported by: ted.rippert@… Owned by: ctreleaven (Craig Treleaven)
Priority: Normal Milestone:
Component: ports Version: 2.1.2
Keywords: Cc: pixilla (Bradley Giesbrecht)
Port: mythtv-core.25

Description (last modified by mf2k (Frank Schima))

The python modules stored in the tree beginning at /opt/local/lib/python2.6/site-packages/MythTV cannot be loaded by the macports python2.6 installation since it utilizes /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages for third party modules. This results, for example, in the metadata grabbers not working.

Work around:

cd /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages
sudo ln -s /opt/local/lib/python2.6/site-packages/MythTV MythTV

Change History (17)

comment:1 Changed 11 years ago by pixilla (Bradley Giesbrecht)

Cc: pixilla@… added

Cc Me!

comment:2 in reply to:  1 Changed 11 years ago by ted.rippert@…

Replying to pixilla@…:

Cc Me!

I forgot to fill in the port field in the original ticket. I can't seem to change it now. The port is mythtv-core.25 00.25.2-Fixes-20120918.

comment:3 Changed 11 years ago by mf2k (Frank Schima)

Description: modified (diff)
Port: mythtv-core.25 added

The port is actually called "mythtv-core.25". The rest is the version number. Also, please use WikiFormatting in the future.

comment:4 Changed 11 years ago by ted.rippert@…

Sorry about all that. I'm new to writing tickets here. You might want to add ctreleaven@… as a CC since he's the maintainer for the port. Thanks.

comment:5 Changed 11 years ago by mf2k (Frank Schima)

Owner: changed from macports-tickets@… to ctreleaven@…

comment:6 Changed 11 years ago by ctreleaven (Craig Treleaven)

Being no expert in Python, I was advised to add the following to my /users/<username>/.profile :

export PYTHONPATH=/opt/local/lib/python2.6/site-packages:$PYTHONPATH

Works for me!

comment:7 Changed 11 years ago by ted.rippert@…

The PYTHONPATH variable in .profile would work for an individual user when they start the backend from the command line, but not generally. Since the backend is started by a plist in /Library/LaunchDeamons you would need to insert an environment variable statement into the plist to set it up for the automated backend launcher. Since the mythbackend plist is created by the macports installation, that may be a file you could modify in the port to get this working out of the box for a new installation.

comment:8 Changed 11 years ago by ctreleaven (Craig Treleaven)

The backend plist does set PYTHONPATH (as well as HOME) for the backend, see:

https://trac.macports.org/browser/trunk/dports/multimedia/mythtv-core.25/files/org.mythtv.mythbackend.plist

If you enable the automatic metadata update, it should inherit that environment when it runs. Log output from those runs should be in /opt/local/var/log/mythttv.25/ .

The frontend user still needs PYTHONPATH to do metadatalookups while creating a new recording rule, etc.

comment:9 Changed 11 years ago by ted.rippert@…

You're right, of course. I actually modified the EnvironmentVariables key without noticing the PYTHONPATH key in it. The automated backend metadata updates seemed very flaky (only worked once for some reason), and all the frontend and mythweb rescans didn't work at all until I added the symbolic link noted in the original ticket. Given that, I would recommend that the port should create the symbolic link noted in the workaround as a fix. The PYTHONPATH definition would then be redundant, and there might be a better way from the python point of view. I'm no expert in python either.

By the way, the other keys I added to the EnvironmentVariables group are:

        <key>LC_CTYPE</key>
        <string>en_US.UTF-8</string>
        <key>LANG</key>
        <string>en_US.UTF-8</string>

This was to get rid of a warning about the language definition that kept popping up in the backend logs. I didn't notice any real problems with the port operation due to this warning, so I didn't think it rated a ticket.

comment:10 Changed 11 years ago by ned-deily (Ned Deily)

If the mythtv port is installing into /opt/local/lib/python2.x/site-packages, the port is behaving incorrectly for MacPorts Pythons. It should be installing into the standard framework location /opt/local/Library/Frameworks/Python.framework/Versions/2.x/lib/python2.x/site-packages. Setting PYTHONPATH or the suggested symlinks are fragile bandaids. If the port is using standard Python installation components, like Distutils, things should be automatically installed in the right place.

comment:11 in reply to:  10 ; Changed 11 years ago by ctreleaven (Craig Treleaven)

Replying to nad@…:

... standard Python installation components, like Distutils, things should be automatically installed in the right place.

Perhaps you can assist. AFAICT, Myth is using disutils (see https://github.com/MythTV/mythtv/blob/fixes/0.25/mythtv/bindings/python/setup.py ). If the port is failing to set up something, I'd be glad to know it. As I said, I don't know Python.

In fact, Myth's Python bindings are heavily used by certain Myth plugins and I have not been able to make those plugins work satisfactorily. (And thus the port hasn't been submitted to MacPorts.) Perhaps an improper installation of the bindings is at fault?

comment:12 in reply to:  11 Changed 11 years ago by ted.rippert@…

Replying to ctreleaven@…:

Replying to nad@…:

... standard Python installation components, like Distutils, things should be automatically installed in the right place.

Perhaps you can assist. AFAICT, Myth is using disutils (see https://github.com/MythTV/mythtv/blob/fixes/0.25/mythtv/bindings/python/setup.py ).

Looking at the file you reference, the first line is:

#!/usr/bin/env python

When I invoke it this way in a terminal window, I get the Apple installed python from /usr/bin/ Actually I have separate python installs for 2.5, 2.6 and 2.7 in /usr/bin, /opt/local/bin and /sw/bin.

Perhaps the interpreter for the script should be:

#!/opt/local/bin/python2.x

where I assume you would use x=6, since all the MythTV scripts I found were under 2.6 rather than 2.7.

comment:13 Changed 11 years ago by ted.rippert@…

OK. I've played around with it, and I think I see what is going on. Here's what gives the correct install path:

$ /opt/local/bin/python2.6 -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages

Here's what I get using the syntax from the MythTV setup.py in my normal shell:

$ /usr/bin/env python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
/Library/Python/2.5/site-packages

which doesn't seem to give anything like the path that the MythTV port ended up using. However, assuming that "python" in the port set-up had been aliased to python2.6:

$ /usr/bin/env python2.6 -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
/sw/lib/python2.6/site-packages

which is in my Fink installation. Assuming that your port is set to replace install directory prefixes with /opt/local, you end up with the /opt/local/lib/python2.6/site-packages that the MythTV directory ended up in for me.

It seems like the script would work as is if the macports tree was before the Fink tree in my path, but that seems like something prone to breakage for a lot of people. I don't know if all your bindings problems are caused by this, but you might try using the explicit path to the macports python2.6 in your setup scripts if that is an acceptable practice.

comment:14 Changed 11 years ago by pixilla (Bradley Giesbrecht)

It would be better for the Portfile to replace "/usr/bin/env python" with "/opt/local/bin/python2.6".

comment:15 Changed 11 years ago by ctreleaven (Craig Treleaven)

Working on it now...

comment:16 Changed 11 years ago by ctreleaven (Craig Treleaven)

Modifying the shebang lines* did _not_ cause Myth's python modules to be installed under /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages

The log verifies that mythtv/bindings/python/setup.py was executed with /opt/local/bin/python2.6, as expected.

Going to ask for assistance on the macports-dev list.

*There are close to 100 python scripts in the MythTV source!

comment:17 Changed 11 years ago by pixilla (Bradley Giesbrecht)

Resolution: fixed
Status: newclosed

See r99758

Note: See TracTickets for help on using tickets.