确定哪些项目阻止您移植到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如何在导入到Google工作表时使用ApachePOI显示系列标签   java在Swing表上修改数据生成SQL   java TCP数据包在网络级别合并   java自动连线bean在线程位置为空   javasocket。禁用无线连接时getOutputStream()阻塞   JSON上的javascript字符串数组。stringify输出unicode字符   java在Oracle数据库中存储不同类型数据的最佳体验   Spring MVC中模板引擎后的java进程输出   不知从哪里来的java空字符串。   如何加载java。使用Adobe Flex的客户端的属性文件?   java如何替换多层括号之间的所有内容?   {JSONObject必须以java'开头   java使用commandButton或commandLink返回并管理HTML控件值   java Android大文本视图动态   java JMock需要自定义类   java Android应用程序在emulator中工作,但在设备中失败   java连接到derby数据库时使用什么文件路径格式?   java在一个函数调用中返回两个结果?