设为首页 加入收藏

TOP

简洁好用的python-pip包更新工具(一)
2023-09-09 10:25:44 】 浏览:136
Tags:简洁好 python-pip 包更新

今天推荐一个github的开源工具 pkgu,支持以表格形式展示当前python环境下的有新版本的package的版本信息,并支持全部或部分更新这些已经过期或者有新版的库。

该工具目前还提供了 cache 功能,会将当前python环境下的过期包信息保存在数据库内,数据库采用了python的 sqlite3 内置数据库,数据库文件保存在 ~/.cache/cache.db 下,并支持过期后重新执行脚本获取过期库的数据,然后覆盖更新,默认过期时间是 43200秒

支持windows、linux和macos,但是python版本要在python3.10(包括)及以上。

并且你可以在你的主python环境安装它,它会被安装在主python环境下的 bin 目录内。这样,即使你在其他虚拟python环境下,也可以主动发现当前环境下的python路径,并通过python -m pip 去发现当前虚拟python环境下的安装包信息。

安装

pip install pkgu

使用

╰─± pkgu -h
usage: pkgu [-h] [-a] [-d CACHE_FOLDER] [-e EXPIRE_TIME] [--no-cache] [-v]

Upgrade python lib.

options:
  -h, --help            show this help message and exit
  -a, --async_upgrade   Update the library asynchronously. Default: False
  -d CACHE_FOLDER, --cache_folder CACHE_FOLDER
                        The cache.db file. Default: ~/.cache/cache.db
  -e EXPIRE_TIME, --expire_time EXPIRE_TIME
                        The expiration time. Default: 43200
  --no-cache            Whether to use db cache. Default: False
  -v, --version         Display pkgu version and information

主要参数说明:

  • -a : 开启异步更新, 默认不开启
  • -d: 设置 cache.db 所在的位置, 默认 ~/.cache/cache.db
  • -e: 设置数据库的过期时间, 默认 43200 秒(12小时)
  • --no-cache: 是否开启缓存,如果不开启,每次都需要重新执行去获取过期库的包。默认不开启

检查更新

╰─± pkgu -a
(   ●  ) checking for updates...2023-08-30 22:21:39.869 | DEBUG    | pkgu:get_result_with_no_cache:622 - Origin result
+---------------+---------+----------------+-----------------+
|      Name     | Version | Latest Version | Latest FileType |
+---------------+---------+----------------+-----------------+
|      cfgv     |  3.3.1  |     3.4.0      |      wheel      |
|    distlib    |  0.3.6  |     0.3.7      |      wheel      |
|    filelock   |  3.9.0  |     3.12.3     |      wheel      |
|    identify   |  2.5.24 |     2.5.27     |      wheel      |
|      mock     |  4.0.3  |     5.1.0      |      wheel      |
|      pip      |  23.0.1 |     23.2.1     |      wheel      |
|  platformdirs |  3.0.0  |     3.10.0     |      wheel      |
|     pluggy    |  1.2.0  |     1.3.0      |      wheel      |
|    pydantic   |  2.2.1  |     2.3.0      |      wheel      |
| pydantic_core |  2.6.1  |     2.7.0      |      wheel      |
|    Pygments   |  2.15.1 |     2.16.1     |      wheel      |
|     pytest    |  6.2.5  |     7.4.0      |      wheel      |
|     PyYAML    |   6.0   |     6.0.1      |      wheel      |
|      ruff     | 0.0.277 |    0.0.286     |      wheel      |
|   setuptools  |  67.6.1 |     68.1.2     |      wheel      |
|   stevedore   |  5.0.0  |     5.1.0      |      wheel      |
|   virtualenv  | 20.20.0 |    20.24.3     |      wheel      |
|     wheel     |  0.40.0 |     0.41.2     |      wheel      |
+---------------+---------+----------------+-----------------+
continue with the package update?
> yes
  no
# 选择yes后
Update all packages listed above or portion of them?
  all
> portion

# 选择portion部分更新
Select one of these packages to update
  [ ] cfgv@3.3.1=>3.4.0
  [ ] distlib@0.3.6=>0.3.7
  [ ] filelock@3.9.0=>3.12.3
  [ ] identify@2.5.24=>2.5.27
  [*] mock@4.0.3=>5.1.0
  [ ] pip@23.0.1=>23.2.1
  [ ] platformdirs@3.0.0=>3.10.0
  [ ] pluggy@1.2.0=>1.3.0
  [ ] pydantic@2.2.1=>2.3.0
  [ ] pydantic_core@2.6.1=>2.7.0
  [ ] Pygments@2.15.1=>2.16.1
  [ ] pytest@6.2.5=>7.4.0
  [*] PyYAML@6.0=>6.0.1
> [*] ruff@0.0.277=>0.0.286
  [ ] setuptools@67.6.1=>68.1.2
  [ ] stevedore@5.0.0=>5.1.0
  [ ] virtualenv@20.20.0=>20.24.3
  [ ] wheel@0.40.0=>0.41.2
(Press "/" to search)
Press <space>, <tab> for multi-selection and <enter> to select and accept

可以支持多选更新。

? installing ruff, version: from 0.0.277 to 0.0.286...? installed PyYAML, version: from 6.0 to 6.0.1...
? installed mock, version: from 4.0.3 to 5.1.0...
? installed ruff, version: from 0.0.277 to 0.0.286...
------------------------------------------------------------
? Successfully installed 3 packages. 「mock, PyYAML, ruff」
? Unsuccessfully instal
首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇 Python的数据类型的内置方法 下一篇【matplotlib基础】--子图

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目