LoginSignup
1

More than 5 years have passed since last update.

OSXでjhbuildでビルドしたPythonを動くようにする

Last updated at Posted at 2015-05-24

背景

GTK+ Download: Mac OS Xを参考に
jhbuildでGimpをビルドした。

OSXでjhbuildでビルドしたPythonを動くようにする

普通に以下を行うと後で色々ハマる。

~/.local/bin/jhbuild build python

少なくとも、PATHは/bin:/usr/bin:/sbinのみで始めるのが吉。

Homebrewのopensslを使わない場合

PATHで/usr/local/binを抜いて、prefixで~/gtk/inst指定していても、

/usr/local/includeや/usr/local/libのopensslを検出してこれを使おうとしてしまうので、リンクを削除しておく。

brew unlink openssl

Homebrewのopensslを使う場合

Python自体は、Homebrewのopensslを使ったものを
作成して動かせるが、他のGtk+関連のライブラリをインストールしていく中では
かなり面倒な事が起きる。(というか起きたので、この方法はおすすめしない)

jhbuild shell

でシェルに入り、

pythonのconfigure実行時に

CFLAGS=-I/usr/local/opt/openssl/include LDFLAGS=-L/usr/local/opt/openssl/lib ./configure --prefix ~/gtk/inst --libdir ~/gtk/inst/lib --enable-shared

のように、CFLAGSとLDFLAGSを追加する。

pythonのリンクの設定を変更する

Python本体がAppleの純正のPythonのライブラリを参照する設定になっているので、
これをinstall_name_toolで変更する。

cd ~/gtk/inst/bin
install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python ~/gtk/inst/lib/libpython2.7.dylib python

この作業をしていないと起こる悲劇

  • openssl周りをクリアしていないと、import md5ができない
  • なにかのモジュールをインポートするとスレッドがどうのとエラーを吐き死ぬ。

関連投稿

関連記事

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