$ python setup.py build $ python setup.py install $ python setup.py sdist $ python setup.py register $ python setup.py upload
$ python setup.py bdist_egg $ python setup.py develop $ easy_install $ ez_setup.py
- distribute = better setuptools
- pip は easy_install に相当
$ pip install $ pip search $ pip freeze # インストール済みパッケージのリストを出力 $ pip uninstall # アンインストールもできる!
- distutils を改良したものが distutils2
- Python のバージョンによって呼び名が変わる
- Python 3.x => packaging (標準)
- Python 2.4-3.3 => distutils2 (サードパーティー)
$ pysetup search $ pysetup install $ pysetup list $ pysetup remove $ pysetup metadata $ pysetup create $ generate-setup $ pysetup run [ build | sdist | bdist | register | upload ]
- 新標準を実装
- PEP345: Metadata 1.2
- PEP376: インストール情報データベース
- PEP386: バージョン番号標準
- packaging の後継? → No
- packaging から派生した低レベルライブラリ → Yes
Distlib evolved out of packaging
Distlib is a library which implements low-level functions that relate to packaging and distribution of Python software. It consists in part of the functions in the packaging Python package, which was intended to be released as part of Python 3.3, but was removed shortly before Python 3.3 entered beta testing.
http://pythonhosted.org/distlib/overview.html
- egg に変わる新フォーマット
- wheel フォーマットを操作するためのライブラリやツールを集めたパッケージの名前でもある
- 新標準に対応
- PEP345: Metadata 1.2 (not requires.txt)
- PEP376: インストール情報データベース (dist-info)
Why not egg?
Python’s egg format predates the packaging related standards we have today, the most important being PEP 376 “Database of Installed Python Distributions” which specifies the .dist-info directory (instead of .egg-info) and PEP 345 “Metadata for Python Software Packages 1.2” which specifies how to express dependencies (instead of requires.txt in .egg-info).
Wheel implements these things. It also provides a richer file naming convention that communicates the Python implementation and ABI as well as simply the language version used in a particular package.
Unlike .egg, wheel will be a fully-documented standard at the binary level that is truly easy to install even if you do not want to use the reference implementation.
http://wheel.readthedocs.org/en/latest/
- entry points の代替手段
- egg と wheel は非互換
- 既存の egg から wheel にどれだけスムーズに移行が進むか
- pip が egg を扱えない
- バイナリパッケージをインストールできない
- wheel への移行で解決?
- packaging が Python 3.3 に入らなかった
- pip に wheel 対応コードがマージされた
- setuptools と distribute が統合される?
[参考]
Python プロフェッショナルプログラミング 7章
パーフェクト Python 12章
http://www.freia.jp/taka/docs/pyhack4/environments.html
http://www.slideshare.net/aodag/distutil-setuptools-distribute
http://www.slideshare.net/shimizukawa/python-packaging-pyfes-201203
http://guide.python-distribute.org/index.html
http://shimizukawa.bitbucket.org/python-distribute-ja/index.html