Metadata-Version: 2.1
Name: minimum-dependencies
Version: 0.1.0
Summary: Get the minimum dependencies of a Python package
Author-email: William Jamieson <help@stsci.edu>
License: BSD 3-Clause License
        
        Copyright (c) 2021 Association of Universities for Research in Astronomy.
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Development Status :: 5 - Production/Stable
Requires-Python: >=3.8
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: importlib-metadata (>=4.11.4)
Requires-Dist: packaging (>=23)
Requires-Dist: requests (>=2.25)
Provides-Extra: other
Requires-Dist: astropy[all] (>=5) ; extra == 'other'
Provides-Extra: test
Requires-Dist: pytest (>=6) ; extra == 'test'
Requires-Dist: pytest-doctestplus (>=0.12) ; extra == 'test'

minimum_dependencies
====================

.. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white
    :target: https://github.com/pre-commit/pre-commit
    :alt: pre-commit

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/psf/black

.. image:: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336
    :target: https://pycqa.github.io/isort/


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:

.. code-block:: bash

    $ 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:

.. code-block:: bash

    $ 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``:

.. code-block:: console

    $ 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``):

.. code-block:: console

    $ 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``:

.. code:: pycon

    >>> 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:

.. code:: pycon

    >>> 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
