setup.py install_require 带选项 [英] setup.py install_require with options

查看:59
本文介绍了setup.py install_require 带选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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

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

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

推荐答案

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

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

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

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

这篇关于setup.py install_require 带选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆