python - 来自 setup.py 的 dh_python2 版本化依赖项
问题描述
我正在使用dpkg-buildpackage构建 python 模块的 .deb 包。在setup.py我已经指定install_requires=['othermodule>=2.0']
但生成的控制文件没有指定版本。Depends: python (>= 2.7), othermodule,
dh_python 正在根据 setup.py 文件猜测需求。但是dh_python2的联机帮助页指出
(默认忽略版本要求)
但我无法设法将版本包含在控制文件中。问题是没有包含的版本, .deb 包被安装,但随后启动我得到的程序:
pkg_resources.DistributionNotFound: The 'othermodule>=2.0' distribution was not found and is required by ...
因为安装的版本小于2.0
我希望能够只指定一次依赖版本(例如在 setup.py 中)
[编辑:]
我在 pydist.py 中看到函数 load() 在绝对路径中搜索:
def load(dname='/usr/share/python/dist/', fname='debian/pydist-overrides',
fbname='/usr/share/python/dist_fallback'):
而不是在我的包结构所在的 ./debian 下。由于该软件包尚未安装(我正在构建它),因此找不到 pydist 文件。我错过了什么吗???
解决方案
如Pybuild wiki中所述:
dh_python2 和 dh_python3 将正确填写安装依赖项(分别通过 ${python:Depends} 和 ${python3:Depends} )
因此,如果您将${python:Depends}
在 debian/control 中使用,dh_python 将尝试将您的install_requires
from映射setup.py
到实际的 deb 依赖项。像这样使用它:
Depends: python (>= 2.7), ${misc:Depends}, ${python:Depends}
您还可以othermodule
像在 python 中一样为您的 debian/control 指定所需的版本:
Depends: python (>= 2.7), othermodule (>=2.0)
[编辑]
您可以pydist-overrides
在 debian 文件夹下放置一个文件,PEP386
用于强制 dh_python 在解析安装依赖项时包含版本信息。它使用与 .pydist 文件相同的语法:
OthermoduleName python-othermodule; PEP386
希望这可以帮助。
推荐阅读
- typescript - TypeScript:如何使用所有相同类型的属性对对象进行类型注释?(目的
大批 ) - rust - 如何将字符串连接到宏派生中的标识?
- android - 如何从 kotlin 协程中的函数返回 fusedLocationProviderClient().lastLocation 作为流
- flutter - Flutter - 有没有办法列出应用程序中的所有流
- symfony - Symfony flashbag 获得多次
- javascript - 翻译过程中元素沿css动画方向淡出
- regex - 替换字符串,从最后一次出现的字符开始
- python - 处理自动化警报
- node.js - nodejs中的跨线程同步
- javascript - 如何刷新 Angular 上的 Font Awesome 图标?