简体   繁体   English

我应该在PyPI发布的软件包中测试不受支持的Django版本吗?

[英]Should I test for unsupported Django versions in PyPI published packages?

I have some packages on PyPI, some of which are actually used by others. 我在PyPI上有一些软件包,其中一些实际上已被其他人使用。

When I drop support for older Django versions, what is the best way to inform the user (apart from changelog/history file)? 当我不再支持较早的Django版本时,通知用户的最佳方法是什么(除了changelog / history文件之外)?

EDIT: I know about using install_requires in setup.py , but this would install Django if someone installs my package. 编辑:我知道在setup.py使用install_requires ,但是如果有人安装我的软件包,这将安装Django。 I think this is bad practice, a Django component should not install Django itself. 我认为这是一种不好的做法,Django组件不应安装Django本身。 Other package authors seem to agree with this (look at Django REST Framework), but not all (look at Django Debug Toolbar). 其他软件包作者似乎对此表示同意(请参阅Django REST Framework),但并非全部(请参阅Django Debug Toolbar)。

Should I explicitly make the app fail if Django version does not match? 如果Django版本不匹配,我是否应该明确使应用程序失败? Can I put this elegantly in setup.py (without forcing a Django install)? 我可以将它优雅地放在setup.py (不强制执行Django安装)吗? Other solutions (preferably best practices)? 其他解决方案(最好是最佳做法)? Input welcome! 欢迎输入!

You can specify your requirements in setup.py and requirements file. 您可以在setup.py和需求文件中指定需求。 Say, you are providing support for django versions greater than django 1.6. 假设您正在提供高于django 1.6的django版本的支持。

from distutils.core import setup

setup(
     ...
     install_requires = [
          'django>1.6'
     ],
)

You should add django>1.6 to your requirements file, too. 您也应该将django>1.6添加到您的需求文件中。

For further guidance, consult - documentation 有关更多指导,请参阅- 文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM