extra_require实际上不应该以这种方式使用,它只指定依赖项.
如果你想提供一个自定义选项,你应该写这样的东西
from setuptools import setup
from setuptools.command.install import install
class InstallCommand(install):
user_options = install.user_options + [
('someopt',None,None),# a 'flag' option
('someval=',None) # an option that takes a value
]
def initialize_options(self):
install.initialize_options(self)
self.someopt = None
self.someval = None
def finalize_options(self):
super(InstallCommand,self).finalize_options()
assert self.someopt
assert self.someval == 'asdf'
setup(
name="pkg",cmdclass={
'install': InstallCommand,},)
然后可以用作
./setup.py install --someopt --someval=asdf
或者用pip
pip install pkg --install-option='--someopt' --install-option='--someval=asdf'