whatsonpypi
1.0.0
從PYPI獲取包裝信息。修改您的需求文件。
我發現自己經常檢查PYPI頁面,主要是在升級依賴項以獲取最新版本時。我天生就很懶惰,不想把我的屁股從終端窗口上拿出來。
這裡沒有真正的魔術。它使用requests包來擊中公共PYPI REST API,解析JSON並顯示它。還有一些基本文件操作來修改需求文件。尷尬的簡單。
pip install whatsonpypi
在PYPI上找到有關包裝的信息
示例:
$ whatsonpypi django NAME Django LATEST VERSION 2.1.5 SUMMARY A high-level Python Web framework that encourages rapid development and clean, pragmatic design. PACKAGE URL https://pypi.org/project/Django/ AUTHOR Django Software Foundation LATEST RELEASES 2.2a1, 2.1rc1, 2.1b1, 2.1a1, 2.1.5
有關更多信息..
示例:
$ whatsonpypi django --more ...
版本特定的信息..
示例:
$ whatsonpypi django==2.1.4 --more ...
在瀏覽器選項卡中啟動項目的PYPI URL
示例:
$ whatsonpypi django --open
在瀏覽器選項卡中啟動項目的文檔URL
示例:
$ whatsonpypi django --docs
將軟件包添加到您的需求文件中。
示例:
$ whatsonpypi django --add默認情況下,它在當前工作目錄中搜索具有匹配
requirements*.txt文件,並將依賴關係添加到文件末尾。您可以更改文件名模式以搜索。該圖案可能包含簡單的殼式通配符。
$ whatsonpypi django --add --req-pattern " *.txt "如果有多個文件,您將看到一個提示符,允許您選擇應修改的文件。
如果您希望將依賴項添加到特定行中,請在其自己的行上提及評論
#wopp,該評論將被依賴性替換:例子:
在您的要求中執行此操作。 txt:
# Django django==2.1.5 # testing pytest==4.1.1 # wopp然後運行這個:
$ whatsonpypi pytest-runner --add會產生這個:
# Django django==2.1.5 # testing pytest==4.1.1 pytest-runner==4.2根據需要使用需求規格。
==,>=,<=或~=使用--ee,--ge,--le或--te。默認值為--ee:$ whatsonpypi pytest-runner --add --ge會產生這個:
# Django django==2.1.5 # testing pytest==4.1.1 pytest-runner>=4.2現有的依賴項將被較新版本替換。默認情況下,依賴項版本是最新的,除非明確指定:
$ whatsonpypi pytest-runner==4.1 --add請注意,您可能需要將其加倍引用,以防止Bash解析它。
$ whatsonpypi " pytest-runner>=4.1 " --add可選地,可以使用
--req-dir指定搜索需求文件的目錄。允許絕對路徑和相對路徑。必須是目錄。$ whatsonpypi pytest-runner==4.1 --add --req-dir /Users/Me/Documents/GitHub/project/requirements默認值(如果不提供)是運行命令的目錄(CWD)。
另外,您可以選擇在依賴項之前指定要添加的註釋。請注意,如果文件已經存在於文件中,則不會添加評論。
例如,運行以下操作:
$ whatsonpypi pytest-runner --add --comment ' testing '將添加此:
# testing pytest-runner==4.2
$ whatsonpypi --help
Usage: whatsonpypi [OPTIONS] PACKAGE
CLI tool to get package info from PyPI and/or manipulate requirements.
Example usages:
$ whatsonpypi django
Options:
-v, --version Show the version and exit.
-m, --more Flag to enable expanded output [required]
-d, --docs Flag to open docs or homepage of project
-o, --open Flag to open PyPI page
-a, --add Flag to enable adding of dependencies to requirement
files. By default, it searches for files with names
matching requirements*.txt in the current working
directory and adds the dependency to the end of the
file. If you want the dependency to be added to a
specific line, mention the comment '#wopp' on its own
line which will be replaced with the dependency.
Existing dependencies will be replaced with newer
versions. Dependency version by default is the latest
unless specified explicitly with 'whatsonpypi
package==version'. Directory to search for
requirement files can be specified with --req-dir
-r, --req-dir DIRECTORY Directory to search for requirement files. Only used
when --add is used. [default: .]
-p, --req-pattern TEXT Filename pattern for searching requirements files.
[default: requirements*.txt; required]
-c, --comment TEXT Comment to be added for the dependency when using
--add.
--ee use == when adding to requirements.
--le use <= when adding to requirements.
--ge use >= when adding to requirements.
--te use ~= when adding to requirements.
-h, --help Show this message and exit.