开发者

Can python projects depend on specific versions of python?

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.

  1. Is distutils2 the only way to specify this information for your project, and
  2. 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 pytho开发者_运维问答n-dateutil 2?


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 and easy_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 both python-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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜