LoginSignup
1
1

More than 5 years have passed since last update.

ThriftでPython3にコンパイルするまでの道のり

Last updated at Posted at 2016-11-23

Thriftがpython3に対応してなくね?と思ったので調べてみました。

https://issues.apache.org/jira/browse/THRIFT-1857
あれ? Issueは fixed, closed になっているがこれは…。

よくて見てみるとver 0.10.0では対応していますが、最新版のリリースが現状(2016/11/23現在)では0.9.3なので、python3にコンパイルできないと。
最新版をチェックアウトするしかなさそうですね…。

チェックアウト

git clone https://github.com/apache/thrift.git
git branch -a  //存在するbranchの確認
git checkout -b 0.10.0 remotes/origin/0.10.0

makeする時に必要になるものをInstall

ここの"Requirements for building from source"ってとこ全部
http://thrift.apache.org/docs/install/

sudo apt-get update
sudo apt-get install libboost-dev libboost-test-dev libboost-program-options-dev libboost-filesystem-dev libboost-thread-dev libevent-dev automake libtool flex bison pkg-config g++ libssl-dev

あとはREADME通りに

./bootstrap.sh
./configure
sudo make
sudo make install

動作確認

Thriftインストールの確認

thrift -version

"Thrift version 0.10.0"とプリントされたらインストールは成功です。

thrift -r --gen py test.thrift

無事"py-gen"のディレクトリが作成されました!
python3.5からimportもできました。

なんというか…python3への道はまだまだ遠いなと感じました。

補足

thriftpyというものを使ってもpython 3系に対応できるみたいです。
https://github.com/eleme/thriftpy

0.10.0のリリース版がいつ出るかは分かりませんが、python3にコンパイルすることだけが目的なら
使わなくてもいい気がするかなーとは個人的には思います。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1