中指定可选的依赖项

中指定可选的依赖项

本文介绍了在 pypi python setup.py 中指定可选的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 python 的 setup.py 中指定可选依赖项?

How do I specify optional dependencies in python's setup.py ?

这是我为我的开源库指定可选依赖项的尝试,但它似乎没有做太多事情.

Here's my stab at specifying an optional dependency for an open source library of mine but it doesn't seem to do much.

https://github.com/od-eon/django-cherrypy/blob/master/setup.py

特别是在这个片段中的extra_requires:

Specifically extra_requires in this snippet:

setup(
    name='django-cherrypy',
    version='0.1',
    packages=packages,
    license='LICENSE',
    description='cherrypy, running under django',
    long_description=open('README.md').read(),
    author='Calvin Cheng',
    author_email='[email protected]',
    install_requires=['cherrypy-wsgiserver'],
    extra_requires=['newrelic'],
    url='https://github.com/od-eon/django-cherrypy',
)

建议?

推荐答案

您输入的关键字不正确.它是extras_require,而它应该是一个字典.

You've got an incorrect keyword. It's extras_require, and it's supposed to be a dict.

setup(
    name="django-cherrypy",
    ...
    extras_require = {
        'mysterious_feature_x':  ["newrelic"]
    }
)

这篇关于在 pypi python setup.py 中指定可选的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 21:00