python - 动态依赖项在 python setup.py 中如何工作?

标签 python dependencies setuptools setup.py

我的软件包有一些可选安装

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

设置函数定义了这个额外的内容,如下所示:

extras_require={
    'cmd': cmd_line_requirements,
},

入口点定义如下:

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] 选项安装包的情况下才会生成控制台脚本。 哪个 Threedigrid 产生

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

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

最佳答案

入口点始终会创建,但尝试在不带 [cmd] 的情况下运行脚本 thirdigrid 将导致 pkg_resources.DistributionNotFound 异常:

The 'Click' distribution was not found and is required by the application

关于python - 动态依赖项在 python setup.py 中如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49298594/

相关文章:

windows-phone-7 - Nuget 是否支持与特定平台相关的依赖项?

linux - 适用于 Linux 的可重现自定义分发构建系统

python - 如何使用 turtle 父类(super class)

python - 用 Python Mechanize 模块填充文本区域

python - jupyter lab 404错误如何解决

python - 当作为函数调用时,向 easy_install 添加额外的查找链接的正确方法是什么?

python - 依赖 setup.py 中的 git 仓库

java - 如何使用Runtime在java中调用python程序

java - Gradle:子模块中抛出的类错误没有这样的属性?

virtualenv - 为什么我 pip freeze 没有出现 setuptools 1.3.1?