设置.py安装需要选项

2024-06-26 00:24:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要通过在设置.py. 在

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

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

我想知道,如何将这个开关添加到install_require字符串中。在


Tags: install方法字符串pysetupextensionsrequirewithout
2条回答

您需要在需求文本中提供 install-option global-option。在

你可以参考doc here

我解决了用global-options安装依赖关系的问题,方法是对setuptools.command.install类进行子分类并重写其run()方法,如下面的代码-

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

在这里,我使用全局选项pycurl安装{}

相关问题 更多 >