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.