الحصول على معلومات الحزمة من PYPI. تعديل ملفات المتطلبات الخاصة بك.
أجد نفسي أتحقق من صفحة PYPI بشكل متكرر في الغالب عند ترقية التبعيات للحصول على أحدث الإصدارات. أنا كسول بطبيعته ولا أرغب في إخراج مؤخرتي من نافذتي الطرفية.
لا يوجد سحر حقيقي هنا. يستخدم حزمة requests للضغط على API Pypi Rest Public ، وتوصيف 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 ...
قم بتشغيل عنوان URL لـ PYPI من Project في علامة تبويب المتصفح
أمثلة:
$ 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استخدام مواصفات المتطلبات حسب الحاجة.
==،>=،<=or~=use--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.