easy_install を介してインストールされた、より新しいバージョンが利用可能なすべての Python ライブラリのレポートを取得する簡単な方法はありますか? 新しいライブラリには下位互換性のない変更が含まれている可能性があるため、既知のインストール済みライブラリのリストに対して単純に easy_install を再実行したくありません。リストを取得して、変更点をすばやく確認し、新しいリリースを調べて、競合する可能性のある変更を調べたいと思います。
1382 次
1 に答える
5
これは、ファイルをスキャンしてeasy-install.pth
、インストールされているパッケージの新しいバージョンのリストを印刷するための簡単なスクリプトです。利用可能な最新バージョンのみを表示するようにカスタマイズしたり(最大でparsed_version
)、出力形式を微調整したりすることができます。
#!/usr/bin/env python
import os, sys
from distutils import sysconfig
from pkg_resources import Requirement
from setuptools.package_index import PackageIndex
index = PackageIndex()
root = sysconfig.get_python_lib()
path = os.path.join(root, 'easy-install.pth')
if not os.path.exists(path):
sys.exit(1)
for line in open(path, 'rb'):
if line.startswith('import sys'):
continue
path = os.path.join(root, line.strip(), 'EGG-INFO', 'PKG-INFO')
if not os.path.exists(path):
continue
lines = [r.split(':', 1) for r in open(path, 'rb').readlines() if ':' in r]
info = dict((k.strip(), v.strip()) for k, v in lines)
print '%s %s updates..' % (info['Name'], info['Version'])
spec = Requirement.parse(info['Name'] + '>' + info['Version'])
index.find_packages(spec)
versions = set([
(d.parsed_version, d.version) for d in index[spec.key] if d in spec
])
if versions:
for _, version in sorted(versions):
print '\t', version
else:
print '\tnone'
使用法:
% easy_install networkx==1.3
% easy_install gdata==2.0.5
% ./pkgreport
networkx 1.3 updates..
1.4rc1
1.4
gdata 2.0.5 updates..
2.0.6
2.0.7
2.0.8
2.0.9
2.0.14
于 2011-05-13T05:39:04.740 に答える