确定哪些项目阻止您移植到python 3

caniusepython3的Python项目详细描述


这个脚本接受一组依赖项,然后计算出 其中的一个阻碍了您移植到python 3。

命令行/web用法

您可以通过多种方式指定依赖项:

caniusepython3 -r requirements.txt test-requirement.txt
caniusepython3 -m PKG-INFO
caniusepython3 -p numpy scipy ipython
# If your project's setup.py uses setuptools
# (note that setup_requires can't be checked) ...
python setup.py caniusepython3

脚本的输出将告诉您需要多少(隐式)依赖项 转换到python 3以便允许您进行相同的转换。它 还将列出哪些项目没有阻止其 转换,以便让他们启动到python 3的端口。

如果您喜欢Web界面,可以使用https://caniusepython3.comby 詹尼斯·莱德尔。

与您的测试集成

如果您想在测试中检查python 3的可用性,可以 使用caniusepython3.check()

defcheck(requirements_paths=[],metadata=[],projects=[]):"""Return True if all of the specified dependencies have been ported to Python 3.

    The requirements_paths argument takes a sequence of file paths to
    requirements files. The 'metadata' argument takes a sequence of strings
    representing metadata. The 'projects' argument takes a sequence of project
    names.

    Any project that is not listed on PyPI will be considered ported.
    """

然后,您可以将其集成到您的测试中,如下所示:

importunittestimportcaniusepython3classDependenciesOnPython3(unittest.TestCase):deftest_dependencies(self):# Will begin to fail when dependencies are no longer blocking you# from using Python 3.self.assertFalse(caniusepython3.check(projects=['ipython']))

对于更改日志,如何判断项目是否已被移植,以及 如何移植项目,请参见 project website

扩展pylint --py3k

Pylint1.4中,--py3k选项是 添加到linting工具以启用python 2/3的检查 不兼容(关闭所有其他检查)。虽然很棒, 这些支票有点保守,以便总是准确的。填补 用更严格的——尽管可能不准确的——跳棋检查, {TT4} $存在。在一切之上pylint --py3k 已经检查过,它会添加检查:

  1. 使用open()(在python3中,open()实际上是io.open()
  2. 没有前缀b/ufrom __future__ import unicode_literals

如果您想将检查器与pylint一起使用,可以将其添加到pylint中 配置文件,例如:

[MASTER]load-plugins=caniusepython3.pylint_checker

秘密,奖励功能

如果您想对脚本使用不同的名称, setuptools命令然后将环境变量CIU_ALT_NAME设置为 你想要另一个名字。reddit建议使用icanhazpython3

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Android改造响应不等于邮递员响应   bean的spring初始化失败;嵌套的例外是java。lang.IllegalArgumentException:Pointcut格式不正确:应为“')”   java在运行时传递可选的未知参数   java Android:无法使用密码保护条目   java无法从SimpleIntegerProperty转换为属性<Integer>   java Ibatis:有没有办法在sqlmap xml中的Ibatis resultmap子选择中添加行处理程序?   java如何使用ant脚本运行maven项目?   java如何在DesignGridLayout库中动态创建JButton值?   java JPA多事务管理器   java Eclipse RCP,为编辑器添加了一个新视图   从源文件夹导入时,不会显示Java图像   使用hadoop2设置java单节点集群。4.0与cygwin   java如何连接图像?   JavaJPQL:向数据库中已经存在的值添加一个int值