รับข้อมูลแพ็คเกจจาก 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โปรดทราบว่าคุณอาจให้คุณอ้างถึงสองครั้งเพื่อป้องกันไม่ให้ทุบตีแยกวิเคราะห์
$ 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.