setup.py:限制python解释器的允许版本 [英] setup.py: restrict the allowable version of the python interpreter

查看:402
本文介绍了setup.py:限制python解释器的允许版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个python库.不幸的是,我尚未将其更新为可与python 3一起使用.

I have a python library. Unfortunately I have not updated it to work with python 3 yet.

在我的setup.py中,我添加了

in its setup.py, I added

install_requires=['python<3'],

我的意图是不允许在python 3下安装/使用此软件包,因为我知道它目前还无法正常工作.我认为这不是正确的方法,因为pip然后尝试下载并安装python 2.7.3(已经安装了版本!).

My intent was to not allow this package to be installed / used under python 3, because I know it doesn't (yet) work. I don't think this is the right way to do it, because pip then tries to download and install python 2.7.3 (which is already the installed version!).

我应如何在特定范围的python解释器版本中指定我的库依赖项?我应该添加Programming Language :: Python :: 2 :: Only标签吗?这实际上会阻止在python 3下安装吗?如果我还想将最低版本限制为python 2.6怎么办?

How should I specify my library dependency on a particular range of python interpreter versions? Should I add a Programming Language :: Python :: 2 :: Only tag? Will this actually prevent installation under python 3? What if I also want to restrict the minimum version to python 2.6?

我希望可以在任何地方都可以使用的解决方案,但会选择仅在pip下可以使用的解决方案(并希望不会导致easy_install阻塞).

I'd prefer a solution that works everywhere, but would settle for one that only works in pip (and hopefully doesn't cause easy_install to choke).

推荐答案

As of version 9.0.1 pip will honor a new python_requires string, specifying the python version required for installation, eg:

setup(
    ...,
    python_requires=">=3.3"
)

有关更多详细信息,请参见此处.另请参见此答案.

See here for more details. See also this answer on SO.

这篇关于setup.py:限制python解释器的允许版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆