CentOSにPyPyをインストールしたときのメモ
CentOSにPyPyをインストールするためにいろいろ試行錯誤した結果、epelリポジトリから落として来れば十分だったのでメモを残しておきます。
ソース落としてきてコンパイルすればいいのですが、挑戦する型方は、メモリも時間もかなり消費するので覚悟しておきましょう。
要約
ログだらけで本文が長かったので必要なコマンドのみ列挙します。rpmパッケージをepelレポジトリからダウンロードしてくるだけです。
# yum --enablerepo=epel,rpmforge,remi search pypy
# yum --enablerepo=epel,rpmforge,remi info pypy
# yum --enablerepo=epel install pypy
# yum --enablerepo=epel install pypy-devel
試行錯誤
PyPyのページからDownloadする方法を以下の二通り試しました。
- ライブラリのバージョンが合わず断念しました
- PyPy - Downloadの2.2.1にあるSource (tar.bz2)のソースからコンパイル
- メモリと時間のどちらも足らず断念しました
そこで、リポジトリからrpmパッケージを探すことにしました。
リポジトリからのインストール
CentOSのバージョンを確認
一応CentOSのバージョンを確認しておきます。
# cat /etc/redhat-release
CentOS release 6.5 (Final)
yum searchコマンドでPyPyを探す
--enablerepoオプションで、epel, rpmforge, remiリポジトリから探すように指定してyum searchしました。
そもそもリポジトリを追加していない場合は以下の記事を参考に追加してください。
# yum --enablerepo=epel,rpmforge,remi search pypy
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* epel: ftp.jaist.ac.jp
* extras: ftp.iij.ad.jp
* remi: remi.kazukioishi.net
* rpmforge: ftp.kddilabs.jp
* updates: ftp.iij.ad.jp
=================================================================== N/S Matched: pypy ===================================================================
pypy-devel.i686 : Development tools for working with PyPy
pypy-devel.x86_64 : Development tools for working with PyPy
pypy-libs.x86_64 : Run-time libraries used by PyPy implementations of Python
pypy.x86_64 : Python implementation with a Just-In-Time compiler
Name and summary matches only, use "search all" for everything.
yum infoコマンドでリポジトリやその他情報の確認
yum searchでは、どのリポジトリにPyPyがあるのかわからないので、yum infoで特定します。ついでにバージョンも確認しておきます。
# yum --enablerepo=epel,rpmforge,remi info pypy
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* epel: ftp.jaist.ac.jp
* extras: ftp.iij.ad.jp
* remi: remi.kazukioishi.net
* rpmforge: ftp.kddilabs.jp
* updates: ftp.iij.ad.jp
Available Packages
Name : pypy
Arch : x86_64
Version : 2.0.2
Release : 1.el6
Size : 7.3 M
Repo : epel
Summary : Python implementation with a Just-In-Time compiler
URL : http://pypy.org/
License : MIT and Python and UCD
Description : PyPy's implementation of Python, featuring a Just-In-Time compiler on some CPU
: architectures, and various optimized implementations of the standard types
: (strings, dictionaries, etc)
:
:
: This build of PyPy has JIT-compilation enabled.
yum installコマンドでインストール
ここまでの情報によると、epelリポジトリにpypyがあるので、--enablerepoにepelを指定してインストールします。
# yum --enablerepo=epel install pypy
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* epel: ftp.jaist.ac.jp
* extras: ftp.iij.ad.jp
* updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package pypy.x86_64 0:2.0.2-1.el6 will be installed
--> Processing Dependency: pypy-libs = 2.0.2-1.el6 for package: pypy-2.0.2-1.el6.x86_64
--> Running transaction check
---> Package pypy-libs.x86_64 0:2.0.2-1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================================================================================
Package Arch Version Repository Size
=========================================================================================================================================================
Installing:
pypy x86_64 2.0.2-1.el6 epel 7.3 M
Installing for dependencies:
pypy-libs x86_64 2.0.2-1.el6 epel 5.0 M
Transaction Summary
=========================================================================================================================================================
Install 2 Package(s)
Total download size: 12 M
Installed size: 70 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): pypy-2.0.2-1.el6.x86_64.rpm | 7.3 MB 00:01
(2/2): pypy-libs-2.0.2-1.el6.x86_64.rpm | 5.0 MB 00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------
Total 4.6 MB/s | 12 MB 00:02
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
Installing : pypy-libs-2.0.2-1.el6.x86_64 1/2
Installing : pypy-2.0.2-1.el6.x86_64 2/2
Verifying : pypy-2.0.2-1.el6.x86_64 1/2
Verifying : pypy-libs-2.0.2-1.el6.x86_64 2/2
Installed:
pypy.x86_64 0:2.0.2-1.el6
Dependency Installed:
pypy-libs.x86_64 0:2.0.2-1.el6
Complete!
develも入れる
develも一応入れておきましょう。
# yum --enablerepo=epel install pypy-devel
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* epel: ftp.jaist.ac.jp
* extras: ftp.iij.ad.jp
* remi: remi.kazukioishi.net
* rpmforge: ftp.kddilabs.jp
* updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package pypy-devel.x86_64 0:2.0.2-1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================================================================================
Package Arch Version Repository Size
=========================================================================================================================================================
Installing:
pypy-devel x86_64 2.0.2-1.el6 epel 35 k
Transaction Summary
=========================================================================================================================================================
Install 1 Package(s)
Total download size: 35 k
Installed size: 88 k
Is this ok [y/N]: y
Downloading Packages:
pypy-devel-2.0.2-1.el6.x86_64.rpm | 35 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : pypy-devel-2.0.2-1.el6.x86_64 1/1
Verifying : pypy-devel-2.0.2-1.el6.x86_64 1/1
Installed:
pypy-devel.x86_64 0:2.0.2-1.el6
Complete!
動作確認
Hello World
定番のHello Worldを実行します。
$ pypy
Python 2.7.3 (f66246c46ca30b26a5c73e4cc95dd6235c966b8f, Jul 30 2013, 09:27:06)
[PyPy 2.0.2 with GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>> print("Hello World")
Hello World
表示されました。
実行時間の比較。
CPythonとPyPyの実行時間の比較で使った関数で実行時間を比較します。
CPython
>>> rangelist = range(1,10000000)
>>> print reduce(lambda x, y: x + y, [testfunc1(rangelist) for temp in range(10)])/10
0:00:01.717502
>>> print reduce(lambda x, y: x + y, [testfunc2(rangelist) for temp in range(10)])/10
0:00:01.183652
>>> print reduce(lambda x, y: x + y, [testfunc3(rangelist) for temp in range(10)])/10
0:00:00.734407
PyPy
>>> rangelist = range(1,10000000)
>>> print reduce(lambda x, y: x + y, [testfunc1(rangelist) for temp in range(10)])/10
0:00:01.017655
>>> print reduce(lambda x, y: x + y, [testfunc2(rangelist) for temp in range(10)])/10
0:00:00.983054
>>> print reduce(lambda x, y: x + y, [testfunc3(rangelist) for temp in range(10)])/10
0:00:00.250842
PyPyでの実行時間はCPythonに比べてかなり短くなりました。