| Works
Pythonの"easy_install"について
自分用のMercurialサーバを構築するときに、MercurialやPygmentsは"easy_install"を使ってインストールしました。
使っていく中では当然アップデート等をしていくのですが、その度にやり方を忘れてしまってネットで調べたりしているのでメモしておきます。
- "easy_install"自体のインストール方法
- "easy_install"でパッケージをインストール
- "easy_install"でインストールしたパッケージの一覧
- "easy_install"でインストールしたパッケージのアップデート
- "easy_install"でインストールしたパッケージのアンインストール
これくらい分かっていればとりあえずは困らないかな?
環境はCentOS 6を想定しています。
1. "easy_install"自体のインストール方法
"easy_install"を使用するために以下のCentOSパッケージを追加します。
# yum install -y gcc python-devel python-setuptools
これで"easy_install"が使えるようになります。
2. "easy_install"でパッケージをインストール
# easy_install <パッケージ名>
3. "easy_install"でインストールしたパッケージの一覧
"/usr/lib/python2.6/site-packages/easy-install.pth"ファイルに記述されています。("python2.6"の部分はPythonバージョンによって異なる)
自分のMercurialサーバでは以下のような内容でした。"~.egg"がパッケージですね。
import sys; sys.__plen = len(sys.path)
./mercurial-3.2.1-py2.6-linux-i686.egg
./Pygments-2.0.1-py2.6.egg
import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)
4. "easy_install"でインストールしたパッケージのアップデート
# easy_install -U <パッケージ名>
5. "easy_install"でインストールしたパッケージのアンインストール
# easy_install -m <パッケージ名>
これだけだとパッケージのファイルは消えないので、"/usr/lib/python2.6/site-packages/<パッケージ>.egg"は個別に削除する。
ついでに"easy_install"のヘルプ
Global options:
--verbose (-v) run verbosely (default)
--quiet (-q) run quietly (turns verbosity off)
--dry-run (-n) don't actually do anything
--help (-h) show detailed help message
Options for 'easy_install' command:
--prefix installation prefix
--zip-ok (-z) install package as a zipfile
--multi-version (-m) make apps have to require() a version
--upgrade (-U) force upgrade (searches PyPI for latest
versions)
--install-dir (-d) install package to DIR
--script-dir (-s) install scripts to DIR
--exclude-scripts (-x) Don't install scripts
--always-copy (-a) Copy all needed packages to install dir
--index-url (-i) base URL of Python Package Index
--find-links (-f) additional URL(s) to search for packages
--delete-conflicting (-D) no longer needed; don't use this
--ignore-conflicts-at-my-risk no longer needed; don't use this
--build-directory (-b) download/extract/build in DIR; keep the
results
--optimize (-O) also compile with optimization: -O1 for
"python -O", -O2 for "python -OO", and -O0 to
disable [default: -O0]
--record filename in which to record list of installed
files
--always-unzip (-Z) don't install as a zipfile, no matter what
--site-dirs (-S) list of directories where .pth files work
--editable (-e) Install specified packages in editable form
--no-deps (-N) don't install dependencies
--allow-hosts (-H) pattern(s) that hostnames must match
--local-snapshots-ok (-l) allow building eggs from local checkouts
--version print version information and exit
usage: easy_install [options] requirement_or_url ...
or: easy_install --help