Skip to main content

extras-require

Travis Build Status Documentation Status PyPI PyPI - Python Version PyPI - Wheel PyPI - Implementation License GitHub top language GitHub commits since tagged version GitHub last commit Maintenance CodeFactor Grade

Display a warning at the top of module documentation that it has additional requirements.


Overview

This extension assumes you have a repository laid out like this:

/
├── chemistry_tools
│   ├── __init__.py
│   ├── formulae
│   │   ├── __init__.py
│   │   ├── compound.py
│   │   ├── formula.py
│   │   ├── parser.py
│   │   └── requirements.txt
│   ├── constants.py
│   └── utils.py
├── doc-source
│   ├── api
│   │   ├── chemistry_tools.rst
│   │   ├── elements.rst
│   │   ├── formulae.rst
│   │   └── pubchem.rst
│   ├── conf.py
│   ├── index.rst
│   └── requirements.txt
├── LICENSE
├── README.rst
├── requirements.txt
├── setup.py
└── tox.ini

The file /chemistry_tools/formulae/requirements.txt contains the additional requirements to run the formulae subpackage. These would be defined in setup.py like this:

setup(
    extras_require = {
        'formulae': [
            'mathematical>=0.1.7',
            'pandas>=1.0.1',
            'pyparsing>=2.2.0',
            'tabulate>=0.8.3',
            'cawdrey>=0.1.2',
            'quantities>=0.12.4',
            ],
    }
)

A message can be displayed in the documentation to indicate that the subpackage has these additional requirements that must be installed.

For instance, this:

.. extras-require::
    :file: formulae/requirements.txt
    :extra: formulae

will look like this:

.images/example.png

The path given in :file: is relative to the package_root variable given in conf.py, which in turn is relative to the parent directory of the sphinx documentation.

i.e, this line:

package_root = "chemistry_tools"

points to /chemistry_tools, and therefore :file: formulae/requirements.txt points to /chemistry_tools/formulae/requirements.txt.

Installation

extras_require can be installed with pip:

$ python -m pip install extras_require

Enable extras_require by adding the following line to the extensions variable in conf.py:

"sphinxcontrib.extras_require",

For more information see https://www.sphinx-doc.org/en/master/usage/extensions/index.html#third-party-extensions .

Future Enhancements

  • Allow use of different “scopes”, e.g. package, module, class, function, depending on what the additional requirements are for.

  • Support different methods of defining the requirements, e.g. setup.cfg, setup.py, __pkginfo__.py, pyproject.toml, or typing as entries in the directive itself.

Metadata

Release files for extras-require 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for extras-require 0.0.2
File Size Uploaded
extras_require-0.0.2.tar.gz 6.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for extras-require 0.0.2
File Interpreter ABI Platform
extras_require-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 12.6 kB

Release files / extras_require-0.0.2.tar.gz

Download URL extras_require-0.0.2.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c8c25304d5385817cda382829dcdbee5500f832a41f13639bd26f89436d0fa33
BLAKE2b-256 checksum
How to use checksums
2c70675310c71ab2540aa371cc5582229519c4f4890b7e0f7e83cb95c6c3722b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.7

Release files / extras_require-0.0.2-py3-none-any.whl

Download URL extras_require-0.0.2-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
54e1f84b74ceeaa4e768b9e84d09629980bdcde76ebac4709017a62946b8adfd
BLAKE2b-256 checksum
How to use checksums
f092cd39b9821b50c5d5c55bc992399dcda2bb6f9400f783a70b752f6bfce6ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.7

Release history Release notifications | RSS feed

0.5.0

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

This release

0.0.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page