end0tknr's kipple - 新web写経開発

http://d.hatena.ne.jp/end0tknr/ から移転します

fedora10 on colinuxにpython v2.7.3をsrcからinstall

dotCloudのcliツールのインストールで、python環境が必要になったものの、colinux(fedora10)にpre-installの /usr/bin/python 2.5.2が壊れているのか「yum install python-setuptools」がどうしても成功しないので、仕方なくv2.7.3をsrcからinstall。

前準備( zlib openssl)

zlib
$ su -
# yum install zlib zlib-devel

zlibがない場合、pythonのパッケージ管理ツールのinstall時に次のようなエラーとなります。

# /usr/local/bin/python ./ez_setup.py 
Downloading http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
Traceback (most recent call last):
  File "./ez_setup.py", line 278, in <module>
    main(sys.argv[1:])
  File "./ez_setup.py", line 212, in main
    from setuptools.command.easy_install import main
zipimport.ZipImportError: can't decompress data; zlib not available
openssl
$ wget http://www.openssl.org/source/openssl-1.0.1b.tar.gz
$ tar -zxvf openssl-1.0.1b.tar.gz 
$ cd openssl-1.0.1b
$ ./config --prefix=/usr/local/openssl
$ make
$ make test
$ su
# make install
# easy_install pip && sudo pip install dotcloud
<略>    
Downloading/unpacking dotcloud.cli==0.4.3 (from dotcloud)
  Downloading dotcloud.cli-0.4.3.tar.gz
  Running setup.py egg_info for package dotcloud.cli
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
      File "/home/endo/tmp/build/dotcloud.cli/setup.py", line 28, in <module>
        from cli import VERSION
      File "cli.py", line 30, in <module>
        import https
      File "https.py", line 23, in <module>
        import ssl
      File "/usr/local/lib/python2.7/ssl.py", line 60, in <module>
        import _ssl   # if we can't import it, let the error propagate
    ImportError: No module named _ssl
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 14, in <module>
  File "/home/endo/tmp/build/dotcloud.cli/setup.py", line 28, in <module>
    from cli import VERSION
  File "cli.py", line 30, in <module>
    import https
  File "https.py", line 23, in <module>
    import ssl
  File "/usr/local/lib/python2.7/ssl.py", line 60, in <module>
    import _ssl       # if we can't import it, let the error propagate
ImportError: No module named _ssl

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /home/endo/tmp/build/dotcloud.cli
Storing complete log in /root/.pip/pip.log
bzip2-devel

javascript engine v8のia32.releaseで次のようなerrorとなる為、「yum install bzip2-devel」でinstall

<略>
  AR(target) /home/endo/tmp/v8/out/ia32.release/obj.target/tools/gyp/libv8_base.a
  ACTION js2c_js2c /home/endo/tmp/v8/out/ia32.release/obj/gen/libraries.cc
Traceback (most recent call last):
  File "../../tools/js2c.py", line 36, in <module>
    import bz2
ImportError: No module named bz2
make[1]: *** [/home/endo/tmp/v8/out/ia32.release/obj/gen/libraries.cc] Error 1
make[1]: Leaving directory `/home/endo/tmp/v8/out'
make: *** [ia32.release] Error

configure

Modules/Setup で zlibを有効にすると、なぜかmake testでエラーとなった為、--with-threads を追加しています。

$ wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
$ tar -zxvf Python-2.7.3.tgz
$ cd Python-2.7.3
[Python-2.7.3]$ ./configure --with-threads
$ make test
<略>
test_threading_local
test test_threading_local failed -- Traceback (most recent call last):
  File "/home/endo/tmp/Python-2.7.3/Lib/test/test_threading_local.py", line 25, in test_local_refs
    self._local_refs(50)
  File "/home/endo/tmp/Python-2.7.3/Lib/test/test_threading_local.py", line 42, in _local_refs
    self.assertIn(len(deadlist), (n-1, n))
AssertionError: 48 not found in (49, 50)
<略>
343 tests OK.
1 test failed:
    test_threading_local
45 tests skipped:
    test_aepack test_al test_applesingle test_bsddb test_bsddb185
    test_bsddb3 test_bz2 test_cd test_cl test_codecmaps_cn
    test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr
    test_codecmaps_tw test_curses test_dbm test_gdb test_gdbm test_gl
    test_imgfile test_kqueue test_linuxaudiodev test_macos
    test_macostools test_msilib test_ossaudiodev test_pep277
    test_scriptpackages test_smtpnet test_socketserver test_sqlite
    test_ssl test_startfile test_sunaudiodev test_tcl test_timeout
    test_tk test_ttk_guionly test_ttk_textonly test_unicode_file
    test_urllib2net test_urllibnet test_winreg test_winsound
    test_zipfile64
11 skips unexpected on linux2:
    test_bsddb test_bsddb3 test_bz2 test_dbm test_gdb test_gdbm
    test_ssl test_tcl test_tk test_ttk_guionly test_ttk_textonly
make: *** [test] Error 1

Modules/Setup の編集でinstallモジュール選択

[Python-2.7.3]$ vi Modules/Setup

###次の部分を変更します
### 214行目付近をuncomment & 編集
SSL=/usr/local/openssl
_ssl _ssl.c \
	-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
	-L$(SSL)/lib -lssl -lcrypto

### 463行目をuncomment
zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz

fedoraの場合 Lib/test/test_locale.py を編集

http://mail.python.org/pipermail/python-dev/2011-August/112721.html
https://bugzilla.redhat.com/show_bug.cgi?id=726536

fedoraの場合、トルコ語(Turkish)のlocaleにバグがあるらしく、make testで失敗します。次のurlを参考に test caseをskipして下さい。

http://hg.python.org/cpython/rev/68b5f87566fb
patchの内容(差分)

--- a/Lib/test/test_locale.py
+++ b/Lib/test/test_locale.py
@@ -1,4 +1,5 @@
 from test.support import run_unittest, verbose
+from platform import linux_distribution
 import unittest
 import locale
 import sys
@@ -391,6 +392,8 @@ class TestMiscellaneous(unittest.TestCas
         # crasher from bug #7419
         self.assertRaises(locale.Error, locale.setlocale, 12345)
 
+    @unittest.skipIf(linux_distribution()[0] == 'Fedora', "Fedora setlocale() "
+                     "bug: https://bugzilla.redhat.com/show_bug.cgi?id=726536")
     def test_getsetlocale_issue1813(self):
         # Issue #1813: setting and getting the locale under a Turkish locale
         oldlocale = locale.setlocale(locale.LC_CTYPE)

make testのエラー

$ make test
<略>
test_locale
test test_locale failed -- Traceback (most recent call last):
  File "/home/endo/tmp/Python-2.7.3/Lib/test/test_locale.py", line 409, in test_getsetlocale_issue1813
    locale.setlocale(locale.LC_CTYPE, loc)
  File "/home/endo/tmp/Python-2.7.3/Lib/locale.py", line 539, in setlocale
    return _setlocale(category, locale)
Error: unsupported locale setting
<略>
341 tests OK.
1 test failed:
    test_locale
47 tests skipped:
    test_aepack test_al test_applesingle test_bsddb test_bsddb185
    test_bsddb3 test_bz2 test_cd test_cl test_codecmaps_cn
    test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr
    test_codecmaps_tw test_curses test_dbm test_gdb test_gdbm test_gl
    test_gzip test_imgfile test_kqueue test_linuxaudiodev test_macos
    test_macostools test_msilib test_ossaudiodev test_pep277
    test_scriptpackages test_smtpnet test_socketserver test_sqlite
    test_ssl test_startfile test_sunaudiodev test_tcl test_timeout
    test_tk test_ttk_guionly test_ttk_textonly test_unicode_file
    test_urllib2net test_urllibnet test_winreg test_winsound
    test_zipfile64 test_zlib
13 skips unexpected on linux2:
    test_bsddb test_bsddb3 test_bz2 test_dbm test_gdb test_gdbm
    test_gzip test_ssl test_tcl test_tk test_ttk_guionly
    test_ttk_textonly test_zlib
make: *** [test] Error 1
[endo@colinux Python-2.7.3]$ 

./Lib/test/test_locale.pyを単体で実行した際のエラー

[Python-2.7.3]$ ./python ./Lib/test/test_locale.py
<略>
test_getsetlocale_issue1813 (__main__.TestMiscellaneous) ... ERROR
<略>
======================================================================
ERROR: test_getsetlocale_issue1813 (__main__.TestMiscellaneous)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./Lib/test/test_locale.py", line 409, in test_getsetlocale_issue1813
    locale.setlocale(locale.LC_CTYPE, loc)
  File "/home/endo/tmp/Python-2.7.3/Lib/locale.py", line 539, in setlocale
    return _setlocale(category, locale)
Error: unsupported locale setting

----------------------------------------------------------------------
Ran 40 tests in 0.010s

FAILED (errors=1)
Traceback (most recent call last):
  File "./Lib/test/test_locale.py", line 438, in <module>
    test_main()
  File "./Lib/test/test_locale.py", line 435, in test_main
    run_unittest(*tests)
  File "/home/endo/tmp/Python-2.7.3/Lib/test/test_support.py", line 1094, in run_unittest
    _run_suite(suite)
  File "/home/endo/tmp/Python-2.7.3/Lib/test/test_support.py", line 1077, in _run_suite
    raise TestFailed(err)
test.test_support.TestFailed: Traceback (most recent call last):
  File "./Lib/test/test_locale.py", line 409, in test_getsetlocale_issue1813
    locale.setlocale(locale.LC_CTYPE, loc)
  File "/home/endo/tmp/Python-2.7.3/Lib/locale.py", line 539, in setlocale
    return _setlocale(category, locale)
Error: unsupported locale setting

make 〜 make install

以上でpython 2.7.3は問題なく、インストールできます

$ make
$ make test
$ su
# make install

python-setuptools

http://docs.dotcloud.com/firststeps/install/ を参考にしましたが、「yum install python-setuptools」では上手くいかないので、次の通り

$ wget http://peak.telecommunity.com/dist/ez_setup.py
$ su
# /usr/local/bin/python ./ez_setup.py

dotCloud CLIツール

http://docs.dotcloud.com/firststeps/install/

$ su -
# easy_install pip && sudo pip install dotcloud

dotclundの初回起動時は、https://www.dotcloud.com/settings/ にある api keyの入力を忘れずに

$ dotcloud
Enter your api key (You can find it at http://www.dotcloud.com/account/settings):