繁体   English   中英

setup.py install_require with options

[英]setup.py install_require with options

我需要在setup.py中通过install_requirerjsmin添加到我的依赖项中。

rjsmin提供了一种通过使用--without-c-extensions开关来禁用c扩展的方法,如下所示

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

我想知道,如何将此开关添加到install_require字符串。

通过对setuptools.command.install类进行子类化并覆盖其run()方法,我解决了使用global-options安装依赖项的问题,如下面的代码 -

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,
      },
)

在这里,我正在使用全局选项--with-nss安装pycurl

您需要提供--install-option--global-option以及需求文本。

你可以在这里参考文档

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM