OS XでPython-3.0a5をビルド
そのままだとX-MAC-JAPANESEが無いと言われてモジュールのバイトコンパイル中(?)にエラーで止まってしまう。
X-MAC-JAPANESEはファイル名などに使うためのApple独自のUTF-8拡張だそうで、Pythonはこれを正しく取り扱えない模様。
http://weblog.metareal.org/2007/09/09/fixup-python-locale-problems-by-apple-darwin-patch/
これを参考にしてAppleから10.5.2版のパッチを落として当ててみたらビルドできた。
http://www.opensource.apple.com/darwinsource/10.5.2/python-30.1.2/
python-30.x.xと23.x.x、16.x.xという数種類のパッチ群があるが、それぞれ3.0、2.3、1.6ベースのパッチだと適当に予想。
python-30.x.xを落としてきたらうまくいったようだ。
以下パッチ。Python-3.0a5のトップフォルダに
patch -p1
して下さい。
diff -Naru Python-3.0a5.orig/Lib/locale.py Python-3.0a5/Lib/locale.py --- Python-3.0a5.orig/Lib/locale.py 2008-05-13 07:51:03.000000000 +0900 +++ Python-3.0a5/Lib/locale.py 2008-05-13 07:51:26.000000000 +0900 @@ -494,7 +494,7 @@ """ _setlocale(category, _build_localename(getdefaultlocale())) -if sys.platform in ('win32', 'darwin', 'mac'): +if sys.platform in ('win32', 'mac'): # On Win32, this will return the ANSI code page # On the Mac, it should return the system encoding; # it might return "ascii" instead diff -Naru Python-3.0a5.orig/Modules/_localemodule.c Python-3.0a5/Modules/_localemodule.c --- Python-3.0a5.orig/Modules/_localemodule.c 2008-05-13 07:51:10.000000000 +0900 +++ Python-3.0a5/Modules/_localemodule.c 2008-05-13 07:51:26.000000000 +0900 @@ -32,7 +32,7 @@ #include <wchar.h> #endif -#if defined(__APPLE__) +#if 0 #include <CoreFoundation/CoreFoundation.h> #endif @@ -353,7 +353,7 @@ } #endif -#if defined(__APPLE__) +#if 0 /* ** Find out what the current script is. ** Donated by Fredrik Lundh. @@ -631,7 +631,7 @@ {"strxfrm", (PyCFunction) PyLocale_strxfrm, METH_VARARGS, strxfrm__doc__}, #endif -#if defined(MS_WINDOWS) || defined(__APPLE__) +#if defined(MS_WINDOWS) || 0 {"_getdefaultlocale", (PyCFunction) PyLocale_getdefaultlocale, METH_NOARGS}, #endif #ifdef HAVE_LANGINFO_H