简体   繁体   English

使用 setup.py 的 extras_require 中定义的要求

[英]Use requirements defined in extras_require of setup.py

I have a library, which has a demo website.我有一个图书馆,里面有一个演示网站。 The setup.py for the library looks like this:库的 setup.py 如下所示:

setup(
    ...
    install_requires=[
        ...
    ],
    extras_require={
        "test": [
            ...
        ],
        "demo": [
            ...
        ]
    },
    ...
)

I run the demo on Heroku.我在 Heroku 上运行演示。 How do I tell heroku to do pip install -e .[demo] ?我如何告诉 heroku 做pip install -e .[demo]

My reading of the docs was somewhat fruitful.对文档的阅读有些收获。 I've added requirements.txt which does我添加了requirements.txt

# heroku needs this
-e .[demo]

But perhaps there is a better way?但也许有更好的方法? I'm aiming to solve this without creating a requirements.txt file.我的目标是在不创建 requirements.txt 文件的情况下解决这个问题。

I don't know about the extras_require , but if your issue is to adapt the requirements to the platform, you could try the following:我不知道extras_require ,但如果您的问题是使要求适应平台,您可以尝试以下操作:

First find a way to check inside setup.py if it runs on Heroku or not, see this SO question .首先找到一种方法来检查setup.py是否在 Heroku 上运行,请参阅此 SO 问题

And then you can use this strategy to adapt the install_requires variable of setuptools.setup to what you need on Heroku.然后你可以使用这个策略来调整setuptools.setupinstall_requires变量以适应你在 Heroku 上的需求。

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

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