pywhchを作成
概要
easy_installなどで入ったコマンドの在り処を調べる。
% pywhich sphinx-build
#/usr/local/lib/python2.6/dist-packages/sphinx.py
動機
easy_installやpipで入ったコマンドが、どこで定義されたものなのかわからない。
% cat `which sphinx-build`
例えば、sphinx-buildはこんな感じ。
#!/usr/bin/python # EASY-INSTALL-ENTRY-SCRIPT: 'Sphinx==1.0.5','console_scripts','sphinx-build' __requires__ = 'Sphinx==1.0.5' import sys from pkg_resources import load_entry_point if __name__ == '__main__': sys.exit( load_entry_point('Sphinx==1.0.5', 'console_scripts', 'sphinx-build')() )
少しpkg_resources.pyを読んでみたところ、どこのファイルを参照しているのか分かりそうなので、それができるようなコマンドを書いた。
code
実はevalしちゃっている。もっと良い方法がありそう。