今天推薦一個(gè)github的開(kāi)源工具 pkgu,支持以表格形式展示當(dāng)前python環(huán)境下的有新版本的package的版本信息,并支持全部或部分更新這些已經(jīng)過(guò)期或者有新版的庫(kù)。
該工具目前還提供了 cache
功能,會(huì)將當(dāng)前python環(huán)境下的過(guò)期包信息保存在數(shù)據(jù)庫(kù)內(nèi),數(shù)據(jù)庫(kù)采用了python的 sqlite3
內(nèi)置數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù)文件保存在 ~/.cache/cache.db
下,并支持過(guò)期后重新執(zhí)行腳本獲取過(guò)期庫(kù)的數(shù)據(jù),然后覆蓋更新,默認(rèn)過(guò)期時(shí)間是 43200秒
。
支持windows、linux和macos,但是python版本要在python3.10(包括)及以上。
并且你可以在你的主python環(huán)境安裝它,它會(huì)被安裝在主python環(huán)境下的 bin
目錄內(nèi)。這樣,即使你在其他虛擬python環(huán)境下,也可以主動(dòng)發(fā)現(xiàn)當(dāng)前環(huán)境下的python路徑,并通過(guò)python -m pip
去發(fā)現(xiàn)當(dāng)前虛擬python環(huán)境下的安裝包信息。
安裝
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
主要參數(shù)說(shuō)明:
-
-a
: 開(kāi)啟異步更新, 默認(rèn)不開(kāi)啟 -
-d
: 設(shè)置cache.db
所在的位置, 默認(rèn)~/.cache/cache.db
-
-e
: 設(shè)置數(shù)據(jù)庫(kù)的過(guò)期時(shí)間, 默認(rèn) 43200 秒(12小時(shí)) -
--no-cache
: 是否開(kāi)啟緩存,如果不開(kāi)啟,每次都需要重新執(zhí)行去獲取過(guò)期庫(kù)的包。默認(rèn)不開(kāi)啟
檢查更新
╰─± 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
可以支持多選更新。文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-685459.html
? 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 installed 0 packages. 「」
通過(guò)上面看出,它可以很方便的使用,幫助我們平常查看哪些包需要更新,以及更新你所需要更新的一些包。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-685459.html
到了這里,關(guān)于python之pip更新開(kāi)源工具分享的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!