在Snow Leopard上使用Python 2.5构建mod_wsgi

3 投票
1 回答
569 浏览
提问于 2025-04-16 03:05

我在使用随 Mac OS X Snow Leopard(10.6)自带的 Python 2.5。我设置了默认值:defaults write com.apple.versioner.python Version 2.5,通常情况下,我会得到 Python 2.5,这正是我想要的。

但是,当我尝试构建 mod_wsgi 时,这个设置似乎没有生效。我使用了 --with-python=/usr/bin/python2.5 这个选项来强制它使用 Python 2.5,但最终构建出来的共享库却引用了 Python 2.6 的库。

我还尝试过:

  • 在构建之前将 $VERSIONER_PYTHON_VERSION 设置为 2.5
  • 不使用 --with-python 选项

我看过一个类似的讨论,关于 StackOverflow 上的问题。与那个人不同,我使用的是 Mac OS X 自带的 Python,这应该可以与 mod_wsgi 构建过程中的 Frameworks 代码兼容。


以下是一些相关命令的输出。请注意最后的 otool -L 输出,它显示正在查找 Python 2.6 的框架目录。

$ make distclean
rm -rf .libs
rm -f mod_wsgi.o mod_wsgi.la mod_wsgi.lo mod_wsgi.slo mod_wsgi.loT
rm -f config.log config.status
rm -rf autom4te.cache
rm -f Makefile Makefile.in

$ ./configure --with-python=/usr/bin/python2.5
checking for apxs2... no
checking for apxs... /usr/sbin/apxs
checking Apache version... 2.2.14
configure: creating ./config.status
config.status: creating Makefile

$ make

  (compilation messages, no errors)

$ otool -L .libs/mod_wsgi.so
.libs/mod_wsgi.so:
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0)
    /System/Library/Frameworks/Python.framework/Versions/2.6/Python (compatibility version 2.6.0, current version 2.6.1)

1 个回答

2

试着在配置的时候使用 '--disable-framework' 这个选项。这样做会让链接 Python 库的时候用 -L/-l 的方式,而不是用框架的链接方式。这样做是必要的,因为我不知道怎么让框架链接使用一个不同于标记为 'Current' 的版本。

撰写回答