I naively ported my Django app to Python 3 and didn't realize WSGI was going to be an issue. I saw python3-django was available for Fedora 20 and thought I was all set until I saw in my httpd logs that python2.7 seems to be the assumed default for mod_wsgi. After reading the README and more, I see the writing on the wall:
""" If you have multiple versions of Python installed and you are not using that which is the default, you may have to organise that the PATH inherited by the Apache application when run will result in Apache finding the alternate version. Alternatively, the WSGIPythonHome directive should be used to specify the exact location of the Python installation corresponding to the version of Python compiled against. If this is not done, the version of Python running within Apache may attempt to use the Python modules from the wrong version of Python. """
I take this to mean that merely fiddling with WSGIPythonHome alone will be insufficient and that I would need to recompile the package. Is that correct, or did I miss a Python3-specific mod_wsgi package or some other neater solution? If I am truly forced to recompile -- as reversing the Python 3 is really undesirable at this point -- is there any reason Fedora couldn't have two mod_wsgi packages (one for Python2 and another for Python3)?
-- John Florian
----- Original Message -----
I naively ported my Django app to Python 3 and didn't realize WSGI was going to be an issue. I saw python3-django was available for Fedora 20 and thought I was all set until I saw in my httpd logs that python2.7 seems to be the assumed default for mod_wsgi. After reading the README and more, I see the writing on the wall:
""" If you have multiple versions of Python installed and you are not using that which is the default, you may have to organise that the PATH inherited by the Apache application when run will result in Apache finding the alternate version. Alternatively, the WSGIPythonHome directive should be used to specify the exact location of the Python installation corresponding to the version of Python compiled against. If this is not done, the version of Python running within Apache may attempt to use the Python modules from the wrong version of Python. """
I take this to mean that merely fiddling with WSGIPythonHome alone will be insufficient and that I would need to recompile the package. Is that correct, or did I miss a Python3-specific mod_wsgi package or some other neater solution? If I am truly forced to recompile -- as reversing the Python 3 is really undesirable at this point -- is there any reason Fedora couldn't have two mod_wsgi packages (one for Python2 and another for Python3)?
AFAIK you can't have 2 mod_wsgi's, each one compiled against a different Python major.minor, loaded by Apache at the same time for various reasons. So the best solution would IMO be to create python3-mod_wsgi (subpackage of mod_wsgi), that would conflict with mod_wsgi. It should be perfectly doable and it shouldn't break anything. CCing Matthias, the owner of mod_wsgi in Fedora - Matthias, what do you think?
Regards, Slavek
-- John Florian
On Mon, Apr 14, 2014 at 04:54:33PM -0400, Bohuslav Kabrda wrote:
AFAIK you can't have 2 mod_wsgi's, each one compiled against a different Python major.minor, loaded by Apache at the same time for various reasons. So the best solution would IMO be to create python3-mod_wsgi (subpackage of mod_wsgi), that would conflict with mod_wsgi. It should be perfectly doable and it shouldn't break anything. CCing Matthias, the owner of mod_wsgi in Fedora - Matthias, what do you think?
This is done in f21 already thanks to Jakub Dorňák (#1035876) - I guess we could backport to f20 without any problems.
Regards, Joe
From: jorton@redhat.com Date: 04/15/2014 07:08 Subject: Re: Python 3 and mod_wsgi
On Mon, Apr 14, 2014 at 04:54:33PM -0400, Bohuslav Kabrda wrote:
AFAIK you can't have 2 mod_wsgi's, each one compiled against a different Python major.minor, loaded by Apache at the same time for various reasons.
Makes sense.
So the best solution would IMO be to create python3-mod_wsgi (subpackage of mod_wsgi), that would conflict with mod_wsgi.
Seems reasonable.
This is done in f21 already thanks to Jakub Dorňák (#1035876) - I guess we could backport to f20 without any problems.
That would be extremely helpful here, especially given that f21 is still a ways off.
-- John Florian
On 04/15/2014 01:08 PM, Joe Orton wrote:
On Mon, Apr 14, 2014 at 04:54:33PM -0400, Bohuslav Kabrda wrote:
AFAIK you can't have 2 mod_wsgi's, each one compiled against a different Python major.minor, loaded by Apache at the same time for various reasons. So the best solution would IMO be to create python3-mod_wsgi (subpackage of mod_wsgi), that would conflict with mod_wsgi. It should be perfectly doable and it shouldn't break anything. CCing Matthias, the owner of mod_wsgi in Fedora - Matthias, what do you think?
This is done in f21 already thanks to Jakub Dorňák (#1035876) - I guess we could backport to f20 without any problems.
Sorry for jumping in so late here, I'm currently on PTO and nearly excluded from the net.
To the question: yes, there is already a patch for f21 and it makes sense to backport it. There's also a bz ticket requesting exactly that[1]. I also saw Toshios additions and his bz ticket[2] to track the conflicts issue.
I simply didn't found the time to do so, but will look onto that, when I'm back. If anyone wants to do this earlier, please go ahead!
Best, Matthias
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1082109 [2] https://bugzilla.redhat.com/show_bug.cgi?id=1087943
On Mon, Apr 14, 2014 at 04:54:33PM -0400, Bohuslav Kabrda wrote:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
I naively ported my Django app to Python 3 and didn't realize WSGI was going to be an issue. I saw python3-django was available for Fedora 20 and thought I was all set until I saw in my httpd logs that python2.7 seems to be the assumed default for mod_wsgi. After reading the README and more, I see the writing on the wall: """ If you have multiple versions of Python installed and you are not using that which is the default, you may have to organise that the PATH inherited by the Apache application when run will result in Apache finding the alternate version. Alternatively, the WSGIPythonHome directive should be used to specify the exact location of the Python installation corresponding to the version of Python compiled against. If this is not done, the version of Python running within Apache may attempt to use the Python modules from the wrong version of Python. """ I take this to mean that merely fiddling with WSGIPythonHome alone will be insufficient and that I would need to recompile the package. Is that correct, or did I miss a Python3-specific mod_wsgi package or some other neater solution? If I am truly forced to recompile -- as reversing the Python 3 is really undesirable at this point -- is there any reason Fedora couldn't have two mod_wsgi packages (one for Python2 and another for Python3)?
AFAIK you can't have 2 mod_wsgi's, each one compiled against a different Python major.minor, loaded by Apache at the same time for various reasons. So the best solution would IMO be to create python3-mod_wsgi (subpackage of mod_wsgi), that would conflict with mod_wsgi. It should be perfectly doable and it shouldn't break anything. CCing Matthias, the owner of mod_wsgi in Fedora - Matthias, what do you think?
It's available in rawhide already and uses the conflicts that you outline: http://koji.fedoraproject.org/koji/buildinfo?buildID=493296 https://bugzilla.redhat.com/show_bug.cgi?id=1007002
However, conflicts aren't the correct strategy here.
Instead, take a look at how the python26-mod_wsgi package is implemented for epel5. The two mod_wsgi packages should be parallel installable. But the apache config files should prevent both from being loaded into a single apache process. Here's the config file for the python26-mod_wsgi package as a example of this:
# NOTE: By default python26-mod_python with not load if mod_wsgi is # installed and enabled. Only load if mod_python and mod_wsgi are not # already loaded.
<IfModule !wsgi_module> LoadModule wsgi_module modules/python26-mod_wsgi.so </IfModule>
We should probably have a similar guard in the mod_wsgi config file as well. Then be sure that we consciously name the conf files so that we are promoting one of these as the default (because sort order will load one of them before the other) if both packages are installed.
Having both packages be parallel installable makes it easier for people who are willing to configure apache to start two separate instances of apache. The two instances could each run a different version of mod_wsgi by adding the correct mod_wsgi config for each.
Bug filed: https://bugzilla.redhat.com/show_bug.cgi?id=1087943
-Toshio
On Tue, Apr 15, 2014 at 09:21:50AM -0700, Toshio Kuratomi wrote:
We should probably have a similar guard in the mod_wsgi config file as well. Then be sure that we consciously name the conf files so that we are promoting one of these as the default (because sort order will load one of them before the other) if both packages are installed.
I agree about the Conflicts, and it would be better to use the numeric prefix to guarantee the sort order.
It is a little ugly to have both modules installed but to silently disable one, though the Python version does get logged at startup so it is reasonably obvious which was selected. It might be nice to have a run-time warning or debug message for that case, but I can't think of a way to do that.
Regards, Joe