PEP426: http://legacy.python.org/dev/peps/pep-0426/#environment-markers
extras_require (dict) のキーに ”:” 以下で指定する。 “test:sys_platform==‘win32’” など。
環境が一致する場合に依存関係が使用される
書き方:
extras_require={ '': ['pep8'], # <= この行は無視されるので、こういうのはinstall_requiresに書く ':python_version=="2.7"': ['pyflakes'], ':python_version in "2.6,2.5"': ['that'], 'bucho': ['bucho'], 'bucho:python_version=="2.7"': ['six'], 'bucho:python_version!="2.7"': ['future'], }Markerに使える変数と値:
- python_version : '{0.major}.{0.minor}'.format(sys.version_info) => ‘2.7’
- python_full_version : ‘2.7.7’ とか ‘2.7.7rc1’ とか。
- sys_platform : sys.platform => ‘win32’
- platform_release : platform.release() => '13.3.0'
- platform_version : platform.version() => 'Darwin Kernel Version 13.3.0: Tue Jun 3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64'
- platform_machine : platform.machine() => 'x86_64'
- platform_python_implementation : platform.python_implementation() => 'CPython'
- implementation_name : sys.implementation.name => 'cpython'
- implementation_version : sys.implementation.version => (3, 3, 5, ‘final’, 0)
Markerとの比較に使える演算子:
- ==, !=, <, >, <=, >=, in, not in
- "bucho:python_version == ‘2.7’”
- "bucho:python_version != ‘2.7’”
- "bucho:python_version < ‘2.7’” # 動作していない(setuptools 0.7.2, 5.4.1)
- "bucho:python_version > ‘2.7’” # 動作していない(setuptools 0.7.2, 5.4.1)
- "bucho:python_version <= ‘2.7’” # 動作していない(setuptools 0.7.2, 5.4.1)
- "bucho:python_version >= ‘2.7’” # 動作していない(setuptools 0.7.2, 5.4.1)
- "bucho:python_version in ‘2.7,2.6’”
- "bucho:python_version not in ‘2.7,2.6’”
- setuptools 0.6c11 -> marker を認識, インストール無視
- distribute 0.6.1 -> markerを認識, インストール無視
- distribute 0.6.49 -> markerを認識, インストール無視
- setuptools 0.7.2 -> markerを認識, インストールOK
- setuptools 0.8 -> markerを認識, インストールOK
- setuptools 1.0 -> markerを認識, インストールOK
- setuptools 2.2 -> marker を認識, インストールOK
- setuptools 5.4.1 -> marker を認識, インストールOK
https://pypi.python.org/pypi/setuptools/0.7.3#id4 によると、0.6c12で実装されたようだ。 0.6c12はPyPIにアップロードされていなかったため、確認できなかった(リポジトリ探すの面倒)。
- setuptools : 0.6c12の一部と、0.7.2以降
- pip: 1.5.6 (2014/7/10最新版)時点で未対応
- wheel: 0.9.5 (2012/9/16) でsetup.cfg内で対応し、0.24.0 (2014//7/6) で extras_require での記述に移行しPEP426に準拠。