确定哪些项目阻止您移植到 Python 3
项目描述
** 注意 ** 此项目不再积极开发!
我可以使用 Python 3 吗?
该脚本接受一组依赖项,然后找出它们中的哪些阻碍了您移植到 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 界面,可以使用Jannis Leidel 的https://caniusepython3.com。
与您的测试集成
如果您想在测试中检查 Python 3 的可用性,可以使用caniusepython3.check():
def check(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.
"""
然后,您可以将其集成到您的测试中,如下所示:
import unittest
import caniusepython3
class DependenciesOnPython3(unittest.TestCase):
def test_dependencies(self):
# Will begin to fail when dependencies are no longer blocking you
# from using Python 3.
self.assertFalse(caniusepython3.check(projects=['ipython']))
有关更改日志,如何判断项目是否已被移植,以及如何移植项目的帮助,请参阅 项目网站。
扩展pylint --py3k
在Pylint 1.4 中,向 linting 工具添加了一个--py3k选项,以打开对 Python 2/3 不兼容性的检查(所有其他检查均已关闭)。虽然很棒,但为了始终准确,这些检查有点保守。为了使用更严格(尽管可能不准确)检查器填写这些检查, 存在caniusepython3.pylint_checker。除了pylint --py3k已经检查的所有内容之外 ,它还添加了以下检查:
open()的使用(在 Python3 中,open()实际上是io.open())
没有b / u前缀或 from __future__ import unicode_literals的字符串文字
如果您希望将检查器与 Pylint 一起使用,您可以将其添加到您的 Pylint 配置文件中,例如:
[MASTER]
load-plugins=<s>caniusepython3.pylint_checker</s>
秘密,奖金功能
如果您想为脚本和 setuptools 命令使用不同的名称,请将环境变量CIU_ALT_NAME设置为您希望的替代名称。Reddit 建议icanhazpython3。
项目详情
caniusepython3-7.3.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 58cb3b3643530bc955d3dc5fe49385ccd1f0d2677bf1d9b159814c0f5e677562 |
|
MD5 | 3f0204729c6ddf9228c31f4413eac642 |
|
布莱克2-256 | 69b2d1cf4440751eaa1a33bd6dbf8e5120aecd49a662ae9568c4203282d6af79 |
caniusepython3-7.3.0 -py2.py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 003d59386905809b7d83a7f093643f11f3003d1766560e02f61f2aa8d8c63d9e |
|
MD5 | a1be3a9f9e84e4680951aa928df185d5 |
|
布莱克2-256 | c903dd95687a4b1eb0c3396a3ab0cdd94cd784d79285b6eec83d01cdc7d8e823 |