【问题标题】:Is there somewhere an index of Py3k-only libraries?是否有仅 Py3k 库的索引?
【发布时间】:2011-02-09 17:56:30
【问题描述】:

我很好奇是否有只支持 Python 3 的重要库,因为似乎许多支持它的库也恰好支持 Python 2。

【问题讨论】:

    标签: python python-3.x


    【解决方案1】:

    不,没有这样的索引,但您可以根据 PyPI 上的分类器数据创建一个。

    您可以列出所有包含“Programming Language :: Python :: 3”或 Programming Language :: Python :: 3.0 或“Programming Language :: Python 3.1”但没有 Python 2 分类器的包.

    http://pypi.python.org/pypi?:action=browse&c=214

    XML 接口可能有用:

    http://wiki.python.org/moin/PyPiXmlRpc

    【讨论】:

      【解决方案2】:

      出现there isn't,所以我写了这个(with some help):

      #!/usr/bin/env python3
      
      import xmlrpc.client
      
      # PyPI classifiers for all Python 3 versions
      PY3 = [
          "Programming Language :: Python :: 3",
          "Programming Language :: Python :: 3.0",
          "Programming Language :: Python :: 3.1",
          "Programming Language :: Python :: 3.2",
          "Programming Language :: Python :: 3.3",
          "Programming Language :: Python :: 3.4",
      ]
      
      # PyPI classifiers for all Python 2 versions
      PY2 = [
          "Programming Language :: Python :: 2",
          "Programming Language :: Python :: 2.7",
          "Programming Language :: Python :: 2.6",
          "Programming Language :: Python :: 2.5",
          "Programming Language :: Python :: 2.4",
          "Programming Language :: Python :: 2.3",
      ]
      
      def main():
          client = xmlrpc.client.ServerProxy('http://pypi.python.org/pypi')
          # name[0] is package name
          # name[1] is package version
          py3names = [
              name[0] for classifier in PY3 for name in client.browse([classifier])
          ]
          py2names = [
              name[0] for classifier in PY2 for name in client.browse([classifier])
          ]
          py3only = [name for name in py3names if name not in py2names]
          template = "Python3-only packages: {} (of {})"
          print(template.format(len(py3only), len(set(py2names + py3names))))
      
      if __name__ == "__main__":
          main()
      

      【讨论】:

      • 当前输出:Python3-only packages: 2823 (of 14595)
      【解决方案3】:

      在 PyPI 中有一个 Programming Language :: Python :: 3 :: Only 分类器,只有 Python 3 的包应该使用它。但是,并非所有仅 Python 3 的软件包都配置了它。

      您可以使用此分类器过滤 PyPI 网站中的包:https://pypi.org/search/?c=Programming+Language+%3A%3A+Python+%3A%3A+3+%3A%3A+Only

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-06-11
        • 2016-11-08
        • 2012-03-30
        • 1970-01-01
        • 1970-01-01
        • 2021-05-18
        • 1970-01-01
        • 2016-08-19
        相关资源
        最近更新 更多