I seemingly tried everything and I failed to achieve to run Python in 32-bit mode.
So here is my situation:
I am running OSX 10.8. I developed CherryPy app that has to connect to Oracle 10g2 database. There is a well-known issue that prevent CX_Oracle to work in 64-bit, thus the requirement to run in 32.
<IfModule wsgi_module>
<Directory "/Library/WebServer/WSGI-Executables">
AllowOverride None
Options None FollowSymLinks
Order allow,deny
Allow from all
SetEnv CONFIG_PATH /Users/bioffe/src/Icap/trunk/cgi-bin
SetEnv ORACLE_HOME /Applications/ORACLE/instantclient_10_2
SetEnv TNS_ADMIN /Applications/ORACLE/instantclient_10_2
SetEnv LD_LIBRARY_PATH /Applications/ORACLE/instantclient_10_2
SetEnv DYLD_LIBRARY_PATH /Applications/ORACLE/instantclient_10_2
SetEnv VERSIONER_PYTHON_PREFER_32_BIT yes
</Directory>
WSGIPythonHome /usr/local/bin/python2.7-32
WSGIPythonPath /Library/WebServer/WSGI-Executables
WSGIScriptAlias /etc /Library/WebServer/WSGI-Executables/ETCConfWebApp.py
#WSGIDaemonProcess etc_config user=bioffe group=wheel threads=4 python_path=/Library/Python/2.7/site-packages/
ProxyPreserveHost On
SetEnv VERSIONER_PYTHON_PREFER_32_BIT yes
</IfModule>
App's code
@cherrypy.expose
def index(self):
result = ''
for key, value in os.environ.items():
result += key + '=' + value + '\r\n'
cherrypy.response.headers['Content-Type']= 'text/plain'
result += '*' * 10
result += '\rCurrent Dir = %s \r' % os.getcwd()
result += '__file__ = %s \r' % __file__
result += 'PID=%d \r' % os.getpid()
result += 'PPID=%d \r' % os.getppid()
result += 'UID=%d \r' % os.getuid()
import threading
th = threading.current_thread()
result += "ThreadID=%d name=%s \r" %(th.ident,th.name)
result += "ThreadPool Size=%d \r" %(cherrypy.server.thread_pool)
result += "ThreadPool Max Size=%d \r" %(cherrypy.server.thread_pool_max)
import sys
result += "%s \r" %(sys.version)
result += "%d \r" %(sys.maxint)
Output
PATH=/usr/bin:/bin:/usr/sbin:/sbin
**********
Current Dir = /Library/WebServer/WSGI-Executables
__file__ = /Library/WebServer/WSGI-Executables/ETCConfWebApp.py
PID=16170
PPID=16167
UID=70
ThreadID=140735313402208 name=MainThread
ThreadPool Size=10
ThreadPool Max Size=-1
2.7.1 (r271:86832, Jun 25 2011, 05:09:01)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)]
9223372036854775807 <- 64 bit, I want to see 32-bit's 2147483647
Here is what tried so far:
To force Python by setting environment variable
export VERSIONER_PYTHON_PREFER_32_BIT=yes
This one is ignored by WSGI_mod. os.environ contains only one PATH environment variable
To force Python by setting defaults value and make it accessible to _www(70) user.
defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
To create virtualenv and lipo thin i386 executable out of it
WSGIPythonHome /usr/local/bin/python2.7-32
To create thin executable into default python environment, didn't work.
To compile mod_wsgi link using python2.7-32's headers and *.sos.
Nothing works. I was wondering of someone could shed some light on this issue.
BONUS Q: I added
WSGIDaemonProcess etc_config user=bioffe group=wheel threads=4 python_path=/Library/Python/2.7/site-packages/
I see extra https process that is run with UID bioffe, however my app still being processed by httpd process with UID _www. How come my request is being processed by different httpd process ?
Have you read:
Also be aware SetEnv doesn't set environment variables. For mod_wsgi it sets per request environ variables which are passed in a dictionary to the WSGI application on each request. Thus, you cannot SetEnv to set process environment variables.
As to WSGIDaemonProcess, you likely are missing the required WSGIProcessGroup that needs to go with it.
Please ensure you are reading the mod_wsgi documentation on the official mod_wsgi site as such details are covered there.
You possibly have some other things wrong, but too hard to tell as no detail provided which would help to confirm that.