Pypiからパッケージ情報を入手してください。要件ファイルを変更します。
依存関係をアップグレードして最新のバージョンを取得するときに、Pypiページを非常に頻繁にチェックしています。私は本質的に怠zyで、ターミナルの窓からお尻を取り除きたくありませんでした。
ここには本当の魔法はありません。 requestsパッケージを使用して、Public 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 --addBashが解析するのを防ぐために、それを二重に引用する必要があることに注意してください。
$ 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.