Skip to main content

一个命令行工具,帮助您找到支持您 requirements.txt 文件中所有库的 Python 版本

Project description

PyReqVer - Python 依赖版本检查工具

PyReqVer 是一个命令行工具,帮助您找到支持您 requirements.txt 文件中所有库的 Python 版本。它分析来自 PyPI 的每个包的兼容性信息,并确定支持所有依赖项的 Python 版本的交集。

功能特点

  • 分析 requirements.txt 文件中的包
  • 从 PyPI 获取 Python 版本兼容性数据
  • 识别所有包都支持的通用 Python 版本
  • 处理复杂的版本说明符和分类器
  • 提供清晰的输出,显示兼容的 Python 版本
  • 使用并发请求高效获取包信息

安装

从源代码安装

  1. 克隆或下载此仓库
  2. 安装依赖:
    pip install -r requirements.txt
    

使用 pip 安装(如果已发布)

pip install pyreqver

使用方法

基本用法

python main.py path/to/your/requirements.txt

示例:

python main.py requirements.txt

命令行参数

  • requirements: requirements.txt 文件的路径(必需)

输出示例

requests 可用版本: ['3.13', '3.12', '3.11', '3.10', '3.9', '3.8', '3.7', '3.6', '3.5', '2.7']
scikit-learn 可用版本: ['3.13', '3.12', '3.11', '3.10', '3.9', '3.8', '3.7', '3.6', '3.5']
pandas 可用版本: ['3.13', '3.12', '3.11', '3.10', '3.9', '3.8', '3.7', '3.6', '3.5', '2.7']
matplotlib 可用版本: ['3.13', '3.12', '3.11', '3.10', '3.9', '3.8', '3.7', '3.6', '3.5']
numpy 可用版本: ['3.13', '3.12', '3.11', '3.10', '3.9', '3.8', '3.7', '3.6', '3.5', '2.7']
--------------------------------------------------------------------------------
所有库支持的 Python 版本: ['3.13', '3.12', '3.11', '3.10', '3.9', '3.8', '3.7', '3.6', '3.5']

工作原理

  1. 解析依赖项:工具读取并解析 requirements.txt 文件以提取包名。
  2. 获取包信息:对于每个包,它查询 PyPI 的 JSON API 以获取有关可用版本及其 Python 版本兼容性的元数据。
  3. 分析兼容性:它检查两个兼容性信息来源:
    • 包元数据中的 requires_python 字段
    • 指示 Python 版本支持的包分类器
  4. 查找通用版本:它计算支持您 requirements 中所有包的 Python 版本的交集。
  5. 显示结果:工具显示每个包支持的 Python 版本,并突出显示与所有包兼容的版本。

技术细节

  • 使用 packaging 库处理版本说明符
  • 实现缓存以避免冗余 API 调用
  • 使用并发请求高效获取包信息
  • 处理各种边缘情况,如缺少包信息或不完整的元数据

依赖项

  • requests>=2.25.0:用于向 PyPI 发送 HTTP 请求
  • packaging>=21.0:用于解析版本说明符和处理版本比较

限制

  1. 需要互联网连接以从 PyPI 获取包信息
  2. 某些包可能没有明确的 Python 版本支持信息
  3. 结果基于包元数据,可能不反映实际的运行时兼容性
  4. 该工具检查声明的兼容性,而不是跨 Python 版本的实际功能

贡献

欢迎贡献!请随时提交 Pull Request。

许可证

本项目基于 MIT 许可证授权 - 有关详细信息,请参阅 LICENSE 文件。

注意事项

  1. 此工具需要互联网连接以从 PyPI 获取包信息
  2. 某些包可能没有明确的 Python 版本支持信息
  3. 结果仅供参考,请确保在所选 Python 版本上测试您的代码的兼容性
  4. 该工具可能无法正确处理使用非标准版本控制方案的包

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyreqver_cn-0.1.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyreqver_cn-0.1.0-py2.py3-none-any.whl (6.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pyreqver_cn-0.1.0.tar.gz.

File metadata

  • Download URL: pyreqver_cn-0.1.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for pyreqver_cn-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b89615636617bff1de6abdd470f655ee7d3bd0e4981a9454d52b197228709f4a
MD5 2d4eac5177525c1e259b33d1a0152070
BLAKE2b-256 0f1558b00833b14e44c1324e0501a7811d178f4bf5c414a14bdd1496f2824de5

See more details on using hashes here.

File details

Details for the file pyreqver_cn-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pyreqver_cn-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for pyreqver_cn-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b6eb4d7dac023fe8e9b3c07939a2143296953599dffe65060cfe4e88a3dcf8ed
MD5 3c35e25a28ea2425fe74d855c852c447
BLAKE2b-256 1810b65ed70b8e932793e829f7cf7d5b9dd2814a52b9a3da86d6fdbdeeba3cec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page