extras_require¶
Display a warning at the top of module documentation that it has additional requirements.
Docs |
|
|---|---|
Tests |
|
PyPI |
|
Anaconda |
|
Activity |
|
QA |
|
Other |
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:: formulae
:file: formulae/requirements.txt
will produce this:
Attention
This module has the following additional requirements:
cawdrey>=0.1.2 mathematical>=0.1.7 pandas>=1.0.1 pyparsing>=2.2.0 quantities>=0.12.4 tabulate>=0.8.3
These can be installed as follows:
python -m pip install chemistry_tools[formulae]
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. For example, this line:.
package_root = "chemistry_tools"
points to ./chemistry_tools, and therefore :file: formulae/requirements.txt points to ./chemistry_tools/formulae/requirements.txt.
Requirements can also be specified in pyproject.toml (using the option :pyproject:), setup.cfg (using the option :setup.cfg::), or by typing in the requirements manually, one per line.
The :scope: option can be used to specify a different scope for additional requirements, such as package, module, class or function. Any string value can be supplied here.
Usage
API Reference
View the Function Index or browse the Source Code.