setup.py install_require with options

ぃ、小莉子 提交于 2020-01-14 12:35:56

问题


I need to add rjsmin to my dependencies via install_require in a setup.py.

rjsmin offers a way to disable the c-extension by using the --without-c-extensions switch like following

python setup.py install --without-c-extensions

I wonder, how to add this switch to the install_require string.


回答1:


You need to provide an --install-option or --global-option along with the requirement text.

You can refer the doc here




回答2:


I solved my problem of installing dependencies with global-options by sub-classing setuptools.command.install class and overriding its run() method, like following code -

from setuptools import setup
from setuptools.command.install import install
from subprocess import call


class CustomInstall(install):
    def run(self):
        install.run(self)
        call(['pip', 'install', 'pycurl', '--global-option=--with-nss'])

setup( ...
      cmdclass={
          'install': CustomInstall,
      },
)

Here, I am installing pycurl with global option --with-nss



来源:https://stackoverflow.com/questions/31805385/setup-py-install-require-with-options

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!