【问题标题】:how do dynamic dependencies work in python setup.py?python setup.py中的动态依赖如何工作?
【发布时间】:2018-08-24 05:07:17
【问题描述】:

我的包有一些可选安装

# for extra 'cmd'
cmd_line_requirements = [
    'Click>=6.0'
]

setup 函数这样定义这个额外的:

extras_require={
    'cmd': cmd_line_requirements,
},

entry_points 定义如下:

entry_points={
    'console_scripts': [
        'threedigrid=threedigrid.cli:main [cmd]',
    ],
},

当我使用 pip 安装包时

pip install --editable .

Click 没有安装,但我的threedigrid.egg.info 中的entry_points.txt 包含以下内容:

[console_scripts]
threedigrid = threedigrid.cli:main [cmd]

我对此感到有些困惑,因为我假设只有在使用指定的 [cmd] 选项安装软件包时才会生成控制台脚本。 which threedigrid 产量

/home/<>/.virtualenvs/grid_test/bin/threedigrid

我是否误解了动态依赖项的工作原理?

【问题讨论】:

  • 为什么投反对票?

标签: python dependencies setuptools setup.py


【解决方案1】:

入口点总是被创建,但尝试在没有[cmd] 的情况下运行脚本threedigrid 将导致pkg_resources.DistributionNotFound 异常:

未找到“点击”分布,应用程序需要此分布

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-26
    • 2021-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-09
    • 1970-01-01
    • 2021-01-14
    相关资源
    最近更新 更多