schrodinger 社が提供している open source 版は以下。
https://github.com/schrodinger/pymol-open-source
こちらのインストール手順に従う。
環境は mac
c++ のライブラリ
brew install glm
brew install freetype
ちょっと試すだけなのに、システム全体に入れなければならないのがツライ。
docker で、、、と思ったが、GUI アプリなのでそれはそれでツライと思って、システムにライブラリを入れることに。。
brew で後から削除することもできるし、、と思いつつ。
下記の条件で実行
- venv 環境を使う
- ビルド結果は ./build に配置する
python setup.py install --prefix=./build
補足
freetype はインストール済みなのに以下のエラーが出た。
clang++ -std=c++11 -D_PYMOL_LIBPNG -D_PYMOL_FREETYPE -D_PYMOL_VMD_PLUGINS -D_HAVE_LIBXML -D_PYMOL_NO_MSGPACKC -D_PYMOL_NO_MAIN -D_PYMOL_OSX -Iinclude -Icontrib/uiuc/plugins/include -Iov/src -Ilayer0 -Ilayer1 -Ilayer2 -Ilayer3 -Ilayer4 -Ilayer5 -Ibuild/generated -Icontrib/uiuc/plugins/molfile_plugin/src -I/Users/hnishi/work/pymol-open-source/.venv/include -I/Users/hnishi/.pyenv/versions/3.9.0/include/python3.9 -c -MMD layer1/View.cpp -o build/temp.macosx-10.15-x86_64-3.9/layer1/View.o -Werror=return-type -Wunused-variable -Wno-switch -Wno-narrowing -Wno-char-subscripts -O3 -fno-strict-aliasing
clang++ -std=c++11 -D_PYMOL_LIBPNG -D_PYMOL_FREETYPE -D_PYMOL_VMD_PLUGINS -D_HAVE_LIBXML -D_PYMOL_NO_MSGPACKC -D_PYMOL_NO_MAIN -D_PYMOL_OSX -Iinclude -Icontrib/uiuc/plugins/include -Iov/src -Ilayer0 -Ilayer1 -Ilayer2 -Ilayer3 -Ilayer4 -Ilayer5 -Ibuild/generated -Icontrib/uiuc/plugins/molfile_plugin/src -I/Users/hnishi/work/pymol-open-source/.venv/include -I/Users/hnishi/.pyenv/versions/3.9.0/include/python3.9 -c -MMD layer4/Cmd.cpp -o build/temp.macosx-10.15-x86_64-3.9/layer4/Cmd.o -Werror=return-type -Wunused-variable -Wno-switch -Wno-narrowing -Wno-char-subscripts -O3 -fno-strict-aliasing
layer1/TypeFace.cpp:25:10: fatal error: 'ft2build.h' file not found
#include <ft2build.h>
^~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang++' failed with exit code 1
下記の箇所にヘッダファイルは存在する。
$ ls /usr/local/Cellar/freetype/2.10.4/include/freetype2/ft2build.h
/usr/local/Cellar/freetype/2.10.4/include/freetype2/ft2build.h
clang++ の man を見て、include path を環境変数から追加してみる。
$ man clang++
C_INCLUDE_PATH, OBJC_INCLUDE_PATH, CPLUS_INCLUDE_PATH, OBJCPLUS_INCLUDE_PATH
These environment variables specify additional paths, as for CPATH, which
are only used when processing the appropriate language.
下記で無事に build が終了した。
CPLUS_INCLUDE_PATH=/usr/local/Cellar/freetype/2.10.4/include/freetype2 python setup.py install --prefix=./build
下記のエラー。
$ ./build/bin/pymol
Qt not available (pymol.Qt), using GLUT/Tk interface
Traceback (most recent call last):
File "/Users/hnishi/work/pymol-open-source/./build/lib/python3.9/site-packages/pymol/__init__.py", line 73, in <module>
sys.exit(pymol.launch(args))
File "/Users/hnishi/work/pymol-open-source/build/lib/python3.9/site-packages/pymol/__init__.py", line 429, in launch
_cmd.runpymol(None, block_input_hook)
NotImplementedError: compile with --glut
GUI を使うために Qt もしくは GLUT が必要みたい。
Qt not available (pymol.Qt), using GLUT/Tk interface
再度、下記のようにビルド
rm -rf build
CPLUS_INCLUDE_PATH=/usr/local/Cellar/freetype/2.10.4/include/freetype2 python setup.py install --glut --prefix=./build
下記で問題なく GUI が起動することを確認。
./build/bin/pymol
と思ったが、なぜか 左下にしか分子モデルがレンダリングされない。
$ ./build/bin/pymol
で以下のエラーが出ていた。
Traceback (most recent call last):
File "/Users/hnishi/work/pymol-open-source/build/lib/python3.9/site-packages/pmg_tk/__init__.py", line 27, in run
from .PMGApp import PMGApp
File "/Users/hnishi/work/pymol-open-source/build/lib/python3.9/site-packages/pmg_tk/PMGApp.py", line 20, in <module>
import Pmw
ModuleNotFoundError: No module named 'Pmw'
手順で下記のようにオプショナルでレガシーとあるので、Pmw は不要かと思ったのだけど。。。
Pmw (Python Megawidgets) (optional, for legacy GUI/plugins)
Pmw を有効にすれば直るかもしれない。しかし、今回は pymol を CUI で実行したいだけだったので、一旦ここまでとする。