Generating a list of the top most packages that are installed to be written to a requirements.txt file

  Kiến thức lập trình

I’m working on a script to generate a requirements.txt file for compiling the top most packages that I have installed.

I’m not sure how to handle this to figure out what the package requires so I can remove it from the requirements.txt file.

from importlib.metadata import distribution

print(distribution('pytest').requires)
[
    'iniconfig',
    'packaging',
    'pluggy <2,>=1.5',
    'exceptiongroup >=1.0.0rc8 ; python_version < "3.11"',
    'tomli >=1 ; python_version < "3.11"',
    'colorama ; sys_platform == "win32"',
    "argcomplete ; extra == 'dev'",
    "attrs >=19.2 ; extra == 'dev'",
    "hypothesis >=3.56 ; extra == 'dev'",
    "mock ; extra == 'dev'",
    "pygments >=2.7.2 ; extra == 'dev'",
    "requests ; extra == 'dev'",
    "setuptools ; extra == 'dev'",
    "xmlschema ; extra == 'dev'"
]

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT