Skip to main content

Create a minimal requirements.txt file from Python source code

Project description

pymin_reqs

This module attempt to make a minimal requirements.txt file based on the imports are used inside of the code of your project, .py files. These requirements are a subset of what would be given using pip freeze or conda list --export as these commands give everything that is used inside of the Python environment. This is useful if a project is used inside of a shared environment or if you want a cleaner requirements.txt that only has your imported modules but not the dependencies, and sub-dependencies, of those modules.

Install With Pip

python3 -m pip install pymin-reqs

Usage

usage: pymin_reqs [-h] [-d DIRECTORY] [--conda] [--pip] [-f] [-s] [-v] [-e] [-o OUTFILE]

optional arguments:
  -h, --help            show this help message and exit
  -d DIRECTORY, --directory DIRECTORY
                        Specify the input directory. Default: '.'
  --conda               Output conda requirements instead of pip. Use --pip --conda to show both
  --pip                 Show pip requirements. not required by default unless --conda is also specified
  -f, --force           Force overwrite of the given file in --outfile
  -s, --stats           Show import locations and count of imported modules.
  -v, --verbose         Verbose mode
  -e, --ignore-errors   Ignore errors when possible
  -o OUTFILE, --outfile OUTFILE
                        Specify the output file. Default 'requirements.txt'

Examples

Show requirements on command line

pymin_reqs

Output requirements to a file "requirements.txt"

pymin_reqs -o requirements.txt

Output requirements to a file "requirements.txt" and force overwrite

pymin_reqs -f -o requirements.txt

This module uses the abstract syntax tree(ast module) to find imports. If there are invalid python file this might cause errors in parsing. To get around this you can specify --ignore-errors

pymin_reqs --ignore-errors

Example output from commands

pip==20.2.4
setuptools==50.3.1

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymin-reqs-1.0.2.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

pymin_reqs-1.0.2-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file pymin-reqs-1.0.2.tar.gz.

File metadata

  • Download URL: pymin-reqs-1.0.2.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for pymin-reqs-1.0.2.tar.gz
Algorithm Hash digest
SHA256 c13e193cc94d1d618bdd0025a5ac49d90ad1da42c487c6c222d5dd664c64741a
MD5 d7d527155dae1803773185d7365260a1
BLAKE2b-256 e6a50b3865a236818c1ef7376a5fd43328aabf3752611f042bbb1d8294b09051

See more details on using hashes here.

File details

Details for the file pymin_reqs-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: pymin_reqs-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for pymin_reqs-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5b4684c6f407be94f0ac00da76b7e60b87c0b3372bcbed4149efd6b15ced09f2
MD5 96e3fb5e39e9778ec756811e754828fb
BLAKE2b-256 ca3abd430a4910269f043b8fea0410d17755097f53e84694a0fd54633a62d8c0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page