Skip to main content

Get the minimum dependencies of a Python package

Project description

pre-commit https://img.shields.io/badge/code%20style-black-000000.svg https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336

Generate the minimum dependencies for a Python project based on the lower pins.

Installation

This package is available on PyPI. You can install it with pip:

$ pip install minimum_dependencies

Usage

minumum_dependencies can be used as a command line tool or as a library.

CLI

The manpage for the CLI tool is below:

$ minimum_dependencies --help
usage: minimum_deps [-h] [--filename FILENAME] [--extras [EXTRAS ...]] package

Generate the minimum requirements for a package based on the lower pins of its dependencies.

positional arguments:
package               Name of the package to generate requirements for

options:
-h, --help            show this help message and exit
--filename FILENAME, -f FILENAME
                        Name of the file to write out
--extras [EXTRAS ...], -e [EXTRAS ...]
                        List of optional dependency sets to include

For example, to generate the minimum dependencies for minimum_dependencies:

$ minimum_dependencies requests
importlib-metadata==4.11.4
packaging==23.0
requests==2.25.0

Similarly, to generate this with some of its optional dependencies (test and other):

$ minimum_dependencies minimum_dependencies --extras test other
importlib-metadata==4.11.4
packaging==23.0
requests==2.25.0
astropy[all]==5.0
pytest==6.0.0
pytest-doctestplus==0.12.0

Library Usage

The library provides two public functions:
  • create: takes a package name and returns a list of requirement strings.

  • write: takes a package name and a filename and writes the requirements to the file.

For example, to generate the minimum dependencies for minimum_dependencies:

>>> import minimum_dependencies
>>> minimum_dependencies.create("minimum_dependencies")
['importlib-metadata==4.11.4\n', 'packaging==23.0\n', 'requests==2.25.0\n']
>>> minimum_dependencies.write(
...     "minimum_dependencies", "requirements.txt"
... )  # writes the requirements to requirements.txt

One can also pass these methods a list of extras (optional installs for the package) to include in the requirements. For example, to generate the minimum dependencies for minimum_dependencies with all its optional dependencies:

>>> import minimum_dependencies
>>> minimum_dependencies.create("minimum_dependencies", extras=["test", "other"])
['importlib-metadata==4.11.4\n', 'packaging==23.0\n', 'requests==2.25.0\n',
'astropy[all]==5.0\n', 'pytest==6.0.0\n', 'pytest-doctestplus==0.12.0\n']
>>> minimum_dependencies.write(
...     "minimum_dependencies", "requirements.txt", extras=["test", "other"]
... )  # writes the requirements to requirements.txt

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

minimum_dependencies-0.1.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file minimum_dependencies-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for minimum_dependencies-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1aeec019c8dd1d430246633eb519665335f2bd24340ec9976c87e74a6ff5abd8
MD5 4c3640f0971c24c47c36f95c349b86df
BLAKE2b-256 e04f1a10a5cefe1b36e9a3b80d8ce6d88cb80645ac2168615f8602e83fe5d52f

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