python 项目可以依赖于特定版本的 python 吗?
我有一个 python 项目,它依赖于另一个依赖 python-dateutil 的项目。当我尝试 python setup.py install
我的项目时,它解决了对 python-dateutil 2.0 的 dateutil 依赖关系,这在 python 2.x 上根本不起作用。我发现解决问题并使我的项目可安装的唯一方法是使我的项目直接依赖于 python-dateutil<2,即使它根本不直接使用 dateutil(如果其依赖项不存在) 't。
看起来 distutils2 / PEP 345 有一个 Requires-Python字段指定项目兼容的 python 版本。
- distutils2 是为您的项目指定此信息的唯一方法吗?
- pypi 或类似的东西是否能够利用此信息,这样如果我在 python 2.x 上安装项目,那么依赖项解析将忽略 python -dateutil 2?
I have a python project that depends on another project that depended on python-dateutil. When I tried to python setup.py install
my project, it resolved the dateutil dependency to python-dateutil 2.0, which doesn't work at all on python 2.x. The only way I found to fix the problem and make my project installable is to make my project directly depend on python-dateutil<2
, even though it doesn't directly use dateutil at all if its dependency doesn't.
It looks like distutils2 / PEP 345 has a Requires-Python field to specify which versions of python the project is compatible.
- Is distutils2 the only way to specify this information for your project, and
- Will pypi or something similar be able to make use of this information, so that if I'm installing a project on python 2.x, then the dependency resolution will ignore python-dateutil 2?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用 python-dateutil 也遇到了同样的问题。与作者进行了对该问题的一些讨论,但没有真正的解决方案。 pypi 上列出的 版本 是 1.5,但都是
pip
和easy_install
从 pypi 列表中抓取主页进行下载,并获取其中列出的 2.0 版本 (python3)。distutils2 中可能有一些东西可以解决这个问题,但这意味着 python-dateutil 和您的第 3 方库都必须更新其分发元数据以包括/使用此“需要 Python”信息。
我认为你最好的选择是做你已经在做的事情,并确保你的项目直接依赖于它。
I have had this same problem using python-dateutil. There is some discussion of the problem with it's author, but no real solution. The version listed on pypi is 1.5, but both
pip
andeasy_install
scrape the home page from the pypi listing for downloads and pickup up the 2.0 version (python3) that is listed there.There might be something in
distutils2
that could work around it, but it would mean that bothpython-dateutil
and your 3rd party library would have to update their distribution metadata to include/use this `Requires-Python' info.I think you're best option is to do what you have already been doing and make sure your project depends on it directly.